Numbers in Python

It's easy to crunch numbers in Python. Let's add two numbers and print the result:

print(1.5 + 2)

The result of running this code is:


We can also store the numbers in variables, and then add the values using the variables:

a = 1.5
b = 2
print(a + b)

Variables are often used to store input from users (e.g. if we created a calculator application), and then do things with those values later.

Next: Strings in Python 3


Leave a comment

What color are brown eyes? (spam prevention)
Code under MIT License unless otherwise indicated.
© 2020, Downranked, LLC.