Learn Python MCQs

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

How do you import a module in Python?

1) import module_name

2) from module_name import *

3) Both a and b

4) None of the above

Answer : Option 1

What is the output of print(1 == 1.0)?

1) True

2) False

3) Error

4) None

Answer : Option 1

How do you access the first element of a list in Python?

1) list[0]

2) list[1]

3) list.first()

4) None of the above

Answer : Option 1

What is the output of print(list("123"))?

1) ['1', '2', '3']

2) Error

3) None

4) 123

Answer : Option 1

How do you create a non-local variable in Python?

1) nonlocal variable

2) variable = nonlocal

3) local variable

4) None of the above

Answer : Option 1

What is the output of print("123".isdigit())?

1) True

2) False

3) Error

4) None

Answer : Option 1

How do you create a function that takes variable arguments in Python?

1) def func(*args):

2) def func(args):

3) def func(**args):

4) None of the above

Answer : Option 1

What is the output of print([1, 2, 3][1:2])?

1) [2]

2) [1, 2]

3) Error

4) [2, 3]

Answer : Option 1

How do you define a method that can accept any number of keyword arguments?

1) def method(**kwargs):

2) def method(*args):

3) None of the above

4) def method(args):

Answer : Option 1

What is the output of print([1, 2] == [1, 2])?

1) True

2) False

3) Error

4) None

Answer : Option 1