PRP201c_-_FA_2024_-_PE1_3166.webp
K

PRP201c_-_FA_2024_-_PE1_3166.webp

insightful queries using Python.
In this exam, you will implement a system to manage user data, including their names, emails, and locations, using different data structures. You will load user data from a file (user_data.csv), visualize the data, and manage it in a database. Finally, you will enrich the system by fetching additional user details from a live API.
Question 1: User Data Class and CSV Data Loading (1.5 marks)
Task 1: Create a class User that represents a user's ID, name, email, location, gender, date of birth, and registration date.
Task 2: Implement a function load_user_data(filename) to:
Load user data from a CSV file (user_data.csv) and store it in a list of User objects.
• Validate the data:
Ensure all rows contain valid ID, Name, and Email.
Convert DateOfBirth and RegisteredDate to Python datetime objects.
Task 3: Discuss the advantages and disadvantages of using a list to store user data (ascomments in the code).
Question 2: Data Visualization (1.5 marks)
Task 1: Write a function visualize_user_data(data) to:
Generate a line chart showing the trend of user registrations over the years.
Generate a stacked bar chart showing the number of male and female users per location.
Task 2: Discuss the challenges of handling data inconsistencies in visualizations (as
comments).
Question 3: Database Integration (2.5 marks)
Task 1: Write a function store_user_data_in_database(data) to:
Create a SQLite database UserData.db.
Create a table Users with columns:
ID, Name, Email, Location, Gender, DateOfBirth, RegisteredDate.
Insert all user data into the database.
Task 2: Implement a query to:
Retrieve and display the top 5 locations with the highest number of registered users.Display the number of users per gender who registered after 2015.
Question 4: Fetching Live Data from API (2.5 marks)
Task 1: Write a function fetch_and_update_user_info() to:
Fetch additional user details (e.g., Username, PictureURL, Timezone) from the Random User API (https://randomuser.me/api/).Undate the database schema to include now fields.
Zoom
+ 110%
Close

Thông tin

Category
PRP201c
Thêm bởi
Kusakabe93
Ngày thêm
Lượt xem
4,291
Lượt bình luận
1
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRP201c_-_FA_2024_-_PE1_3166.webp
File size
796.4 KB
Dimensions
3840px x 1718px

Share this media

Back
Bên trên Bottom