Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a simple function named greet.
Blockchain / Solidity
function [1]() { return "Hello!"; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name than 'greet'.
Forgetting to write the function name after 'function'.
✗ Incorrect
The function name must be
greet as specified.2fill in blank
mediumComplete the code to declare a function named add that takes two parameters a and b.
Blockchain / Solidity
function add([1], b) { return a + b; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different parameter name than 'a'.
Mismatching parameter names with the function body.
✗ Incorrect
The first parameter must be named
a to match the function signature.3fill in blank
hardFix the error in the function declaration by completing the missing keyword.
Blockchain / Solidity
[1] add(a, b) { return a + b; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'func' or 'def' instead of 'function'.
Omitting the function declaration keyword.
✗ Incorrect
In blockchain smart contract languages like Solidity, the keyword
function declares a function.4fill in blank
hardFill both blanks to declare a public function named multiply that returns the product of two numbers.
Blockchain / Solidity
function [1](uint a, uint b) public returns (uint) { return a [2] b; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '*' for multiplication.
Using a wrong function name that does not match the operation.
✗ Incorrect
The function name is 'multiply' and the operator for multiplication is '*'.
5fill in blank
hardFill all three blanks to declare a private function named subtract that takes two uint parameters and returns their difference.
Blockchain / Solidity
function [1](uint [2], uint [3]) private returns (uint) { return a - b; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names that do not match the function body.
Using a wrong function name like 'add' instead of 'subtract'.
✗ Incorrect
The function name is 'subtract', and the parameters are 'a' and 'b' to match the return statement.