Skip to content

Latest commit

 

History

History
80 lines (51 loc) · 3.24 KB

File metadata and controls

80 lines (51 loc) · 3.24 KB

User Configuration Manager (Python)

This project is part of the freeCodeCamp Python Certification.

It implements a simple user configuration manager that allows adding, updating, deleting, and viewing settings stored in a dictionary.


📌 Features

  • Add a new setting (key-value pair)
  • Update an existing setting
  • Delete a setting
  • View all current settings

🛠️ Technologies

  • Python 3

📖 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

  2. 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.
  3. You should define a function named update_setting with two parameters representing a dictionary of settings and a tuple containing a key-value pair.

  4. 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.
  5. You should define a function named delete_setting with two parameters representing a dictionary of settings and a key.

  6. 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.
  7. You should define a function named view_settings with one parameter representing a dictionary of settings.

  8. 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:
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.

🧪 Example Usage

Example test cases are included as commented lines at the bottom of main.py.

Uncomment them to run and see the output.


📚 Notes

  • This project was developed to meet the certification requirements.
  • The implementation focuses on correctness and clarity rather than extended functionality.