class apartment:
def __init__(self,flat_number,owner_name,electricity_bill_ammount):
self.flat_number=flat_number
self.owner_name=owner_name
self.electricity_bill_ammount=electricity_bill_ammount
class apartment_demo:
def __init__(self):
pass
def getSecondMinBill(self,objList):
electricityList=[]
for i in objList:
electricityList.append(i.electricity_bill_ammount)
electricityList.sort()
for j in electricityList:
return print(electricityList[1])
if __name__=='__main__':
count=int(input())
objList=[]
for i in range (count):
flat_number=int(input())
owner_name=input()
electricity_bill_ammount=int(input())
objList.append(apartment(flat_number,owner_name,electricity_bill_ammount))
output=apartment_demo().getSecondMinBill(objList)
Q2. Create a class Bill with attributes mobile number and payment bill. Create another class mobile with attributes serviceprovider, mobilenumber, dataused,
payment method. Service provider maybe airtel or jio.Data used is integer values in Gigabytes(GB). Payment method maybe paytm,gpay,amazon and soon. Create a method calculatebill that takes the list of objects and calculates the bill and
returns the list of objects of class bill with mobile number and paymentbill.
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 cash back of 10% of the total bill for airtel users only.The bill is calculated and roundedoff after deducing the cashback value.
Sample Input:
3
airtel
123
16
paytm
airtel
456
10
amazon
jio
789
10
paytm
Sample Output:
(123,158)
(456,110)
(789,100)
Solution:
class Bill:
def __init__(self,mobileNumber,paymentBill):
self.mobileNumber=mobileNumber
self.paymentBill=paymentBill
class mobile:
def __init__(self,serviceProvider,mobileNumber,dataUsed,paymentMethod):
self.serviceProvider=serviceProvider
self.mobileNumber=mobileNumber
self.dataUsed=dataUsed
self.paymentMethod=paymentMethod
def calculateBill(self,olist):
blist=[]
for i in olist:
if i.serviceProvider=="airtel":
bill=11*i.dataUsed
totalBill=bill
if i.paymentMethod=="paytm":
totalBill=bill-(0.1*bill)
elif i.serviceProvider=="jio":
totalBill=10*i.dataUsed
blist.append(mobile(i.mobileNumber,int(totalBill)))
return blist
if __name__=='__main__':
count=int(input())
olist=[]
for i in range (count):
serviceProvider=input()
mobileNumber=int(input())
dataUsed=int(input())
paymentMethod=input()
olist.append(Bill(serviceProvider,mobileNumber,dataUsed,paymentMethod))
output=mobile("",0,0,"").calculateBill(olist)
for j in output:
print(j.mobileNumber,j.paymentBill)