Blockly Coding Tasks
Recommended Practice:
It is not necessary to understand how to create functions to answer these tasks. Your code needs to form a mini-program inside the function block provided. However, there are a few things that you do need to know:
- When a program is executed, functions are ignored until called by the Execute block.
- These functions need to be passed input values which are given identifier names. You will find these input variable blocks in the Variable blocks menu.
- In these sort of tasks, the functions return a value which is an output. This is used by the marking program.
- Your program needs to produce the correct answer for a variety of input values as well as any test data provided.
e.g.
The Execute Block
The Execute block is made especially for these challenges and performs these tasks:
- When the Run button is pressed, Execute acts like a Print block
- When the task is part of a challenge that is in Review mode and the Run button is pressed, Execute gives output in the same way as the Print block and also activates the grader.
- When the task is part of a llive challenge and the Run button is pressed, Execute gives output in the same way as the Print block and also stores the user's answer for later grading.
The grader works by trying input/output pairs to work out whether to mark the tasks as correct or incorrect. The test data, given in the task, forms one such input/output pair but there are also hidden input/output pairs entered into the system by the task author. To be marked as correct, a solution has to have all input/output pairs evaluate correctly. In other words your function has to work as asked for, not just work with the test data.
Coding tasks - Intro
Recommended practice
Functions, Procedures and Subroutines
Example 1
Example 2
Example 3
Example 4
Did you know the UK Bebras Challenge is run by the Raspberry Pi Foundation? Discover free teaching resources, tools, and expert support for computing education at raspberrypi.org.