The purpose of these assignments is to help you review the concept of the dictionary data structure in programming. Dictionaries are an amazing data structure that allow use to add and retrieve an item very quickly.
Utilize the lab sessions to work on these exercises, and reach out to your Teaching Assistant (TA) or instructor for help. You have unlimited attempts to solve and resubmit these assignments on codePost.io, so use this opportunity to learn, experiment, and improve.
Submission Instructions
For each of the following practice assignments, save your solution in a .py file, with the name being "dicts" followed by the number of the assignment. For example, for "Dicts01: Login Validation", save your solution in a file named dicts01.py (notice the lowercase "d"). Then, submit that file to the respective assignment on codePost.io .
There are two types of problems: Required and Optional/Bonus. The Required problems must be submitted to attain full credit for the codePost assignment, while Optional/Bonus problems are provided to help you practice further and deepen your understanding of Python.
To register for a free codePost account, please follow these instructions.
You can submit to codePost multiple times if you want.
Only your last submission will be graded.
From the starting date of this assignment, you have one week to complete and submit your solutions.
Watch this short video for a demonstration of submitting an assignment, reviewing the results and resubmitting.
Practice Assignments
Dicts01: Login Validation (Required)
Compete the passwordCheck() function that will authenticate a user's login by accepting that user's name, their password, and a dictionary of users' login credentials. The function will return the str 'login successful' if the user's login information is correct and the str 'login failed' otherwise.
Complete the function charFrequency( ) so that it will accept a str, and use a dictionary to store each character’s frequency. Return the dictionary.
Suggested steps:
Create an empty dictionary
Traverse the string of characters, one at a time. For each character, use the character as the key. If the character's not in the dictionary, then add it. Otherwise, increment it's count.