• IvanOverdrive@lemm.ee
    link
    fedilink
    English
    arrow-up
    37
    ·
    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()
    
      • IvanOverdrive@lemm.ee
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        8 months ago

        Are you on your phone? On desktop it shows the Python code. Memmy doesn’t show it. I’m guessing that’s probably why it’s so cryptic.

        • Leg@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          8 months ago

          I’m referring to the bit where we have literal cryptic prompts lol

              "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."
          
          • IvanOverdrive@lemm.ee
            link
            fedilink
            English
            arrow-up
            1
            ·
            8 months ago

            Of course. My eyes are going. I saw “posts” instead of “prompts” and got confused.