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

Publié le: 24 mai 2021
sur la chaîne: 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


Sur cette page du site, vous pouvez voir la vidéo en ligne Quick Python | Using Underscores as Digit Separators in Python | Shorts durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur choobtorials 24 mai 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 231 fois et il a aimé 9 téléspectateurs. Bon visionnage!