Skip to content

Instantly share code, notes, and snippets.

@codingsnap
Created January 3, 2021 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingsnap/9c8391a0dc7e5b4a50c45342e749812e to your computer and use it in GitHub Desktop.
Save codingsnap/9c8391a0dc7e5b4a50c45342e749812e to your computer and use it in GitHub Desktop.
# Creating the class Mobile
class Mobile:
def __init__(self, serviceProvider, mobileNumber, dataUsed, paymentMethod):
self.serviceProvider = serviceProvider
self.mobileNumber = mobileNumber
self.dataUsed = dataUsed
self.paymentMethod = paymentMethod
# Creating the class Bill
class Bill:
def __init__(self):
paymentBill = 0
# Creating the method CalculateBill
def calculateBill(self, listOfMobileObjects):
l = [] # list to store final result object
# Iterating over all objects in the list
for i in listOfMobileObjects:
# www.codingsnap.tech
# Checking for the provider if it is airtel
if(i.serviceProvider.lower() == "airtel"):
paymentBill = 11 * i.dataUsed
# Checking the payment_method
if(i.paymentMethod.lower() == "Paytm"):
paymentBill = 0.9 * paymentBill
obj = (i.mobileNumber, paymentBill)
l.append(obj)
# Checking for the provider if it is jio
elif(i.serviceProvider.lower() == "jio"):
paymentBill = 10 * i.dataUsed
if(i.paymentMethod.lower() == "paytm"):
paymentBill = paymentBill * 0.9
obj = (i.mobileNumber, paymentBill)
l.append(obj)
return l
# Main program
noOfObjects = int(input())
l = []
for i in range(noOfObjects):
serviceProvider = input()
mobileNumber = int(input())
dataUsed = int(input())
paymentMethod = input()
l.append(Mobile(serviceProvider, mobileNumber, dataUsed, paymentMethod))
bill = Bill()
output = bill.calculateBill(l)
print(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment