Learn IT Compute IT Coding with Edu Blocks

Learn IT Compute IT Coding with Edu. Blocks Transition from Scratch to Python

About Me • Marty Edwards • Runs Learn IT Compute IT Ltd • GCSE and A-level Computer Science teacher • Ex IT-professional as a designer and programmer • Raspberry Pi Certified Educator • Run CPD, workshops and Coding and Maker Clubs • STEM events • Email: marty. Edwards@learnitcomputeit. com

So…what is Edu. Blocks? • Edublocks language is based on Google’s “Blockly” language. • It allows us to effectively bridge the gap between a graphical coding language and a text based coding language.

Educ. Blocks and Raspberry Pi • Built for the Raspberry Pi! • Edu. Blocks for Raspberry Pi is the original edition of the program. • Allows you to drag and drop blocks of python code using its friendly environment • Build simple and complex projects with the GPIO pins, Minecraft and much more!

Install Edu. Blocks How do I Install Edu. Blocks on my Raspberry Pi running Raspbian? 1. Make sure your Raspberry Pi is setup and connected to the internet. 2. Open up a Terminal window, this can be done by clicking on this icon in the top left hand corner of the Pi's screen. 3. Type this command to intall Edu. Blocks o curl -s. SL get. edublocks. org | bash

Edu. Blocks Block programming Edu. Blocks Swap between languages Write Python code Another Block based language to help pupils become programmers but this one has a difference

Edu. Blocks Libraries Basic Python Minecraft GPIOZero Edu. Blocks Pi features a range of Basic Python functions to get you started with how the basics of Python work. Edu. Blocks includes the Python library that allows you to hack Minecraft! GPIOZero is the most common library for controlling the Pi's GPIO pins e. g to spin motors Sonic Pi Pimoroni Addons Advanced and Sense Hat Sonic Piallows you to make music with code. The unoffical Python library for Sonic Pi is included in Edu. Blocks includes the official libraries to control the BLINKT! LED stip and the Explorer hat Edu. Blocks allows further investigation of programming including Internet and the Sense Hat libraries

Open Edu. Blocks • You will either find an icon on the desktop • OR • Raspberry Pi -> Programming -> Edu. Blocks • It can take a little while to open

Let’s compare Before going any further, lets use some of the main Python commands in Edu. Blocks Using the Basic library you can create programs By clicking on the Blockly button you can see the Python code this has produced.






Other Examples

Average values The program asks the user to enter a number between 1 and 20. If -1 entered the program stops asking and calculates the average total. It then creates suitable outputs formatted to be informative

Average Value Program

More Complex Coding Ideas This script is an interactive guessing game, which will ask the user to guess a number between 1 and 99. We are using the random module with the randint function to get a random number. The script also contains a while loop, which make the script run until the user guess the right number.

Running the Program


Using Functions

Running the Program

Functions Extension

Creating Minecraft Code 1. Click on Minecraft and then General 2. Select the commands highlighted by a RED box 3. Add them to your programming panel 4. Select basic and scroll down to find import time 5. Select the import time command highlighted by a GREEN box

Programming Setup 1. From the Basic section find time. sleep(1) 2. Add this to your program. 3. Change the value in the brackets to be 2. 4. Your program should no look like this This will be the first 4 lines for all of our programs for Minecraft

Let’s say hello From Minecraft Commands add the mc. post. To. Chat() command to the previous four lines Add a message inside the brackets e. g.

Posting Coordinates Add the next lines to our code These will get the player coordinates and print them The last line also prints the coordinates in a message on Minecraft. Here we need to use string manipulation from Python

Introduce the For Loop This code uses a FOR loop. This type of loop runs for a fixed number of times. Here we can see the SYNTAX of the Python FOR loop In our FOR loop we add 1 to the y coordinate so that each time we go around the loop y gets bigger. We then place a block at the new x, y, z coordinate and then repeat the steps.
- Slides: 28