Learning Outcomes

Learning intention: how to use sequence to create algorithms.

  1. To convert an algorithm to a program.
  2. To understand how to set up in Repl.
  3. To use decomposition to test and trial the program when inputting.
  4. To debug any errors and modify/improve programs.


Online learning: Setting up Replit

Edit Go to https://replit.com.

Edit Log in, or Sign up

Edit

Already have a Repl account? Click Log in.

Need to create one? Click Sign up.

Edit

Edit Go to https://replit.com/@ByteEdPython/ByteEdNavigatingNZ?v=1.

Edit Press the Fork button: Edit

Edit Press the Run button:

Edit

If you see this, you’re all set!

Edit




Familiarising with Replit

Once the project is forked, you get your own copy of the project as follows:

Edit

Press the Edit button!

Edit

As shown in the picture above, it is important you do not modify any of the code inside the Edit sections.




Try this out!

Below is the embedded project – but you will need to sign in, and fork it (see instructions above) to work on your own copy.

You should at least be able to run the example:




Testing the code!

We are now ready to write a little bit of code, and see what happens!

In the section outlined below, type in the code shown.

Edit

Once you’ve done that, press the Edit button to check if you see any land!




Edit Guess the letter!

Consider this code:

Edit

What letter do you think it prints? Fill out the printed grid to figure it out.




Unsure how that works? View the hint below:




Want an extra challenge? Write the code to draw the following letters:






Programming Land

Edit

It’s time to build your land by converting the algorithm into a program!

Now that we know where and how to type our Python code, we can plot our actual land!

We will need to transfer the algorithm (our blocks) into a Python program.

Here’s examples of the algorithm blocks, and their equivalent Python code:

Edit


Use decomposition and iterative testing:

Edit

During your programming, try to check and test your program regularly.

This will help you to find any errors (bugs), and debug them quickly.

Edit Find the bugs! Edit

Consider the following (correct) code snippet:

Edit

In this part of programming, there are a number of common errors (bugs) that you may find.

Can you guess what the errors are in each of the following cases?


Bug #1:  




Bug #2:  




Bug #3:  




Bug #4:  




Bug #5:  




Bug #6:  




Bug #7:  




Bug #8:  




Bug #9:  






Peer Testing & Feedback (Round 1)

Edit

  1. Complete the program - check it matches the algorithm.
  2. Ask a friend to check your program, while you check theirs:
    • Does it add all of the land blocks needed when the program is run?
    • Are there any errors (bugs)?
    • Can you find where the errors are, and debug them?
    • Do you need to make any changes based on the feedback?




Programming the Origin and Destination

Once you have built the land, you need to:

Add the starting point (origin) for ByteEd’s travels:

Edit

Then add the end point (destination) for ByteEd’s travels:

Edit

You should then see your origin and destination placed in your Repl output when you run your program.

For the example above, we get the following:

Edit


Peer Testing & Feedback (Round 2)

Edit

Similar to the previous round of peer testing, but now focus on the origin and destination.

  1. Complete the program - check it matches the algorithm.
  2. Ask a friend to check your program, while you check theirs. Try to ask someone new this time - it’s better to get feedback from different people:
    • Does it add all of the land blocks needed when the program is run?
    • Are there any errors (bugs)?
    • Can you find where the errors are, and debug them?
    • Do you need to make any changes based on the feedback?
    • Is the origin set correctly?
    • is the destination set correctly?