Python as a calculator
Python is perfectly suited to do basic calculations. It can do addition, subtraction, multiplication and division.
The code in the script gives some examples.
Now it's your turn to practice by writing some code yourself.
This exercise is part of the course
Introduction to Python
Exercise instructions
- Print the result of subtracting
5
from5
under# Subtraction
usingprint()
. - Print the result of multiplying
3
by5
under# Multiplication
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Addition and division
print(4 + 5)
print(10 / 2)
# Subtraction
print()
# Multiplication