Learn Python MCQs

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

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

1) abcabcabc

2) Error

3) None

4) 3abc

Answer : abcabcabc

How do you check the data type of a variable in Python?

1) type(var)

2) isinstance(var, type)

3) Both a and b

4) None of the above

Answer : Both a and b

What is the output of print(sorted([3, 1, 2], reverse=True))?

1) [3, 2, 1]

2) [1, 2, 3]

3) Error

4) None

Answer : [3, 2, 1]

How do you create a subclass in Python?

1) class SubClass(ParentClass):

2) class SubClass extends ParentClass:

3) class SubClass inherits ParentClass:

4) None of the above

Answer : class SubClass(ParentClass):

What is the output of print("a" in "abc")?

1) True

2) False

3) Error

4) None

Answer : True

How do you declare a global variable in Python?

1) global variable

2) var = global

3) global var

4) None of the above

Answer : global variable

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

1) [2, 3]

2) [1, 2]

3) Error

4) [2]

Answer : [2, 3]

How do you convert a list to a string in Python?

1) '.join(list)

2) str(list)

3) list.toString()

4) None of the above

Answer : '.join(list)

What is the output of print("Hello, World!".count("o"))?

1) 2

2) 1

3) Error

4) None

Answer : 1

How do you get the length of a string in Python?

1) len(string)

2) string.length()

3) string.len()

4) None of the above

Answer : len(string)