Podcast
Questions and Answers
Which of the following is the correct syntax to define a class in Python?
Which of the following is the correct syntax to define a class in Python?
- function MyClass():
- class MyClass(): (correct)
- MyClass():
- def MyClass():
What is the purpose of the 'init' method in a Python class?
What is the purpose of the 'init' method in a Python class?
- To delete an instance of the class.
- To define class variables.
- To define instance variables. (correct)
- To create a new instance of the class.
Which of the following is the correct way to create a new instance of a class in Python?
Which of the following is the correct way to create a new instance of a class in Python?
- create MyClass()
- MyClass.new()
- MyClass() (correct)
- new MyClass()