Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. >>> def convert_temp(keyword, temp):
  2. ... if keyword == "F2C":
  3. ... c = int((temp - 32) * (5 / 9))
  4. ... return c
  5. ... elif keyword == "C2F":
  6. ... f = float((temp * (9 / 5)) + 32)
  7. ... return f
  8. ... else:
  9. ... print(
  10. ... "Please indicate \"F2C\" for Fahrenheit to Celsius, or \"C2F\" for Celsius to Fahrenheit, and the temperature to convert")
  11. ...
  12. >>> convert_temp("F2C", 212)
  13. 100
  14. >>> convert_temp("C2F", 100)
  15. 212.0
  16. >>> convert_temp("F2C", 32)
  17. 0
  18. >>> convert_temp("C2F", 0)
  19. 32.0
  20. >>> convert_temp("F2C", 98.6)
  21. 37
  22. >>> convert_temp("C2F", 37)
  23. 98.60000000000001
  24. >>> convert_temp("F2C", -40)
  25. -40
  26. >>> convert_temp("C2F", -40)
  27. -40.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement