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

Veröffentlicht am: 24 Mai 2021
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video Quick Python | Using Underscores as Digit Separators in Python | Shorts mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer choobtorials 24 Mai 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 231 Mal angesehen und es wurde von 9 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!