Arithmetic Operators
Standard Arithmetic Operators ( + - * / )
Standard arithmetic functions work as normal in Python. Take note that multiplication is achieved using an asterisk * .
a = 5 b = 3 result = a + b
result = a - b print(result) #The output will be 2.
result = a * b print(result) #The output will be 15.
a = 10 b = 2 result = a / b print(result) # The output will be 5.0.
Arithmetic operators are used to perform [[mathematical]] calculations.
{"cloze_text": "Arithmetic operators are used to perform [[mathematical]] calculations."}
The arithmetic operator [[*]] is used to perform multiplication.
{"cloze_text": "The arithmetic operator [[*]] is used to perform multiplication."}
In Python, what is the result of the expression 20 - 10?
{"answers": {"A": "10", "B": "None", "C": "30", "D": "20"}, "question_text": "In Python, what is the result of the expression 20 - 10?", "correct_answer": "A"}
Modulo (%)
The modulo operator is used to find the remainder of a division. For example:
a = 15 b = 4 result = a % b print(result) #The output will be 3.
What is the remainder when 7 is divided by 2?
{"answers": {"A": "3", "B": "2", "C": "1", "D": "0"}, "question_text": "What is the remainder when 7 is divided by 2?", "correct_answer": "C"}
Floor division
Floor division (also known as integer division) is performed using the double forward slash operator //.
It divides one number by another and returns the quotient rounded down to the nearest whole number.
x = 10
y = 3
result = x // y # Floor division of 10 by 3
print(result) # Output: 3
What is the result of 10 // 3?
{"answers": {"A": "3", "B": "2", "C": "3.33", "D": "2.5"}, "question_text": "What is the result of 10 // 3?", "correct_answer": "A"}
Exponentiation (**)
The exponentiation operator is used to raise a number to a power.
Example:
a = 2
b = 3
result = a ** b
print(result) #The output will be 8.
In Python, what is the result of 2 ** 4?
{"answers": {"A": "6", "B": "0.5", "C": "16", "D": "8"}, "question_text": "In Python, what is the result of 2 ** 4?", "correct_answer": "C"}
Review: Fill in the Blanks
Standard arithmetic operators in Python include addition, subtraction, multiplication, and division. Multiplication is represented by the (*), while division is performed using the (/). For example, if you have variables a and b, you can find the sum of a and b using the expression a + b.
The modulo operator, denoted by (%), is utilized to determine the of a division. For instance, if a is 15 and b is 4, the expression a % b will yield a result of 3, which represents the remainder when 15 is divided by 4.
Floor division, also known as integer division, is executed using the (//). This operator divides one number by another and returns the rounded down to the nearest whole number. For example, using x = 10 and y = 3, the expression x // y gives an output of 3.
Exponentiation is performed with the (**) operator, which raises a number to a specific . For instance, if a is 2 and b is 3, the expression a ** b will produce a result of 8, as it calculates 2 raised to the power of 3.
The modulo operator, denoted by (%), is utilized to determine the of a division. For instance, if a is 15 and b is 4, the expression a % b will yield a result of 3, which represents the remainder when 15 is divided by 4.
Floor division, also known as integer division, is executed using the (//). This operator divides one number by another and returns the rounded down to the nearest whole number. For example, using x = 10 and y = 3, the expression x // y gives an output of 3.
Exponentiation is performed with the (**) operator, which raises a number to a specific . For instance, if a is 2 and b is 3, the expression a ** b will produce a result of 8, as it calculates 2 raised to the power of 3.
Click the keywords below to fill in the blanks:
Remainder
Forward Slash
Asterisk
Quotient
Double Asterisk
Power
Percent Sign
Double Forward Slash
â All blanks filled correctly! Great job!
Complete! Ready to test your knowledge?
Arithmetic Operators in Python
- Standard Arithmetic Operators ( + - * / )
- Modulo (%)
- Floor division
- Exponentiation (**)
Topic Tests
Š learnlearn.uk 2025 |
[email protected] |
Privacy Policy.