Bird
0
0

Which of the following is the correct way to define a simple class named Car in Python?

easy📝 Syntax Q12 of 15
Python - Object-Oriented Programming Foundations
Which of the following is the correct way to define a simple class named Car in Python?
Aclass Car()
Bclass Car: pass
Cdef Car: pass
DCar = class()
Step-by-Step Solution
Solution:
  1. Step 1: Recall Python class syntax

    Classes start with the keyword class, followed by the class name and a colon.
  2. Step 2: Check each option

    class Car: pass correctly uses class Car: and a body with pass. Others have syntax errors.
  3. Final Answer:

    class Car:\n pass -> Option B
  4. Quick Check:

    class keyword + name + colon = correct class [OK]
Quick Trick: Use 'class ClassName:' to define a class [OK]
Common Mistakes:
  • Using def instead of class
  • Missing colon after class name
  • Trying to assign class to a variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes