Bird
Raised Fist0
Intro to Computingfundamentals~10 mins

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

Choose your learning style10 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.

Practice

(1/5)
1. What is the main purpose of two-factor authentication (2FA)?
easy
A. To allow users to log in without any password
B. To make passwords shorter and easier to remember
C. To add an extra layer of security by requiring two ways to prove identity
D. To speed up the login process by skipping verification

Solution

  1. Step 1: Understand what 2FA means

    Two-factor authentication means using two different methods to confirm who you are.
  2. Step 2: Identify the main goal of 2FA

    The goal is to make it harder for others to access your account by adding extra security.
  3. Final Answer:

    To add an extra layer of security by requiring two ways to prove identity -> Option C
  4. Quick Check:

    Extra security = To add an extra layer of security by requiring two ways to prove identity [OK]
Hint: 2FA means two ways to prove identity, not shortcuts [OK]
Common Mistakes:
  • Thinking 2FA makes passwords shorter
  • Believing 2FA removes the need for passwords
  • Assuming 2FA speeds up login by skipping steps
2. Which of the following is a correct example of a second factor in two-factor authentication?
easy
A. A code sent to your phone via SMS
B. A password you create
C. Your username
D. Your email address

Solution

  1. Step 1: Identify what counts as a second factor

    The second factor is something you have or receive, like a code sent to your phone.
  2. Step 2: Compare options to the second factor definition

    A password and username are first factors; a code sent to your phone is a second factor.
  3. Final Answer:

    A code sent to your phone via SMS -> Option A
  4. Quick Check:

    Second factor = code on phone [OK]
Hint: Second factor is usually a code or device, not password [OK]
Common Mistakes:
  • Confusing password as second factor
  • Thinking username or email is a second factor
  • Ignoring the difference between first and second factors
3. Consider this flowchart for a login process with two-factor authentication:

What happens if the password is correct but the code is wrong?
medium
A. Access is granted immediately
B. Access is denied after code verification fails
C. User is asked to enter the password again
D. User is logged in without code verification

Solution

  1. Step 1: Follow the flowchart steps

    The user enters password first; if correct, then code is requested.
  2. Step 2: Check what happens if code is wrong

    If the code verification fails, the flowchart shows access is denied.
  3. Final Answer:

    Access is denied after code verification fails -> Option B
  4. Quick Check:

    Wrong code = access denied [OK]
Hint: Both password and code must be correct to access [OK]
Common Mistakes:
  • Assuming password alone grants access
  • Thinking user retries password after code fails
  • Ignoring the code verification step
4. A user complains they cannot log in even after entering the correct password and code. Which of these is a likely error in the two-factor authentication process?
medium
A. The password was too simple
B. The user entered the wrong username
C. The user did not enter any code
D. The code sent to the user expired before use

Solution

  1. Step 1: Analyze the problem with correct password and code

    If the password and code are correct but login fails, the code might have expired.
  2. Step 2: Eliminate other options

    Wrong username or no code would cause different errors; password simplicity does not block login.
  3. Final Answer:

    The code sent to the user expired before use -> Option D
  4. Quick Check:

    Expired code blocks login [OK]
Hint: Expired codes cause login failure despite correct input [OK]
Common Mistakes:
  • Blaming password strength for login failure
  • Ignoring code expiration time
  • Assuming username error when password is correct
5. You want to improve your online account security using two-factor authentication. Which combination below is the best choice?
hard
A. Password + fingerprint scan on your phone
B. Password + security question answer
C. Password + username
D. Password + code sent by email

Solution

  1. Step 1: Identify strong second factors

    Biometric methods like fingerprint scans are stronger and harder to fake than codes or questions.
  2. Step 2: Compare options for security

    Code by email can be intercepted; username is not a factor; security questions can be guessed.
  3. Final Answer:

    Password + fingerprint scan on your phone -> Option A
  4. Quick Check:

    Biometric second factor = strongest security [OK]
Hint: Biometrics + password is stronger than codes or questions [OK]
Common Mistakes:
  • Thinking username is a second factor
  • Believing email codes are always safest
  • Underestimating security questions' weakness
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard