IB Computer Science Year 1 Standard Level - May 18 2018 Lesson Notes: Difference between revisions
Mr. MacKenty (talk | contribs) |
Mr. MacKenty (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 9: | Line 9: | ||
1. Copy this code into whatever you are running python in: | 1. Copy this code into whatever you are running python in: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="Python"> | ||
credentials = {'joe':'mypassword', 'anna':'annpassword', 'pawel':'password123!'} | credentials = {'joe':'mypassword', 'anna':'annpassword', 'pawel':'password123!'} | ||
Line 33: | Line 33: | ||
4. Please design and implement: | 4. Please design and implement: | ||
<br /> | |||
4.1 A function to get consent to process data. This consent must be stored. | 4.1 A function to get consent to process data. This consent must be stored. | ||
<br /> | |||
4.2 A function to remove consent. | 4.2 A function to remove consent. | ||
<br /> | |||
4.3 A function that realizes "the right to be forgotten" | 4.3 A function that realizes "the right to be forgotten" | ||
It may be helpful to have this code later: | |||
<syntaxhighlight lang="Python"> | |||
credentials = {'joe':'mypassword', 'anna':'annpassword', 'pawel':'password123!'} | |||
global logged_in | |||
def main(): | |||
while True: | |||
print("="*45) | |||
print("Welcome to our application thing!") | |||
print("="*45) | |||
print("1. Login") | |||
print("Menu option 2") | |||
print("Menu option 3") | |||
print("Menu option 4") | |||
print("Menu option 5") | |||
print("Menu option 6") | |||
print("Menu option 7") | |||
print("\n") | |||
print("enter 99 to quit") | |||
print("\n") | |||
choice = input("Enter your choice > ") | |||
if choice == "99": | |||
break | |||
elif choice == "1": | |||
login() | |||
elif choice == "2": | |||
print("You have selected choice 2.") | |||
elif choice == "3": | |||
print("You have selected choice 3.") | |||
elif choice == "4": | |||
print("You have selected choice 4.") | |||
elif choice == "5": | |||
print("You have selected choice 5.") | |||
elif choice == "6": | |||
print("You have selected choice 6.") | |||
elif choice == "7": | |||
print("You have selected choice 7.") | |||
return | |||
def login(): | |||
name = input("Please enter your name: ") | |||
if name in credentials: | |||
password = input("Please enter your password: ") | |||
if credentials[name] == password: | |||
print("Correct password") | |||
print("We can now continue on with our program") | |||
logged_in = True | |||
return logged_in | |||
else: | |||
print("incorrect password") | |||
else: | |||
print("We don't have that user in our system.") | |||
main() | |||
</syntaxhighlight> | |||
</td> | </td> |
Latest revision as of 13:46, 2 July 2019
|
|
|
|
|
|
|