Quiz: Python Classes

Main.PythonQuiz13 History

Hide minor edits - Show changes to output

May 18, 2022, at 02:09 AM by 10.35.117.248 -
Changed line 77 from:
-->%blue%Correct.%% ''__init__'' function with 2 underscores on either side of ''init''
to:
-->%blue%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:)
-->%blue%Correct.%%
(:divend:)

->'''B.''' False

-->(:toggle hide q1b button show="Select":)
(:div id=q1b:)
-->%red%Incorrect.%%
(:divend:)

----

'''2.''' In the example in the [[https://youtu.be/LwOg0b0ZwCM|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:)
-->%blue%Correct.%% Jane is an instance of the parent class.
(:divend:)

->'''B.''' class Person

-->(:toggle hide q2b button show="Select":)
(:div id=q2b:)
-->%red%Incorrect.%% The parent class is not an instance.
(:divend:)

->'''C.''' Eric

-->(:toggle hide q2c button show="Select":)
(:div id=q2c:)
-->%blue%Correct.%% Eric is an instance of the parent class.
(:divend:)

->'''D.''' addSkill

-->(:toggle hide q2d button show="Select":)
(:div id=q2d:)
-->%red%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:)
-->%red%Incorrect.%%
(:divend:)

->'''B.''' def addSkill(self,skill):

-->(:toggle hide q3b button show="Select":)
(:div id=q3b:)
-->%red%Incorrect.%%
(:divend:)

->'''C.''' def __init__(self):

-->(:toggle hide q3c button show="Select":)
(:div id=q3c:)
-->%blue%Correct.%% ''__init__'' function with 2 underscores on either side of ''init''
(:divend:)

----