python mcqs test 2

Python MCQs Test 3

1 / 20

What is the purpose of the finally block in a try-except statement in Python?

2 / 20

How do you remove an item from a set named my_set in Python?

3 / 20

What does the max() function return in Python?

4 / 20

Which of the following is NOT a valid data type in Python?

5 / 20

What is the output of the following code? \npython\nx = "hello"\nprint(x[::-1])

6 / 20

What does the is keyword do in Python?

7 / 20

What is the output of the following code? \npython\nx = [1, 2, 3]\nx.append(4)\nprint(x)

8 / 20

Which of the following is NOT a valid way to concatenate strings in Python?

9 / 20

What does the split() method do in Python?

10 / 20

What is the output of the following code? \npython\nprint(2 ** 3)

11 / 20

What is the purpose of the else statement in Python loops?

12 / 20

How do you check if a key exists in a dictionary named my_dict in Python?

13 / 20

What is the result of the expression 4 + 5 * 2 / 2 in Python?

14 / 20

What is the output of the following code? \npython\nx = "hello"\nprint(x[1:3])

15 / 20

Which of the following is the correct way to open a file named example.txt in Python for writing?

16 / 20

What is the output of the following code? \npython\nprint("Python".find("t"))

17 / 20

What is the output of the following code? \npython\nprint("Python".find("t"))

18 / 20

What does the isdigit() method do in Python?

19 / 20

Which of the following is NOT a valid way to define a tuple in Python?

20 / 20

What does the remove() method do in Python?

Your score is

The average score is 65%

0%

Scroll to Top