FREE! Click here to Join FunTrivia. Thousands of games, quizzes, and lots more!
Quiz about The Zen of Confusion Python Edition
Quiz about The Zen of Confusion Python Edition

The Zen of Confusion: Python Edition Quiz


Welcome to The Zen of Python, where whitespace is sacred, bugs are inevitable, and every question is a riddle wrapped in an exception. Enlightenment awaits... if you survive all 10 questions. Have fun.

A multiple-choice quiz by Hesting_horts. Estimated time: 2 mins.
  1. Home
  2. »
  3. Quizzes
  4. »
  5. Science Trivia
  6. »
  7. Computers
  8. »
  9. Software and Programming

Time
2 mins
Type
Multiple Choice
Quiz #
421,533
Updated
Oct 26 25
# Qns
10
Difficulty
Average
Avg Score
6 / 10
Plays
24
Last 3 plays: dmaxst (1/10), Guest 222 (1/10), lethisen250582 (10/10).
Author's Note: This quiz is designed for those who are already well-versed in Python, its syntax, behavior, and subtle corner cases. The questions are intentionally tricky and aim to challenge your understanding of how Python really works under the hood. While it's not intended for complete beginners, anyone curious and eager to learn is welcome to give it a try. You might be surprised by how even the simplest-looking code can reveal unexpected behavior.
- -
Question 1 of 10
1. What is the output of print("5" * 3)? Hint


Question 2 of 10
2. What is the output of print([i for i in range(3)])? Hint


Question 3 of 10
3. What is the output of print(bool("False"))?


Question 4 of 10
4. What does the following snippet output and why?
x = [False] * 3
print(any(x))
Hint


Question 5 of 10
5. Which of these statements about Python functions is TRUE? Hint


Question 6 of 10
6. What is the output of this code?
a = [1, 2, 3]
b = a
b.append(4)
print(a)
Hint


Question 7 of 10
7. Which of the following is NOT a valid way to create a set in Python? Hint


Question 8 of 10
8. What is the output of this code?
print(bool([0]), bool(), bool(()))
Hint


Question 9 of 10
9. What is the output of the following code?
x = 5
x = x++ + ++x
print(x)
Hint


Question 10 of 10
10. What will be the output of the following snippet?
x = [1, 2, 3]
del x[1]
print(x)
Hint



(Optional) Create a Free FunTrivia ID to save the points you are about to earn:

arrow Select a User ID:
arrow Choose a Password:
arrow Your Email:




Most Recent Scores
Today : dmaxst: 1/10
Today : Guest 222: 1/10
Today : lethisen250582: 10/10
Today : Joepetz: 10/10
Today : pingohits: 8/10
Today : james1947: 10/10
Today : griller: 10/10
Today : Olderbison: 3/10
Today : Guest 80: 6/10

Quiz Answer Key and Fun Facts
1. What is the output of print("5" * 3)?

Answer: "555"

This is one of those quirky Python behaviors that surprises many! When you multiply a string by an integer, Python repeats the string that many times. So "5" * 3 becomes "555". It's not math, it's string repetition. This trick is often used in formatting or generating patterns. Just remember that strings and numbers don't mix unless you convert them explicitly.
2. What is the output of print([i for i in range(3)])?

Answer: [0, 1, 2]

List comprehension is a Pythonic way to build lists. range(3) generates numbers from 0 to 2, and the list comprehension wraps them into a list. It's a concise, readable, and powerful, perfect for filtering or transforming data.
3. What is the output of print(bool("False"))?

Answer: True

This one's sneaky! Even though the string is "False", it's still a non-empty string, and in Python, any non-empty string evaluates to True. So bool("False") is True. It's a great reminder to understand truthy and falsy values.
4. What does the following snippet output and why? x = [False] * 3 print(any(x))

Answer: False, because all elements are False

In Python, [False] * 3 creates a list with three False values, not a mathematical operation. This is a neat trick to initialize lists with repeated elements. The any() function then checks if any item in that list is truthy. Since all elements are False, any(x) returns False. If even one element were True, the result would flip.

This makes any() perfect for quick validations, like checking if a user filled out at least one field in a form. Its counterpart, all(), returns True only if every item is truthy. Together, they're Python's dynamic duo for logical checks.
5. Which of these statements about Python functions is TRUE?

Answer: Functions can return multiple values by packing them into a single tuple

Python functions are flexible! They can return multiple values using tuples. You can unpack them easily, making your code clean and expressive. Functions don't need to have parameters or need to return values. They can be as simple or complex as you need.
6. What is the output of this code? a = [1, 2, 3] b = a b.append(4) print(a)

Answer: [1,2,3,4]

Python doesn't have traditional pointers like C or C++, but it does use references. When you assign b = a, both a and b point to the same list object in memory. So, when b.append(4) is called, it modifies the list that a also refers to. To avoid this, use b = a.copy() or b = list(a) to create a separate copy. Python's reference model is subtle, and it can lead to unexpected side effects if you're not careful.
7. Which of the following is NOT a valid way to create a set in Python?

Answer: set(1, 2, 3)

In Python, (1, 2, 3) is a tuple, [1, 2, 3] is a list, and {1, 2, 3} is a set. A tuple is an ordered and immutable sequence, a list is ordered and mutable, and a set is an unordered collection of unique items. (Mutable means the object can be changed after it's created-like adding, removing, or modifying elements.) All three are single objects that contain multiple elements.

However, when using the set() constructor, it's crucial to pass one iterable-like set([1, 2, 3]), not multiple individual arguments like set(1, 2, 3), which throws a TypeError. That's because set(1, 2, 3) is interpreted as three separate inputs, not one container.

This mistake often happens when developers confuse the syntax of sets with that of lists or tuples. Sets are especially useful for removing duplicates and checking membership quickly.
8. What is the output of this code? print(bool([0]), bool({}), bool(()))

Answer: True False False

In Python, empty containers like lists, dictionaries, and tuples, are considered false. This means they evaluate to False in boolean contexts. It's a handy shortcut for checking if something has content. But be careful, a container with zero-like values (e.g., [0]) is still true because it's not empty.
9. What is the output of the following code? x = 5 x = x++ + ++x print(x)

Answer: SyntaxError

Python does not support ++ or -- operators. Trying to use x++ will result in a SyntaxError. This often trips up developers coming from C-like languages. Interestingly, ++x is technically valid, but it's interpreted as +(+x), which does nothing. Python prefers clarity, so it uses x += 1 and x -= 1 for incrementing and decrementing.

It's a great example of how Python avoids ambiguous syntax in favor of readability. Although if you do something like that in C or C++ answer will be 12 (5+7).
10. What will be the output of the following snippet? x = [1, 2, 3] del x[1] print(x)

Answer: [1,3]

The del keyword in Python is a powerful tool for managing memory and controlling variable scope. It can be used to delete specific elements from sequences like lists or to completely remove variables from the current namespace. In the example above, del x[1] removes the element at index 1, which is 2, resulting in the list [1, 3].

However, if you use del x without an index, it deletes the entire variable x. Any attempt to access x afterward will raise a NameError because it no longer exists. This makes del useful but potentially dangerous if misused, especially in large codebases where variable tracking is critical. Always double-check what you're deleting!
Source: Author Hesting_horts

This quiz was reviewed by FunTrivia editor WesleyCrusher before going online.
Any errors found in FunTrivia content are routinely corrected through our feedback system.
10/26/2025, Copyright 2025 FunTrivia, Inc. - Report an Error / Contact Us