0
0
Data Analysis Pythondata~10 mins

Why advanced operations handle complex data in Data Analysis Python - Test Your Understanding

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

Complete the code to create a list of squares for numbers 1 to 5.

Data Analysis Python
squares = [x[1]2 for x in range(1, 6)]
print(squares)
Drag options to blanks, or click blank then click option'
A//
B+
C**
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '**' will add numbers instead of squaring.
Using '*' will multiply but not square correctly in this context.
2fill in blank
medium

Complete the code to filter numbers greater than 3 from the list.

Data Analysis Python
numbers = [1, 2, 3, 4, 5]
greater_than_three = [n for n in numbers if n [1] 3]
print(greater_than_three)
Drag options to blanks, or click blank then click option'
A<
B>
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' will filter numbers less than 3, which is incorrect here.
Using '==' will only select numbers equal to 3.
3fill in blank
hard

Fix the error in the code to calculate the average of a list of numbers.

Data Analysis Python
data = [10, 20, 30, 40]
average = sum(data) [1] len(data)
print(average)
Drag options to blanks, or click blank then click option'
A/
B-
C+
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' will not calculate average correctly.
Using '*' multiplies instead of dividing.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 letters.

Data Analysis Python
words = ['apple', 'bat', 'carrot', 'dog']
lengths = {word: [1] for word in words if len(word) [2] 3}
print(lengths)
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) will store the word itself, not its length.
Using '<=' will select words with length 3 or less, which is incorrect.
5fill in blank
hard

Fill both blanks to create a dictionary with uppercase keys and values greater than 10.

Data Analysis Python
data = {'a': 5, 'b': 15, 'c': 25}
result = {k[1]: v for k, v in data.items() if v [2] 10}
print(result)
Drag options to blanks, or click blank then click option'
A{
Bv
C>
Dk.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Not starting with '{' will cause syntax errors.
Using 'k' instead of 'k.upper()' keeps keys lowercase.
Using '<' or '<=' will filter wrong values.