Bird
Raised Fist0
Intro to Computingfundamentals~10 mins

Passwords and authentication best practices 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 a password is at least 8 characters long.

Intro to Computing
if len(password) [1] 8:
    print("Password length is sufficient")
Drag options to blanks, or click blank then click option'
A>=
B!=
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>=' causes short passwords to pass.
Using '==' only allows passwords exactly 8 characters long.
2fill in blank
medium

Complete the code to verify if the entered password matches the stored password.

Intro to Computing
if entered_password [1] stored_password:
    print("Access granted")
else:
    print("Access denied")
Drag options to blanks, or click blank then click option'
A>
B!=
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' causes access to be denied when passwords match.
Using '>' or '<' does not make sense for string comparison here.
3fill in blank
hard

Fix the error in the code to hash a password using SHA-256.

Intro to Computing
import hashlib

hashed = hashlib.sha256([1].encode()).hexdigest()
print(hashed)
Drag options to blanks, or click blank then click option'
Ahashlib
Bpassword.encode()
Cpassword.hash()
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Passing password.encode() causes an error because encode() returns bytes and then encode() is called again.
Using hashlib or password.hash() is incorrect syntax.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that stores usernames and their hashed passwords only if the password length is at least 8.

Intro to Computing
hashed_passwords = {user: hashlib.sha256(passwd[1]).hexdigest() for user, passwd in users.items() if len(passwd) [2] 8}
Drag options to blanks, or click blank then click option'
A.encode()
B>=
C<
D.decode()
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.decode()' instead of '.encode()' causes errors.
Using '<' allows short passwords to be hashed.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that stores usernames in uppercase, their passwords, and filters only those with passwords containing more than 6 characters.

Intro to Computing
filtered_users = [1]: [2] for [3], pwd in users.items() if len(pwd) > 6
Drag options to blanks, or click blank then click option'
Auser.upper()
Bpwd
Cuser
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'password' instead of 'pwd' causes errors.
Using 'user' instead of 'user.upper()' does not convert usernames.

Practice

(1/5)
1. Which of the following is the best practice for creating a strong password?
easy
A. Use your username as the password
B. Use only your birthdate
C. Use a simple word like 'password'
D. Use a mix of letters, numbers, and symbols

Solution

  1. Step 1: Understand password strength factors

    A strong password includes a mix of letters, numbers, and symbols to make it hard to guess.
  2. Step 2: Evaluate each option

    The other options use easily guessable information like birthdates, simple words, or usernames, making them weak passwords.
  3. Final Answer:

    Use a mix of letters, numbers, and symbols -> Option D
  4. Quick Check:

    Strong password = mix of characters [OK]
Hint: Strong passwords mix letters, numbers, and symbols [OK]
Common Mistakes:
  • Using only simple words or personal info
  • Ignoring symbols and numbers
  • Reusing the same password everywhere
2. Which of the following is the correct way to enable two-factor authentication (2FA)?
easy
A. Use only a password without any extra step
B. Enter a password and then a code sent to your phone
C. Use your password twice in a row
D. Share your password with a friend for backup

Solution

  1. Step 1: Understand two-factor authentication

    2FA requires two steps: something you know (password) and something you have (code from phone).
  2. Step 2: Check each option

    Only Enter a password and then a code sent to your phone describes entering a password plus a code sent to your phone, which is correct 2FA.
  3. Final Answer:

    Enter a password and then a code sent to your phone -> Option B
  4. Quick Check:

    2FA = password + code [OK]
Hint: 2FA means password plus a code from your device [OK]
Common Mistakes:
  • Thinking 2FA is just repeating the password
  • Sharing passwords with others
  • Skipping the second authentication step
3. Consider this scenario: You create a password 'P@ssw0rd123' and enable 2FA. What is the main benefit of enabling 2FA?
medium
A. It adds an extra layer of security beyond the password
B. It allows password sharing safely
C. It makes the password shorter
D. It removes the need to remember the password

Solution

  1. Step 1: Analyze the role of 2FA

    2FA adds a second step to verify identity, making unauthorized access harder.
  2. Step 2: Evaluate options

    Only It adds an extra layer of security beyond the password correctly states that 2FA adds extra security beyond just the password.
  3. Final Answer:

    It adds an extra layer of security beyond the password -> Option A
  4. Quick Check:

    2FA = extra security layer [OK]
Hint: 2FA adds security beyond just the password [OK]
Common Mistakes:
  • Thinking 2FA shortens passwords
  • Believing 2FA allows safe password sharing
  • Assuming 2FA removes password need
4. You wrote a password policy that requires users to create passwords with at least 8 characters, but you forgot to include numbers or symbols. What is the main issue with this policy?
medium
A. Users will be forced to use 2FA
B. Passwords will be too complex to remember
C. Passwords may be weak because they lack variety
D. Passwords will always be secure

Solution

  1. Step 1: Understand password complexity

    Passwords need variety (letters, numbers, symbols) to be strong, not just length.
  2. Step 2: Analyze the policy

    The policy only requires length, missing variety, so passwords may be weak.
  3. Final Answer:

    Passwords may be weak because they lack variety -> Option C
  4. Quick Check:

    Password strength = length + variety [OK]
Hint: Length alone doesn't ensure strong passwords [OK]
Common Mistakes:
  • Assuming length alone makes passwords strong
  • Forgetting to require symbols or numbers
  • Confusing 2FA with password complexity
5. You manage a website login system. To improve security, you want to implement a policy that forces users to update their passwords every 90 days and use 2FA. Which of the following best explains why this combination is effective?
hard
A. Regular password changes reduce risk if passwords are stolen; 2FA adds a second verification step
B. Frequent password changes make users forget passwords; 2FA removes the need for passwords
C. Password updates and 2FA both replace the need for strong passwords
D. This policy allows users to share passwords safely with 2FA

Solution

  1. Step 1: Understand password update benefits

    Changing passwords regularly limits the time stolen passwords can be used.
  2. Step 2: Understand 2FA benefits

    2FA adds a second verification step, making unauthorized access harder even if password is known.
  3. Step 3: Combine both concepts

    Together, they reduce risk from stolen passwords and add extra security layers.
  4. Final Answer:

    Regular password changes reduce risk if passwords are stolen; 2FA adds a second verification step -> Option A
  5. Quick Check:

    Password updates + 2FA = stronger security [OK]
Hint: Update passwords often and use 2FA for best security [OK]
Common Mistakes:
  • Thinking 2FA removes need for passwords
  • Believing frequent changes cause security issues
  • Assuming password sharing is safe with 2FA
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