MCQ

Python MCQ and Answers – Part 6

This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer.
 

1. What is the output of the following code?
nbrs = [1, 2, 3]
print(nbrs)

A 1, 2, 3

B 1 2 3

C [1, 2, 3]

D [1 2 3]  
 

C
 

2. What is the output of the following code?
print 0.1 + 0.2 == 0.3

A False

B True

C Depends on System

D Error

A
Neither 0.1, 0.2 nor 0.3 can be represented in binary. The rounding errors of 0.1 and 0.2 result in a difference of 5.5511e-17 between (0.1 + 0.2) and 0.3.
 

3. What is the output of the following code?
print(5 >= 5)

A 5 >= 5

B True

C False

D None

B
 

4. Which one is not a complex number?

A z = 1 + 2j

B z = 1 + 2l

C z = 1 + 2J

D z = complex(1, 2)

B
 

5. An instruction using the “AND” operator returns “true” if _______

A Both operands are “true”

B Both operands are “false”

C One of the operands is “true”

D The first operand is “true”

A
 

6. Which of the following statements is correct about Python?

A It automatically takes care of the garbage collector.

B It can be easily integrated with C, C ++, COM, ActiveX, CORBA and Java.

C Both A and B are true.

D All the answers are true

C
 

7. Based on the following code, which of the following statements is true?
def sayHello():
    print("Hello")     
str = sayHello()

A sayHello() is a function, str is a variable. The two are not objects.

B sayHello() and str refer to the same object.

C sayHello() and str refer to different objects.

D Syntax error! You cannot assign a function to a variable in Python.

C
 

8. What is the output of the following code?
def fun1():
    global x
    x = 20
    def fun2():
        global x
        x = 30
        print('x =', x)  
x = 10
fun1()
print('x =', x)

A x = 10

B x = 20

C x = 30

D x = 10 x = 30

B
 

9. Which of these data types is not a basic type in Python?

A Lists

B Class

C Dictionary

D Tuples

B
“Class” is a user-defined data type
 

10. Which of the following statements is true?

A An object is constructed from a class

B You can only create one object from a given class.

C Both A and B are true.

D All the answers are true

A
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *