Write a python class to welcome


Topic: Write a python class to welcome

Solution

class Welcome(object):
    # Constructor
    def __init__(self, name):
        self.name = name  # Create an instance variable
    # Instance method
    def welcome(self, up=False):
        if up:
            print('Hi, %s!' % self.name.upper())
        else:
            print('Hey, %s' % self.name)
w = Welcome('Geeta')           
w.welcome(up=True)



List all Python Programs