Created
January 3, 2021 19:19
-
-
Save codingsnap/0dd639b3ab5a6f39f68f56eb361fd11c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating the class Apartment | |
class Apartment: | |
def __init__(self, flatNumber, ownerName, billAmount): | |
self.flatNumber = flatNumber | |
self.ownerName = ownerName | |
self.billAmount = billAmount | |
# Creating the class Apartment_Demo | |
class Apartment_demo: | |
# Since the constructor function does not initialises any variable, it is optional to write. | |
def __init__(self): | |
pass | |
# Function to calculate the second minimum Bill Amount from the list of Apartment Object. | |
def getSecondMinBill(self, listOfApartments): | |
# Initialising the list "minimum[]" to store all the electricity amount from the Apartment Object list. | |
minimum = [] | |
for i in listOfApartments: | |
minimum.append(i.billAmount) | |
# Sorting the list to easily pick up the second minimum bill amount. | |
minimum.sort() | |
# Index 0 has the least value since the list is sorted, so our result is in the first index. | |
return minimum[1] | |
# Main Program | |
noOfObjectsToBeCreated = int(input()) | |
objList = [] | |
for i in range(noOfObjectsToBeCreated): | |
flatNumber = int(input()) | |
ownerName = input() | |
billAmount = int(input()) | |
objList.append(Apartment(flatNumber, ownerName,billAmount)) | |
demo = Apartment_demo() | |
secondMinBill = demo.getSecondMinBill(objList) | |
print(secondMinBill) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment