Python Quiz

/30

The test begins as soon as you click the Start button. You may continue working until the time limit expires. When the time is up, your test will be submitted automatically, whether you have finished or not. Please manage your time carefully and review your answers before the deadline.

When your time is up, your test will be submitted automatically, whether you have finished answering or not. Please manage your time wisely.


Python quiz

Python Practice Quiz: 30 Logical & Coding Questions

Test your Python knowledge with 30 carefully selected questions, ranging from basics to tricky logical problems. Perfect for beginners and intermediate learners.

1 / 30

Which method removes the last element from the list?

2 / 30

Which method removes an element by value?

3 / 30

Which method returns sorted list without modifying original?

4 / 30

What does __repr__ return?

5 / 30

Which prefix makes variable private in class?

6 / 30

Which decorator makes method belong to class not object?

7 / 30

What is the output?

print(len(set([1,2,2,3,3,3])))

 

8 / 30

Which function returns both index and value in a loop?

9 / 30

Which function checks the existence of a path?

10 / 30

Who developed Python?

11 / 30

What will be the output?

a = []

for i in range(3):

   a.append(lambda x: i * x)

print([f(2) for f in a])

12 / 30

How do you check if a key exists in a dictionary?

13 / 30

What is polymorphism?

14 / 30

Which method returns dictionary items as pairs?

15 / 30

What is the output?

def add(a, b=[]):

   b.append(a)

   return b

print(add(1))

print(add(2))

16 / 30

What keyword is used for exception handling?

17 / 30

What is Python?

18 / 30

Predict the result:

print({True: "yes", 1: "no", 0: "zero", False: "false"})

19 / 30

Predict the output:

print([x for x in "Python" if x in "aeiou"])

20 / 30

What will be the output?


a = [1, 2, 3]
b = a
b.append(4)
print(a)

21 / 30

What is the output?

print("hello world".title())

 

22 / 30

What is a decorator in Python?

23 / 30

What does if __name__ == "__main__": do?

24 / 30

Which of the following statements about Python are TRUE?

25 / 30

What does **kwargs represent?

26 / 30

Which keyword calls parent class method?

27 / 30

What is the output?

print({x: x**2 for x in range(3)})

28 / 30

What is the output?

print(0.1 + 0.2 == 0.3)

29 / 30

Which method clears all elements from a list?

30 / 30

What is the output of

len({"a": 1, "b": 2})

Your score is

0%

Scroll to Top