SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top