0
0
Intro to Computingfundamentals~10 mins

Database in everyday apps (social media, banking) 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 select all records from a database table named 'users'.

Intro to Computing
SELECT [1] FROM users;
Drag options to blanks, or click blank then click option'
Aname
B*
Cuser_id
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using a specific column name when the task asks for all columns.
Leaving the blank empty.
2fill in blank
medium

Complete the code to find users with the username 'alice'.

Intro to Computing
SELECT * FROM users WHERE username [1] 'alice';
Drag options to blanks, or click blank then click option'
A=
BLIKE
C!=
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' which means 'not equal'.
Using 'LIKE' without wildcards for exact match.
3fill in blank
hard

Fix the error in the SQL query to count the number of transactions.

Intro to Computing
SELECT COUNT([1]) FROM transactions;
Drag options to blanks, or click blank then click option'
Atransaction_id
Bdate
C*
Damount
Attempts:
3 left
💡 Hint
Common Mistakes
Counting a specific column which may have NULLs and cause incorrect counts.
Leaving the parentheses empty.
4fill in blank
hard

Fill both blanks to select usernames and emails of users who have logged in more than 5 times.

Intro to Computing
SELECT [1], [2] FROM users WHERE login_count > 5;
Drag options to blanks, or click blank then click option'
Ausername
Bemail
Cpassword
Duser_id
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting password instead of email.
Selecting user_id instead of username.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps user IDs to their email addresses for users with active status.

Intro to Computing
user_emails = { [3]['[1]']: [3]['[2]'] for [3] in users if [3]['status'] == 'active' }
Drag options to blanks, or click blank then click option'
Auser_id
Bemail
Cuser
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'user_id' as key.
Using 'users' as loop variable instead of a single user.
Mixing up keys and values in the comprehension.