简体   繁体   中英

How Do I Display a number without it being in scientific notation in a Python calculator?

How Do I make a number appear like this:

$25.23   

Instead of this?:

$2.5 e+02

besides on how to do it, why it is being shown in scientific notation?

Also, if it matters, I am trying to make a price calculator, so I need prices to be shown as that:

xyz.wd

The current code I am using:

p1= float(input("Price:"))
d= float(input("discount percentage:"))
discount = p1*(d/100)
p2 = p1-discount
print(f"discount value: ${discount:10.2}")
print(f"final value: ${p2:10.2}")
print(f"discount value: ${discount:10.2f}")
print(f"final value: ${p2:10.2f}")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM