+ 2

Help

Вам дан возраст человека в качестве входных данных, выведите его возрастную группу. Вот используемые возрастные группы: Child: 0 to 11 Teen: 12 to 17 Adult: 18 to 64 Пример входных данных 42 Пример выходных данных Adult https://code.sololearn.com/cxWQ52Iu2N0c/?ref=app

31st Mar 2022, 10:14 AM
Elisey
Elisey - avatar
9 Answers
+ 2
year = int(input()) if (year <= 11): print("Child") elif (year >= 12) and (year <= 17): print("Teen") elif (year >= 18) and (year <= 64): print("Adult")
31st Mar 2022, 2:41 PM
Zetfrick
Zetfrick - avatar
+ 2
year = int(input()) # Используйте “аnd” if year > 0 and year <= 11: print("Child") elif year >= 12 and year <= 17: print("Teen") elif year >= 18 and year <= 64: print("Adult")
1st Apr 2022, 3:47 AM
CodeStory
CodeStory - avatar
+ 1
Instead of 'or' use 'and' and better to use elif instead of if only Вместо «или» используйте «и». и лучше использовать elif вместо if only
31st Mar 2022, 10:33 AM
Jayakrishna 🇮🇳
+ 1
Ion Kare This is nothing special This is clearly logical : 4< n<8 Better than use 4<n or n<8
31st Mar 2022, 12:06 PM
Amir
Amir - avatar
0
If you want to do it your way You can do in range method If age in range(0, 11 + 1): print("child") If .....
31st Mar 2022, 10:49 AM
Ion Kare
Ion Kare - avatar
0
1 use elif For the second and third condition 2 use : 11<year <17 Instead of 'or'
31st Mar 2022, 11:54 AM
Amir
Amir - avatar
0
Amir you think he/she knows how to chain conditions?? Come on guy be reasonable
31st Mar 2022, 12:00 PM
Ion Kare
Ion Kare - avatar
0
Blog
2nd Aug 2022, 6:52 PM
Asilbek