0
0
Intro to Computingfundamentals~10 mins

Why networks enable communication 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 show how devices connect in a network.

Intro to Computing
devices = ['Computer', 'Phone', 'Printer']
network = [1](devices)
print(network)
Drag options to blanks, or click blank then click option'
Aset
Blist
Cdict
Dtuple
Attempts:
3 left
💡 Hint
Common Mistakes
Using a set which does not keep order.
Using a dict which needs key-value pairs.
2fill in blank
medium

Complete the code to send a message from one device to another.

Intro to Computing
def send_message(sender, receiver, message):
    print(f"{sender} sends to {receiver}: {message}")

send_message('Phone', 'Computer', [1])
Drag options to blanks, or click blank then click option'
A'Hello!'
BHello
Cmessage
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the message.
Using a variable name that is not defined.
3fill in blank
hard

Fix the error in the code that simulates devices communicating in a network.

Intro to Computing
network = {'Computer': 'Online', 'Phone': 'Offline'}
status = network.get([1])
print(status)
Drag options to blanks, or click blank then click option'
A'Phone'
B'Tablet'
CPhone
DTablet
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name without quotes.
Using a key not in the dictionary.
4fill in blank
hard

Fill both blanks to create a dictionary showing device statuses and check if a device is online.

Intro to Computing
devices_status = [1](Computer='Online', Phone='Offline')
if devices_status.get('Computer') == [2]:
    print('Computer is connected')
Drag options to blanks, or click blank then click option'
Adict
B'Online'
C'Offline'
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using list instead of dict.
Comparing to 'Offline' instead of 'Online'.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps devices to their status if they are online.

Intro to Computing
devices = ['Computer', 'Phone', 'Printer']
statuses = {'Computer': 'Online', 'Phone': 'Offline', 'Printer': 'Online'}
online_devices = { [1]: [2] for [3] in devices if statuses[[3]] == 'Online' }
Drag options to blanks, or click blank then click option'
Adevice
Bstatuses[device]
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name not defined in the loop.
Mixing up keys and values in the comprehension.