16: Procedures in python

Debug it

Reuse sections of your code
Procedures in python: Reuse sections of your code

Below is some code that has been deliberately broken so that you can fix it. 

The code is supposed to draw 10 triangles in random positions

Challenges

  1. Fix the syntax error

    Hint: A syntax error means the code has broken the rules of the language. Work upwards from the line number in the error message to see what’s wrong or what’s missing.

  2. Define the missing constant to draw 10 shapes

    Hint: the constant is used on line 20 so it needs to be defined before that line

  3. Call random_position properly so the triangles appear in random positions

    Hint: To call a procedure you need brackets after the procedure name

On the next page you’ll get some ideas for projects where you can use procedures in your own projects

2 thoughts on “16: Procedures in python

  • November 22, 2020 at 4:47 pm
    Permalink

    Hi there,

    Absolutely love your resources on programming and started using them today. Just wondering if there are solutions for the de-bugs on the programs here that pupils are supposed to de-bug. It will help me a lot so I can compare their answers with it.

    Reply
    • November 24, 2020 at 11:40 am
      Permalink

      Hello,
      Thanks so much for your message. I haven’t written up the answers yet – I’m trying go get through the full set of 20 activities then the next job will be to publish a student workbook and set of answers. Sorry not to help yet. Hope you’re well

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *