You are on page 1of 6

''' Question 1

Create a class Employee

computeNetSalary method to compute the net salary of an employee and


display method to display employee details. Net Salary is computed using
below formulae:

DA = basic * 0.40
Gross Salary = basic + DA
Net Salary = Gross Salary - Tax Deduction
Tax Deduction is computed using below table:
'''

class Employee:

def __init__(self, *args):


self.id = args[0]
self.name = args[1]
self.sal = args[2]

def display (self):


print(self.id, self.name, self.sal, self.netsal())

def netsal(self):
basic = self.sal
DA = float(basic) * 0.40
grosssal = basic + DA

taxded=0

if(grosssal>300000):
if(grosssal>500000):
if(grosssal>1000000):
taxded += (grosssal-1000000)*0.3
grosssal -= 1000000
taxded += (grosssal-500000)*0.2
grosssal -= 500000
taxded += (grosssal-300000)*0.1
grosssal -= 300000

return grosssal-taxded

if __name__ == "__main__" :
e1 = Employee('001', 'Samik', 700000)
e1.display()
'''Question 2
Dairy farm'''

class DairyProduct :
def __init__(self, *args) :
self.dairyId = int(args[0])
self.dairyBrand = args[1]
self.productType = args[2]
self.price = int(args[3])
self.grade = args[4]

class ProductGrade :
def __init__(self, *args) :
self.dairyList = args[0]
self.weightageDict = args[1]

def priceBasedOnBrandAndType(self, brand, ptype) :


ans = []
# iterate through each DairyProduct objects present in the list
for obj in self.dairyList :
if obj.dairyBrand == brand and obj.productType == ptype :
obj.price += (obj.price * self.weightageDict[obj.grade]) /
100
ans.append((brand, obj.price))

if len(ans) :
return ans
else :
return None

if __name__ == "__main__" :
n1 = int(input())
dairyProducts = []

for i in range(n1) :
dId = input()
dBrand = input()
pType = input()
price = input()
grade = input().lower()

dpObj = DairyProduct(dId, dBrand, pType, price, grade)


dairyProducts.append(dpObj)

n2 = int(input())
weightageDict = {}

for i in range(n2) :
grade = input().lower()
value = int(input())
weightageDict[grade] = value

pgObj = ProductGrade(dairyProducts, weightageDict)

# reading brand name and product type


dairyBrand = input()
producttype = input()

# priceBasedOnBrandAndType() method called


rslt = pgObj.priceBasedOnBrandAndType(dairyBrand, producttype)

if rslt :
for item in rslt :
print("Dairy Brand:", item[0])
print("Price:", item[1])

else :
print("No dairy product found")
'''Question 3
Zero padded time'''

class Time:
def __init__ (self, *args):
self.hours = args[0]
self.minutes = args[1]
self.seconds = args[2]

def disptime (self):


print(str(self.hours).zfill(2)+':'+str(self.minutes).zfill(2)+':'+str
(self.seconds).zfill(2))

if __name__ == '__main__':
t = Time(4,20,2)
t.disptime()

'''Question 4
Simple Inheritance
'''

class Person():
def __init__(self, name):
self.name = name

def getName(self):
return self.name

def isEmployee(self):
return False

class Employee(Person):
def isEmployee(self):
return True

emp = Person("Geek1")
print(emp.getName(), emp.isEmployee())

emp = Employee("Geek2")
print(emp.getName(), emp.isEmployee())

#Output:
#('Geek1', False)
#('Geek2', True)
'''Question 5
Banquet Hall
'''

class BanquetHall:
def __init__ (self, *args):
self.id = int(args[0])
self.name = args[1]
self.capacity = int(args[2])
self.prices = args[3]
self.amenities = args[4]

class HallMgmtSys:
def __init__ (self, *args):
self.bHallList = args[0]

def billCalc(self, *args):


n = args[0]
amenities = args[1]

for hall in self.bHallList:


allAmen = 1

if n<=hall.capacity:

for amenity in amenities:


if amenity in hall.amenities:
continue
else:
allAmen = 0
break

if allAmen == 0:
continue

else:
PPP = hall.prices

bill = PPP
print(f"Taxable Bill = {bill}")
#print(f"Total Bill = {bill*1.13}")

break

if __name__=="__main__":
num = int(input("Number of halls: "))
ipHalls = []

for i in range(num):
hallID=input("Hall ID: ")
hallName=input("Hall Name: ")
hallCapacity=int(input("Hall Capacity: "))

hallPrices=[]
priceCount=int(input("Count of price inputs: "))
for j in range(priceCount):
PPP = [input("--price: "), input("--lowerlim "), input("--
upperlim ")]
hallPrices.append(PPP)

hallAmenities=[]
amenCount=int(input("Number of amenities: "))
for j in range(amenCount):
hallAmenities.append(input("--amenity: "))

hall = BanquetHall(hallID, hallName, hallCapacity, hallPrices,


hallAmenities)
ipHalls.append(hall)

HallList = HallMgmtSys(ipHalls)

cap=int(input("Required capacity: "))


amenc=int(input("How many amenities: "))
amen=[]
for i in range(amenc):
amen.append(input("Enter amen: "))

HallList.billCalc(cap, amen)

You might also like