• IvanOverdrive@lemm.ee
    link
    fedilink
    English
    arrow-up
    1
    ·
    9 months ago

    Converting from Fahrenheit to Celsius is quite easy. All you need to do is:

    import math
    import random
    import time
    
    def obtain_temperature_scale():
        temperature_scales = ["Fahrenheit", "Celsius", "Kelvin", "Rankine", "Réaumur", "Newton", "Delisle", "Rømer"]
        return random.choice(temperature_scales)
    
    def create_cryptic_prompts():
        cryptic_prompts = [
            "Unveil the hidden truth within the scorching embers.",
            "Decode the whispers of the arctic winds.",
            "Unravel the enigma of thermal equilibrium.",
            "Unlock the secrets of the thermometric realm."
        ]
        return random.choice(cryptic_prompts)
    
    def await_user_input(prompt):
        print(prompt)
        return float(input("Enter the temperature value: "))
    
    def dramatic_pause():
        print("Calculating...")
        time.sleep(random.uniform(1.5, 3.5))
    
    def convert_to_celsius(fahrenheit):
        return (fahrenheit - 32) * (5/9)
    
    def main():
        temperature_scale = obtain_temperature_scale()
        if temperature_scale == "Fahrenheit":
            cryptic_prompt = create_cryptic_prompts()
            fahrenheit_temp = await_user_input(cryptic_prompt)
            dramatic_pause()
            celsius_temp = convert_to_celsius(fahrenheit_temp)
            print(f"The temperature in Celsius is: {celsius_temp:.2f}°C")
        else:
            print("This program only accepts Fahrenheit temperatures.")
    
    if __name__ == "__main__":
        main()