Learning Guides
Python Quiz for Beginners: Test Your Basics (Level 1)
Quick answer: A beginner-level Python quiz covering variables, data types, loops, functions and lists, with explained answers to test your fundamentals.
How to Use This Quiz
Try answering each question yourself before checking the answer. This level covers Python fundamentals: variables, data types, conditionals, loops, functions and lists.
Question 1: Output Prediction
x = 5
y = "5"
print(x == y)
Show Answer
False. x is an integer and y is a string. Python's == compares both value and type here since they are different types, so they are never equal even though they look similar.
Question 2: List Mutability
a = [1, 2, 3]
b = a
b.append(4)
print(a)
Show Answer
[1, 2, 3, 4]. b = a does not create a copy; both names point to the same list object, so modifying b also changes what a sees.
Question 3: Loop Output
for i in range(1, 10, 3):
print(i)
Show Answer
1, 4, 7. range(1, 10, 3) starts at 1, stops before 10, and steps by 3 each time.
Question 4: Function Return
def check(n):
if n % 2 == 0:
return "Even"
return "Odd"
print(check(7))
Show Answer
Odd. 7 divided by 2 leaves a remainder of 1, so the if condition is false and the function falls through to the final return statement.
Question 5: String Slicing
text = "Fireblaze"
print(text[2:5])
Show Answer
reb. Slicing starts at index 2 (the third character) and stops before index 5, giving characters at positions 2, 3 and 4.
Question 6: Type Conversion
print(int("42") + int("8"))
Show Answer
50. Both strings are converted to integers before addition, so this performs numeric addition, not string concatenation.
Question 7: Boolean Logic
print(True and False or True)
Show Answer
True. Python evaluates and before or, so this is (True and False) or True, which is False or True, giving True.
How to Interpret Your Score
If you answered 6 or 7 correctly without checking the answer first, you have a solid grip on Python fundamentals and are ready to move on to Pandas and data manipulation. If you missed several, revisit lists, loops and basic operators before moving forward.
FAQ
Frequently Asked Questions
What topics does this beginner Python quiz cover?
Variables, data types, conditionals, loops, functions and lists, all at a fundamental level appropriate for someone new to Python.
Why does list assignment like b = a cause both variables to change together?
In Python, variables are references to objects, not copies of the data itself. Assigning one variable to another copies the reference, so both names point to the same underlying list.
Why does Python evaluate 'and' before 'or' in a boolean expression?
Python follows a defined operator precedence where 'and' binds tighter than 'or', similar to how multiplication is evaluated before addition in arithmetic.
Keep Reading
Related Articles
Learning Guides
INNER JOIN in SQL with Examples: Complete Beginner's Guide
Learn INNER JOIN in SQL with practical examples, syntax, interview questions, and real-world use cases. A complete beginner-friendly SQL JOI
Learning Guides
OUTER JOIN in SQL: Complete Guide with Examples for Beginners
Master OUTER JOIN in SQL with practical examples and real-world scenarios. Learn LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, syntax, use cases,
Learning Guides
Multi-Row Functions in SQL: Complete Guide with Examples
Learn multi-row (aggregate) functions in SQL including SUM, AVG, COUNT, MIN, MAX, GROUP BY and HAVING, with practical examples, NULL handlin