-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
Difficulty Level: medium
Q1: What is the purpose of the match statement in Python? (1 points)
Q2: Which Python version introduced the match-case statement? (1 points)
Q3: What is the correct syntax of a match statement? (1 points)
Q4: What will this code print? (1 points)
x = 3
match x:
case 1:
print("One")
case 2:
print("Two")
case 3:
print("Three")
Q5: What happens if no case matches in a match statement? (1 points)
Q6: Which symbol is used for the default case in match-case? (1 points)
Q7: What will this code output? (1 points)
x = "red"
match x:
case "blue":
print("Blue color")
case "green":
print("Green color")
case _:
print("Other color")
Q8: Can match-case be used with strings in Python? (1 points)
Q9: What will be printed? (1 points)
x = 10
match x:
case 5 | 10 | 15:
print("Multiple Match")
case _:
print("No Match")
Q10: What keyword starts the alternative condition in match-case? (1 points)
Q11: What will be the output of this code? (1 points)
status = 404
match status:
case 200:
print("OK")
case 404:
print("Not Found")
case _:
print("Unknown")
Q12: What is pattern matching used for in Python match-case? (1 points)
Q13: What will this code print? (1 points)
data = ("Alice", 25)
match data:
case ("Alice", age):
print(f"Alice is {age}")
case _:
print("No match")
Q14: Which of the following is true about match-case? (1 points)
Q15: What will this code output? (1 points)
num = -5
match num:
case x if x > 0:
print("Positive")
case x if x < 0:
print("Negative")
case _:
print("Zero")
Welcome to the Python Match Quiz.
This quiz is designed to test your understanding of Python’s match statement and basic pattern matching. Please read the instructions before you begin.
Quiz Format
Total Questions: 15
Difficulty Level: Medium
Question Type: Multiple Choice
Each question has one correct answer.
Timing
You will get a total of 10 minutes to complete the quiz.
Manage your time carefully and move steadily through each question.
Scoring
Each correct answer = +1 point
No negative marking
Maximum Score = 15 points
How to Play
Read each question carefully.
Understand how the match block processes patterns.
Select the option you think is correct.
Once you move to the next question, you cannot go back.
Rules
Do not refresh or close the quiz page.
Avoid using external help.
Keep an eye on the timer.
Before You Start
You can review the Python match tutorial here: Free Python Match Tutorial
After Submission
Your score will be displayed immediately.
You can review the correct answers to learn and improve.
