Q1. 1,2 Q2.
class Person():
def setName(self,name):
self.name=name
def getName(self):
return self.name
p1=Person()
p2=Person()
p1.setName(input("p1 name: "))
p2.setName(input("p2 name: "))
print("p1 name:",p1.getName())
print("p2 name:",p2.getName())
Q3.
class Person():
def setName(self,name):
self.name=name
def getName(self):
return self.name
p1=Person()
p2=Person()
p1.setName(input("name1: "))
p2.setName(input("name2: "))
print(p1.getName())
print(p2.getName())
Q4.
class Greeting:
def sayHello(self, name = None, wish = None):
if name is not None and wish is not None:
print ('Hello' + name + wish)
elif name is not None and wish is None:
print ('Hello' + name)
else:
print ('Hello')
greet = Greeting()
# Call the method with zero, one and two parameters
greet.sayHello()
greet.sayHello('Ram')
greet.sayHello('Ram,', 'Good Morning!!!')