0
0
Intro to Computingfundamentals~10 mins

Data compression basics in Intro to Computing - Interactive Code Practice

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

Complete the code to assign the variable that stores the original data size.

Intro to Computing
original_size = [1]
Drag options to blanks, or click blank then click option'
Alen(data)
Bcompression_ratio
Cdecompressed_data
Dcompressed_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using the compressed data variable instead of the original data.
Confusing compression ratio with data size.
2fill in blank
medium

Complete the code to calculate the compression ratio correctly.

Intro to Computing
compression_ratio = [1] / original_size
Drag options to blanks, or click blank then click option'
Acompressed_size
Boriginal_size
Cdecompressed_size
Ddata_length
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing original size by compressed size instead of the other way.
Using decompressed size which is not defined.
3fill in blank
hard

Fix the error in the code to decompress data using the correct method.

Intro to Computing
decompressed_data = compressed_data.[1]()
Drag options to blanks, or click blank then click option'
Acompress
Bdecompress
Cencode
Ddecode
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'compress' which compresses data again.
Using 'encode' or 'decode' which are for text encoding.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its compressed length if the length is less than 5.

Intro to Computing
{word: len(word)[1] for word in words if len(word) [2] 5}
Drag options to blanks, or click blank then click option'
A**2
B>
C<
D+1
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '**' for squaring.
Using '>' instead of '<' in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps the uppercase word to its length if the length is greater than 3.

Intro to Computing
result = {{ [1]: [2] for word in words if len(word) [3] 3 }}
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase instead of uppercase for keys.
Using '<' instead of '>' in the condition.