Python - MCQ

Multiple Choice Questions


Share with a Friend

 

Python - Multiple Choice Questions (MCQ) - Python Operators and Control Flow Statements - Set 13

26. What is the output of the following code

def func1():
    x = 50
    return x
func1()
print(x)
A). 0
B). 50
C). NameError
D). None
View Answer
Correct: C



27. In Python 3, what is the type of type(range(5))
A). int
B). list
C). range
D). tuple
View Answer
Correct: C


28. What is the data type of the following

aTuple = (11, 'Anand', 1+3j)
print(type(aTuple[2:3]))
A). list
B). complex
C). tuple
D). dictionary
View Answer
Correct: C



29. What is the output of the following code

print(bool(0), bool(3.14159), bool(-3), bool(1.0+1j))
A). False True False True
B). True True False True
C). True True False True
D). False True True True
View Answer
Correct: D


30. Please select the correct expression to reassign a global variable “x” to 20 inside a function fun1()

x = 50
def fun1():
    # your code to assign global x = 20
fun1()
print(x) # it should print 20
A). global x =20
B). global var x
x = 20
C). global.x = 20
D). global x
x = 20
View Answer
Correct: D



31. What is the data type of print(type(10))
A). float
B). integer
C). int
D). double
View Answer
Correct: C



 
 
 
   
   
   
UltraInfo Technologies
ITDeveloper