Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- degrees = float(input())
- if 5 <= degrees < 12:
- print('Cold')
- elif 12 <= degrees < 15:
- print('Cool')
- elif 15 <= degrees <= 20:
- print('Mild')
- elif 20 < degrees < 26:
- print('Warm')
- elif 26 <= degrees <= 35:
- print('Hot')
- else:
- print('unknown')
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- degrees = float(input())
- weather = ('Cold' if 5 <= degrees < 12 else
- 'Cool' if 12 <= degrees < 15 else
- 'Mild' if 15 <= degrees <= 20 else
- 'Warm' if 20 < degrees < 26 else
- 'Hot' if 26 <= degrees <= 35 else 'unknown')
- print(weather)
- РЕШЕНИЕ С РЕЧНИК:
- degrees = float(input())
- weather = {degrees < 5: 'unknown',
- 5 <= degrees < 12: 'Cold',
- 12 <= degrees < 15: 'Cool',
- 15 <= degrees <= 20: 'Mild',
- 20 < degrees < 26: 'Warm',
- 26 <= degrees <= 35: 'Hot',
- degrees > 35: 'unknown'}
- print(weather[True])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement