
Learn Python 3 - Lesson 10 Introduction to Classes
Authored by Dhea Amalia Lutfiani
Mathematics, English, Computers
11th Grade - Professional Development

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
7 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What does the hasattr() function call in the last line here evaluate to?
class HoldsFive:
five = 5
five_holder = HoldsFive()
hasattr(five_holder, 'five')
True
False
5
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What function, defined within a class, provides instructions on what to assign to a new instance when it is created?
__ init __
__ create __
init
__ new __
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the first argument of a method?
The context in which the object is created. We usually name the parameter this.
The instance of the object itself. We usually refer to it as self.
The class itself. We usually refer to it as self.
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What would be printed from the following code?
class User:
def __init__(self, name):
self.name = name
def __repr__(self):
return "Hiya {}!".format(self.name)
devorah = User("Devorah")
print(devorah)
Hiya Devorah!
Devorah
Hiya devorah!
devorah
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What keyword is used to indicate the start of a class definition?
__ init __
def
class
type
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What does the type() function do in Python?
Returns a type object that contains some metadata about the class.
Returns the class that an object implements.
Returns a string that’s the name of the class.
Returns an implementation of a class.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How would we create an instance of the following class?
class NiceClass:
neat_attribute = "neat"
nice_instance = NiceClass()
nice_instance = new NiceClass
nice_instance = NiceClass
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?