Python Single Decimal

Jase

When I enter this code the answer ends with 2 characters behind the decimal. How do I make this only have 1 number behind it?

tempature=float(input("Enter the temp(F):"))
formant_tempature = f"{tempature:2f}"
print(round(((int(tempature)-32)*5/9)+273.15,2))
Aleksa Majkic

When you used round function you have specified that you want two decimal places. Just replace 2 with a number 1.

print(round(((int(tempature)-32)*5/9)+273.15,1))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related