0
0
LLDsystem_design~10 mins

Class diagrams in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a class named Vehicle.

LLD
class [1]:
    pass
Drag options to blanks, or click blank then click option'
AVehicle
Bvehicle
CCar
DvehicleClass
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names for class names.
Using unrelated class names.
2fill in blank
medium

Complete the code to add an attribute named speed to the Vehicle class.

LLD
class Vehicle:
    def __init__(self, [1]):
        self.speed = speed
Drag options to blanks, or click blank then click option'
Aspeed_value
Bvelocity
Cspeed
Dspeedy
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different parameter name than the attribute name.
Forgetting to add the parameter in __init__.
3fill in blank
hard

Fix the error in the method that returns the speed of the vehicle.

LLD
class Vehicle:
    def __init__(self, speed):
        self.speed = speed

    def get_speed(self):
        return [1].speed
Drag options to blanks, or click blank then click option'
Aself
Bspeed
CVehicle
Dthis
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name instead of self.
Using undefined variables.
4fill in blank
hard

Fill both blanks to define a subclass Car that inherits from Vehicle and adds a new attribute brand.

LLD
class [1]([2]):
    def __init__(self, speed, brand):
        super().__init__(speed)
        self.brand = brand
Drag options to blanks, or click blank then click option'
ACar
BVehicle
CBike
DTransport
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong class names for subclass or parent.
Forgetting to inherit from the parent class.
5fill in blank
hard

Fill all three blanks to complete the class diagram code with an association: Garage has many Cars.

LLD
class Garage:
    def __init__(self):
        self.[1] = []

    def add_car(self, [2]):
        self.[3].append(car)
Drag options to blanks, or click blank then click option'
Acars
Bcar
Dvehicles
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent names for the list attribute.
Using wrong parameter names.