Go through this information (come back to it as and when you need) and then attempt the challenges
Challenge - use dictionaries to solve this problem
First, watch the demo video below. Your task is to code something like this, and use the code below to get started
You can either edit and code online in repl.it or you can simply cut and paste the below into your own python file
#TASK: Understand how a dictionary is sometimes an amazing solution (works better than two lists)#****1. SELECT REGISTRATION AND ADD MORE USERS#*** 2. GO THROUGH THE CODE AND NOTE HOW THE DICTIONARY HAS BEEN CREATED with key value pairs#****3. Note the code to search a dictionary in the login function, to add to the dictionary in the reg function and how to print out a dictionary and its items in the registration_details function
print("=======Press L to login :")
print("=======Press R to register :")
if choice1=="L"or choice1=="l":
elif choice1=="R"or choice1=="r":
print("please make a valid selection")
if username notin usernames_passwords:
print("The user does not exist")
print("That's fine - access granted!")
elif usernames_passwords[username] !=password:
print("Sorry - wrong combination")
username=input("Enter a username:")
password=input("Enter a password:")
usernames_passwords[username]=password #this adds a username and password key value pair to the existing dictionary
answer=input("Do you want to make another registration?")
print(usernames_passwords) #note that a dictionary does not store the items in any particular sorted order#****CAN ALSO BE PRINTED OUT USING A FOR LOOP BELOW#for k, v in usernames_passwords.items():#print(k,v)
Code your solution here
Systems Life Cycle (in a nutshell): Analyse - Design - Create - Test - Evaluate.
Designing something or writing out some pseudocode before you actually write code is always a good idea! Get in to the habit of doing so! You can draw your flowchart here and screenshot it.
A sample flow chart (design) for this particular challenge could look like:
Each challenge section below provides an online drawing tool where you can dynamically create flowcharts. Screenshot them into your presentation for submission.
Solutions & Answers
Answers /Solutions in the "members area" drive under: "Solve and Learn >>SOLUTIONS"
You may want to read a little about Testing first. A teacher may go through some examples with you. Feel free to fill in the test table here, and screenshot it in to your powerpoint.
Testing is absolutely essential once you have created a program!