Mastering 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.
var = 1000000
If you want to use separators for better readability, Python allows the following syntax:
var = 1_000_000
Swipe to start coding
A small company is planning its budget for the first two quarters of the year. However, some financial figures need to be formatted correctly.
Here are the allocated budgets:
- Q1 budget allocation:
q1_budget = 750000
. - Q2 budget allocation:
q2_budget = 1200500
.
Adjust these values so they are compatible and output them.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 3.03Awesome!
Completion rate improved to 3.03
Mastering 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.
var = 1000000
If you want to use separators for better readability, Python allows the following syntax:
var = 1_000_000
Swipe to start coding
A small company is planning its budget for the first two quarters of the year. However, some financial figures need to be formatted correctly.
Here are the allocated budgets:
- Q1 budget allocation:
q1_budget = 750000
. - Q2 budget allocation:
q2_budget = 1200500
.
Adjust these values so they are compatible and output them.
Solution
Thanks for your feedback!
single
Awesome!
Completion rate improved to 3.03
Mastering Integer Numbers in Python
Swipe to show menu
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.
var = 1000000
If you want to use separators for better readability, Python allows the following syntax:
var = 1_000_000
Swipe to start coding
A small company is planning its budget for the first two quarters of the year. However, some financial figures need to be formatted correctly.
Here are the allocated budgets:
- Q1 budget allocation:
q1_budget = 750000
. - Q2 budget allocation:
q2_budget = 1200500
.
Adjust these values so they are compatible and output them.
Solution
Thanks for your feedback!