How Long Will It Take?
Beginner · Write the code · from How the Internet Works: Networks, Packets and Protocols
From the lesson: What is bandwidth?
The bandwidth of a network is the maximum amount of data that can be sent in a fixed amount of time. It is usually measured in bits per second, most often in megabits per second (Mbps, millions of bits per second). Bandwidth works like the number of lanes on a highway: more lanes let more cars through each minute.
Read this part of the lessonWrite transfer_seconds(megabytes, mbps). It returns the least time, in seconds, to send a file of megabytes megabytes over a connection with a bandwidth of mbps megabits per second, rounded to 1 decimal place.
transfer_seconds(100, 50) -> 16.0 (100 MB is 800 megabits, and 800 / 50 = 16)def transfer_seconds(megabytes, mbps):
# Turn bytes into bits first
pass
What Check runs
Your code runs first, then each of these lines, and 1 more that stay hidden. The output must match exactly.
| Runs | Expected output |
|---|---|
| print(transfer_seconds(100, 50)) | 16.0 |
| print(transfer_seconds(25, 200)) | 1.0 |
| print(transfer_seconds(4000, 100)) | 320.0 |
More Networking exercises
- Is It a Path?Intermediate
- Reassemble a MessageIntermediate