51.9k views
2 votes
What is the output?

class car:
model = "
age = 20
myCar = car()
myCar.age= myCarage + 10
print(myCarage)
Output:

What is the output? class car: model = " age = 20 myCar = car() myCar.age= myCarage-example-1
User Pal
by
8.1k points

1 Answer

3 votes

Answer:

Following are the modified code to this question:

class car:#defining a class car

model = ""#defining a class

age = 20#defining an integer variable that hold a value

myCar = car()#creating reference of class

myCar.age= myCar.age+ 10#Use reference to add value in age variable

print(myCar.age)#print age value

Output:

30

Step-by-step explanation:

In the above code class care is defined, inside the car a string variable "model", and an integer variable "age" is defined that hold a value, in the next step, class reference myCar is defined, that used to add value in age variable an at the last we use print method to print age variable value.

User Sara Ree
by
9.2k points