Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to convert 8 bits into 1 byte.
Intro to Computing
byte = [1] bits Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing bits with bytes and using 4 or 16 instead of 8.
Using 1 bit as a byte.
✗ Incorrect
One byte is made up of exactly 8 bits, like 8 small pieces forming a block.
2fill in blank
mediumComplete the code to calculate how many bits are in 3 bytes.
Intro to Computing
bits = 3 [1] 8
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Dividing or subtracting which does not give correct total bits.
✗ Incorrect
Each byte has 8 bits, so multiply 3 by 8 to get total bits.
3fill in blank
hardFix the error in the code to convert bits to bytes correctly.
Intro to Computing
bytes = bits [1] 8
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Multiplying bits by 8 instead of dividing.
Adding or subtracting which does not convert correctly.
✗ Incorrect
To convert bits to bytes, divide the number of bits by 8.
4fill in blank
hardFill both blanks to create a dictionary mapping bytes to bits for 1 to 4 bytes.
Intro to Computing
bytes_to_bits = {x: x [1] 8 for x in range(1, 5) if x [2] 4} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Using wrong comparison operators like '>' instead of '<='.
✗ Incorrect
Multiply x by 8 to get bits from bytes, and include bytes less than or equal to 4.
5fill in blank
hardFill all three blanks to create a dictionary of bytes to bits for 1 to 5 bytes, only if bits are greater than 16.
Intro to Computing
bytes_to_bits = { [1]: [2] for [3] in range(1, 6) if [2] > 16 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names.
Not multiplying bytes by 8 to get bits.
Incorrect condition for filtering bits.
✗ Incorrect
Use variable 'b' for bytes, multiply by 8 for bits, and iterate with 'b' in range.