Explore topic-wise MCQs in Python.

This section includes 21 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of the below program ?

A. x is now 50
B. x is now 2
C. x is now 100
D. None of the mentioned
Answer» B. x is now 2
2.

What is the output of the function:

A. True
B. False
C. Error
D. 0
Answer» D. 0
3.

What are the outcomes of the functions shown below?

A. Error, 6
B. 12, Error
C. 12, 6
D. Error, Error
Answer» B. 12, Error
4.

What is the output of the expression?

A. 4.5
B. 4.6
C. 4.57
D. 4.56
Answer» D. 4.56
5.

What is the output of the functions shown below?

A. A65
B. Error65
C. ErrorError
D. ErrorJunk value
Answer» C. ErrorError
6.

The output of the function: (Note that the number of blank spaces before the number is 5)

A. -12345.0 (5 blank spaces before the number)
B. -12345.0
C. Error
D. -12345.000000000…. (infinite decimal places)
Answer» C. Error
7.

What is the output of the below program?

A. Hello World!Hello World!
B. ‘Hello World!’‘Hello World!’
C. HelloHello
D. None of the mentioned
Answer» B. ‘Hello World!’‘Hello World!’
8.

The function complex(‘2-3j’) is valid but the function complex(‘2 – 3j’) is invalid. State whether this statement is true or false.

A. True
B. False
C. May be
D. Can't say
Answer» B. False
9.

What is the output of below program?

A. Arthur Sir
B. Sir Arthur
C. Arthur
D. None of the mentioned
Answer» C. Arthur
10.

Suppose there is a list such that: l=[2,3,4].If we want to print this list in reverse order, which of the following methods should be used?

A. reverse(l)
B. list(reverse[(l)])
C. reversed(l)
D. list(reversed(l))
Answer» E.
11.

What is the output of the expression:

A. 4.5
B. 5
C. 4
D. 4.6
Answer» C. 4
12.

What is the output of the following piece of code when executed in Python shell?

A. 1
B. 0
C. An exception is thrown
D. ‘ ‘
Answer» C. An exception is thrown
13.

What are the outcomes of the following functions?

A. aError
B. ‘a’a
C. Errora
D. ErrorError
Answer» D. ErrorError
14.

Lambda contains block of statements.

A. True
B. False
C. May be
D. Can't say
Answer» C. May be
15.

The following piece of code is invalid. True or False?

A. True
B. False
C. May be
D. Can't say
Answer» C. May be
16.

Which of the following isn’t true about dictionary keys?

A. More than one key isn’t allowed
B. Keys must be immutable
C. Keys must be integers
D. When duplicate keys encountered, the last assignment wins
Answer» D. When duplicate keys encountered, the last assignment wins
17.

What is the output of the following snippet of code?

A. method del doesn’t exist for the dictionary
B. del deletes the values in the dictionary
C. del deletes the entire dictionary
D. del deletes the keys in the dictionary
Answer» D. del deletes the keys in the dictionary
18.

Execute the following in Python shell?

A. Syntax error
B. dict_items([(‘A’), (‘B’), (‘C’)])
C. dict_items([(1,2,3)])
D. dict_items([(1, ‘A’), (2, ‘B’), (3, ‘C’)])
Answer» E.
19.

What is the output?

A. 40
B. 45
C. “john”
D. “peter”
Answer» B. 45
20.

Read the code shown below carefully and pick out the keys?

A. “john”, 40, 45, and “peter”
B. “john” and “peter”
C. 40 and 45
D. d = (40:”john”, 45:”peter”)
Answer» C. 40 and 45
21.

–inf$

A.
B. –infinity
Answer» C.