Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does the + operator do in Python?
The + operator adds two numbers together. For example, 3 + 2 equals 5.
Click to reveal answer
beginner
What is the result of 7 - 4 in Python?
The result is 3 because the - operator subtracts the right number from the left number.
Click to reveal answer
beginner
Explain the * operator in Python.
The * operator multiplies two numbers. For example, 5 * 6 equals 30.
Click to reveal answer
beginner
What does the / operator do?
The / operator divides the left number by the right number and gives a decimal result. For example, 8 / 4 equals 2.0.
Click to reveal answer
intermediate
What is the difference between / and // operators?
The / operator gives a decimal (float) result, while the // operator gives the whole number part only (floor division). For example, 7 / 2 is 3.5, but 7 // 2 is 3.
Click to reveal answer
What is the result of 4 + 5 * 2 in Python?
A14
B18
C13
D10
✗ Incorrect
Multiplication happens before addition, so 5 * 2 = 10, then 4 + 10 = 14.
Which operator gives the remainder of a division?
A+
B%
C//
D/
✗ Incorrect
The % operator gives the remainder after division.
What does 10 // 3 return?
A3
B3.33
C1
D4
✗ Incorrect
// does floor division, so it returns the whole number part only.
What is the output of 2 ** 3?
A9
B6
C8
D5
✗ Incorrect
** is the power operator, so 2 to the power of 3 is 8.
Which operator would you use to multiply two numbers?
A+
B/
C-
D*
✗ Incorrect
The * operator multiplies two numbers.
List the basic arithmetic operators in Python and explain what each one does.
Think about adding, subtracting, multiplying, dividing, and powers.
You got /14 concepts.
Explain the difference between / and // operators with examples.
One gives decimals, the other gives whole numbers.
You got /5 concepts.
Practice
(1/5)
1. Which arithmetic operator in Python is used to find the remainder of a division?
easy
A. **
B. //
C. %
D. +
Solution
Step 1: Understand the meaning of each operator
The operator % gives the remainder after division, // gives the floor division result, ** is for power, and + is for addition.
Step 2: Identify the operator for remainder
The remainder operator is %, which returns the leftover part after dividing two numbers.
Final Answer:
% -> Option C
Quick Check:
Remainder operator = % [OK]
Hint: Remainder operator looks like a percent sign % [OK]
Common Mistakes:
Confusing // (floor division) with %
Using ** instead of %
Thinking + gives remainder
2. Which of the following is the correct operator syntax to calculate 5 to the power of 3 in Python?
easy
A. 5 ^ 3
B. pow(5, 3)
C. 5 ^^ 3
D. 5 ** 3
Solution
Step 1: Recall Python's power operator syntax
Python uses ** to calculate powers, so 5 ** 3 means 5 to the power of 3.
Step 2: Check other options for correctness
5 ^ 3 is bitwise XOR, 5 ^^ 3 is invalid syntax, and pow(5, 3) is a function call but not an operator syntax.
Final Answer:
5 ** 3 -> Option D
Quick Check:
Power operator = ** [OK]
Hint: Use ** for power, not ^ or ^^ [OK]
Common Mistakes:
Using ^ instead of ** for power
Trying ^^ which is invalid
Confusing function pow() with operator syntax
3. What is the output of the following code?
result = 17 // 4
print(result)
medium
A. 4.25
B. 4
C. 1
D. Error
Solution
Step 1: Understand floor division operator //
The operator // divides and returns the largest whole number less than or equal to the result.
Step 2: Calculate 17 // 4
17 divided by 4 is 4.25, floor division drops the decimal part, so result is 4.
Final Answer:
4 -> Option B
Quick Check:
17 // 4 = 4 [OK]
Hint: Floor division drops decimals, so 17//4 is 4 [OK]
Common Mistakes:
Confusing // with / which gives float
Expecting 4.25 instead of 4
Thinking // rounds up
4. Find the error in this code snippet:
num = 10
result = num % 0
print(result)
medium
A. ZeroDivisionError at runtime
B. No error, output is 0
C. SyntaxError due to % operator
D. TypeError because 0 is int
Solution
Step 1: Understand modulo operator with zero
The modulo operator % cannot divide by zero; it causes an error.
Step 2: Identify the error type
Dividing or modulo by zero raises a ZeroDivisionError at runtime.
Final Answer:
ZeroDivisionError at runtime -> Option A
Quick Check:
Modulo by zero causes ZeroDivisionError [OK]
Hint: Modulo by zero causes runtime error, never allowed [OK]
Common Mistakes:
Thinking it causes syntax error
Expecting output 0 instead of error
Confusing with TypeError
5. You want to calculate the area of a square with side length stored in variable side. Which expression correctly uses arithmetic operators to do this?
hard
A. area = side ** 2
B. area = side // 2
C. area = side + side
D. area = side * 2
Solution
Step 1: Recall formula for square area
The area of a square is side length multiplied by itself, or side squared.
Step 2: Match formula with operators
Using side ** 2 calculates side to the power of 2, which is correct for area.