Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- number = float(input())
- inputMetric = input()
- outputMetric = input()
- if inputMetric == "mm":
- if outputMetric == "cm":
- number /= 10
- else:
- number /= 1000
- elif inputMetric == "cm":
- if outputMetric == "m":
- number /= 100
- else:
- number *= 10
- else:
- if outputMetric == "cm":
- number *= 100
- else:
- number *= 1000
- print(f"{number:.3f}")
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- number = float(input())
- inputMetric = input()
- outputMetric = input()
- if inputMetric == "mm":
- number /= 10 if outputMetric == "cm" else 1000
- elif inputMetric == "cm":
- number *= 0.01 if outputMetric == "m" else 10
- else:
- number *= 100 if outputMetric == "cm" else 1000
- print(f"{number:.3f}")
- ИЛИ:
- number = float(input())
- inputMetric = input()
- outputMetric = input()
- number *= ((0.1 if outputMetric == "cm" else 0.001) if inputMetric == "mm" else
- (0.01 if outputMetric == "m" else 10) if inputMetric == "cm" else
- (100 if outputMetric == "cm" else 1000))
- print(f"{number:.3f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement