wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Inheritance in python

Total questions: 15

Worksheet time: 13mins

Name
Class
Date
1.

How do you say "inheritance" in Chinese?

a)

继承 (jìchéng)

b)
继承人
c)
遗产
d)
继承物
2.

What is inheritance in python?

a)

New class created from an existing class

b)
A type of computer virus
c)
A type of genetic mutation
d)
A type of tax deduction
3.

In ​ (a)   programming you write ​ (b)   that represent ​ (c)   things and situations, and you create ​ (d)   based on these classes.

Choose from the below words
object-oriented
classes
real-world
objects
4.

Making an object from a class is called ​ (a)   , and you work with ​ (b)   of a class.

Choose from the below words
instantiation
instances
5.

What is the keyword to create a class in Python?

a)
function
b)
variable
c)
method
d)
class
6.

What is a method in Python?

a)
A conditional statement in Python
b)
A type of variable in Python
c)

A function that is part of a class

d)
A built-in module in Python
7.

What is the special method that Python runs automatically whenever we create a new instance of a class?

(a)  

8.

Given the class Person in the picture. Create an instance of the class.

​ (a)   ​ (b)   ​ (c)   (​ (d)   )

Choose from the below words
student_1
=
Person
'Alastor', 15, 'Female'
self, 'Alastor', 15, 'Female'
9.

Given the class Person in the picture and the following object:
student_1 = Person('Jay',15,'Male')

Write how you will access the attribute gender.

(a)  

10.

Given the class Person in the picture and the following object:
student_1 = Person('Jay',15,'Male')

Write how you will access the attribute name.

(a)  

11.

Given the class Person of the picture. And the following instantiation:
students = [Person('Jade',15,'Male')]

How do you call the method describe_self in the first element of the list?

(a)  

12.

What is the correct way to use the __init__() method of the parent class?

a)

b)

c)

d)

None of the 3 examples is correct

13.

Can you override a method of the Parent class in Python?

a)
Only in certain cases
b)
Yes
c)

Maybe?

d)
No
14.

How do you override a method of the Parent class?

a)
Create a method with the same name and signature in the Child class
b)
Change the name of the parent method
c)
Call the parent method from the child method
d)
Delete the parent method
15.

What is the self parameter that it is used in the methods of the classes in Python?

a)

It is a reference to the instance of the class itself.

b)

It is a reserved keyword in Python.

c)

It allows us to create multiple instances of a class.

d)

I don't know. Is it a fire bird?