All Tracks/lab user configuration manager/
Đang tải...
Hướng dẫn thử thách
1 / 1

Build a User Configuration Manager

In this lab, you will build a User Configuration Manager that allows users to manage their settings such as theme, language, and notifications. You will implement functions to add, update, delete, and view user settings. **Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab. **User Stories:** 1. You should define a function named `add_setting` with two parameters representing a dictionary of settings and a tuple containing a key-value pair 1. `add_setting` function should: - Convert the key and value to lowercase. - If the key setting exists, return `Setting '[key]' already exists! Cannot add a new setting with this name.` - If the key setting doesn't exist, add the key-value pair to the given dictionary of settings and return `Setting '[key]' added with value '[value]' successfully!`. - The messages returned should have the key and value in lowercase. 1. You should define a function named `update_setting` with two parameters representing a dictionary of settings and a tuple containing a key-value pair. 1. `update_setting` function should: - Convert the key and value to lowercase. - If the key setting exists, update its value in the given dictionary of settings and return: `Setting '[key]' updated to '[value]' successfully!` - If the key setting doesn't exist, return `Setting '[key]' does not exist! Cannot update a non-existing setting.` - The messages returned should have the key and value in lowercase. 1. You should define a function named `delete_setting` with two parameters representing a dictionary of settings and a key. 1. `delete_setting` function should: - Convert the key passed to lowercase. - If the key setting exists, remove the key-value pair from the given dictionary of settings and return `Setting '[key]' deleted successfully!` - If the key setting does not exist, return `Setting not found!` - The messages returned should have the key in lowercase. 1. You should define a function named `view_settings` with one parameter representing a dictionary of settings. 1. `view_settings` function should: - Return `No settings available.` if the given dictionary of settings is empty. - If the dictionary contains any settings, return a string displaying the settings. The string should start with `Current User Settings:` followed by the key-value pairs, each on a new line and with the key capitalized. For example, `view_settings({'theme': 'dark', 'notifications': 'enabled', 'volume': 'high'})` should return: ```md Current User Settings: Theme: dark Notifications: enabled Volume: high ``` 1. For testing the code, you should create a dictionary named `test_settings` to store some user configuration preferences.
Vượt qua bài kiểm tra hiện tại để mở khóa bài tiếp theo.
main.py
UTF-8 • Tab Size: 2Kiểm tra bài:⌘↵
Test Output
Thử thách này không có bài test tự động. Hãy quan sát kết quả trực tiếp ở khung Preview.