Question

Use Python to create a function that collects temperature in degree Celsius as input from a...

Use Python to create a function that collects temperature in degree Celsius as input from a user and converts it to degree Fahrenheit. The same function should convert temperature from degree Fahrenheit to degree Celsius if the temperature provided was in degree Fahrenheit. You can use branching (for example, if-else) statements within the body of your function ( Hint: First collect the number, then also collect the unit of temperature so you can use that unit of temperature as a condition to determine whether your conversion should be from degree Fahrenheit to degree Celsius or vice-versa. Look up for the conversion formulas online).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

def conversionOfTemperature(temperature, unit) :
    if(unit == "f" or unit == "F") :
   print (temperature - 32) / 1.8, "in Fahrenheit"
    else :
        print (temperature * 1.8) + 32, "in Celcius"


temperature = input("Enter Temperature :: ");
unit = raw_input("Enter unit(c for celcius | f for Fahrenheit) :: ");

conversionOfTemperature(temperature,unit);

OUTPUT SCREEN:

Add a comment
Know the answer?
Add Answer to:
Use Python to create a function that collects temperature in degree Celsius as input from a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice...

    FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom functionc_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a...

  • Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The...

    Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...

  • i need a python code For an exact conversion between "Fahrenheit temperature scale" and "Celsius temperature...

    i need a python code For an exact conversion between "Fahrenheit temperature scale" and "Celsius temperature scale", the following formulas can be applied. Here, F is the value in Fahrenheit and the value in Celsius: Temperature Conversions C = 5 9 (F - 32) F = (š xc) + 3 Write a Python program that uses the above formula to convert Celsius to Fahrenheit and vice versa. We ask user to input "Enter a degree: ", and then we get...

  • Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The...

    Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...

  • Fahrenheit scale is a temperate scale and it uses the degree Fahrenheit (symbol °F) as the...

    Fahrenheit scale is a temperate scale and it uses the degree Fahrenheit (symbol °F) as the unit. Celsius scale is another temperature scale and its symbol is °C. Fahrenheit is used by United States whereas all other countries in the world use Celsius. The formulas of conversion between Fahrenheit and Celsius are as follows: From Fahrenheit: [°C] = ([°F] − 32) × 5⁄9 From Celsius: [°F] = [°C] × 9⁄5 + 32 Write a function named convertTemp( degree, ForC )...

  • Create a program in Python that will allow the user to enter a temperature in Fahrenheit...

    Create a program in Python that will allow the user to enter a temperature in Fahrenheit which will then be converted to degrees Celsius. The program will keep asking the user for a Fahrenheit temperature until the user enters Q to quit. After each conversion the program needs to print out the degrees Celsius. The input prompts for this problem need to look like the following: Degrees Fahrenheit: Continue: For these input prompts watch the capitalization and spacing. There are...

  • C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have...

    C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...

  • Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin...

    Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin Newton Your program should take a character which represents the temperature to convert from and a value to be converted to using the following specification: C - Celsius K - Kelvin N - Newton In addition your program should take in the following character to exit the program: X - eXit the program The numeric input for your program should be of type double....

  • Design a VI to convert temperature from Degree Fahrenheit (F) to Degree Celsius (C). The VI...

    Design a VI to convert temperature from Degree Fahrenheit (F) to Degree Celsius (C). The VI accepts Fahrenheit from the user and displays the corresponding Celsius. Use the following equation: F = (9/5)*C + 32 Design a VI that computes f = 5x2 + 9y – z, where x, y, and z are real numbers. Provide two solution methods. For the first solution use only arithmetic functions (such as Square, Add, Multiply, and Subtract). For the second solution use the...

  • Write a program in C that will convert all 12 months' average temperature from Celsius to...

    Write a program in C that will convert all 12 months' average temperature from Celsius to Fahrenheit. You need to create an array named aye jump and prompt the user to input average temperature in Celsius for all 12 months. After that, you need to develop a user temperatures from Celsius to Fahrenheit and pass the array as reference and convert all temperatures from Celsius to Fahrenheit. Next, compute the average temperature of the year and assign it to a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT