Integer Numbers
You might be accustomed to specifying numbers in ways such as:
1,000,000
(with commas);1 000 000
(with spaces).
However, Python will not understand this.😢
These formats are understandable for a person but not for a computer, so the right way is 1000000
without commas or spaces.
Tarefa
Here is the distance from the sun to the Earth in miles: var1 = 91,400,000
. And here is the distance from the Earth to the moon: var2 = 238 855
. You need to adjust these number formats to be compatible with Python.
- Rewrite the values of these two distances so they are recognizable by Python;
- Output these variables by including their names in
print
function calls.
Note
If you have a strong desire to use separators, Python understands the following syntax:
var = 1_000_000
.
Tudo estava claro?
Conteúdo do Curso
Data Types in Python
1. Getting Familiar With Numbers in Python
4. Bring All the Topics Together
Data Types in Python
Integer Numbers
You might be accustomed to specifying numbers in ways such as:
1,000,000
(with commas);1 000 000
(with spaces).
However, Python will not understand this.😢
These formats are understandable for a person but not for a computer, so the right way is 1000000
without commas or spaces.
Tarefa
Here is the distance from the sun to the Earth in miles: var1 = 91,400,000
. And here is the distance from the Earth to the moon: var2 = 238 855
. You need to adjust these number formats to be compatible with Python.
- Rewrite the values of these two distances so they are recognizable by Python;
- Output these variables by including their names in
print
function calls.
Note
If you have a strong desire to use separators, Python understands the following syntax:
var = 1_000_000
.
Tudo estava claro?