Python Temperature Conversion
Temperature can be converted in Python using simple formulas:
Celsius to Fahrenheit = (C × 9/5) + 32
Fahrenheit to Celsius = (F − 32) × 5/9
Python में temperature conversion निम्नल सूत्रों की मदद से की जा सकती है:
Celsius से Fahrenheit = (C × 9/5) + 32
Fahrenheit से Celsius = (F - 32) × 5/9
Example 1: Celsius to Fahrenheit
c = 25
f = (c * 9/5) + 32
print("Fahrenheit =", f)
Output:
Fahrenheit = 77.0
Converts Celsius to Fahrenheit.
Celsius को Fahrenheit में बदलता है।
Example 2: Fahrenheit to Celsius
f = 98.6
c = (f - 32) * 5/9
print("Celsius =", c)
Output:
Celsius = 37.0
Converts Fahrenheit to Celsius.
Fahrenheit को Celsius में बदलता है।
Example 3: User Input (C to F)
c = float(input("Enter temp in Celsius: ") )
f = (c * 9/5) + 32
print("Fahrenheit =", f)
Output:
Enter temp in Celsius: 30 Fahrenheit = 86.0
Takes Celsius input and converts to Fahrenheit.
User से Celsius input लेकर Fahrenheit की calculation करता है।
Example 4: User Input (F to C)
f = float(input("Enter temp in Fahrenheit: ") )
c = (f - 32) * 5/9
print("Celsius =", round(c, 2))
Output:
Enter temp in Fahrenheit: 100 Celsius = 37.78
Takes Fahrenheit input and converts to Celsius.
User से Fahrenheit input लेकर Celsius की calculation करता है।