Skip to content

amlaklak/Tempertures-coveter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Prompt the user to input a temperature in the format (e.g., 45F, 102C, etc.)

temp = input("Input the temperature you like to convert? (e.g., 45F, 102C etc.) : ")

Extract the numerical part of the temperature and convert it to an integer

degree = int(temp[:-1])

Extract the convention part of the temperature input (either 'C' or 'F')

i_convention = temp[-1]

Check if the input convention is in uppercase 'C' (Celsius)

if i_convention.upper() == "C": # Convert the Celsius temperature to Fahrenheit result = int(round((9 * degree) / 5 + 32)) o_convention = "Fahrenheit" # Set the output convention as Fahrenheit

Check if the input convention is in uppercase 'F' (Fahrenheit)

elif i_convention.upper() == "F": # Convert the Fahrenheit temperature to Celsius result = int(round((degree - 32) * 5 / 9)) o_convention = "Celsius" # Set the output convention as Celsius else: # If the input convention is neither 'C' nor 'F', print an error message and exit the program print("Input proper convention.") quit()

Display the converted temperature in the specified output convention

print("The temperature in", o_convention, "is", result, "degrees.")

About

Python program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published