Complete the code to get the absolute value of -7.
result = [1](-7) print(result)
The abs() function returns the absolute value of a number, which means it makes negative numbers positive.
Complete the code to round the number 3.14159 to 2 decimal places.
result = round(3.14159, [1]) print(result)
The round() function rounds a number to the specified number of decimal places. Here, 2 means two digits after the decimal point.
Fix the error in the code to correctly round the number 5.6789 without decimals.
result = round([1]) print(result)
The round() function needs a number as input, not a string or another function call inside.
Fill both blanks to create a dictionary with words as keys and their absolute length difference from 4 as values.
words = ['cat', 'house', 'dog', 'tree'] length_diff = {word: abs(len(word) [1] 4) for word in words if len(word) [2] 2} print(length_diff)
The code calculates the absolute difference between the length of each word and 4, but only for words longer than 2 characters.
Fill all three blanks to create a dictionary with uppercase words as keys, their rounded lengths as values, only if length is greater than 3.
words = ['apple', 'bat', 'carrot', 'dog'] result = { [1]: round(len(word), [2]) for word in words if len(word) [3] 3 } print(result)
word.lower() instead of uppercase keys.The dictionary keys are uppercase words, values are lengths rounded to 1 decimal (though lengths are integers), and only words longer than 3 are included.