There was only one question. The timing was 60 minutes.
""" 1. Define Project class (variables ,constructor and function ) code here in the below space as per the requirement"""
class Project:
def _init_(self,projId,projectName,manHours,technologyList):
self.projectId=projId
self.projectName=projectName
self.manHours=manHours
self.technologyList=technologyList
self.avgProjCost=0
def calculateProjCost(self,r):
temp=self.manHours*r
return temp
""" 2. Define Organization class( Variables,Constructor and function) code here in the below space as per requirement """
class Organization:
def _init_(self,orgName,projList):
self.orgName=orgName
self.projList=projList
def projAvgCostByTechnology(self,projId,rate):
apc=0
for i in (self.projList):
if i.projectId==projId:
i.avgProjcost=i.calculateProjCost(rate)/len(i.technologyList)
return i
#refer last screenshot if there is any confusion in last method
# main function snippet
if _name=='main_':
projectList=[]
n=int(input())
for i in range(n):
projectId=int(input())
projectName=input()
manHours=int(input())
k=int(input())
technologyList=[]
for j in range(k):
technologyList.append(input())
o=Project(projectId,projectName,manHours,technologyList)
projectList.append(o)
org=Organization("ABC",projectList)
projId=int(input())
rate=int(input())
avgProj=org.projAvgCostByTechnology(projId,rate)
if avgProj==None:
print("No Project Exists")
else:
print(avgProj.projectId,avgProj.projectName,avgProj.manHours,avgProj.technologyList,avgProj.calculateProjCost(rate)/len(avgProj.technologyList))
Kommentare