Learn Python MCQs

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

What is the output of print(5 | 3)?

1) 7

2) 8

3) 6

4) None

Answer : Option 1

How do you get the current working directory in Python?

1) os.getcwd()

2) getcwd()

3) os.current_directory()

4) None of the above

Answer : Option 1

Which of the following methods can be used to add elements to a list?

1) append()

2) insert()

3) extend()

4) All of the above

Answer : Option 1

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

1) abcabc

2) Error

3) None

4) abc + abc

Answer : Option 1

How do you check if a variable is of a specific type in Python?

1) isinstance(var, type)

2) type(var) == type

3) var.type() == type

4) None of the above

Answer : Option 1

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

1) [1, 2, 3]

2) [3, 2, 1]

3) Error

4) None

Answer : Option 1

How do you concatenate two lists in Python?

1) list1 + list2

2) list1.append(list2)

3) list1.extend(list2)

4) None of the above

Answer : Option 1

What is the output of print("Hello".replace("e", "a"))?

1) Hallo

2) Hello

3) Error

4) Halla

Answer : Option 1

How do you check if a string is a palindrome in Python?

1) s == s[::-1]

2) s.is_palindrome()

3) s == reverse(s)

4) None of the above

Answer : Option 1

What is the output of print(abs(-10))?

1) 10

2) -10

3) Error

4) None

Answer : Option 1