Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to extract the first field from a file using cut.
Bash Scripting
cut -d',' -f[1] data.csv
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as field number (fields start at 1).
Using wrong delimiter.
✗ Incorrect
The -f option specifies which field to extract. Here, 1 extracts the first field.
2fill in blank
mediumComplete the code to paste two files side by side separated by a comma.
Bash Scripting
paste -d[1] file1.txt file2.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using colon or pipe instead of comma.
Forgetting the -d option.
✗ Incorrect
The -d option sets the delimiter between pasted columns. A comma is used here.
3fill in blank
hardFix the error in the command to extract the second field separated by colon.
Bash Scripting
cut -d[1] -f2 /etc/passwd Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma or semicolon as delimiter.
Omitting the -d option.
✗ Incorrect
The fields in /etc/passwd are separated by colons, so -d: is correct.
4fill in blank
hardFill both blanks to create a dictionary of word lengths for words longer than 3 characters.
Bash Scripting
lengths = {word: [1] for word in words if len(word) [2] 3} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) for length.
Using < instead of > for filtering.
✗ Incorrect
We want the length of each word, so len(word). We filter words longer than 3, so > 3.
5fill in blank
hardFill all three blanks to create a dictionary with uppercase keys and values greater than zero.
Bash Scripting
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using k instead of k.upper() for keys.
Using < instead of > for filtering values.
✗ Incorrect
Keys are converted to uppercase with k.upper(), values are v, and we filter values > 0.