0% found this document useful (0 votes)
6 views4 pages

Dhriti Py

Trades

Uploaded by

hdtcdwrtdd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Dhriti Py

Trades

Uploaded by

hdtcdwrtdd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

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

1. Aim: Real Estate Management


Property Ro manages residential and commercial
properties. Problem Statement: Property listings
Client preferences
Viewing schedules Tasks:
1.Create sets of available properties
2.Use selection sort for property ranking

2. Requirements (Hardware/Software): Python 3.11 (Install


latest according to your system).

3. Procedure: class Property: def __init_ (self, name, type,


price, area):
self.name = name
self.type = type # 'Residential' or
'Commercial' self.price = price self.area =
area

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 add_property(self, property):


self.available_properties.add(property)
self.property_list.append(property)

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)

# Main code if __name__ ==


"__main__":
manager = RealEstateManager()
# Adding properties
manager.add_property(Property("Downtown
Apartment", "Residential", 500000, 1200))
manager.add_property(Property("Corporate Office",
"Commercial", 750000, 2500))
manager.add_property(Property("Suburban House",
"Residential", 300000, 1800))
manager.add_property(Property("Retail Store",
"Commercial", 600000, 1500))

# Displaying properties
manager.display_properties()

# Ranking properties by price


manager.rank_properties()

# Display ranked properties


manager.display_ranked_properties()
4. Learning Outcome:
Data types: Data types are the classification or
categorization of data items. It represents the kind of
value that tells what operations can be performed on a
particular data.
Id(): The id() function returns the unique identifier
(memory address) of an object. This identifier is a unique
integer that identifies the object's location in memory.

You might also like