Python Tip: Constants and Reading large numbers in Python

preview_player
Показать описание
This video looks at a useful tip for typing in large numbers in a Python program for the sole purpose of making it easier to read. In addition it revises the 'for iteration' and the range() function. It also considers constants in Python.

Рекомендации по теме
Комментарии
Автор

You can print underscores inside numbers using f-strings or string format function, examples:

print(f'The sum of the series is: {running_total:_}') -> "The sum of the series is: 500_000_500_000"
print(f'The sum of the series in hex is: 0x{running_total:019_X}') -> "The sum of the series in hex is: 0x0000_0074_6A5A_2920"
print(f'The sum of the series in binary is: 0b{running_total:_b}') -> "The sum of the series in binary is:

voytechj
Автор

in this playlist, you may teach us how to solve the Leetcode problem in python. That would be cool

LonglongFeng