Chapter - 3: Brief Overview of Python Multiple Choice Questions
Chapter - 3: Brief Overview of Python Multiple Choice Questions
Answer : A
2. Data items that will never change and have fixed values are known as ________________
A) Identifiers B) Functions
C) Keywords D) Literals
Answer : D
Answer : B
Answer : C
Answer : A
Answer : A
7. Which of the following function is used to convert the read value through input( ) into an integer?
A) floating( ) B) float( )
C) int( ) D) integer( )
Answer : C
9. The operator used to check if both the operands reference the same object memory, is the ________
operator
A) in B) as
C) id D) = =
Answer : C
10. A variable may be assigned a value of one type, and then later can be assigned with another type value.
This is referred as _____________?
A) Immutability B) Dynamic Typing
C) Type Conversion D) Mutability
Answer : B
Answer : B
12. Which of the following statements will make a statement to execute repeatedly?
A) if B) if – else
C) for D) while
Answer : C, D
Answer : D
Answer : A
Answer : B
Answer: A
Answer: D (Explanation: All the statements will execute successfully but at the cost of reduced readability)
Answer: D (Explanation: True, False and None are capitalized while the others are in lower case)
i=1
while True:
if i%3 == 0:
break
print(i)
i+=1
A) 1 2 B) 1 2 3
C) error D) none of the mentioned
i=1
while True:
if i%2 == 0:
break
print(i)
i += 2
A) 1 B) 1 2
C) 1 2 3 4 5 6 … D) 1 3 5 7 9 11 …
Answer: D (Explanation: The loop does not terminate since i is never an even number)
for i in range(2.0):
print(i)
A) 0.0 1.0 B) 0 1
C) error D) none of the mentioned
27. What will be the output of the following Python code snippet?
x=2
for i in range(x):
x += 1
print (x)
A) 0 1 2 3 4 … B) 0 1
C) 3 4 D) 0 1 2 3
28. What will be the output of the following Python code snippet?
x=2
for i in range(x):
x -= 2
print (x)
A) 0 1 2 3 4 … B1) 0 -2
C) 0 D) error
for i in range(10):
if i == 5:
break
else:
print(i)
else:
print("Here")
-5-
A) 0 1 2 3 4 Here B) 0 1 2 3 4 5 Here
C) 0 1 2 3 4 D) 1 2 3 4 5
Answer: C (Explanation: The else part is executed if control doesn’t break out of the loop)
for i in range(5):
if i == 5:
break
else:
print(i)
else:
print("Here")
A) 0 1 2 3 4 Here B) 0 1 2 3 4 5 Here
C) 0 1 2 3 4 D) 1 2 3 4 5
Answer: A (Explanation: The else part is executed if control doesn’t break out of the loop)
x = (i for i in range(3))
for i in x:
print(i)
A) 0 1 2 B) error
C) 0 1 2 0 1 2 D) none of the mentioned
x = (i for i in range(3))
for i in x:
print(i)
for i in x:
print(i)
A) 0 1 2 B) error
C) 0 1 2 0 1 2 D) none of the mentioned