Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = int(input())
- if num == 1:
- print('Monday')
- elif num == 2:
- print('Tuesday')
- elif num == 3:
- print('Wednesday')
- elif num == 4:
- print('Thursday')
- elif num == 5:
- print('Friday')
- elif num == 6:
- print('Saturday')
- elif num == 7:
- print('Sunday')
- else:
- print('Error')
- Фундаменталс решения:)
- Решение с масив и тернарен оператор:
- num = int(input())
- day_of_week = ["Error", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
- print(day_of_week[num if 0 < num < 8 else 0])
- Решение с речник и тернарен оператор:
- num = int(input())
- day_of_week = {
- 1: 'Monday',
- 2: 'Tuesday',
- 3: 'Wednesday',
- 4: 'Thursday',
- 5: 'Friday',
- 6: 'Saturday',
- 7: 'Sunday'
- }
- print(f'{day_of_week[num]}' if 0 < num < 8 else 'Error')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement