import pandas as pd
data = pd.read_csv("school_supplies.csv")
data_cleaned = data.dropna()
data_sorted = data_cleaned.sort_values(by="Price")
price_list = data_sorted["Price"].tolist()
print("First few rows of sorted data:")
print(data_sorted.head())
print("Original row count:", len(data))
print("Cleaned row count:", len(data_cleaned))
def binary_search(prices, target):
left, right = 0, len(prices) - 1
while left <= right:
mid = (left + right) // 2
if prices[mid] == target:
return True
elif prices[mid] < target:
left = mid + 1
else:
right = mid - 1
return False
search_prices = [1.25, 6.49, 10.00]
for price in search_prices:
found = binary_search(price_list, price)
if found:
print(f"Price ${price:.2f} was FOUND in the list.")
else:
print(f"Price ${price:.2f} was NOT FOUND in the list.")
First few rows of sorted data:
Product Price
5 Eraser 0.50
14 Paper Clips 0.89
2 Pencil 0.99
9 Glue Stick 1.25
1 Pen 1.50
Original row count: 15
Cleaned row count: 15
Price $1.25 was FOUND in the list.
Price $6.49 was FOUND in the list.
Price $10.00 was NOT FOUND in the list.