|Previous Lesson||Table of Contents||Next Lesson|
Python can function as a basic calculator, allowing you to perform computations, however basic, much faster than most of us could using our own brainpower.
Here is a basic example:
print(1 + 1)
This will output:
Notice how we use print statements from Lesson 1 to display the output of this addition. Now this was a pretty simple calculation, but how about this one:
print(1581 * (7502 / (3.5 + 1)) - 0.25**5)
In less than half a second, Python outputs:
Notice here that we utilized addition, subtraction, multiplication, and
division in this one expression, with some not so friendly numbers! We
also added an exponential (denoted by the double asterisks
**) at the end.
Let’s now practice doing some other computations in Python:
Compute the sum of
5. Divide it by the product of
Compute the product of
6789. Then subtract from it
When you’re ready, click here to go to Lesson 3!