The conversion depends on the temperature and other factors, but an approximation is that 1inch of rain is equivalent to 6.5inches of snow. Write a script that prompts the user for the number of inches of rain, calls a function to return the equivalent amount of snow, and prints this result. Write the function, as well. Do this two ways: in a separate code file and as a local function.

Respuesta :

Answer:

rainInches = int(input("Enter rainfall in inches: "))

def rain_snow_convert( rain):

   snow_size = rain * 6.5

   return snw_size

snowInches = rain_snow_convert( rainInches)

print(snowInches)

Explanation:

The python source code above return the equivalent size of rainfall to snowfall in inches. There are two ways to write this, one is like on a single file as the code above, the second way is defining the function "rain_snow_convert" in another python file, then importing and calling the function in the input file.

from functionsfile import rain_snow_convert

rainInches = int(input("Enter rainfall in inches: "))

snowInches = rain_snow_convert( rainInches)

print(snowInches)

where "functionfiles" (actually with the extension .py) is the name of the python file with the rain_snow_convert function.