0
0
Hadoopdata~10 mins

Map phase explained in Hadoop - Interactive Code Practice

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

Complete the code to define the map function that processes input key-value pairs.

Hadoop
def map([1], value):
    # process input key and value
    pass
Drag options to blanks, or click blank then click option'
Arecord
Bkey
Cdata
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'input' or 'data' instead of 'key' as the first parameter.
2fill in blank
medium

Complete the code to emit intermediate key-value pairs from the map function.

Hadoop
def map(key, value):
    words = value.split()
    for word in words:
        [1](word, 1)
Drag options to blanks, or click blank then click option'
Aemit
Bprint
Creturn
Doutput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'print' or 'return' instead of 'emit'.
3fill in blank
hard

Fix the error in the map function to correctly split the input value into words.

Hadoop
def map(key, value):
    words = value.[1]()
    for word in words:
        emit(word, 1)
Drag options to blanks, or click blank then click option'
Areplace
Bjoin
Cstrip
Dsplit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'join' which combines strings instead of splitting.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that counts word lengths greater than 3.

Hadoop
lengths = {word: [1] for word in words if len(word) [2] 3 }
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension filtering words by length and mapping to uppercase keys.

Hadoop
result = { [1]: [2] for word in words if len(word) [3] 4 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bword
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' instead of '>' in the condition.