Question: Problem Statement Write a Python function named convertTemp that takes two parameters: temps A list of temperature values. tempScale A character representing the
Write a Python function named convertTemp that takes two parameters:
- temps – A list of temperature values.
- tempScale – A character representing the temperature scale (\"C\" for Celsius or \"F\" for Fahrenheit).
The function should evaluate the provided temperature scale using an if/elif statement:
- If tempScale is \"F\", convert each temperature from Fahrenheit to Celsius using the formula: C = (F - 32) * 5 / 9
- If tempScale is \"C\", convert each temperature from Celsius to Fahrenheit using the formula: F = (C * 9 / 5) + 32
The converted temperatures should replace the original values in the temps list at their respective index positions. The function should return the updated temps list.
Sample Output
Output:
[0.0, 37.77777777777778, 100.0]Example 2: Converting Celsius to Fahrenheittemps_list = [0, 37.78, 100] converted_temps = convertTemp(temps_list, \"C\") print(converted_temps)
Output:
[32.0, 100.00399999999999, 212.0]Step by Step Solution
There are 3 Steps involved in it
Python Code for Temperature Conversion def convertTemptemps tempScale Check the temperature scale provided if tempScale F Convert each Fahrenheit temp... View full answer
Get step-by-step solutions from verified subject matter experts
