Answers for "hackerrank day 4 solution in python"

0

hackerrank day 4 solution in python

class Person:
    def __init__(self, initialAge):
        # Add some more code to run some checks on initialAge
        self.age = 0
        if initialAge < 0:
            print("Age is not valid, setting age to 0.")
        else:
            self.age = initialAge


    def amIOld(self):
        # Do some computations in here and print out the correct statement to the console
        if age < 13:
            print("You are young.")
        elif 13 <= age < 18:
            print("You are a teenager.")
        elif age >= 18:
            print("You are old.")

    def yearPasses(self):    
        # Increment the age of the person in here
        global age
Posted by: Guest on September-07-2021

Code answers related to "hackerrank day 4 solution in python"

Python Answers by Framework

Browse Popular Code Answers by Language