Quick Python | Using Underscores as Digit Separators in Python | Shorts

Опубликовано: 24 Май 2021
на канале: choobtorials
231
9

In this Quick Python tutorial, we see how underscores can be used to help improve readability when writing long numeric values.

=====

In Python, as well as many other programming languages, commas cannot be used when writing numbers.

In this example, the commas will cause Python to treat these as separate values and pack them into what’s called a tuple.

So in place of commas, we can use underscores to visually separate the digits into groups. This is a common feature in many modern languages and can be used to help improve the readability of long numeric values.

So in this updated example, underscores are now being used as separators. And when this gets evaluated, the underscores are ignored, and the value is interpreted as having a numeric type.

=====

Twitter:   / choobtorials  

#PythonTips


На этой странице сайта вы можете посмотреть видео онлайн Quick Python | Using Underscores as Digit Separators in Python | Shorts длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь choobtorials 24 Май 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 231 раз и оно понравилось 9 зрителям. Приятного просмотра!