Dhriti Py
Dhriti Py
Worksheet 4
Student Name: Dhriti Jaswal UID: 23BCS12813
Branch: CSE Section/Group:719-A Semester: 3rd Date of
Performance:
04/11/2024
Subject Name: Python Programming Subject Code:23CSP-201
def __str__(self):
return f"Name: {self.name}, Type: {self.type}, Price:
${self.price}, Area: {self.area} sqft"
class RealEstateManager: def __init__(self):
self.available_properties = set() # A set to hold unique
properties
self.property_list = [] # A list for sorting and ranking
def display_properties(self):
print("Available Properties:") for
property in self.available_properties:
print(property)
def rank_properties(self):
# Using Selection Sort to rank properties by price
(lowest to highest) n=
len(self.property_list) for
i in range(n - 1):
min_idx = i for
j in range(i + 1, n):
if self.property_list[j].price <
self.property_list[min_idx].price:
min_idx = j
# Swap the found minimum element with the first
element
self.property_list[i], self.property_list[min_idx]
= self.property_list[min_idx], self.property_list[i]
def display_ranked_properties(self):
print("\nRanked Properties by Price:")
for property in self.property_list:
print(property)
# Displaying properties
manager.display_properties()