Complete the following exercises using the code and concepts from workshop_6. All work should be committed to your GitHub repository.
- Create a Python script that:
- Creates a dictionary representing a student with keys for name, age, courses (a list), and GPA
- Prints the entire dictionary
- Accesses and prints specific values using keys
- Modifies at least two values in the dictionary
- Adds at least two new key-value pairs
- Removes at least one key-value pair
- Prints the final dictionary
- Reference the approach shown in
dicts.py
- Write a script that:
- Creates a dictionary of at least 5 countries as keys and their capitals as values
- Uses different dictionary methods (keys(), values(), items()) to iterate through the dictionary
- Formats and prints the data in a readable way (e.g., "The capital of [country] is [capital]")
- Creates a new dictionary where the keys and values are swapped (capitals become keys, countries become values)
- Prints the new dictionary
- Follow the pattern in
dicts.pybut implement your own solution
- Create a script that:
- Creates at least 3 different tuples representing various data (e.g., geographic coordinates, RGB colors, date components)
- Demonstrates accessing tuple elements by index
- Demonstrates unpacking tuples into separate variables
- Uses tuples as dictionary keys (research how to do this)
- Shows an example of when tuples are preferable to lists
- Reference the approach in
tuples.py
- Write a script that:
- Creates a list of dictionaries where each dictionary represents a different product with keys for name, price, category, and stock
- Implements a search function that allows the user to search products by name or category
- Implements a filter function that shows products below a certain price or with stock above a certain threshold
- Calculates and displays the total value of all products (price × stock)
- Follow the pattern shown in
nested_dict.py
- Create a program that:
- Allows the user to enter student names and scores for multiple subjects
- Stores this data in an appropriate nested data structure (dictionaries inside a dictionary or list)
- Calculates and displays each student's average score
- Identifies and displays the highest scoring student for each subject
- Calculates and displays the class average for each subject
- Reference the concepts from
nested_dict.pyandarctic.py
- Extend the temperature analysis from
arctic.pywith the following enhancements:- Store temperature data as tuples with (day, temperature) pairs
- Convert the data to a dictionary with days as keys and temperatures as values
- Allow the user to:
- Add new temperature readings
- Find the average temperature for a specific range of days
- Identify days with temperatures above or below a certain threshold
- Display all recorded temperatures in ascending or descending order
- Use appropriate dictionary and tuple operations for all functionality
- Create a folder named
homework_6in your GitHub repository. - Create separate
.pyfiles for each exercise (6 files total). - Include meaningful comments in your code explaining your logic.
- Make sure to commit and push your changes to GitHub.
- Test all your scripts to ensure they work as expected.
- Proper use of dictionaries and dictionary methods
- Effective implementation of tuples and their operations
- Correct use of nested data structures
- Appropriate data structure selection for each task
- Input validation and user feedback
- Code organization and readability
- Following the submission guidelines