3.1. Numeric Int
Represents an integer
Could be both signed and unsigned
Default
int
size is 64 bitPython automatically extends
int
when need bigger number
3.1.1. Syntax
Signed and Unsigned
>>> data = 1
>>> data = +1
>>> data = -1
3.1.2. Thousands Separator
Use
_
for thousand separatorYou can use
_
for easier read especially with big numbers
>>> million = 1000000
>>> million = 1_000_000
>>> million = 1_000_000
>>> print(million)
1000000
3.1.3. Conversion
Builtin function
int()
converts argument toint
It is not rounding
Works with strings if they have numbers and
+
,-
,_
(underscore)
Builtin function int()
converts argument to int
:
>>> int(1.0)
1
>>>
>>> int(-1.0)
-1
>>> int('1')
1
>>>
>>> int('-1')
-1
Builtin function int()
fails when in argument there are parameters
other than a digit, +
or -
sign and _
:
>>> int('1.0')
Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: '1.0'
3.1.4. Rounding
Builtin function
int()
does not round numbers - only converts toint
Use
round()
for numbers rounding
Builtin function int()
does not round numbers, it just cuts off decimals:
>>> int(1.11)
1
>>>
>>> int(1.99)
1
Builtin function round()
does that:
>>> round(1.11)
1
>>>
>>> round(1.99)
2
3.1.5. Use Case - 1
>>> SECOND = 1
>>> MINUTE = 60 * SECOND
>>> HOUR = 60 * MINUTE
>>> DAY = 24 * HOUR
>>>
>>>
>>> duration = 123456 * SECOND
>>>
>>> duration // DAY
1
>>> duration // HOUR
34
>>> duration // MINUTE
2057
>>> duration // SECOND
123456
3.1.6. Use Case - 2
>>> m = 1
>>> km = 1000 * m
>>> mi = 1652 * m
>>>
>>>
>>> distance = 123*mi
>>>
>>> distance // m
203196
>>> distance // km
203
3.1.7. Use Case - 3
>>> PLN = 1
>>> EUR = 4.71 * PLN # 2023-03-19 17:00 GMT+1
>>> USD = 4.41 * PLN # 2023-03-19 17:00 GMT+1
>>>
>>>
>>> price = 100*PLN
>>>
>>> round(price // EUR)
21
>>> round(price // USD)
22
3.1.8. Assignments
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Constants
# - Difficulty: easy
# - Lines: 5
# - Minutes: 3
# %% English
# 1. Define "constant" SECOND with value of 1 second
# 2. Define "constant" MINUTE with value of 1 minute (60 seconds)
# 3. Define "constant" HOUR with value of 1 hour (60 minutes)
# 4. Define "constant" DAY with value of 1 day (24 hours)
# 5. Define "constant" WEEK with value of 1 week (7 days)
# 6. All variables must be in seconds
# 7. Run doctests - all must succeed
# %% Polish
# 1. Zdefiniuj "stałą" SECOND z wartością dla 1 sekundy
# 2. Zdefiniuj "stałą" MINUTE z wartością dla 1 minuty (60 sekund)
# 3. Zdefiniuj "stałą" HOUR z wartością dla 1 godziny (60 minut)
# 4. Zdefiniuj "stałą" DAY z wartością dla 1 dzień (24 godziny)
# 5. Zdefiniuj "stałą" WEEK z wartością dla 1 tydzień (7 dni)
# 6. Wszystkie zmienne muszą być wyrażone w sekundach
# 7. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `*` - mul operator
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert SECOND is not Ellipsis, \
'Assign your result to variable `SECOND`'
>>> assert MINUTE is not Ellipsis, \
'Assign your result to variable `MINUTE`'
>>> assert HOUR is not Ellipsis, \
'Assign your result to variable `HOUR`'
>>> assert DAY is not Ellipsis, \
'Assign your result to variable `DAY`'
>>> assert WEEK is not Ellipsis, \
'Assign your result to variable `WEEK`'
>>> assert type(SECOND) is int, \
'Variable `SECOND` has invalid type, should be int'
>>> assert type(MINUTE) is int, \
'Variable `MINUTE` has invalid type, should be int'
>>> assert type(HOUR) is int, \
'Variable `HOUR` has invalid type, should be int'
>>> assert type(DAY) is int, \
'Variable `DAY` has invalid type, should be int'
>>> assert type(WEEK) is int, \
'Variable `WEEK` has invalid type, should be int'
>>> assert SECOND == 1, \
'Variable `SECOND` has invalid value. Check your calculation.'
>>> assert MINUTE == 60, \
'Variable `MINUTE` has invalid value. Check your calculation.'
>>> assert HOUR == 3600, \
'Variable `HOUR` has invalid value. Check your calculation.'
>>> assert DAY == 86400, \
'Variable `DAY` has invalid value. Check your calculation.'
>>> assert WEEK == 604800, \
'Variable `WEEK` has invalid value. Check your calculation.'
"""
# Define "constant" SECOND with value of 1 second
# type: int
SECOND = ...
# Define "constant" MINUTE with value of 1 minute (60 seconds)
# type: int
MINUTE = ...
# Define "constant" HOUR with value of 1 hour (60 minutes)
# type: int
HOUR = ...
# Define "constant" DAY with value of 1 day (24 hours)
# type: int
DAY = ...
# Define "constant" WEEK with value of 1 week (7 days)
# type: int
WEEK = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Duration
# - Difficulty: easy
# - Lines: 5
# - Minutes: 3
# %% English
# 1. Define `result_a` with: 69 seconds
# 2. Define `result_b` with: 13 minutes 37 seconds
# 3. Define `result_c` with: 2 hours 56 minutes
# 4. Define `result_d` with: 1 day 2 hours 8 minutes
# 5. Define `result_e` with: 3 weeks 1 day 3 hours 3 minutes 7 seconds
# 6. All values must be in seconds
# 7. Run doctests - all must succeed
# %% Polish
# 1. Zdefiniuj `result_a` z: 69 sekund
# 2. Zdefiniuj `result_b` z: 13 minut 37 sekund
# 3. Zdefiniuj `result_c` z: 2 godziny 56 minut
# 4. Zdefiniuj `result_d` z: 1 dzień 2 godziny 8 minut
# 5. Zdefiniuj `result_e` z: 3 tygodnie 1 dzień 3 godziny 3 minuty 7 sekund
# 6. Wszystkie zmienne muszą być wyrażone w sekundach
# 7. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `*` - mul operator
# - `+` - add
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert result_a is not Ellipsis, \
'Assign your result to variable `result_a`'
>>> assert result_b is not Ellipsis, \
'Assign your result to variable `result_b`'
>>> assert result_c is not Ellipsis, \
'Assign your result to variable `result_c`'
>>> assert result_d is not Ellipsis, \
'Assign your result to variable `result_d`'
>>> assert result_e is not Ellipsis, \
'Assign your result to variable `result_e`'
>>> assert type(result_a) is int, \
'Variable `result_a` has invalid type, should be int'
>>> assert type(result_b) is int, \
'Variable `result_b` has invalid type, should be int'
>>> assert type(result_c) is int, \
'Variable `result_c` has invalid type, should be int'
>>> assert type(result_d) is int, \
'Variable `result_d` has invalid type, should be int'
>>> assert type(result_e) is int, \
'Variable `result_e` has invalid type, should be int'
>>> assert result_a == 69, \
'Variable `result_a` has invalid value. Check your calculation.'
>>> assert result_b == 817, \
'Variable `result_b` has invalid value. Check your calculation.'
>>> assert result_c == 10560, \
'Variable `result_c` has invalid value. Check your calculation.'
>>> assert result_d == 94080, \
'Variable `result_d` has invalid value. Check your calculation.'
>>> assert result_e == 1911787, \
'Variable `result_e` has invalid value. Check your calculation.'
"""
SECOND = 1
MINUTE = 60 * SECOND
HOUR = 60 * MINUTE
DAY = 24 * HOUR
WEEK = 7 * DAY
# Define `result_a` with: 69 seconds
# Value must be in seconds
# type: int
result_a = ...
# Define `result_b` with: 13 minutes 37 seconds
# Value must be in seconds
# type: int
result_b = ...
# Define `result_c` with: 2 hours 56 minutes
# Value must be in seconds
# type: int
result_c = ...
# Define `result_d` with: 1 day 2 hours 8 minutes
# Value must be in seconds
# type: int
result_d = ...
# Define `result_e` with: 3 weeks 1 day 3 hours 3 minutes 7 seconds
# Value must be in seconds
# type: int
result_e = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Variables
# - Difficulty: easy
# - Lines: 4
# - Minutes: 2
# %% English
# 1. Define variables for breaks in work:
# - workbreak: 5 minutes
# - workday: 8 workbreak
# - workweek: 5 workday
# - workmonth: 4 workweek
# 2. All variables must be in seconds
# 3. Run doctests - all must succeed
# %% Polish
# 1. Zdefiniuj zmienne dla przerw w pracy:
# - workbreak: 5 minut
# - workday: 8 workbreak
# - workweek: 5 workday
# - workmonth: 4 workweek
# 2. Wszystkie zmienne muszą być wyrażone w sekundach
# 3. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `*` - mul operator
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> from pprint import pprint
>>> assert workbreak is not Ellipsis, \
'Assign your result to variable `workbreak`'
>>> assert workday is not Ellipsis, \
'Assign your result to variable `workday`'
>>> assert workweek is not Ellipsis, \
'Assign your result to variable `workweek`'
>>> assert workmonth is not Ellipsis, \
'Assign your result to variable `workmonth`'
>>> assert type(workbreak) is int, \
'Variable `workbreak` has invalid type, should be int'
>>> assert type(workday) is int, \
'Variable `workday` has invalid type, should be int'
>>> assert type(workweek) is int, \
'Variable `workweek` has invalid type, should be int'
>>> assert type(workmonth) is int, \
'Variable `workmonth` has invalid type, should be int'
>>> pprint(workbreak)
300
>>> pprint(workday)
2400
>>> pprint(workweek)
12000
>>> pprint(workmonth)
48000
"""
SECOND = 1
MINUTE = 60 * SECOND
HOUR = 60 * MINUTE
DAY = 24 * HOUR
WEEK = 7 * DAY
# workbreak: 5 minutes
# type: int
workbreak = ...
# workday: 8 workbreak
# type: int
workday = ...
# workweek: 5 workday
# type: int
workweek = ...
# workmonth: 4 workweek
# type: int
workmonth = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Conversion
# - Difficulty: easy
# - Lines: 6
# - Minutes: 3
# %% English
# 1. Calculate how many seconds is one day (24 hours)
# 2. Calculate how many minutes is one week (7 days)
# 3. Calculate how many hours is in one month (31 days)
# 4. Calculate how many seconds is work day (8 hours)
# 5. Calculate how many minutes is work week (5 work days)
# 6. Calculate how many hours is work month (22 work days)
# 7. Use floordiv (`//`) operator
# 8. Run doctests - all must succeed
# %% Polish
# 1. Oblicz ile sekund to jedna dzień (24 godziny)
# 2. Oblicz ile minut to jeden tydzień (7 dni)
# 3. Oblicz ile godzin to jeden miesiąc (31 dni)
# 4. Oblicz ile sekund to dzień pracy (8 godzin)
# 5. Oblicz ile minut to tydzień pracy (5 dni pracy)
# 6. Oblicz ile godzin to miesiąc pracy (22 dni pracy)
# 7. Użyj operatora floordiv (`//`)
# 8. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `*` - mul operator
# - `//` - floordiv
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert day is not Ellipsis, \
'Assign your result to variable `day`'
>>> assert week is not Ellipsis, \
'Assign your result to variable `week`'
>>> assert month is not Ellipsis, \
'Assign your result to variable `month`'
>>> assert workday is not Ellipsis, \
'Assign your result to variable `workday`'
>>> assert workweek is not Ellipsis, \
'Assign your result to variable `workweek`'
>>> assert workmonth is not Ellipsis, \
'Assign your result to variable `workmonth`'
>>> assert type(day) is int, \
'Variable `day` has invalid type, should be int'
>>> assert type(week) is int, \
'Variable `week` has invalid type, should be int'
>>> assert type(month) is int, \
'Variable `month` has invalid type, should be int'
>>> assert type(workday) is int, \
'Variable `workday` has invalid type, should be int'
>>> assert type(workweek) is int, \
'Variable `workweek` has invalid type, should be int'
>>> assert type(workmonth) is int, \
'Variable `workmonth` has invalid type, should be int'
>>> assert day == 86400, \
'Variable `day` has invalid value. Check your calculation.'
>>> assert week == 10080, \
'Variable `week` has invalid value. Check your calculation.'
>>> assert month == 744, \
'Variable `month` has invalid value. Check your calculation.'
>>> assert workday == 28800, \
'Variable `workday` has invalid value. Check your calculation.'
>>> assert workweek == 2400, \
'Variable `workweek` has invalid value. Check your calculation.'
>>> assert workmonth == 176, \
'Variable `workmonth` has invalid value. Check your calculation.'
"""
SECOND = 1
MINUTE = 60 * SECOND
HOUR = 60 * MINUTE
DAY = 24 * HOUR
# 1 day in seconds
# Use floordiv (`//`) operator
# type: int
day = ...
# 7 days in minutes
# Use floordiv (`//`) operator
# type: int
week = ...
# 31 days in hours
# Use floordiv (`//`) operator
# type: int
month = ...
# 8 hours in seconds
# Use floordiv (`//`) operator
# type: int
workday = ...
# 5 workdays in minutes
# Use floordiv (`//`) operator
# type: int
workweek = ...
# 22 workdays in hours
# Use floordiv (`//`) operator
# type: int
workmonth = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Definition
# - Difficulty: easy
# - Lines: 5
# - Minutes: 3
# %% English
# 1. Define average temperatures at surface of Mars [1]:
# - `mars_highest`: 20 °C
# - `mars_lowest`: -153 °C
# - `mars_average`: −63 °C
# 2. Define average temperatures at surface of Moon [1]:
# - `lunar_day`: 453 K
# - `lunar_night`: 93 K
# 3. Run doctests - all must succeed
# %% Polish
# 1. Zdefiniuj średnie temperatury powierzchni Marsa [1]:
# - `mars_highest`: 20 °C (najwyższa)
# - `mars_lowest`: -153 °C (najniższa)
# - `mars_average`: −63 °C (średnia)
# 2. Zdefiniuj średnie temperatury powierzchni Księżyca [1]:
# - `lunar_day`: 453 K (dzień)
# - `lunar_night`: 93 K (noc)
# 3. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `*` - mul operator
# %% References
# [1] Centro de Astrobiología (CSIC-INTA).
# Rover Environmental Monitoring Station, Mars Science Laboratory (NASA).
# Year: 2019.
# Retrieved: 2019-08-06.
# URL: http://cab.inta-csic.es/rems/marsweather.html
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert mars_highest is not Ellipsis, \
'Assign your result to variable `mars_highest`'
>>> assert type(mars_highest) is int, \
'Variable `mars_highest` has invalid type, should be int'
>>> assert mars_highest == 20, \
'Invalid value for `mars_highest`, should be 20. Check you calculation'
>>> assert mars_lowest is not Ellipsis, \
'Assign your result to variable `mars_lowest`'
>>> assert type(mars_lowest) is int, \
'Variable `mars_lowest` has invalid type, should be int'
>>> assert mars_lowest == -153, \
'Invalid value for `mars_lowest`, should be -153. Check you calculation'
>>> assert mars_lowest is not Ellipsis, \
'Assign your result to variable `mars_lowest`'
>>> assert type(mars_lowest) is int, \
'Variable `mars_lowest` has invalid type, should be int'
>>> assert mars_average == -63, \
'Invalid value for `mars_average`, should be -63. Check you calculation'
>>> assert lunar_day is not Ellipsis, \
'Assign your result to variable `lunar_day`'
>>> assert type(lunar_day) is int, \
'Variable `lunar_day` has invalid type, should be int'
>>> assert lunar_day == 453, \
'Invalid value for `lunar_day`, should be 453. Check you calculation'
>>> assert lunar_night is not Ellipsis, \
'Assign your result to variable `lunar_night`'
>>> assert type(lunar_night) is int, \
'Variable `lunar_night` has invalid type, should be int'
>>> assert lunar_night == 93, \
'Invalid value for `lunar_night`, should be 93. Check you calculation'
"""
Celsius = 1
Kelvin = 1
# Martian highest temperature: 20 Celsius
# type: int
mars_highest = ...
# Martian lowest temperature: -153 Celsius
# type: int
mars_lowest = ...
# Martian average temperature: -63 Celsius
# type: int
mars_average = ...
# Lunar day: 453 Kelvins
# type: int
lunar_day = ...
# Lunar night: 93 Kelvins
# type: int
lunar_night = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Addition
# - Difficulty: easy
# - Lines: 3
# - Minutes: 3
# %% English
# 1. One Kelvin is equal to 1 Celsius degree (1K = 1°C)
# 2. Zero Celsius degrees is equal to 273.15 Kelvins
# 3. For calculation use round number 273 (0°C = 273K)
# 4. How many Kelvins has average temperatures at surface [1]:
# - Mars highest: 20 °C
# - Mars lowest: -153 °C
# - Mars average: −63 °C
# 5. Run doctests - all must succeed
# %% Polish
# 1. Jeden Kelwin to jeden stopień Celsiusza (1K = 1°C)
# 2. Zero stopni Celsiusza to 273.15 Kelwiny
# 3. W zadaniu przyjmij równe 273°C (0°C = 273K)
# 4. Ile Kelwinów wynoszą średnie temperatury powierzchni [1]:
# - Mars najwyższa: 20 °C
# - Mars najniższa: -153 °C
# - Mars średnia: −63 °C
# 5. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `+` - add
# %% References
# [1] Centro de Astrobiología (CSIC-INTA).
# Rover Environmental Monitoring Station, Mars Science Laboratory (NASA).
# Year: 2019.
# Retrieved: 2019-08-06.
# URL: http://cab.inta-csic.es/rems/marsweather.html
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert mars_highest is not Ellipsis, \
'Assign your result to variable `mars_highest`'
>>> assert mars_lowest is not Ellipsis, \
'Assign your result to variable `mars_lowest`'
>>> assert mars_lowest is not Ellipsis, \
'Assign your result to variable `mars_lowest`'
>>> assert type(mars_highest) is int, \
'Variable `mars_highest` has invalid type, should be int'
>>> assert type(mars_lowest) is int, \
'Variable `mars_lowest` has invalid type, should be int'
>>> assert type(mars_lowest) is int, \
'Variable `mars_average` has invalid type, should be int'
>>> assert mars_highest == 293, \
'Invalid value for `mars_highest`, should be 293. Check you calculation'
>>> assert mars_lowest == 120, \
'Invalid value for `mars_lowest`, should be 120. Check you calculation'
>>> assert mars_average == 210, \
'Invalid value for `mars_average`, should be 210. Check you calculation'
"""
Celsius = 1
Kelvin = 273
MARS_HIGHEST = 20*Celsius
MARS_LOWEST = -153*Celsius
MARS_AVERAGE = -63*Celsius
# Martian highest temperature: 20 Celsius in Kelvin
# type: int
mars_highest = ...
# Martian lowest temperature: -153 Celsius in Kelvin
# type: int
mars_lowest = ...
# Martian average temperature: -63 Celsius in Kelvin
# type: int
mars_average = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Subtraction
# - Difficulty: easy
# - Lines: 2
# - Minutes: 2
# %% English
# 1. One Kelvin is equal to 1 Celsius degree (1K = 1°C)
# 2. Zero Kelvin (absolute) is equal to -273.15 Celsius degrees
# 3. For calculation use round number -273 (0K = -273°C)
# 4. How many Celsius degrees has average temperatures at surface [1]:
# - Lunar day: 453 K
# - Lunar night: 93 K
# 5. Run doctests - all must succeed
# %% Polish
# 1. Jeden Kelwin to jeden stopień Celsiusza (1K = 1°C)
# 2. Zero Kelwina (bezwzględne) to -273.15 stopni Celsiusza
# 3. W zadaniu przyjmij równe -273°C (0K = -273°C)
# 4. Ile stopni Celsiusza wynoszą średnie temperatury powierzchni [1]:
# - Księżyca w dzień: 453 K
# - Księżyca w nocy: 93 K
# 5. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `-` - sub operator
# %% References
# [1] Centro de Astrobiología (CSIC-INTA).
# Rover Environmental Monitoring Station, Mars Science Laboratory (NASA).
# Year: 2019.
# Retrieved: 2019-08-06.
# URL: http://cab.inta-csic.es/rems/marsweather.html
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert lunar_day is not Ellipsis, \
'Assign your result to variable `lunar_day`'
>>> assert lunar_night is not Ellipsis, \
'Assign your result to variable `lunar_night`'
>>> assert type(lunar_day) is int, \
'Variable `lunar_day` has invalid type, should be int'
>>> assert type(lunar_night) is int, \
'Variable `lunar_night` has invalid type, should be int'
>>> assert lunar_day == 180, \
'Invalid value for `lunar_day`, should be 180. Check you calculation'
>>> assert lunar_night == -180, \
'Invalid value for `lunar_night`, should be -180. Check you calculation'
"""
Celsius = 273
Kelvin = 1
LUNAR_DAY = 453*Kelvin
LUNAR_NIGHT = 93*Kelvin
# Lunar day: 453 Kelvin in Celsius
# type: int
lunar_day = ...
# Lunar night: 93 Kelvin in Celsius
# type: int
lunar_night = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Multiplication
# - Difficulty: easy
# - Lines: 3
# - Minutes: 2
# %% English
# 1. Define Armstrong line (19 km) in meters
# 2. Define Stratosphere line (20 km) in meters
# 3. Define USAF space boundary line (80 km) in meters
# 4. Define IAF space boundary line (100 km) in meters
# 5. Example: `sea_level = 0*km`
# 6. Run doctests - all must succeed
# %% Polish
# 1. Zdefiniuj linię Armstrong line (19 km) w metrach
# 2. Zdefiniuj linię stratosfery line (20 km) w metrach
# 3. Zdefiniuj linię granicy kosmosu wg. USAF (80 km) w metrach
# 4. Zdefiniuj linię granicy kosmosu wg. IAF (100 km) w metrach
# 5. Przykład: `sea_level = 0*km`
# 6. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `*` - mul operator
# %% References
# USAF - United States Air Force
# IAF - International Astronautical Federation
# Kármán line (100 km) - boundary between Earth's atmosphere and space
# Armstrong limit (19 km) - altitude above which atmospheric pressure is
# sufficiently low that water boils at the temperature of the human body
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert armstrong_limit is not Ellipsis, \
'Assign your result to variable `armstrong_limit`'
>>> assert stratosphere is not Ellipsis, \
'Assign your result to variable `stratosphere`'
>>> assert usaf_space is not Ellipsis, \
'Assign your result to variable `usaf_space`'
>>> assert iaf_space is not Ellipsis, \
'Assign your result to variable `iaf_space`'
>>> assert type(armstrong_limit) is int, \
'Variable `armstrong_limit` has invalid type, should be int'
>>> assert type(stratosphere) is int, \
'Variable `stratosphere` has invalid type, should be int'
>>> assert type(usaf_space) is int, \
'Variable `usaf_space` has invalid type, should be int'
>>> assert type(iaf_space) is int, \
'Variable `iaf_space` has invalid type, should be int'
>>> assert armstrong_limit == 19_000, \
'Invalid value for `armstrong_limit`. Check you calculation'
>>> assert stratosphere == 20_000, \
'Invalid value for `stratosphere`. Check you calculation'
>>> assert usaf_space == 80_000, \
'Invalid value for `usaf_space`. Check you calculation'
>>> assert iaf_space == 100_000, \
'Invalid value for `iaf_space`. Check you calculation'
"""
m = 1
km = 1000 * m
# Define Armstrong line (19 km) in meters
# type: int
armstrong_limit = ...
# Define Stratosphere line (20 km) in meters
# type: int
stratosphere = ...
# Define USAF space boundary line (80 km) in meters
# type: int
usaf_space = ...
# Define IAF space boundary line (100 km) in meters
# type: int
iaf_space = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Conversion
# - Difficulty: easy
# - Lines: 4
# - Minutes: 2
# %% English
# 1. Calculate altitude in meters:
# - Armstrong Limit: 19 km
# - Stratosphere: 20 km
# - USAF Space Line: 80 km
# - IAF Space Line: 100 km
# 2. Use floordiv (`//`) operator
# 3. Run doctests - all must succeed
# %% Polish
# 1. Oblicz wysokości w metrach:
# - Linia Armstronga: 19 km
# - Stratosfera: 20 km
# - Granica kosmosu wg. USAF: 80 km
# - Granica kosmosu wg. IAF 100 km
# 2. Użyj operatora floordiv (`//`)
# 3. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `//` - floordiv
# - 1 km = 1000 m
# %% References
# USAF - United States Air Force
# IAF - International Astronautical Federation
# Kármán line (100 km) - boundary between Earth's atmosphere and space
# Armstrong limit (19 km) - altitude above which atmospheric pressure is
# sufficiently low that water boils at the temperature of the human body
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert armstrong_limit is not Ellipsis, \
'Assign your result to variable `armstrong_limit`'
>>> assert stratosphere is not Ellipsis, \
'Assign your result to variable `stratosphere`'
>>> assert usaf_space is not Ellipsis, \
'Assign your result to variable `usaf_space`'
>>> assert iaf_space is not Ellipsis, \
'Assign your result to variable `iaf_space`'
>>> assert type(armstrong_limit) is int, \
'Variable `armstrong_limit` has invalid type, should be int'
>>> assert type(stratosphere) is int, \
'Variable `stratosphere` has invalid type, should be int'
>>> assert type(usaf_space) is int, \
'Variable `usaf_space` has invalid type, should be int'
>>> assert type(iaf_space) is int, \
'Variable `iaf_space` has invalid type, should be int'
>>> assert armstrong_limit == 19_000, \
'Invalid value for `armstrong_limit`. Check you calculation'
>>> assert stratosphere == 20_000, \
'Invalid value for `stratosphere`. Check you calculation'
>>> assert usaf_space == 80_000, \
'Invalid value for `usaf_space`. Check you calculation'
>>> assert iaf_space == 100_000, \
'Invalid value for `iaf_space`. Check you calculation'
"""
m = 1
km = 1000 * m
ARMSTRONG_LIMIT = 19*km
STRATOSPHERE = 20*km
USAF_SPACE = 80*km
IAF_SPACE = 100*km
# Armstrong line: 19 kilometers in meters
# Use floordiv (`//`) operator
# type: int
armstrong_limit = ...
# Stratosphere: 20 kilometers in meters
# Use floordiv (`//`) operator
# type: int
stratosphere = ...
# USAF space line: 80 kilometers in meters
# Use floordiv (`//`) operator
# type: int
usaf_space = ...
# IAF space line: 100 kilometers in meters
# Use floordiv (`//`) operator
# type: int
iaf_space = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Definition
# - Difficulty: easy
# - Lines: 3
# - Minutes: 2
# %% English
# 1. Define variable in meters:
# - Kármán Line Earth: 100_000 m
# - Kármán Line Mars: 80_000 m
# - Kármán Line Venus: 250_000 m
# 2. Run doctests - all must succeed
# %% Polish
# 1. Zdefiniuj zmienne w metrach:
# - Linia Kármána Ziemia: 100_000 m
# - Linia Kármána Mars: 80_000 m
# - Linia Kármána Wenus: 250_000 m
# 2. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `*` - mul operator
# - 1 km = 1000 m
# %% References
# Kármán line (100 km) - boundary between planets's atmosphere and space
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert karman_line_earth is not Ellipsis, \
'Assign your result to variable `karman_line_earth`'
>>> assert karman_line_mars is not Ellipsis, \
'Assign your result to variable `karman_line_mars`'
>>> assert karman_line_venus is not Ellipsis, \
'Assign your result to variable `karman_line_venus`'
>>> assert type(karman_line_earth) is int, \
'Variable `karman_line_earth` has invalid type, should be int'
>>> assert type(karman_line_mars) is int, \
'Variable `karman_line_mars` has invalid type, should be int'
>>> assert type(karman_line_venus) is int, \
'Variable `karman_line_venus` has invalid type, should be int'
>>> assert karman_line_earth == 100_000, \
'Invalid value for `karman_line_earth`. Check you calculation'
>>> assert karman_line_mars == 80_000, \
'Invalid value for `karman_line_mars`. Check you calculation'
>>> assert karman_line_venus == 250_000, \
'Invalid value for `usaf_space`. Check you calculation'
"""
m = 1
km = 1000 * m
# Kármán Line Earth: 100_000 meters
# type: int
karman_line_earth = ...
# Kármán Line Mars: 80_000 meters
# type: int
karman_line_mars = ...
# Kármán Line Venus: 250_000 meters
# type: int
karman_line_venus = ...
# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% About
# - Name: Numeric Int Conversion
# - Difficulty: easy
# - Lines: 3
# - Minutes: 2
# %% English
# 1. Calculate altitude in kilometers:
# - Kármán Line Earth: 100_000 m
# - Kármán Line Mars: 80_000 m
# - Kármán Line Venus: 250_000 m
# 2. Use floordiv (`//`) operator
# 3. Run doctests - all must succeed
# %% Polish
# 1. Oblicz wysokości w kilometrach:
# - Linia Kármána Ziemia: 100_000 m
# - Linia Kármána Mars: 80_000 m
# - Linia Kármána Wenus: 250_000 m
# 2. Użyj operatora floordiv (`//`)
# 3. Uruchom doctesty - wszystkie muszą się powieść
# %% Hints
# - `//` - floordiv
# - 1 km = 1000 m
# %% References
# Kármán line (100 km) - boundary between planets's atmosphere and space
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert karman_line_earth is not Ellipsis, \
'Assign your result to variable `karman_line_earth`'
>>> assert karman_line_mars is not Ellipsis, \
'Assign your result to variable `karman_line_mars`'
>>> assert karman_line_venus is not Ellipsis, \
'Assign your result to variable `karman_line_venus`'
>>> assert type(karman_line_earth) is int, \
'Variable `karman_line_earth` has invalid type, should be int'
>>> assert type(karman_line_mars) is int, \
'Variable `karman_line_mars` has invalid type, should be int'
>>> assert type(karman_line_venus) is int, \
'Variable `karman_line_venus` has invalid type, should be int'
>>> assert karman_line_earth == 100, \
'Invalid value for `karman_line_earth`. Check you calculation'
>>> assert karman_line_mars == 80, \
'Invalid value for `karman_line_mars`. Check you calculation'
>>> assert karman_line_venus == 250, \
'Invalid value for `usaf_space`. Check you calculation'
"""
m = 1
km = 1000 * m
KARMAN_LINE_EARTH = 100_000*m
KARMAN_LINE_MARS = 80_000*m
KARMAN_LINE_VENUS = 250_000*m
# Kármán Line Earth: 100_000 meters in km
# Use floordiv (`//`) operator
# type: int
karman_line_earth = ...
# Kármán Line Mars: 80_000 meters in km
# Use floordiv (`//`) operator
# type: int
karman_line_mars = ...
# Kármán Line Venus: 250_000 meters in km
# Use floordiv (`//`) operator
# type: int
karman_line_venus = ...