0

Here is a simple program to calculate some steam properties

import numpy as np

from iapws import IAPWS97

sat_steam=IAPWS97(P=0.1,T=373.15)                   
sat_liquid=IAPWS97(T=100+273.15, x=0)               
steam=IAPWS97(P=2.5, T=500)                     


print(sat_steam.s, sat_liquid.P, steam.h) #calculated properties

How do I output the numbers such that only a single decimal place is showing?

Thanks

user3483203
  • 50,081
  • 9
  • 65
  • 94

1 Answers1

0

Use the round() function from the official documentation: https://docs.python.org/3.6/library/functions.html#round

import numpy as np

from iapws import IAPWS97

sat_steam=round(IAPWS97(P=0.1,T=373.15), 1)                   
sat_liquid=round(IAPWS97(T=100+273.15, x=0), 1)               
steam=round(IAPWS97(P=2.5, T=500), 1)                     


print(sat_steam.s, sat_liquid.P, steam.h) #calculated properties
Retronix
  • 216
  • 2
  • 13