hackerrank day 4 solution in python

Solutions on MaxInterview for hackerrank day 4 solution in python by the best coders in the world

showing results for - "hackerrank day 4 solution in python"
Alessandra
02 Feb 2020
1class Person:
2    def __init__(self, initialAge):
3        # Add some more code to run some checks on initialAge
4        self.age = 0
5        if initialAge < 0:
6            print("Age is not valid, setting age to 0.")
7        else:
8            self.age = initialAge
9
10
11    def amIOld(self):
12        # Do some computations in here and print out the correct statement to the console
13        if age < 13:
14            print("You are young.")
15        elif 13 <= age < 18:
16            print("You are a teenager.")
17        elif age >= 18:
18            print("You are old.")
19
20    def yearPasses(self):    
21        # Increment the age of the person in here
22        global age