top of page

Python Proctored Assessment Programming solution 28th December

​

​

​

Question 1

 

Create a class called apartment with attributes flatnumber,owner name,electicity bill amount.

Create another class apartment_demo with def init(self): pass ​ to create a method getSecondMinBill that takes the list of objects and gives the second minimum electricity bill as output. 

​

​

input:

3(no of objects to be created) 

1000 

Hari 

5000 

1001 

Hena 

5002 

1002 

Harsha 

5001 

​

output:

5001 (since it is the second minimum bill amount among the bills)

​

 Solution:

​

class Apartment: 
    def __init__(self,no,name,eb):
        self.no=no
        self.name=name
        self.eb=eb
class Getsecondminbill:
    def __init__(self):
        pass
    def calc(self,l):
        m=[]
        for i in l:
            m.append(i.eb)
        m.sort()
        return m[1]
if __name__=='__main__':
    l=[]
    count=input()
    for i in range(count):
        no=input()
        name=raw_input()
        eb=input()
        l.append(Apartment(no,name,eb))
    demo=Getsecondminbill()
    m=demo.calc(l)
    print m 

 

​

​

​

Question 2

Create a class Bill with attributes mobile number and payment bill.

Create another class mobile with attributes service provider, mobile number, data used, payment method.

Service provider maybe airtel or jio. Data used is integer values in Gigabytes(GB). Payment method maybe paytm,gpay,amazon and so on.

Create a method calculate bill that takes the list of objects and calculates the bill and returns the list of objects of class bill with mobile number and payment bill.

​

The payment is calculated as follows:

​

1.If the service provider is airtel, the bill is Rs.11 for every 1GB used and if it is jio, the bill is Rs.10 for every 1GB used. 

2. If the payment method is paytm there is a cashback of 10% of the total bill for airtel users only. The bill is calculated and rounded off after deducing the cashback value.

​

input:

​

3(No of objects to be created) 

airtel 

123 

16 

paytm 

airtel 

456 

10 

amazon 

jio 

788 

10 

paytm 

​

Output:

​

(123,158) 

(456,110) 

(789,100) 

​

​

​

Solution:

​


class Bill: 
    def __init__(self,no,b):
        self.no=no
        self.b=b
class Mob:
    def __init__(self,sp,no,net,p):
        self.sp=sp
        self.no=no
        self.net=net
        self.p=p
    def calc(self,l):
        m=[]
        for i in l:
            if i.sp=="airtel":
                b=i.net*11
                if i.p=="paytm":
                    b-=(0.1*b)
            elif i.sp=="jio":
                b=i.net*10
            m.append(Bill(i.no,int(b)))
        return m
if __name__=='__main__':
    l=[]
    count=input()
    for i in range(count):
        sp=raw_input()
        no=input()
        net=input()
        p=raw_input()
        l.append(Mob(sp,no,net,p))
    demo=Mob("",0,0,"")
    m=demo.calc(l)
    for i in m:
        print i.no,i.b

​

​

​

Py pa28 dec: About

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

bottom of page