WorksheetsPython L30 OOP class
Total questions: 9
Worksheet time: 6mins
What is the purpose of the __init__ method in the Snake class?
To destroy the snake
To update the screen
To set up the snake’s initial body segments
To listen to keyboard input
What is the purpose of this loop?
To move the head forward
To delete the last segment
To make each segment follow the one in front
To change the background color
Which of these shows the correct way to create an object from Snake class?
snake1 = Snake()
Snake = snake1()
snake1 = turtle()
class Snake:
In OOP, the self keyword refers to the instance of the class where it is used.
True
False
Fill in the blank with the correct code.
Which of the following best describes a class in Python?
A built-in function
A blueprint for creating objects
A type of loop
A library
Which of the following is a benefit of using OOP?
You must always write longer code
You can reuse and organize your code better
You don’t have to use variables anymore
Python runs faster
What will be printed when the code runs?
Error
my_car
Driving the car!
Car
An object can be created without using a class in Python.
True
False
