Coding Quiz - Creating a Car Class
In this coding quiz, you will write a simple solution function that involves the basics of classes in Python.
You need to define a class named Car that includes attributes to store the car’s model name and speed.
The solution function should create a Car object, initialize it with the given model name and speed, and print both attributes.
Code Format
class Car: def __init__(self, model, speed): # Write your code here def solution(model, speed): # Write your code here return # Write your code here
Constraints
-
The
Carclass must havemodelandspeedattributes. -
modelis a string, andspeedis an integer. -
Output format should follow "Model: [model], Speed: [speed] km/h".
Example Input and Output
-
Input: model name
"Tesla Model S", speed250 -
Output:
"Model: Tesla Model S, Speed: 250 km/h"
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help