Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE
Responsive image

Funky Functions

What am I Learning today?

I am learning how to use python turtle to create repetitions (loops) in programming for creating patterns.
I am learning how to use python turtle to create simple functions that serve a single purpose.

Knowledge Organiser

×

Lesson

Task 1 - Getting Started Click to see more

You are going to screenshot all of your work into a Powerpoint file.

To download the PowerPoint by clicking on the image below

To save your powerpoint go to: File explorer -> Year 9 Common Area:S -> You can save here -> Computer Science -> Term 1 -> Lesson2

Save the Powerpoint file: as your name


  • Complete Task 1 in your Powerpoint


  • Task 2 - Simple loop Click to see more

    Open Thonny

    • Open Thonny create a new file called lesson3 and save it into your computer Science folder.

    Task

    • Copy the code below into your coding window then change it so that it draws a red square rather than a black triangle, then run it.



  • Screenshot your python code and output into your Powerpoint


  • Task 3 - Fun-Key Functions Click to see more

    Func-y Town:

    When developer write code, sometimes their programs need to repeat the same chunks of code over and over again. Programming languages help developers with this by allowing the use of Functions.

    "A Function is a piece of code which performs a task, and can return a value".

    • Let's look at an example.
    • I'd like to draw this pattern…

    pattern1.png

    • In order to do this, I need to start by drawing a square…

    pattern1a.png

    • Then rotating the turtle 45 degrees

    pattern1b.png

    • draw another square…

    pattern1c.png

    • Turn another 45 degrees

    pattern1d.png

    • and again…

    pattern1e.png

    • And so on. If you think about it, what I'm essentially doing is saying
    Repeat the following 8 times:
        DRAW A SQUARE
        ROTATE THE TURTLE 45 degrees
    
    • We can teach the computer how to draw squares (or anything else for that matter) by writing a function which contains the steps needed to perform that task.
    • We're going to start by creating a function called drawsquare().
    Lets try the following tasks:

    Tick each task when you have successfully done it in the following list:

    Complete the following tasks

    Turn your square code into a function called drawSquare
    Call your drawsquare() function in your code
    Turn your turtle 45 degrees
    Repeat this process 8 times.


  • Screenshot your python code and output into your Powerpoint


  • Task 4 - Loopy patterns Click to see more

    Lets go:

    # This is a function called drawsquare
    def drawsquare(): 
        for myMoves in range(4):
            tim.forward(100)
            tim.left(360/4)
    
    • The def drawsquare(): above and the 3 lines that come after it are where we have declared (created) our function. We've said to Python that any time in the future when we write drawsquare(), we want a square drawing.

    Making funky patterns

    pattern1.png

    Lets try the following tasks:

    Tick each task when you have successfully done it in the following list:

    Complete the following tasks

    Change the 8 in the line: for myMoves in range(8) to something else.
    Change the 45 in tim.left(45) to something else.
    What other patterns can you create?


    Extension task:

    Tick each extension task when you have completed it in the following list:


    Can you modify your code to draw the shape below?

    pattern1.png


  • Screenshot your python code and output into your Powerpoint


  • Task 5 - Creating your own function Click to see more

    Triangle time:

    Lets try the following tasks:

    Tick each task when you have successfully done it in the following list:

    Complete the following tasks

    Create a new function in your code called def drawtriangle(): use it to create the shape below.


    pattern1.png


  • Screenshot your python code and output into your Powerpoint


  • Task 6 - Extension task Click to see more

    Extension task:

    Tick each extension task when you have completed it in the following list:


    Modify your code to create the shape below?
    Create 20 squares?

    pattern1.png


  • Screenshot your python code and output into your Powerpoint


  • Task 7 - drawShape extension task Click to see more

    Multi-purpose function

    Extension task:

    Tick each extension task when you have completed it in the following list:


    Create a new function called drawShape()
    Get the user to enter the number of sides for their shape
    hint you will need to use a parameter (look it up)


  • Screenshot your python code and output into your Powerpoint



  • Task 8 - Lesson review Click to see more

    Summing it all up

    Lets look at the learning outcomes and decide which one best describes our current level of understanding :

    Tick the one you feel is closest to your level

    Learning Outcomes I need to learn how to use python turtle to create simple functions that serve a single purpose.

    • I have a basic understanding of how I can use python turtle to create simple functions that serve a single purpose. with a little help from my teacher
    • I can show my teacher that I can use python turtle to create simple functions that serve a single purpose. without their help.
    • I can use python turtle to create simple functions that serve a single purpose. independently and I can also explain it to others and can complete any extension tasks I am given.

    🠜 Now update your learning objectivesClick on the Assessment image

    My Notes: Coding_Turtle

    Student_Comment_1 not found

    Task Notes/Comments - Add here Click to see more

    Comments/Notes

    Copyright © 2013 - 2025 LearnITwithMrC