Quiz 4.1 OOP - CPE 009 CPE12S1 Object Oriented Programming
Quiz 4.1 OOP - CPE 009 CPE12S1 Object Oriented Programming
Attempt History
Attempt Time Score
LATEST Attempt 1
27 minutes 8 out of 10
Correct answers are hidden.
Question 1 1
/ 1 pts
class Person():
def __init__(self):
person1 = Person()
print(self.__name)
The program will run but will not display anything.
The program will output an attribute error because Python could not find an
attribute __name in Person
https://tip.instructure.com/courses/29905/quizzes/378535 1/7
4/6/22, 10:55 AM Quiz 4.1 OOP: CPE 009-CPE12S1 - Object Oriented Programming
The program will output "Default Name"
Question 2 1
/ 1 pts
Which of the following is incorrect about the use of the keyword self in
Python?
self refers to the instance of the class.
Not putting self on a variable inside a method will cause a syntax error.
self is a required parameter in all methods in a class otherwise, methods
without self when called outside of the class will cause an error.
self differentiates each variable per instance.
Incorrect
Question 3 0
/ 1 pts
class Vehicle():
def __init__(self):
https://tip.instructure.com/courses/29905/quizzes/378535 2/7
4/6/22, 10:55 AM Quiz 4.1 OOP: CPE 009-CPE12S1 - Object Oriented Programming
def start(self):
def stop(self):
class Class1Vehicle():
pass
vehicle1 = Class1Vehicle()
Single Inheritance
Multilevel Inheritance
Multiple Inheritance
None
Question 4 1
/ 1 pts
class Student():
class DSCOfficer(Student):
self.event_list = []
self.eventlist.append({"name":name})
officer1 = DSCOfficer("CpE")
https://tip.instructure.com/courses/29905/quizzes/378535 3/7
4/6/22, 10:55 AM Quiz 4.1 OOP: CPE 009-CPE12S1 - Object Oriented Programming
officer1.initiateEvent("General Assembly")
print(officer1.stu_num)
TypeError: initiateEvent() takes 1 positional argument but 2 were given
AttributeError: 'DSCOfficer' object has no attribute 'stu_num'
0
None
Question 5 1
/ 1 pts
__init__
init__
__init
_init_
Question 6 1
/ 1 pts
class
https://tip.instructure.com/courses/29905/quizzes/378535 4/7
4/6/22, 10:55 AM Quiz 4.1 OOP: CPE 009-CPE12S1 - Object Oriented Programming
Question 7 1
/ 1 pts
class Vehicle():
def __init__(self):
def start(self):
def stop(self):
class Class1Vehicle():
pass
vehicle1 = Class1Vehicle()
vehicle1.start()
print(vehicle1.is_enginerunning)
False
True
TypeError: start() takes 0 positional arguments but 1 was given
AttributeError: 'Class1Vehicle' object has no attribute 'start'
https://tip.instructure.com/courses/29905/quizzes/378535 5/7
4/6/22, 10:55 AM Quiz 4.1 OOP: CPE 009-CPE12S1 - Object Oriented Programming
Question 8 1
/ 1 pts
True
False
Question 9 1
/ 1 pts
Modify the object
Create the object
Initialize an object
Create a sub class
Incorrect 0
/ 1 pts
Question 10
Class
https://tip.instructure.com/courses/29905/quizzes/378535 6/7
4/6/22, 10:55 AM Quiz 4.1 OOP: CPE 009-CPE12S1 - Object Oriented Programming
Quiz Score:
8 out of 10
https://tip.instructure.com/courses/29905/quizzes/378535 7/7