Solution - Classes

Car Information Kiosk

Our Solution

Here is our solution. Remember, we can all come to different solutions. If it works, and is relatively simply built, then you’ve successfully written an efficient and successful program.

class Vehicle:
    def __init__(self, name, car_type, power, cost): = name
        self.car_type = car_type
        self.power = power
        self.cost = cost
    def description(self):
        desc_str = "The " + + " is a(n) " + self.car_type + " with " + str(self.power) + "hp and costs $" + str(self.cost) + "."
        return desc_str

car1 = Vehicle("Merc E 330", "sedan", 400, 40000)
car2 = Vehicle("Caterham A5", "sports car", 700, 75000)

choice = input("Model Name: ")

if choice ==
elif choice ==
    print("That car is not registered in the system")

The str() is used to change data from an integer or float type to a string data type. This basically converts the data to text that we can use in strings, print statements, etc.

If you don’t understand something, feel free to ask us on our Discord server or simply contact us.