Question: Make a dictionary from a string The viscosity of gases depends on the temperature TT. For some gases the following formula is relevant: (T)=0T0CT+C(TT0)1.5,(T)=0T0CT+C(TT0)1.5, where
Make a dictionary from a string
The viscosity of gases depends on the temperature TT. For some gases the following formula is relevant:
(T)=0T0CT+C(TT0)1.5,(T)=0T0CT+C(TT0)1.5,
where the values of the constants CC, T0T0, and 00 are found in a file viscosity.dat. The temperature is measured in Kelvin.
Suppose we have already loaded the file into a string viscosity_data using the read method. viscosity_data contains data (in order as gas,C,T_0,mu_0) such as:
viscosity_data = "air,120,291.15,18.27"
Convert the data in the string viscosity_data into a dictionary mu_air such that we can look up CC, T0T0, and 00 for air by mu_air[X], where X can be one of 'C', 'T_0', or 'mu_0'. The numerical values in mu_air should all be floats.
For instance, the following statements should be True:
mu_air[ 'C' ] == 120.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
