Write a program to determine which class a given Bus object belongs to.
Given:
class Vehicle: def __init__(self, name, mileage, capacity): self.name = name self.mileage = mileage self.capacity = capacity class Bus(Vehicle): pass School_bus = Bus("School Volvo", 12, 50)
Hint:
Use Python’s built-in function type().
type()
Solution:
class Vehicle: def __init__(self, name, mileage, capacity): self.name = name self.mileage = mileage self.capacity = capacity class Bus(Vehicle): pass School_bus = Bus("School Volvo", 12, 50) # Python's built-in type() print(type(School_bus))
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Use Python’s built-in function
type()
.Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer