Python Classes Quiz
FREE Online Courses: Click, Learn, Succeed, Start Now!
Quiz Summary
0 of 10 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 10 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 10
1. Question
Which of the following represents a blueprint or template?
CorrectIncorrect -
Question 2 of 10
2. Question
Which of the following statements is true?
CorrectIncorrect -
Question 3 of 10
3. Question
What keyword is used to define a class?
CorrectIncorrect -
Question 4 of 10
4. Question
Statement 1: Instance attributes can be accessed by class name.
Statement 2: Instance attributes are unique to each object.
CorrectIncorrect -
Question 5 of 10
5. Question
>>> class Fruit:
>>> pass
>>> print(Fruit.__name__)
CorrectIncorrect -
Question 6 of 10
6. Question
Statement 1: Instance attributes can be accessed by class name.
Statement 2: Instance attributes are unique to each object.
CorrectIncorrect -
Question 7 of 10
7. Question
>>> class Leaf:
>>> color = “Green”
>>> def __init__(self, color):
>>> self.color = color
>>> leaf1 = Leaf(“Blue”)
>>> color1 = leaf1.color
>>> leaf1.color = “Orange”
>>> color2 = leaf1.color
>>> color3 = Leaf.color
>>> print(color1+color3+color2)
CorrectIncorrect -
Question 8 of 10
8. Question
>>> class SomeClass:
>>> def __init__(self):
>>> self.attr1 = “Hello World”
>>> obj = SomeClass()
>>> setattr(obj, ‘attr2′, getattr(obj,’attr1’))
>>> print(obj.attr2)
CorrectIncorrect -
Question 9 of 10
9. Question
>>> class Person:
>>> def __init__(self, name, age):
>>> self.name = name
>>> self.age = age
>>> def birthday(self):
>>> self.age += 1
>>> p1 = Person(“Smith”, 24)
>>> p2 = Person(“Chris”, 30)
>>> for _ in range(10):
>>> p2.birthday()
>>> num = p1.age + p2.age
>>> print(num)
CorrectIncorrect -
Question 10 of 10
10. Question
>>> from abc import ABC, abstractmethod
>>> class AbstractClass(ABC):
>>> @abstractmethod
>>> def some_method():
>>> pass
>>> ac = AbstractClass()
>>> print(ac)
CorrectIncorrect