0% found this document useful (0 votes)
0 views7 pages

Batch 7 Report Python

This report outlines Python functions for managing customer data, including retrieving, updating, and merging customer records stored in dictionaries. It also introduces sorting and filtering functionalities to enhance data management efficiency. The implementations have been applied in business case studies, demonstrating improvements in customer engagement and retention through effective data handling.

Uploaded by

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

Batch 7 Report Python

This report outlines Python functions for managing customer data, including retrieving, updating, and merging customer records stored in dictionaries. It also introduces sorting and filtering functionalities to enhance data management efficiency. The implementations have been applied in business case studies, demonstrating improvements in customer engagement and retention through effective data handling.

Uploaded by

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

PROBLEM SOLVING THROUGH

PYTHON
Batch no.07

Manoj.Budaniya, 242FA05042
K.Shivani, 242FA05029
G.Mohith venu reddy, 242FA05024
PANDAY.TUFAN, 242FA05051
within a list. The report also
introduces sorting and filtering
Abstract functionalities to improve usability.
This report presents Python Programs to solve
functions for managing customer
data stored in dictionaries. The core A. RETRIEVING A
functionalities include searching for CUSTOMER BY NAME
customers by name, updating The following function searches for
customer ages, and merging a customer by name and returns their
customer records while preserving details:
unique information. Additionally, def
sorting and filtering extensions are get_customer_by_name(customers,
implemented to enhance data name):
management efficiency. """Returns the dictionary for the
customer with the given name."""
Introduction for customer in customers:
Efficient customer data handling is if customer.get("name") ==
crucial in business applications. This name:
report details Python return customer
implementations for retrieving, return None
updating, and merging customer
information stored as dictionaries

2 Insert title of presentation | ieee.org/inserturl


B. UPDATING CUSTOMER C. MERGING CUSTOMER
AGE DATA
The following function updates the The following function merges two
age of a customer in the list of customer dictionaries, combining
dictionaries: purchase histories:
def def
update_customer_age(customers, merge_customer_data(customer1,
name, new_age): customer2):
"""Updates the age of a customer """Combines two customer
in the list of dictionaries.""" dictionaries, merging purchase
for customer in customers: histories and updating fields."""
if customer.get("name") == if customer1.get("name") !=
name: customer2.get("name"):
customer["age"] = new_age return "Error: Customer names
return True # Update do not match!"
successful
return False # Customer not merged_customer =
found customer1.copy()
for key, value in
customer2.items():
if key == "purchases":
merged_customer[key] =

3 Insert title of presentation | ieee.org/inserturl


list(set(customer1.get(key, []) + key=lambda x: x["age"],
customer2.get(key, []))) reverse=descending)
elif key != "name": # Avoid
modifying the name FILTERING
merged_customer[key] =
value
CUSTOMERS BY
MINIMUM AGE
return merged_customer
Extension: Sorting and The following function filters
Filtering customers by a minimum age
SORTING CUSTOMERS BY criterion:
AGE def
The following function sorts filter_customers_by_min_age(custo
customers by age in ascending or mers, min_age):
descending order: """Filters customers by a
def minimum age criteria."""
sort_customers_by_age(customers, return [customer for customer in
descending=False): customers if customer["age"] >=
"""Sorts customers by age in min_age]
ascending or descending order."""
Results and Discussion
return sorted(customers,

4 Insert title of presentation | ieee.org/inserturl


To demonstrate the functionalities, # Merge two customer records
consider the following example customer1 = {"name": "Alice",
dataset: "age": 30, "purchases":
customers = [ ["Laptop", "Phone"]}
{"name": "Alice", "age": 30, customer2 = {"name": "Alice",
"purchases": ["Laptop", "Phone"]}, "age": 32, "purchases":
{"name": "Bob", "age": 25, ["Headphones", "Phone"]}
"purchases": ["Tablet"]}, print(merge_customer_data(custo
{"name": "Charlie", "age": 35, mer1, customer2))
"purchases": ["Monitor",
"Keyboard"]}, # Sort customers by age
] print(sort_customers_by_age(cust
Function Usage Example omers))
# Get a customer by name print(sort_customers_by_age(cust
print(get_customer_by_name(cust omers, descending=True))
omers, "Alice"))
# Filter customers by minimum
# Update customer age age
update_customer_age(customers, print(filter_customers_by_min_ag
"Alice", 31) e(customers, 30))
print(customers)

5 Insert title of presentation | ieee.org/inserturl


Case Studies: Business CASE STUDY 2:
Applications
SUBSCRIPTION SERVICE
CASE STUDY 1: RETAIL OPTIMIZATION
BUSINESS APPLICATION A streaming platform uses the
A retail company, XYZ Electronics, sorting and filtering functions to
uses the implemented Python segment users based on age groups.
functions to manage its customer By analyzing customer data, the
database. By leveraging these company optimized its content
functions, the company efficiently recommendations, leading to a 20%
retrieves customer information, increase in watch time among
updates records, merges purchase younger audiences and a 10%
histories, and filters customers for improvement in customer retention.
targeted marketing campaigns. For
example, XYZ Electronics sorted Conclusion
customers by age to personalize This report presents essential Python
promotions for different functions for handling customer data
demographics, resulting in a 15% effectively. The implemented
increase in customer engagement. solutions support name-based
retrieval, age updates, merging of
records, and extended functionalities
such as sorting and filtering. These
tools facilitate efficient customer

6 Insert title of presentation | ieee.org/inserturl


data management for business
applications.

References
[1] IEEE Standards for Software
Engineering, IEEE Xplore, 2024.
[2] Python Documentation,
https://docs.python.org/3/

7 Insert title of presentation | ieee.org/inserturl

You might also like