Python program that converts Celsius to Fahrenheit:

Created with Sketch.

Python program that converts Celsius to Fahrenheit:

# Input Celsius temperature
celsius = float(input("Enter the temperature in Celsius: "))

# Convert Celsius to Fahrenheit
fahrenheit = (celsius * 9/5) + 32

# Print the result
print("Temperature in Fahrenheit: ", fahrenheit)

The program prompts the user to enter the temperature in Celsius using the input() function, and stores the value in the variable “celsius”. It then uses the formula (celsius * 9/5) + 32 to convert Celsius to Fahrenheit. And then it prints the result using the print() function.

You can also use the built-in python module “tempfile” to convert Celsius to Fahrenheit.

import tempfile

celsius = float(input("Enter the temperature in Celsius: "))
fahrenheit = tempfile.c2f(celsius)
print("Temperature in Fahrenheit: ", fahrenheit)

Here, you need to install “tempfile” library by using “!pip install tempfile” command in your terminal or command prompt.

Both the methods will give you the same output which is the temperature in Fahrenheit. You can use any method that suits your need or preference.

Leave a Reply

Your email address will not be published. Required fields are marked *