# The class that would contain the methods to convert to fahrenheit or celsius temperatures
class TempConverter():
# The method that would convert to a celsuis temperature
@classmethod
def convert_to_celsius(cls):
temperature = float(input("Enter the fahrenheit temperature: "))
convert_temp = (temperature * 9/5) + 32
return convert_temp
# The method that would convert to a fahrenheit temperature
@classmethod
def convert_to_fahrenheit(cls):
temperature = float(input("Enter the celsius tempurature: "))
convert_temp = (temperature * 9/5) + 32
return convert_temp
def go_again():
# Get's the user choice, either a yes or no
user_choice = input("\nWould you like to make another conversion [y or n]: ")[0].lower()
# If the choice is y, print an empty liine and rerun the main function
if user_choice == 'y':
print()
main()
# If the\choice is n, give the user a thank you and exit the function
elif user_choice == 'n':
print("Thanks for using the tempurature converter")
# If not either, delete the user input and prompt user that their input is invalid, and rerun
# The function
else:
print("Enter a valid choice. You can only input y or n")
del user_choice
go_again
def main():
# Get the type of temp to convert to
conversion_type = input("What is the tempurature type that you want a conversion to [f or c]: ")[0].lower()
# Make sure that that the conversion type is valid, if the input is not valid delete the input
# And rerun the main function
if conversion_type != 'f' and conversionType != 'c':
del conversion_type
print("The conversion type that you entered is not valid. You can only input f or c")
main()
# If the conversion type is c, run the convert_to_cesius method
# And store the value into convert_temp
if conversion_type == 'c':
convert_temp = TempConverter.convert_to_celsius()
# Or if the the conversion type is f, run the convert_to_fahrenheit method
# And store the value into convert_temp
elif conversion_type == 'f':
convert_temp = TempConverter.convert_to_fahrenheit()
# Print the formated converted temperature
print("\nThe converted tempurature is {} .{}".format(convert_temp, conversion_type))
# Run the go_again function, to see if the user want's to make another conversion
go_again()
main()