Well done!
You have completed Classes, Attributes, and Methods!
Quiz Question 1 of 7
class Car:
wheels = 4
doors = 2
engine = True
def __init__(self, make, model, year=2020, gas=100):
self.make = make
self.model = model
self.year = year
self.is_moving = False
self.gas = gas
def use_gas(self):
self.gas -= 50
return self.gas
def stop(self):
if self.is_moving:
print('The car has stopped.')
self.is_moving = False
else:
print('The car has already stopped.')
def go(self, speed):
if self.use_gas():
if not self.is_moving:
print('The car starts moving.')
self.is_moving = True
print(f'The car is going {speed}.')
else:
print("You've run out of gas!")
self.stop()
In the code above, stop is a ____.
Choose the correct answer below: