0

Boolean Logic

Boolean Logic Given the age of a person as input, you need to output their age group. Here are the age groups you need to handle: Child: 0 to 11 Teen: 12 to 17 Adult: 18 to 64 Senior: 65+ Sample Input 42 Sample Output Adult i dont understand , pls help

22nd Jul 2021, 11:00 PM
Anna Ghulyan
Anna Ghulyan - avatar
9 Antworten
+ 1
age = int(input()) # your code goes here if age >= 0 and age <= 11: print("Child") elif age >= 12 and age <= 17: print:("Teen") elif age >= 18 and age <= 65: print("Adult") elif age >=64: print("Senior") else: print("Invalid age") This should work, but it doesn't.
13th Sep 2021, 3:54 PM
Kevin
+ 1
a = int(input()) # your code goes here if a in range(0,11): print ('Child') elif a in range(12,17): print ('Teen') elif a in range(18,64): print ('Adult') else: print('Senior')
16th Feb 2022, 12:12 PM
Liria
Liria - avatar
0
Well, the root cause of your misunderstanding is your lack of knowledge of two fundamental things: conditional statements, and magnitude comparison operators. Conditional statements are simply different paths your program can take, and which one it does take depends only on the result of a boolean operation, namely the result from the <, >, <=, >=, ==, and != operators. I suggest you study up on each of these topics in detail (for your language, as you do not have one listed), because this isn't an education board, this is a discussion board. You can use the courses on this site to do just that.
23rd Jul 2021, 12:09 AM
BootInk
BootInk - avatar
0
Check this out..... print("What Your Name:") name = input() print('Enter your Age:') age = int(input()) if age <= 0 or age < 11: print(" You Still A Child",name) elif age <= 12 or age < 17: print("Your Still A Teenager",name) elif age <= 18 or age < 65: print("You Are An Adult",name) elif age <= 64 or age < 150: print("You Are Senior Human",name)
11th Nov 2021, 5:11 AM
Peter Aro
Peter Aro - avatar
0
a = int(input()) # your code goes here if a in range(0,11): print ('Child') elif a in range(12,17): print ('Teen') elif a in range(18,64): print ('Adult') else: print('Senior') done..!
3rd Mar 2022, 2:29 PM
Nikhila
0
purity = float(input()) #your code goes here if purity >= 75 and purity < 83.3: print ("18K") if purity >= 83.3 and purity < 91.7: print ("20K") if purity >= 91.7 and purity < 99.9: print ("22K") if purity > 99.9: print ("24K")
21st Nov 2022, 2:52 AM
Eugene Sedanza
Eugene Sedanza - avatar
0
a = int(input()) if a in range(0,11): print ('Child') elif a in range(12,17): print ('Teen') elif a in range(18,64): print ('Adult') else: print('Senior') ####D\O M.LakshmiNarayana####
11th Dec 2022, 4:43 AM
Lavanya Mangala
0
age =int(input()) if age >= 0 and age <= 11: print("Child") elif age >= 12 and age <= 17: print:("Teen") elif age >= 18 and age <= 65: print("Adult") else: print("Senior")
23rd Mar 2023, 5:16 AM
Shalini Kumari
Shalini Kumari - avatar
- 2
Write a code that takes input, if it is less than 12 print ‘child’ if between 12 and 17, print ‘teen’ ect. What dont you understand?
22nd Jul 2021, 11:29 PM
Brain & Bones
Brain & Bones - avatar