bl00dt3ars

04. Metric Converter

Oct 12th, 2020 (edited)
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. unit = float(input())
  2. conv_from = str(input())
  3. conv_to = str(input())
  4. converted = 0
  5.  
  6. if conv_from == "mm" and conv_to == "cm":
  7.     converted = unit / 10
  8. elif conv_from == "mm" and conv_to == "m":
  9.     converted = unit / 1000
  10. elif conv_from == "cm" and conv_to == "mm":
  11.     converted = unit * 10
  12. elif conv_from == "cm" and conv_to == "m":
  13.     converted = unit / 100
  14. elif conv_from == "m" and conv_to == "cm":
  15.     converted = unit * 100
  16. elif conv_from == "m" and conv_to == "mm":
  17.     converted = unit * 1000
  18.  
  19. print(f"{converted:.3f}")
Add Comment
Please, Sign In to add comment