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)...
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...
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;...
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):      ...
Here is my fibonacci code using pthreads. When I run the code, I am asked for...
Here is my fibonacci code using pthreads. When I run the code, I am asked for a number; however, when I enter in a number, I get my error message of "invalid character." ALSO, if I enter "55" as a number, my code automatically terminates to 0. I copied my code below. PLEASE HELP WITH THE ERROR!!! #include #include #include #include #include int shared_data[10000]; void *fibonacci_thread(void* params); void parent(int* numbers); int main() {    int numbers = 0; //user input....
Python programming: can someone please fix my code to get it to work correctly? The program...
Python programming: can someone please fix my code to get it to work correctly? The program should print "car already started" if you try to start the car twice. And, should print "Car is already stopped" if you try to stop the car twice. Please add comments to explain why my code isn't working. Thanks! # Program goals: # To simulate a car game. Focus is to build the engine for this game. # When we run the program, it...
hi i do not know what is wrong with my python code. this is the class:...
hi i do not know what is wrong with my python code. this is the class: class Cuboid: def __init__(self, width, length, height, colour): self.__width = width self.__length = length self.__height = height self.__colour = colour self.surface_area = (2 * (width * length) + 2 * (width * height) + 2 * (length * height)) self.volume = height * length * width def get_width(self): return self.__width def get_length(self): return self.__length def get_height(self): return self.__height def get_colour(self): return self.__colour def set_width(self,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT