Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to assign the value 'hello' to the variable greeting.
Bash Scripting
greeting=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the value without quotes causes errors or unexpected behavior.
Using the variable name as the value instead of the string.
✗ Incorrect
In bash, to assign a string value to a variable, you enclose the string in single or double quotes. Here, 'hello' is correct.
2fill in blank
mediumComplete the code to print the value stored in the variable greeting.
Bash Scripting
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Printing the variable name without $ prints the name, not the value.
Using quotes around the variable name prints it literally.
✗ Incorrect
To print the value of a variable in bash, prefix the variable name with a dollar sign ($).
3fill in blank
hardFix the error in the code to correctly assign the value 5 to the variable count.
Bash Scripting
count=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ before a number causes bash to look for a positional parameter.
Putting numbers in quotes is allowed but unnecessary here.
✗ Incorrect
In bash, numbers can be assigned without quotes. Using $5 tries to get the fifth argument, which is incorrect here.
4fill in blank
hardFill both blanks to create a variable named name with value 'Alice' and then print it.
Bash Scripting
[1]='Alice' echo [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ when assigning a variable causes errors.
Mismatching variable name case between assignment and usage.
✗ Incorrect
Variable names are case-sensitive. Assign to 'name' without $ and print with $name to get the value.
5fill in blank
hardFill all three blanks to assign 'blue' to color, then assign color to favorite, and finally print favorite.
Bash Scripting
color=[1] favorite=[2] echo [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning variables with $ on the left side causes errors.
Forgetting $ when referencing variable values.
✗ Incorrect
Assign 'blue' with quotes to color, assign favorite to the value of color using $color, then print favorite with $favorite.