Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to assign the value 10 to the variable x.
MATLAB
x = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number 10 inside quotes, which makes it a string.
Using a variable name instead of a value.
✗ Incorrect
In MATLAB, to assign a numeric value to a variable, just write the number without quotes.
2fill in blank
mediumComplete the code to assign the string 'hello' to the variable greeting.
MATLAB
greeting = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes instead of single quotes for strings.
Not using quotes at all.
✗ Incorrect
In MATLAB, strings are enclosed in single quotes.
3fill in blank
hardFix the error in the code to assign the value 5 to variable num.
MATLAB
num = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the semicolon at the end of the statement.
Putting the number inside quotes.
✗ Incorrect
In MATLAB, each statement must end with a semicolon to suppress output.
4fill in blank
hardFill both blanks to create a variable 'result' that stores the sum of 3 and 7.
MATLAB
result = [1] [2] 7;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
Swapping the order of numbers and operators.
✗ Incorrect
To add 3 and 7, use the plus sign (+) between them.
5fill in blank
hardFill all three blanks to create a variable 'area' that stores the product of length and width.
MATLAB
area = [1] [2] [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Mixing up variable names.
✗ Incorrect
To calculate area, multiply length by width using the * operator.