Number Formatting
Number Formatting
Floats
pi = 3.1415926
print(f'Pi is approximately equal to {pi:.2f}')
# Pi is approximately equal to 3.14
Integer
id = 1 # need to print a 3-digit number
print(f"The id is {id:03d}")
# The id is 001
Number separator
N = 1000000000 # need to add separator
print(f'His networth is ${N:,d}')
# His networth is $1,000,000,000