
Python Quiz
Think you know your stuff? This Python Quiz has 15 questions with answers and short explanations. No login – just play, score and compare with friends.
15 questionsMixed (easy → hard)~3 minNo timer
Updated:
If you liked this
Trending today
Bollywood QuizBollywood
India GK Question Answer Quiz (Indian GK)General Knowledge
Cricket World Cup QuizSports
सामान्य ज्ञान प्रश्न (GK in Hindi Questions)Hindi
Guess the FlagGeography
Current Affairs Quiz (October 2026)Current Affairs
Friends TV Series QuizMovies & TV
KBC क्विज़ (KBC Hindi Quiz)Hindi
F1 Quiz (Formula 1)Sports
Naruto QuizAnime & GamesAll Computers & Tech quizzes →
About this Python quiz
This Python quiz checks how well you really know the language, from the basics (who created it, def, comments and indentation) to the output-prediction questions that catch people out in tests and interviews: floor division, slicing, append versus extend, truthy strings, shared references and operator precedence. Every question is checked by running the code in Python 3.
It is made for students learning Python in school or college, candidates practising python MCQ questions for O Level, university or placement tests, and working developers who want a quick refresher. Each MCQ on Python has four options and an explanation that shows why the answer is what it is, so you can fix the gap in your understanding rather than just memorising.
Try predicting each output in your head before picking an option, then check the explanation. If you get one wrong, type the snippet into a Python shell and experiment with small changes - that is the fastest way to make the rule stick. The full answer key below doubles as a short revision sheet.
Fun fact: Python is not named after the snake. Guido van Rossum took the name from the BBC comedy show Monty Python's Flying Circus, which is why the official docs are sprinkled with spam and eggs jokes.
Python questions with answers
Show answers
Who created the Python programming language?
- Dennis Ritchie
- Guido van Rossum
- James Gosling
- Bjarne Stroustrup
Answer: Guido van Rossum. Guido van Rossum began Python in the late 1980s and released it in 1991. Ritchie created C, Gosling Java and Stroustrup C++.
Which keyword is used to define a function in Python?
- function
- func
- define
- def
Answer: def. Functions start with def, for example: def greet(name): followed by an indented body.
Which symbol starts a single-line comment in Python?
- # (hash)
- // (double slash)
- /* (slash star)
- -- (double hyphen)
Answer: # (hash). Everything after # on a line is ignored by Python. // is floor division in Python, not a comment.
How does Python mark which lines belong to a block, such as the body of a loop?
- Curly braces { }
- BEGIN and END keywords
- Indentation
- Semicolons
Answer: Indentation. Python uses indentation (usually four spaces) to group statements. Wrong indentation causes an IndentationError.
Which of these Python data types is immutable?
- list
- tuple
- dict
- set
Answer: tuple. A tuple cannot be changed after it is created. Lists, dictionaries and sets can be modified in place.
What is the output of print(7 // 2)?
- 3.5
- 4
- 3.0
- 3
Answer: 3. // is floor division: it divides and rounds down to a whole number, so 7 // 2 gives 3 (an int, since both operands are ints).
What is the output of print(10 / 2) in Python 3?
- 5.0
- 5
- 0.5
- Error
Answer: 5.0. In Python 3 the / operator always performs true division and returns a float, so 10 / 2 gives 5.0.
What does len("Hello") return?
- 4
- 6
- 5
- "Hello"
Answer: 5. len() counts the items in a sequence. "Hello" has five characters, so it returns 5.
What is the output of print("Hello"[::-1])?
- Hello
- olleH
- H
- o
Answer: olleH. The slice [::-1] steps through the string backwards, which reverses it: olleH.
Which block is used to catch and handle an error in Python?
- catch
- rescue
- on error
- except
Answer: except. Python uses try ... except. Code that might fail goes in try, and the except block runs if that error occurs.
What is the output of print(list(range(1, 10, 3)))?
- [1, 4, 7]
- [1, 4, 7, 10]
- [3, 6, 9]
- [1, 3, 6, 9]
Answer: [1, 4, 7]. range(start, stop, step) starts at 1, adds 3 each time and stops before 10, giving 1, 4 and 7.
a = [1, 2]; a.append([3, 4]). What is len(a) now?
- 2
- 4
- 3
- Error
Answer: 3. append() adds its argument as one item, so a becomes [1, 2, [3, 4]] with 3 items. extend() would have added 3 and 4 separately.
What is the output of print(bool("False"))?
- False
- True
- None
- Error
Answer: True. Any non-empty string is truthy, even the text "False". Only the empty string "" converts to False.
x = [1, 2, 3]; y = x; y.append(4). What does print(x) show?
- [1, 2, 3]
- [4]
- Error
- [1, 2, 3, 4]
Answer: [1, 2, 3, 4]. y = x does not copy the list; both names point to the same object, so changing y changes x too. Use x.copy() for a separate list.
What is the output of print(2 ** 3 ** 2)?
- 512
- 64
- 36
- 12
Answer: 512. The ** operator is right-associative, so Python works out 3 ** 2 = 9 first, then 2 ** 9 = 512.
Frequently asked questions
Where can I find Python questions with answers?
Right here. Once you finish the quiz, open the answer key below to see all 15 Python quiz questions with the correct option and a short explanation for each. Every code snippet has been run in Python 3, so the outputs are reliable.
How many questions are in this Python quiz?
There are 15 multiple-choice questions. The first few cover basics like syntax and keywords, and the later ones ask you to predict the output of short code snippets, which is harder.
Can I play the Python quiz online for free without signing up?
Yes. It is a free Python online test with no login or sign-up. Press start, answer the questions and see your score instantly, then share it with friends if you like.
Is this Python MCQ quiz useful for O Level and placement tests?
Yes, it covers the kind of concepts these tests ask about: data types, mutability, operators, slicing, range, list methods and exception handling. Use it as a quick self-check, and practise writing and running small programs too, since tests increasingly include code-reading questions.




