Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- allowed_types = ["F", "C", "K"]
- temp_type = input("Which type of temperature (F, C, or K): ").upper()
- if temp_type not in allowed_types:
- print("Invalid code.")
- else:
- temp = int(input("Enter temperature: "))
- if temp < -500 or temp > 500:
- print("INVALID value for temperature – setting temperature value to 100")
- temp = 100
- if temp_type == "F":
- F = temp
- C = (F - 32) * 5/9
- K = (F + 459.67) * 5/9
- elif temp_type == "C":
- C = temp
- F = C * 9/5 + 32
- K = (9/5 * C + 491.67) * 5/9
- else:
- K = temp
- F = 9/5 * K - 459.67
- C = (9/5 * K - 491.67) * 5/9
- print("Temperature in degrees Fahrenheit:", F)
- print("Temperature in degrees Celsius:", C)
- print("Temperature in degrees Kelvin:", K)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement