Learn Python MCQs

Prepare Python MCQs (Multiple choice Questions) for exam and job interviews.

What is the output of print("Python"[-2])?

1) o

2) Error

3) None

4) Python

Answer : Option 1

How do you swap two variables in Python?

1) a, b = b, a

2) swap(a, b)

3) a = b; b = a

4) a, b = a, b

Answer : Option 1

What is the output of print("a" * 3)?

1) aaa

2) Error

3) a + a + a

4) 3a

Answer : Option 1

How do you create a subclass in Python?

1) class SubClass(ParentClass):

2) class SubClass inherits ParentClass:

3) class SubClass extends ParentClass:

4) None of the above

Answer : Option 1

What is the output of print("abc".upper())?

1) ABC

2) abc

3) Abc

4) Error

Answer : Option 1

Which method is used to merge two dictionaries in Python?

1) dict.update()

2) dict.merge()

3) dict.combine()

4) None of the above

Answer : Option 1

What will be the output of print(1 == True)?

1) True

2) False

3) Error

4) None

Answer : Option 1

How do you create a tuple in Python?

1) myTuple = (1, 2, 3)

2) myTuple = [1, 2, 3]

3) myTuple = 1, 2, 3

4) Both a and c

Answer : Option 1

What is the output of print(len("abc"))?

1) 3

2) Error

3) None

4) 2

Answer : Option 1

How do you remove duplicates from a list in Python?

1) set(list)

2) list.set()

3) list.remove_duplicates()

4) None of the above

Answer : Option 1