core.py 821 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. def pipe(t):
  2. return t
  3. def ktoc(t):
  4. """ Convert K to C """
  5. return t - 273
  6. def ctok(t):
  7. """ Convert C to K """
  8. return t + 273
  9. def ctof(t):
  10. """ Convert C to F """
  11. return t * 1.8000 + 32.00
  12. def ftoc(t):
  13. """ Convert F to C """
  14. return (t - 32.00) / 1.8000
  15. def ktof(t):
  16. """ Convert K to F """
  17. return t * (9/5) - 459.67
  18. def ftok(t):
  19. """ Convert F to K """
  20. return (t + 459.67) * 5/9
  21. get_func = {
  22. 'C>C': pipe,
  23. 'C>F': ctof,
  24. 'C>K': ctok,
  25. 'K>K': pipe,
  26. 'K>C': ktoc,
  27. 'K>F': ktof,
  28. 'F>F': pipe,
  29. 'F>C': ftoc,
  30. 'F>K': ftok
  31. }
  32. formuls = {
  33. "C>K": " t + 273 ",
  34. "C>F": " t * 1.8000 + 32.00 ",
  35. "K>C": " t - 273 ",
  36. "K>F": " t * (9/5) - 459.67 ",
  37. "F>C": """
  38. t - 32.00
  39. ---------
  40. 1.8000
  41. """,
  42. "F>K": " (t + 459.67) * 5/9 "
  43. }