Advertisement
spacerose

trpp5

May 25th, 2021
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. x = int(input())
  2. a = input()
  3. b = input()
  4. d = {'mm': 1, 'cm': 2, 'dm': 3, 'm': 4, 'km': 7}
  5.  
  6.  
  7. def convert(x, a, b):
  8.     if (d[b] - d[a]) > 0:
  9.         temp = 10 ** abs((d[b] - d[a]))
  10.         return x / temp
  11.     elif (d[b] - d[a]) < 0:
  12.         temp = 10 ** abs((d[b] - d[a]))
  13.         return x * temp
  14.  
  15.  
  16. print(convert(x, a, b))
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement