Complete a program to demonstrate the skills presented in this unit on user-defined functions in Python. In
Question:
Complete a program to demonstrate the skills presented in this unit on user-defined functions in Python.
In this hypothetical scenario, your local weather office needs a temporary solution to take a temperature in Celsius, convert it to Fahrenheit, and issue a general statement or warning based on that temperature.
You will build two separate functions. The first will accept the Celsius value and return the temperature in Fahrenheit, and the second will accept the Fahrenheit temperature value and use it to determine the appropriate output statements. Your role is to create the two functions and test them using six decimal values stored in different variables.
Assignment Requirements
- Define a function that will accept a temperature value representing the Celsius temperature, convert the value to Fahrenheit, and return that Fahrenheit value as a rounded integer value.
- Hint 1: The formula to convert from C to F is TempF = TempC * 9/5 + 32.
- Hint 2: An easy way to round integer values is to add .5 to the decimal value before converting it to an integer.
- Define a function that will accept a value representing the temperature in Fahrenheit. The function will check the value and determine the correct weather statement to return as a string value. The criteria for these statements are as follows:
- >=95F - "A heat advisory has been issued."
- 85F to 94F — "Pleasant but warm."
- 70F to 84F — "Very pleasant weather today."
- 50F to 69F — "Pleasant but cool."
- 33F to 49F — "Cold weather."
- <=32F — "A freeze warning has been issued."
- After the function definitions, define six variables and assign them the following values: 35.5, 30.5, 22.2, 16.1, 7.3, -1 (notice this last value is negative one).
- For each test variable, call the temperature conversion function followed by a call to the weather statement function. After each call, print the temperature in Celsius and in Fahrenheit followed by the appropriate weather statement as determined by the function.
POSSIBLE EXPECTED OUTPUT
The temperature is 35.5C or 96F. A heat advisory has been issued.
The temperature is 30.5C or 87F. Pleasant but warm.
The temperature is 22.2C or 72F. Very pleasant weather today.
The temperature is 16.1C or 61F. Pleasant but cool.
The temperature is 7.3C or 45F. Cold weather.
The temperature is -1C or 30F. A freeze warning has been issued.
Fundamentals Of Corporate Finance
ISBN: 9780135811603
5th Edition
Authors: Jonathan Berk, Peter DeMarzo, Jarrad Harford