0
0
Raspberry Piprogramming~20 mins

User authentication basics in Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
User Authentication Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this simple password check?

Consider this Python code snippet running on a Raspberry Pi. What will it print if the user enters the password 'raspberry'?

Raspberry Pi
password = input('Enter password: ')
if password == 'raspberry':
    print('Access granted')
else:
    print('Access denied')
ASyntaxError
BAccess denied
CAccess granted
DNo output
Attempts:
2 left
💡 Hint

Check the exact string compared in the if condition.

🧠 Conceptual
intermediate
1:30remaining
Which method securely stores passwords on Raspberry Pi?

When building a user login system on a Raspberry Pi, which method is best to store user passwords securely?

AStore passwords hashed with a salt
BStore passwords as plain text in a file
CStore passwords encrypted with a reversible key
DStore passwords in a public shared folder
Attempts:
2 left
💡 Hint

Think about what makes it hard for attackers to recover the original password.

🔧 Debug
advanced
2:00remaining
Why does this Raspberry Pi login script always deny access?

Look at this code snippet. It should grant access if the password is 'pi123', but it always prints 'Access denied'. What is the problem?

Raspberry Pi
password = input('Enter password: ')
if password is 'pi123':
    print('Access granted')
else:
    print('Access denied')
AThe print statements are reversed
BThe input function is not reading the password
CThe string 'pi123' is misspelled
DUsing 'is' instead of '==' causes the problem
Attempts:
2 left
💡 Hint

Check how string comparison works in Python.

📝 Syntax
advanced
1:30remaining
Identify the syntax error in this user authentication code

Which option contains the correct syntax for this Raspberry Pi Python login snippet?

Raspberry Pi
password = input('Password: ')
if password == 'secret'
    print('Welcome!')
else:
    print('Try again')
AAdd a colon ':' after the if condition
BRemove the else block
CChange '==' to '=' in the if condition
DIndent the print statements less
Attempts:
2 left
💡 Hint

Python requires a specific punctuation after conditions.

🚀 Application
expert
1:30remaining
How many users can this Raspberry Pi authentication dictionary hold?

Given this dictionary storing usernames and hashed passwords, how many users are registered?

Raspberry Pi
users = {
    'alice': '5f4dcc3b5aa765d61d8327deb882cf99',
    'bob': '202cb962ac59075b964b07152d234b70',
    'carol': '098f6bcd4621d373cade4e832627b4f6'
}
print(len(users))
A2
B3
C0
D4
Attempts:
2 left
💡 Hint

Count the number of keys in the dictionary.