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:

3.5

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

Comments

Leave a comment

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