Python Programming - Objects - Discussion

Discussion Forum : Objects - General Questions (Q.No. 26)
26.
Consider the following Python code:
class Vehicle:
    def __init__(self, brand, model):
        self.brand = brand
        self.model = model

    def display_info(self):
        return f"{self.brand} {self.model}"
If you create an instance of the `Vehicle` class called car with brand "Toyota" and model "Camry", what will be the result of calling car.display_info()?
"Toyota Camry"
"Camry Toyota"
"Toyota"
"Camry"
Answer: Option
Explanation:
The display_info method returns a string combining the brand and model attributes.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.