top of page

Python Proctored Assessment Programming solution 13th February

​

​

Question 1


Take acc number, holder name, balance as input.

​

Add deposit amount as input.

​

Request a withdrawal. If balance after withdrawal is more than 1000... Allow it... Else don't.

​

 Solution:

​

class Account():
    def _init_(self,id1,name,balance):
        self.id1=id1
        self.name=name
        self.balance=balance
    def after_deposited(self,deposit_amt):
        self.balance+=deposit_amt
        return self.balance
    def after_withdraw(self,withdraw_amt):
        if  (self.balance-withdraw_amt)>=1000:
            self.balance-=withdraw_amt
            return 1
        else:
            return 0
id1=int(input())
name=input()
balance=int(input())
obj=Account(id1,name,balance)
deposit_amt=int(input())
withdraw_amt=int(input())
print(obj.after_deposited(deposit_amt))
res=obj.after_withdraw(withdraw_amt)
if res==1:
    print("AVAILABLE_BALANCE:",obj.balance)
else:
    print("Insufficient_Balance")

​

Question 2

​

Take list of employees (id, name and leaves (el, sl, cl).

​

For a particular employee... Demand a leave from available leave types...

​

Return available leaves...

​

If available is greater than or equal to demand, return 'Granted', else 'Rejected'.

​

​

Solution:

​

class Employee:
    def _init_(self,emp_no,emp_name,leaves):
        self.emp_no=emp_no
        self.emp_name=emp_name
        self.leaves=leaves
class Company:
    def _init_(self,company_name,emps):
        self.company_name=company_name
        self.emps=emps
    def display_leave(self,emp_no1,Ltype):
        for i in self.emps:
            if i.emp_no==emp_no1:
                return i.leaves[Ltype]
    def Number_of_leaves(self,emp_no1,Ltype,nol):
        for i in self.emps:
            if i.emp_no==emp_no1:
                if i.leaves[Ltype]>=nol:
                    return "Granted"
                else:
                    return "Rejected"
n=int(input())
emps=[]
c=Company("ABC",emps)
leaves={}
for i in range(n):
    emp_no=int(input())
    emp_name=input()
    leaves["CL"]=int(input())
    leaves["EL"]=int(input())
    leaves["SL"]=int(input())
    c.emps.append(Employee(emp_no,emp_name,leaves))
emp_no1=int(input())
Ltype=input()
nol=int(input())
print(c.display_leave(emp_no1,Ltype))
print(c.Number_of_leaves(emp_no1,Ltype,nol))
       

Py pa 13 feb: About

©2018 by The real one. Proudly created with Wix.com

bottom of page