Reference no: EM132356355
Answer the following Questions :
1. Explain the difference between a class variable and an instance variable by referring to how changes made to each will affect other instances.
2. The following is the definition for a class named Car and the main program that uses the class Car. The program produces an error.
class Car(object): numwheels = 4
def display(self): print("Make:", self.make)
print("Colour:", self.colour) print("Wheels:", Car.numwheels)
#main program
cObj1 = Car("Ford", "Black") cObj1.display()
Without making any changes to the two lines in the main program, correct the class definition so that the program will execute without error. Provide the complete corrected program.
Identify the class variable(s) of class Car.
Identify the instance variable(s) of class Car.
Identify instance(s) of the class Car in the given program.
3. Write a program that deletes line 2 from the productlist.txt file. Provide the code that you used.
4. Write a program that reads and prints all the content from the productlist.txt file. The program should be able to access specific content in the file by printing only line 3.
5. What is the difference between serialisation and deserialisation?