Beginner Codes/Python/Temperature Conversion Program
12%

Instructions

Syntax

temp_in_f = (temp * 9/5) + 32 if unit.lower() == "c": ...

Temperature Conversion Program 🌡️

Chapter 1 oda kadasisi project-ku vandhuttom! Idhu romba similar to weight conversion dhaan, aana formulas mattum maarum. Celsius-a Fahrenheit-a maathuvom, illa Fahrenheit-a Celsius-a maathuvom.

The Formulas

  • Celsius to Fahrenheit: F = (C * 9/5) + 32
  • Fahrenheit to Celsius: C = (F - 32) * 5/9
temp = float(input("Enter the temperature: "))
unit = input("Is this Celsius or Fahrenheit? (C or F): ")

if unit.lower() == "c":
    # Celsius to Fahrenheit formula
    temp_in_f = (temp * 9/5) + 32
    print(f"The temperature in Fahrenheit is: {round(temp_in_f, 1)}°F")
elif unit.lower() == "f":
    # Fahrenheit to Celsius formula
    temp_in_c = (temp - 32) * 5/9
    print(f"The temperature in Celsius is: {round(temp_in_c, 1)}°C")
else:
    print("Invalid unit! Please enter C or F.")

Idha theliva purinjikka indha interactive visualizer-a test pannunga:

temp = 0
unit = "C"
if unit.lower() == "c":
  f = (temp * 9/5) + 32
  print(f"{f}°F")
elif unit.lower() == "f":
  c = (temp - 32) * 5/9
  print(f"{c}°C")
___
What is happening?
Temperature type pannunga, unit select pannunga, apparam program-a run pannunga.

💡 Did You Know? Degree symbol (°) print panna direct-a "°C" nu string kulla type pannalam. Python 3 default-a emojis, symbols ellam support pannum!

Your Turn! (Unga neram!)

Mela irukka mathiriye ungaloda swondha temperature converter ezhudhunga!

  1. temp and unit vangaradhukku input() use pannunga.
  2. if condition use panni formulas-a apply pannunga.
  3. Output-a f-string use panni °C illa °F oda print pannunga!

Help

Temperature Conversion ProgramExercise 10/7750 XP
❴❵ script.py
python.code
python
Loading...
Terminal
Terminal — python
Beginner Codes Terminal v1.0.0
─────────────────────────────────────
Ready. Click "Run Code" to execute...
Ready
Piston APIPYTHON0 lines