DAY 03 — 60 DAY PYTHON CHALLENGE
💻 Temperature Converter
Python में Temperature Converter बनाएं — Celsius, Fahrenheit, Kelvin
Advertisement
Complete Code
python — day03.py
def temp_converter(): print("🌡️ Temperature Converter") print("1. Celsius → Fahrenheit") print("2. Fahrenheit → Celsius") print("3. Celsius → Kelvin") print("4. Kelvin → Celsius") try: choice = int(input("\nChoice (1-4): ")) temp = float(input("Temperature: ")) if choice == 1: result = (temp * 9/5) + 32 print(f"\n✅ {temp}°C = {result:.1f}°F") elif choice == 2: result = (temp - 32) * 5/9 print(f"\n✅ {temp}°F = {result:.1f}°C") elif choice == 3: result = temp + 273.15 print(f"\n✅ {temp}°C = {result:.2f}K") elif choice == 4: result = temp - 273.15 print(f"\n✅ {temp}K = {result:.2f}°C") else: print("❌ 1-4 में से चुनें!") except ValueError: print("❌ सही number डालें!") temp_converter()
OUTPUT
🌡️ Temperature Converter
Choice (1-4): 1
Temperature: 37
✅ 37.0°C = 98.6°F
यह Code कैसे काम करता है?
Formulas: C to F = (C×9/5)+32 | F to C = (F-32)×5/9 | C to K = C+273.15 | मानव शरीर का तापमान 37°C = 98.6°F होता है।
Advertisement
📋 Project ka Introduction
Temperature Converter ek useful real-world Python project hai. Aaj bhi duniya mein alag alag countries alag alag temperature scales use karti hain — India aur Europe mein Celsius, America mein Fahrenheit, aur science mein Kelvin.
Is project mein aap mathematical formulas ko Python mein implement karna seekhenge. Conversion formulas yaad karna zaroori nahi — bas ek baar likh lo aur program hamesha ke liye kaam karega!
Weather apps, cooking recipes, aur science experiments mein temperature conversion bahut common hai. Yeh project aapko functions aur formulas implement karna sikhayega.
Is project mein aap mathematical formulas ko Python mein implement karna seekhenge. Conversion formulas yaad karna zaroori nahi — bas ek baar likh lo aur program hamesha ke liye kaam karega!
Weather apps, cooking recipes, aur science experiments mein temperature conversion bahut common hai. Yeh project aapko functions aur formulas implement karna sikhayega.
🧠 Is Project mein kya seekhoge?
Yeh project banate waqt aap ye Python concepts use karoge:
| Concept | Kya karta hai |
|---|---|
Functions | Reusable code blocks define karna |
Mathematical formulas | F = C * 9/5 + 32 |
float() conversion | Decimal temperature handle karna |
round() | Result ko 2 decimal tak round karna |
while loop | Multiple conversions karna |
📝 Code kaise kaam karta hai — Step by Step
Neeche code ki poori logic step-by-step samjhayi gayi hai:
- User se temperature value aur source unit lo
- Corresponding conversion formula apply karo
- Result ko round() se format karo
- Clearly display karo with units
⚠️ Common Mistakes — Bhool mat jaana!
Beginners yeh galtiyan aksar karte hain — dhyan rakho:
- ⚠️ Formula yaad rakho: C to F = (C * 9/5) + 32
- ⚠️ Kelvin mein negative values nahi hoti — validate karo
- ⚠️ Results ko round(result, 2) se readable banao
🏋️ Practice Exercises — Aage badho!
Yeh project complete karne ke baad in exercises se practice karo:
- 💡 Sab teeno units mein ek saath convert karo
- 💡 Boiling/freezing points of water mark karo
- 💡 Body temperature (37°C, 98.6°F, 310K) highlight karo
- 💡 GUI version banao tkinter se
❓ Aksar Pooche Jane Wale Sawal (FAQ)
Q: Celsius aur Fahrenheit mein kya fark hai?
A: Water 0°C par freeze hota hai (32°F) aur 100°C par boil (212°F).
A: Water 0°C par freeze hota hai (32°F) aur 100°C par boil (212°F).
Q: Kelvin kab use hota hai?
A: Science aur physics mein. 0 Kelvin = absolute zero = -273.15°C.
A: Science aur physics mein. 0 Kelvin = absolute zero = -273.15°C.
Q: Formula galat result de raha hai?
A: Parentheses dhyan se lagao: C * 9/5 + 32, na ki C * (9/5 + 32).
A: Parentheses dhyan se lagao: C * 9/5 + 32, na ki C * (9/5 + 32).