Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- distance = float(input())
- input_metric = input()
- output_metric = input()
- if input_metric == "m":
- distance /= 1000
- elif input_metric == "cm":
- distance /= 100000
- elif input_metric == "mm":
- distance /= 1000000
- elif input_metric == "mi":
- distance /= 0.621371192
- elif input_metric == "in":
- distance /= 39370.0787
- elif input_metric == "ft":
- distance /= 3280.8399
- elif input_metric == "yd":
- distance /= 1093.6133
- if output_metric == "m":
- distance *= 1000
- elif output_metric == "cm":
- distance *= 100000
- elif output_metric == "mm":
- distance *= 1000000
- elif output_metric == "mi":
- distance *= 0.621371192
- elif output_metric == "in":
- distance *= 39370.0787
- elif output_metric == "ft":
- distance *= 3280.8399
- elif output_metric == "yd":
- distance *= 1093.6133
- print(distance)
- РЕШЕНИЕ С КОЛЕКЦИЯ:
- metrics_to_km = {
- "km": 1,
- "m": 1000,
- "cm": 100000,
- "mm": 1000000,
- "mi": 0.621371192,
- "in": 39370.0787,
- "ft": 3280.8399,
- "yd": 1093.6133
- }
- distance = float(input())
- input_metric = input()
- output_metric = input()
- print(distance / metrics_to_km[input_metric] * metrics_to_km[output_metric])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement