Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- days = int(input()) - 1
- type = input()
- rating = input()
- price = 0
- if days > 0:
- if type == "room for one person":
- price = 18
- elif type == "apartment":
- price = 25
- if days < 10:
- price *= 0.7
- elif days > 15:
- price *= 0.5
- else:
- price *= 0.65
- elif type == "president apartment":
- price = 35
- if days < 10:
- price *= 0.9
- elif days > 15:
- price *= 0.8
- else:
- price *= 0.85
- if rating == "positive":
- price *= 1.25
- else:
- price *= 0.9
- price *= days
- print(f"{price:.2f}")
- РЕШЕНИЕ С IF-ELSE И ТЕРНАРЕН ОПЕРАТОР:
- days = int(input()) - 1
- type = input()
- rating = input()
- price = 0
- if days > 0:
- if type == "room for one person":
- price = 18
- elif type == "apartment":
- price = 25 * (0.7 if days < 10 else 0.5 if days > 15 else 0.65)
- elif type == "president apartment":
- price = 35 * (0.9 if days < 10 else 0.8 if days > 15 else 0.85)
- price *= (1.25 if rating == "positive" else 0.9) * days
- print(f"{price:.2f}")
- РЕШЕНИЕ САМО ТЕРНАРЕН ОПЕРАТОР:
- days = int(input()) - 1
- type = input()
- rating = input()
- price = ((25 * (0.7 if days < 10 else 0.5 if days > 15 else 0.65) if type == "apartment" else
- 35 * (0.9 if days < 10 else 0.8 if days > 15 else 0.85) if type == "president apartment" else 18)
- * (1.25 if rating == "positive" else 0.9) * days) if days > 0 else 0
- print(f"{price:.2f}")
Add Comment
Please, Sign In to add comment