0
0
Intro to Computingfundamentals~10 mins

Two-factor authentication in Intro to Computing - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if the user entered the correct password.

Intro to Computing
if user_input_password == [1]:
    print("Password accepted")
Drag options to blanks, or click blank then click option'
Astored_password
Binput_password
Cuser_password
Dpassword_input
Attempts:
3 left
💡 Hint
Common Mistakes
Using the input variable on both sides of the comparison.
2fill in blank
medium

Complete the code to send a verification code to the user's phone.

Intro to Computing
send_sms(phone_number, [1])
Drag options to blanks, or click blank then click option'
Aphone_number
Buser_password
Cverification_code
Duser_id
Attempts:
3 left
💡 Hint
Common Mistakes
Sending the password instead of the verification code.
3fill in blank
hard

Fix the error in the code that verifies the second factor code.

Intro to Computing
if entered_code == [1]:
    print("Access granted")
else:
    print("Access denied")
Drag options to blanks, or click blank then click option'
Auser_id
Buser_password
Cphone_number
Dverification_code
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing the entered code with the password or phone number.
4fill in blank
hard

Fill both blanks to create a dictionary of users with their 2FA status.

Intro to Computing
users_2fa_status = {user: user.[1] for user in user_list if user.[1] [2] "enabled"}
Drag options to blanks, or click blank then click option'
Ais_2fa_enabled
Bnot
Cin
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'in' or 'not' incorrectly in the condition.
5fill in blank
hard

Fill all three blanks to filter users who passed both authentication steps.

Intro to Computing
authenticated_users = {user: status for user, status in users_status.items() if status['password'] [1] True and status['2fa'] [2] True and user [3] blocked_users}
Drag options to blanks, or click blank then click option'
A==
B!=
Cnot in
Din
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'in' instead of 'not in' for blocked users.