python banner

Python Multiple Choice Questions (MCQs) and Answers

Master Python Programming with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Python Programming. Begin your placement preparation journey now!

Q31

Q31 In Python, which keyword is used to check additional conditions if the previous conditions fail?

A

elif

B

else if

C

then

D

switch

Q32

Q32 What will happen if the condition in an if statement in Python evaluates to False?

A

The program will stop

B

It will execute the else block

C

It will raise an error

D

It will skip to the next if

Q33

Q33 Which of the following is a valid conditional statement in Python?

A

if a = 5:

B

if a == 5:

C

if a <> 5:

D

if (a = 5):

Q34

Q34 What is the outcome if the elif and else blocks are missing in an if statement?

A

Syntax error

B

The program will stop

C

Nothing, it's optional

D

Runtime error

Q35

Q35 What is the output of the following code?

x = 10;
if x > 5:
print("Greater")

A

Error

B

Greater

C

Nothing

D

Less

Q36

Q36 What will the following code print?

x = 10;
if x < 10:
print("Less");
else:
print("Not Less")

A

Less

B

Not Less

C

Error

D

Nothing

Q37

Q37 Pseudocode:

If age > 18,
print "Adult",
else
print "Minor"

A

Prints "Adult"

B

Prints "Minor"

C

Prints "Age"

D

No output

Q38

Q38 Pseudocode:

Check if a number is divisible by 2,
if yes
print "Even",
otherwise
"Odd"

A

Prints "Even"

B

Prints "Odd"

C

Error

D

No output

Q39

Q39 Pseudocode: What is printed when the temperature is 25 degrees?

If temperature > 30,
print "Hot",
elif temperature > 20,
print "Warm",
else
"Cold"

A

Prints "Hot"

B

Prints "Warm"

C

Prints "Cold"

D

No output

Q40

Q40 Identify the error:

if x > 10
print("Greater")

A

Missing parentheses around condition

B

No error

C

Missing colon after condition

D

Incorrect comparison operator

Q41

Q41 Find the mistake:

if x > 5:
print("Yes")
elif x < 10:
print("No")

A

Syntax error in the if block

B

Missing colon after elif

C

Missing else between blocks

D

No error

Q42

Q42 What is the use of a for loop in Python?

A

To repeat a block a fixed number of times

B

To check a condition

C

To declare variables

D

To handle exceptions

Q43

Q43 Which statement immediately terminates a loop in Python?

A

break

B

continue

C

exit

D

stop

Q44

Q44 What does the continue statement do inside a loop?

A

Pauses the loop

B

Stops the loop

C

Skips the current iteration

D

Exits the program

Q45

Q45 In a while loop, what happens if the condition never becomes False?

A

The loop runs forever

B

The loop stops after 10 iterations

C

Syntax error

D

The loop doesn't start

Q46

Q46 What is the difference between a for loop and a while loop in Python?

A

for is used for fixed iterations

B

while is faster than for

C

for can't use conditional statements

D

There is no difference

Q47

Q47 What is the output of the following code?

for i in range(3):
print(i)

A

"0 1 2"

B

"1 2 3"

C

"0 1 2 3"

D

"Error"

Q48

Q48 What will the following code print?

i = 5;
while i > 0:
print(i);
i -= 1

A

5 4 3 2 1

B

5 4 3 2

C

1 2 3 4 5

D

Infinite loop

Q49

Q49 Pseudocode:

Set x = 10;
While x > 0,
decrement x by 1,
print x

A

Prints numbers from 10 to 1

B

Prints numbers from 1 to 10

C

Prints numbers from 9 to 0

D

Infinite loop

Q50

Q50 Pseudocode:

For each element in list [1, 2, 3],
print element

A

Prints 1 2 3

B

Prints 3 2 1

C

Prints [1, 2, 3]

D

No output

Q51

Q51 Pseudocode:

For numbers 1 to 5,
print number
if it's odd

A

Prints 1 3 5

B

Prints 2 4

C

Prints all numbers 1 to 5

D

No output

Q52

Q52 Pseudocode:

For i = 0 to 4,
print "Python"
if i is even

A

Prints "Python" twice

B

Prints "Python" three times

C

Prints "Python" four times

D

No output

Q53

Q53 Identify the error:
for i in range(5)
print(i)

A

Missing colon after range(5)

B

Missing parentheses around print

C

Syntax error in range

D

No error

Q54

Q54 Find the mistake:

while True:
print("Looping");
break

A

Infinite loop

B

No error

C

The loop will never break

D

Incorrect use of print statement

Q55

Q55 What is the main difference between a list and a tuple in Python?

A

Syntax

B

Data type

C

Mutability

D

Method of declaration

Q56

Q56 How do you access the last element of a list named myList?

A

myList[0]

B

myList[-1]

C

myList[len(myList)]

D

myList[-2]

Q57

Q57 In Python, how can you combine two lists, list1 and list2?

A

list1 + list2

B

list1.append(list2)

C

list1.combine(list2)

D

list1.extend(list2)

Q58

Q58 What does myList[::-1] do?

A

Reverses myList

B

Copies myList

C

Removes the last element from myList

D

Sorts myList in descending order

Q59

Q59 How is memory allocation for lists and tuples different in Python?

A

Lists use more memory than tuples

B

Tuples use more memory than lists

C

Both use the same amount of memory

D

Memory usage is random and unpredictable

Q60

Q60 What will be the output of the following code?

myTuple = (1, 2, 3);
print(myTuple[1])

A

1

B

2

C

3

D

Error

ad vertical
ad