Question

In: Computer Science

I cannot get this code to run on my python compiler. It gives me an expected...

I cannot get this code to run on my python compiler. It gives me an expected an indent block message. I do not know what is going on.


#ask why this is now happenning. (Create employee description)
class employee:
def__init__(self, name, employee_id, department, title):
self.name = name
self.employee_id = employee_id
self.department = department
self.title = title

def __str__(self):
return '{} , id={}, is in {} and is a {}.'.format(self.name, self.employee_id, self.department, self.title)


  
def main():
# Create employee list
emp1 = Employee(name='Susan Meyers', employee_id='47899', department='Accounting', title='Vice President')
emp2 = Employee(name='Mark Jones', employee_id='39119', department='IT', title='Programmer')
emp3 = Employee(name='Joy Rogersr', employee_id='81774', department='Manufacturing', title='Engineer')

print(emp1, sep='/n/n')
print(emp2, sep='/n/n')
print(emp3, sep='/n/n')
  
if __name__=="__main__":
main()

Solutions

Expert Solution

class employee:
    def __init__(self, name, employee_id, department,title):
      self.name = name
      self.employee_id = employee_id
      self.department = department
      self.title = title

    def __str__(self):
      return '{} , id={}, is in {} and is a {}.'.format(self.name, self.employee_id, self.department, self.title)


  
def main():
  # Create employee list
  emp1 = employee(name='Susan Meyers', employee_id='47899', department='Accounting', title='Vice President')
  emp2 = employee(name='Mark Jones', employee_id='39119', department='IT', title='Programmer')
  emp3 = employee(name='Joy Rogersr', employee_id='81774', department='Manufacturing', title='Engineer')

  print(emp1, sep='/n/n')
  print(emp2, sep='/n/n')
  print(emp3, sep='/n/n')
  
if __name__=="__main__":
  main()

*

please follow the screenshot to check for the indentation

and after class indentation should be there similarly for methods also and the final if statement also

and modified the class name in object creation as the class names are not matching


Related Solutions

I have an error on my code. the compiler says 'setLastName' was not declared in this...
I have an error on my code. the compiler says 'setLastName' was not declared in this scope. this is my code : #include <iostream> using std::cout; using std::cin; using std::endl; #include <string> using std::string; class Employee {    public :               Employee(string fname, string lname, int salary)        {            setFirstName(fname);            setLastName(lname);            setMonthlySalary(salary);        }               void setFirstName(string fname)        {       ...
Could you double check my program? I cannot get it to run. If you could tell...
Could you double check my program? I cannot get it to run. If you could tell me any changes that need to be made as well show the output I would greatly appreciate it. LinkedList.java public class LinkedList { class Node{ int value; Node nextElement; public Node(int value) { this.value = value; this.nextElement = null; } } public Node first = null; public Node last = null; public void addNewNode(int element) { Node newValueNode = new Node(element); if(first == null)...
In Python I have a code: here's my problem, and below it is my code. Below...
In Python I have a code: here's my problem, and below it is my code. Below that is the error I received. Please assist. Complete the swapCaps() function to change all lowercase letters in string to uppercase letters and all uppercase letters to lowercase letters. Anything else remains the same. Examples: swapCaps( 'Hope you are all enjoying October' ) returns 'hOPE YOU ARE ALL ENJOYING oCTOBER' swapCaps( 'i hope my caps lock does not get stuck on' ) returns 'I...
Python I want to name my hero and my alien in my code how do I...
Python I want to name my hero and my alien in my code how do I do that: Keep in mind I don't want to change my code except to give the hero and alien a name import random class Hero:     def __init__(self,ammo,health):         self.ammo=ammo         self.health=health     def blast(self):         print("The Hero blasts an Alien!")         if self.ammo>0:             self.ammo-=1             return True         else:             print("Oh no! Hero is out of ammo.")             return False     def...
I have to code the assignment below. I cannot get the program to work and I...
I have to code the assignment below. I cannot get the program to work and I am not sure what i am missing to get the code to work past the input of the two numbers from the user. My code is listed under the assignment details. Please help! Write a Java program that displays the prime numbers between A and B. Inputs: Prompt the user for the values A and B, which should be integers with B greater than...
For Python, I cannot figure out why "and" is printing at the beginning of my list....
For Python, I cannot figure out why "and" is printing at the beginning of my list. Can someone help? listToPrint = [] while True: newWord = input("Enter a word to add to the list (prest return to stop adding words) > ") newWord == "": break else: listToPrint.append(newWord) for item in listToPrint[:-1]: print(item, end=', ') print('and', listToPrint[-1]) If I enter m, n, b to the list, it executes to and m, n, b
in java: In my code at have my last two methods that I cannot exactly figure...
in java: In my code at have my last two methods that I cannot exactly figure out how to execute. I have too convert a Roman number to its decimal form for the case 3 switch. The two methods I cannot figure out are the public static int valueOf(int numeral) and public static int convertRomanNumber(int total, int length, String numeral). This is what my code looks like so far: public static void main(String[] args) { // TODO Auto-generated method stub...
Below is my source code for file merging. when i run the code my merged file...
Below is my source code for file merging. when i run the code my merged file is blank and it never shows merging complete prompt. i dont see any errors or why my code would be causing this. i saved both files with male names and female names in the same location my source code is in as a rtf #include #include #include using namespace std; int main() { ifstream inFile1; ifstream inFile2; ofstream outFile1; int mClientNumber, fClientNumber; string mClientName;...
When I run this, gdb gives me a segmentation fault at the for loop. It says...
When I run this, gdb gives me a segmentation fault at the for loop. It says I'm dereferencing curr with curr->data when curr is null. It doesn't even seem to enter the body of the loop sometimes. I am testing it on a linked list that ends with a strange element. Could you help me get this one done? Thanks so much! Here is the instruction and code: LewList *splitStrange(); This function should split the list in two, adding the...
This is my code for python. I am trying to do the fourth command in the...
This is my code for python. I am trying to do the fourth command in the menu which is to add an employee to directory with a new phone number. but I keep getting error saying , "TypeError: unsupported operand type(s) for +: 'dict' and 'dict". Below is my code. What am I doing wrong? from Lab_6.Employee import * def file_to_directory(File): myDirectory={}       with open(File,'r') as f: data=f.read().split('\n')    x=(len(data)) myDirectory = {} for line in range(0,199):      ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT