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
In questa pagina del sito puoi guardare il video online Quick Python | Using Underscores as Digit Separators in Python | Shorts della durata di ore minuti seconda in buona qualità , che l'utente ha caricato choobtorials 24 maggio 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 231 volte e gli è piaciuto 9 spettatori. Buona visione!