Multiple choice quiz about Python - Part 2
- Question 1: Which assertion is correct when talking about the following code:
def printHello():
print("Hello")
a = printHello()
- printHello () is a function and a is a variable. Both are not objects.
- Both printHello () and a represent the same object.
- printHello () and a are two different objects.
- Syntax error. Cannot assign functions to a variable in Python.
-
- Question 2: What is the output of the program below?
def outerFunction():
global a
a = 20
def innerFunction():
global a
a = 30
print('a =', a)
a = 10
outerFunction()
print('a =', a)
- a = 10 a = 30
- a = 10
- a = 20
- a = 30
-
- Question 3: Which of the following statements is true?
- Class (class) is a detailed plan for the object.
- Only one object can be created from a given class.
- Both answers are correct.
- There is no exact answer.
-
- Question 4: What is the result of the code below?
class Foo:
def printLine(self, line='Python'):
print(line)
o1 = Foo()
o1.printLine('Java')
- Python
- line
- Java
- Java
Python
-
- Question 5: What is the meaning of __init __ () function in Python?
- Create a class to use.
- Called when a new object is initialized.
- Initialize and bring all data attributes to 0 when called.
- There is no right answer.
-
- Question 6: What is the output of the program below?
class Point:
def __init__(self, x = 0, y = 0):
self.x = x+1
self.y = y+1
p1 = Point()
print(p1.x, p1.y)
- 0 0
- 1 1
- None None
- xy
-
- Question 7: Which of the following code uses Python's inheritance feature?
-
class Foo:
Pass
-
class Foo(object):
pass
class Hoo(object)
pass
-
class Foo:
pass
class Hoo(Foo):
pass
- There is no exact answer.
-
- Question 8: What is a class inherited from two different classes of attributes?
- Multi-level inheritance (Multilevel Inheritance)
- Multiple Inheritance
- Hierarchical Inheritance
- Inheritance
-
- Question 9: Which of the following statements is true?
- In Python, an operator may have different operations depending on the operand used.
- You can change the way operators work in Python.
- __add () __ is called when the '+' operator is used.
- All answers are correct.
-
- Question 10: The results of the program below are:
class Point:
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y
def __sub__(self, other):
x = self.x + other.x
y = self.y + other.y
return Point(x,y)
p1 = Point(3, 4)
p2 = Point(1, 2)
result = p1-p2
print(result.x, result.y)
- 2 2
- forty six
- 0 0
- 1 1
-
4.2 ★ | 10 Vote
You should read it
- Multiple choice quiz about Python - Part 7
- Multiple choice test on Python - Part 11
- Multiple choice quiz about Python - Part 10
- Multiple choice quiz about Python - Part 5
- Multiple choice quiz about Python - Part 1
- Multiple choice quiz about Python - Part 6
- Multiple choice quiz about Python - Part 8
- Multiple choice quiz about Python - Part 9
May be interested
- Multiple choice quiz about Python - Part 3today's topic quantrimang wants to challenge you is about file and exception handling in python. let's try the following 15 questions!
- Multiple choice quiz about Python - Part 4continue python's thematic quiz, part 4 goes back to the topic core data type - standard data types in python. let's try with quantrimang to try the 10 questions below.
- Multiple choice quiz about Python - Part 5if you are interested in learning about the python programming language, the following quiz of network administrator will provide useful knowledge for your learning.
- What do you know about Data Mining? - Part 2how much did you know about data mining? keep testing your knowledge with quantrimang through the following multiple choice questions!
- What do you know about Data Mining? - Part 1how much did you know about data mining? try your knowledge with quantrimang through the following data mining quiz questions!
- Multiple choice quiz about Python - Part 6to help readers add to their knowledge of python's built-in functions, the network administrator will send you multiple choice questions on this topic. please try.