Tuesday, February 25, 2020

format in python print statement output

a=5678.1023
b=54578.1023
print("this is monthly salary:",format(a,'>15,.2f'))
print("this is monthly expenses:",format(a,'>13,.2f'))
print("this is monthly saving:",format(a,'>15,.2f'))
print("this is monthly total:",format(a,'>16,.2f'))

output:


example 2:
a=5678.1023 b=54578.1023 print("this is monthly salary:",format(a,'>15,.2f')) print("this is monthly expenses:",format(a,'>13,.3f')) print("this is monthly saving:",format(a,'>15,.4f')) print("this is monthly total:",format(a,'>16,.5f'))

output:


No comments:

Post a Comment

python class topic video