0
0
Intro to Computingfundamentals~10 mins

Why understanding the web empowers users in Intro to Computing - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print the main part of a web address.

Intro to Computing
url = 'https://www.example.com'
main_part = url.split('[1]')[1]
print(main_part)
Drag options to blanks, or click blank then click option'
A://
B//
C.com
Dwww
Attempts:
3 left
💡 Hint
Common Mistakes
Using '//' instead of '://' causes wrong splitting.
2fill in blank
medium

Complete the code to check if a web address starts with 'https'.

Intro to Computing
url = 'https://secure.site'
if url.[1]('https'):
    print('Secure connection')
Drag options to blanks, or click blank then click option'
Acontains
Bendswith
Cstartswith
Dfind
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'contains' or 'find' does not check the start specifically.
3fill in blank
hard

Fix the error in the code that extracts the domain name from a URL.

Intro to Computing
url = 'http://openai.com'
domain = url.split('[1]')[1]
print(domain)
Drag options to blanks, or click blank then click option'
A://
Bhttp://
Cwww.
D.com
Attempts:
3 left
💡 Hint
Common Mistakes
Splitting by 'http://' causes the first part to be empty.
4fill in blank
hard

Complete the code to create a dictionary of web pages and their status codes.

Intro to Computing
pages = ['home', 'about', 'contact']
status_codes = {page: 200 for page in pages if page [1] 'home'}
Drag options to blanks, or click blank then click option'
A:
B==
C!=
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of ':' in dictionary comprehension.
Using '==' instead of '!=' in the condition.
5fill in blank
hard

Fill all three blanks to filter and transform a list of URLs.

Intro to Computing
urls = ['http://site1.com', 'https://site2.com', 'ftp://site3.com']
secure_sites = [url[1] for url in urls if url.[2]('https') and url.[3]('.com')]
Drag options to blanks, or click blank then click option'
A[8:]
Bstartswith
Cendswith
D[7:]
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong slice index.
Using 'contains' instead of 'startswith' or 'endswith'.