



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
iMedia coursework asset table template
Typology: Assignments
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Lesson 22 - Structured programming
Code before 1 2 3 4 5 6 7 to_guess = 3 not_guessed = True while not_guessed: print("Guess a number") number = int(input()) if number == to_guess: break Code after 1 2 3 4 5 6 7 to_guess = 3 not_guessed = True while not_guessed: print("Guess a number") number = int(input()) if number == to_guess: not_guessed = False
Lesson 22 - Structured programming
Code before 1 2 3 4 5 6 7 8 9 10 11 def and_function(a, b): if a == True and b == True: return True else: return False one = 4 == 4 two = 2 == 2 print(and_function(one, two))
Lesson 22 - Structured programming
Code before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 def password_check(): password = "12345" entered_pass = "" pass_not_valid = password != entered_pass attempts = 0 while pass_not_valid and attempts < 3: print("Enter a password:") entered_pass = input() attempts = attempts + 1 if password == entered_pass: break if password != entered_pass: return "Access Denied" else: return "Access Granted" print(password_check())
Lesson 22 - Structured programming Code after 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 def password_check(): password = "12345" entered_pass = "" pass_not_valid = password != entered_pass attempts = 0 while pass_not_valid and attempts < 3: print("Enter a password:") entered_pass = input() attempts = attempts + 1 if password == entered_pass: pass_not_valid = False if password != entered_pass: a = "Access Denied" else: a = "Access Granted" return a print(password_check()) Resources are updated regularly — the latest version is available at: ncce.io/tcc.