Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- breed = input()
- gender = input()
- years = 0
- if breed == 'Siberian':
- years = 11
- elif breed == 'American Shorthair':
- years = 12
- elif breed == 'British Shorthair':
- years = 13
- elif breed == 'Persian':
- years = 14
- elif breed == 'Siamese':
- years = 15
- elif breed == 'Ragdoll':
- years = 16
- else:
- print(f'{breed} is invalid cat!')
- if gender == 'f':
- years += 1
- if years > 1:
- print(f'{years * 2} cat months')
- ФУНДАМЕНТАЛС РЕШЕНИЯ:
- Решение с тернарен оператор:
- breed = input()
- gender = input()
- years = 11 if breed == 'Siberian' else \
- 12 if breed == 'American Shorthair' else \
- 13 if breed == 'British Shorthair' else \
- 14 if breed == 'Persian' else \
- 15 if breed == 'Siamese' else \
- 16 if breed == 'Ragdoll' else 0
- print(f'{(years + (1 if gender == "f" else 0)) * 2} cat months' if years > 1 else f'{breed} is invalid cat!')
- Решение с колекция:
- breed = input()
- gender = input()
- years = {'Siberian': 11, 'American Shorthair': 12, 'British Shorthair': 13, 'Persian': 14, 'Siamese': 15, 'Ragdoll': 16}
- print(f'{(years[breed] + (1 if gender == "f" else 0)) * 2} cat months' if breed in years else f'{breed} is invalid cat!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement