Complete the code to create a simple function that compresses text by removing vowels.
def compress_text(text): vowels = 'aeiouAEIOU' return ''.join(char for char in text if [1])
The function removes vowels by keeping only characters not in the vowels string.
Complete the code to calculate the compression ratio of original and compressed text lengths.
def compression_ratio(original, compressed): return len(compressed) / [1]
The compression ratio is the length of compressed text divided by the length of original text.
Fix the error in the function that compresses text by replacing spaces with underscores.
def compress_spaces(text): return text.replace(' ', [1])
Replacing spaces with underscores uses '_' as the replacement string.
Fill both blanks to create a dictionary comprehension that maps words to their compressed forms by removing vowels.
compressed_dict = {word: ''.join(char for char in word if [1]) for word in words if [2]The comprehension removes vowels from words longer than 3 characters.
Fill all three blanks to create a function that compresses text by removing vowels, replacing spaces with underscores, and calculating compression ratio.
def full_compress(text): no_vowels = ''.join(char for char in text if [1]) replaced = no_vowels.replace(' ', [2]) ratio = len(replaced) / [3] return replaced, ratio
The function removes vowels, replaces spaces with underscores, and calculates compression ratio by dividing compressed length by original length.