wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Classes Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a Python class?

a)

A function to create an object.

b)

A template (blueprint) for creating objects.

c)

A procedure related to an object.

d)

A process that repeats are directed.

2.

What is the keyword to create a class?

a)

import

b)

__int__

c)

class

d)

def

3.

Identify the first statement that creates a class named Employee.

a)

class Employee():

b)

Class Employee:

c)

class employee:

d)

class Employee:

4.

Identify the term that describes the creation of a new object.

a)

instantiation

b)

declare

c)

iteration

d)

initialize

5.

Identify the code that properly creates an instance of a class named Car.

a)

camero.car(make, model)

b)

tesla = car.make()

c)

mustang = Car(make,model)

d)

porsche = car.make.model()

6.

Identify the initialization method for a Car class.

a)

class init(self, make, model):

b)

class__init__:

c)

def __init__(self, make, model):

d)

def __init__(self, make, model):

7.

Identify the code that properly accesses an engine_sound() method in a Car class.

a)

porsche.engine_sound()

b)

mustang = engine_sound()

c)

engine_sound(tesla):

d)

engine_sound.Car(camaro)

8.

Identify the keyword that accesses an instance's attributes when three objects are created.

a)

inheritance

b)

class

c)

__init__

d)

self

9.

Inheritance can only be applied between one sub class and one super class.

a)

True

b)

False

c)

Occasionally

d)

Depending on instantiation

10.

What are class variables?

a)

Variables with a sense of style

b)

Variables that apply to all instances of the class

c)

Variables that change with every instance of the class

d)

Integers

11.

Do you think a variable to store a car's value would be a class or instance variable?

a)

Class

b)

Instance

12.

What does __init__ do?

a)

Constructs the instance

b)

Initialize the instance values

c)

Calls the Super class

d)

Creates a circle

13.

Getters and setters

a)

Are important for class incapsulation

b)

Are important to add each data member of the class

c)

Are replaced by the @property decorator in Python

d)

Are replaced by the @classmethod in Python

14.

Who would win in a battle where Bilbo Baggins vs. Frodo Baggins

a)

Bilbo Baggins

b)

Frodo Baggins

15.

Who would win a battle between, Darth Vader vs. Capt. James T. Kirk

a)

Darth Vader

b)

Capt. James T. Kirk