Boolean Logic: Output their age group | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
+ 3

# Boolean Logic: Output their age group

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 My code: age = int(input()) # your code goes here if age >= 0 and < 12: print("Child") elif age > 11 and < 18: print:("Teen") elif age > 17 and <65: print("Adult") elif age > 64: print("Senior") else: print("Invalid age") I keep getting Syntax error in the first line. Any advice would be appreciated!!

8th Aug 2021, 3:25 AM
Riley
28 Réponses
+ 16
age = int(input()) if age <= 11: print("Child") elif( age >= 12 and age <= 18 ): print("Teen") else: print("Adult")
19th Dec 2021, 4:46 PM
‎باسط احمد‎
+ 3
age = int(input()) if age >= 0 and age < 12: print("Child") elif age >= 12 and age <= 18: print("Teen") else: print("Adult")
20th Dec 2021, 8:46 AM
Lema Kefyalew
+ 3
I've tried like every code I can think of nothing works
4th Aug 2022, 2:07 AM
Godwin Coughan
+ 2
// // import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int age = sc.nextInt(); if (age >= 0 && age <= 11) { System.out.println("Child"); } else if (age >= 12 && age <= 17) { System.out.println("Teen"); } else if (age >= 18 && age <= 64) { System.out.println( "Adult"); } else if (age > 64) { System.out.println( "Senior"); } } } //this is the correct java code for this problem .
10th Aug 2023, 6:16 AM
+ 1
age=int(input()) if age>0 and age<=11: print( "Child") elif age>=12 and age<=17 : print ( "Teen") elif age>=18 and age<=64: print( "Adult") use it 100% work and all check point
30th Oct 2022, 8:05 AM
Abhishek Maheshwari
+ 1
// Working code import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int age = sc.nextInt(); if (age >= 0 && age <= 11) { System.out.println("Child"); } else if (age >= 12 && age <= 17) { System.out.println("Teen"); } else if (age >= 18 && age <= 64) { System.out.println( "Adult"); } else if (age > 64) { System.out.println( "Senior"); } } }
21st Feb 2024, 6:17 AM
Irfan Alam
0
age=int(input('Enter the age: ')) if(age>=0 and age<=11): print('child') elif(age>=12 and age<=17): print('teen') elif(age>=18 and age<=64): print('adult') else: print('senior')
21st Dec 2021, 4:55 PM
SANVIKA
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 <= 64: print("Adult") else: print("Senior")
8th Jan 2022, 1:49 PM
Ihor Princ
0
age=int(input()) # codes are here if age>=0 and age<=11 : print("Child") elif age>=12 and age<=17: print("Teen") elif age>=18 and age<=64: print("Adult") else: print("Invalid input")
29th Jan 2022, 2:27 PM
Souvik Pal
0
Try This! It works 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<=64: print("Adult") elif age > 64: print("Senior")
31st Jan 2022, 11:18 AM
JAMESHA IBRAHIM K
0
age = int(input()) if age > 0 and age < 12: print('Child') elif age > 11 and age < 18: print('Teen') elif(age>17 and age < 65): print('Adult') else: print("Senior")
15th Feb 2022, 2:33 PM
Alcino Castelo
0
/*Here it is your answer*/ age = int(input()) if (age >= 0 and age <= 11): print("Child") elif (age >=12 and age <= 17): print("Teen") elif (age >= 18 and age <= 64): print("Adult")
20th May 2022, 9:01 PM
Hamza Limam Eibba
0
age = int(input()) if age <= 11: print("Child") elif (age >=12 and age <= 17): print("Teen") elif (age >=18 and age <= 64): print("Adult") else: print("Invalid input")
31st Aug 2022, 9:28 PM
Nidae El mouhib
0
age=int(input()) if age<11: print("Child") if(age >=12 and age<=18): print("Teen") else : print("Adult")
29th Sep 2022, 12:02 PM
0
Here are the age groups you need to handle: Child: 0 to 11 Teen: 12 to 17 Adult: 18 to 64
6th Dec 2022, 12:34 AM
LK videos
0
age = int(input()) if age <= 11: print("Child") elif( age >= 12 and age <= 18 ): print("Teen") else: print("Adult")
18th Mar 2023, 8:31 PM
المهندس أحمد
0
Draw a flowchart to accept a user's age and determine and print whether the user is a child (under 18), à youth (18 or older but under 40), or a senior (40 or older) then calculate & print his age after 10 years.
18th Apr 2023, 8:53 AM
0
try this one it's worked... age = int(input()) if age <= 11: print('Child') elif age <= 18: print('Teen') else: print('Adult')
2nd Jun 2023, 6:25 AM
Mehedi Hasan
0
fun main(args: Array<String>) { var age = readLine()!!.toInt() if(age<0) print("Invalid age") else {if (age>0 && age<=11) print( "Child") else if (age>=12 && age<=17 ) print ( "Teen") else if (age>=18 && age<=64) print( "Adult") else print( "Senior") } }
2nd Jul 2023, 8:35 AM