Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if a website URL starts with a secure protocol.
Intro to Computing
if url.startswith([1]): print("Secure connection")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'http://' instead of 'https://'
Confusing other protocols like 'ftp://'
✗ Incorrect
Websites that start with https:// use a secure connection.
2fill in blank
mediumComplete the code to block access to a list of unsafe websites.
Intro to Computing
if website in [1]: print("Access blocked")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'safe_sites' which is the opposite
Using unrelated lists like 'favorite_sites'
✗ Incorrect
We check if the website is in the list of unsafe_sites to block it.
3fill in blank
hardFix the error in the code that warns about suspicious links.
Intro to Computing
if 'http://' [1] url: print("Warning: Suspicious link")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which checks equality
Using 'not in' which reverses the logic
✗ Incorrect
The keyword in checks if 'http://' is part of the URL string.
4fill in blank
hardFill both blanks to create a dictionary of websites with their safety status.
Intro to Computing
site_status = {site: [1] for site in websites if site [2] unsafe_sites} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'site.upper()' which changes case incorrectly
Using 'in' which includes unsafe sites
✗ Incorrect
We convert site names to lowercase and include only those not in unsafe_sites.
5fill in blank
hardFill all three blanks to filter and map safe websites with their URL lengths.
Intro to Computing
safe_lengths = [1]: len([2]) for [3] in websites if [2] not in unsafe_sites}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing variable names causing errors
Using 'url' inconsistently
✗ Incorrect
We use 'site' as the key, 'url' as the value to measure length, and iterate with 'site'.