File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ class Person :
2+ age = 0
3+ def __init__ (self ,initialAge ):
4+ # Add some more code to run some checks on initialAge
5+ if (initialAge > 0 ):
6+ self .age = initialAge
7+ else :
8+ print ("Age is not valid, setting age to 0." )
9+ def amIOld (self ):
10+ # Do some computations in here and print out the correct statement to the console
11+ if (self .age < 13 ):
12+ print ("You are young." )
13+ elif (self .age >= 13 ) and (self .age < 18 ):
14+ print ("You are a teenager." )
15+ else :
16+ print ("You are old." )
17+ def yearPasses (self ):
18+ # Increment the age of the person in here
19+ self .age = self .age + 1
20+
21+ t = int (input ())
22+ for i in range (0 , t ):
23+ age = int (input ())
24+ p = Person (age )
25+ p .amIOld ()
26+ for j in range (0 , 3 ):
27+ p .yearPasses ()
28+ p .amIOld ()
29+ print ("" )
You can’t perform that action at this time.
0 commit comments