Quiz: Python Classes

Main.PythonQuiz13 History

Hide minor edits - Show changes to markup

May 18, 2022, at 02:09 AM by 10.35.117.248 -
Changed line 77 from:
Correct. '_init_' function with 2 underscores on either side of init
to:
Correct. 2 underscores on either side of init
May 18, 2022, at 02:08 AM by 10.35.117.248 -
Added lines 1-80:

(:title Quiz: Python Classes:) (:keywords quiz, test, Python, plot, graph, class, object, instance, introduction, course:) (:description Learning assessment on Python data import with Pandas and TCLab.:)


1. Classes are collections of variables and functions that are particularly useful in object-oriented programming.

A. True
(:toggle hide q1a button show="Select":)

(:div id=q1a:)

Correct.

(:divend:)

B. False
(:toggle hide q1b button show="Select":)

(:div id=q1b:)

Incorrect.

(:divend:)


2. In the example in the video introduction to classes, what is an instance of the Person class? Select two correct answers.

A. Jane
(:toggle hide q2a button show="Select":)

(:div id=q2a:)

Correct. Jane is an instance of the parent class.

(:divend:)

B. class Person
(:toggle hide q2b button show="Select":)

(:div id=q2b:)

Incorrect. The parent class is not an instance.

(:divend:)

C. Eric
(:toggle hide q2c button show="Select":)

(:div id=q2c:)

Correct. Eric is an instance of the parent class.

(:divend:)

D. addSkill
(:toggle hide q2d button show="Select":)

(:div id=q2d:)

Incorrect. The function addSkill is a method of the Person class, not an instance of the Person class.

(:divend:)


3. What function is used to initialize variables when creating a new instance of a class?

A. def init(self):
(:toggle hide q3a button show="Select":)

(:div id=q3a:)

Incorrect.

(:divend:)

B. def addSkill(self,skill):
(:toggle hide q3b button show="Select":)

(:div id=q3b:)

Incorrect.

(:divend:)

C. def __init__(self):
(:toggle hide q3c button show="Select":)

(:div id=q3c:)

Correct. '_init_' function with 2 underscores on either side of init

(:divend:)