π€―: Python `___` can be used in numbers ??
Raghav Rathi
Posted on February 3, 2023
π¬: Comment Your Thoughts or Anything
π¨βπ»: Code
a = 1_00_00000.000_000
# b = 10000000.000000
# here b is same as a
print(f'{a:,}')
print('{:_}'.format(a))
π₯οΈ: Output
π€: How to use it
- its numbers / double delimiter
- you can use underscore as a
,
- which doesn't affect the value / meaning of the number
- Can't use it
- at start & end of number
- before & after the decimal point
.
- or multiple underscores in a row
π’: Maths
- its like the maths
,
- which we use in daily life
π§΅: fString
- while printing in console
- can use
fstring
to print it like that - NOTE:
- but it will come after every 3 digit in output
- as American Standard
- not how you added in Number
πββοΈ: to Run
- https://www.sololearn.com/compiler-playground/cVOb0s0mgJZS
- orignally was created on sololearn by me
π: See also
- References / More Details / Might Help
- PEP 515 β Underscores in Numeric Literals
- Whatβs New In Python 3.6
β€οΈ: A Like would be appreciated if it was helpful
π πͺ π
π©
Raghav Rathi
Posted on February 3, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.