Course Content
Data Types in Python
Data Types in Python
Integer Numbers
In Python, 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.
Swipe to begin your solution
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.
Solution
In Python, 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.
Swipe to begin your solution
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.
Solution
Note
If you want to use separators for better readability, Python allows the following syntax:
var = 1_000_000
.
Thanks for your feedback!
Integer Numbers
In Python, 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.
Swipe to begin your solution
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.
Solution
In Python, 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.
Swipe to begin your solution
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.
Solution
Note
If you want to use separators for better readability, Python allows the following syntax:
var = 1_000_000
.
Thanks for your feedback!