Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> def convert_temp(keyword, temp):
- ... if keyword == "F2C":
- ... c = int((temp - 32) * (5 / 9))
- ... return c
- ... elif keyword == "C2F":
- ... f = float((temp * (9 / 5)) + 32)
- ... return f
- ... else:
- ... print(
- ... "Please indicate \"F2C\" for Fahrenheit to Celsius, or \"C2F\" for Celsius to Fahrenheit, and the temperature to convert")
- ...
- >>> convert_temp("F2C", 212)
- 100
- >>> convert_temp("C2F", 100)
- 212.0
- >>> convert_temp("F2C", 32)
- 0
- >>> convert_temp("C2F", 0)
- 32.0
- >>> convert_temp("F2C", 98.6)
- 37
- >>> convert_temp("C2F", 37)
- 98.60000000000001
- >>> convert_temp("F2C", -40)
- -40
- >>> convert_temp("C2F", -40)
- -40.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement