7
© Boardworks Ltd 2013 1 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable) Useful web links in the Notes Page Icons: Worksheet or support sheet available Unit 7 Systems and Control 7.3 Procedures

© Boardworks Ltd 20131 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable)Useful web links in the Notes Page Icons: Worksheet

Embed Size (px)

Citation preview

Page 1: © Boardworks Ltd 20131 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable)Useful web links in the Notes Page Icons: Worksheet

© Boardworks Ltd 20131 of 7

Teacher’s notes in the Notes Page

Flash activity (these are not editable) Useful web links in the Notes PageIcons:

Worksheet or support sheet available

Unit 7 Systems and Control

7.3 Procedures

Page 2: © Boardworks Ltd 20131 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable)Useful web links in the Notes Page Icons: Worksheet

© Boardworks Ltd 20132 of 7

Curriculum links

This presentation supports the following areas of knowledge in the Naace Curriculum Framework for KS3 ICT:

This presentation supports the following sectionsof the Programme of Study for KS3 Computing:

design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems

use two or more programming languages, at least one of which is textual, to solve a variety of computational problems; make appropriate use of data structures such as lists, tables or arrays; design and develop modular programs that use procedures or functions

Skills – Problem solving

Technical Understanding – Programming and control

Page 3: © Boardworks Ltd 20131 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable)Useful web links in the Notes Page Icons: Worksheet

© Boardworks Ltd 20133 of 7

what procedures are and why they are used

how procedures can be used to simplify programming

how procedures are written in text based programming languages.

By the end of this presentation we will have learned:

Learning objectives

Page 4: © Boardworks Ltd 20131 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable)Useful web links in the Notes Page Icons: Worksheet

© Boardworks Ltd 20134 of 7

Log flume flow chart

Start

Is it safe to start the

next ride?

Wait for rider to break second

light beam

Raise barrier

Has first light beam

been broken?

Wait

Spray

PhotoStop

Your flow chart for the log flume might look a bit like this:

What instructions could these procedures include?

No

Yes

No

Yes

Page 5: © Boardworks Ltd 20131 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable)Useful web links in the Notes Page Icons: Worksheet

© Boardworks Ltd 20135 of 7

Procedures in programming

Procedures can also be used in text based programming languages. The syntax needed to create a procedure varies depending on the language that you are using, but the concepts are the same.

First you state that you are writing a procedure and give it a name.

Then you type in the code required to run that procedure.

Finally you end the procedure so that the computer knows to move on to the next line of code.

Page 6: © Boardworks Ltd 20131 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable)Useful web links in the Notes Page Icons: Worksheet

© Boardworks Ltd 20136 of 7

Creating a procedure in Python

In Python®, we state that we are creating a procedure using the command ‘def’. This is short for ‘define’.

We may want a procedure that runs a welcome statement to the user every time they log in. It may look like this:

def welcome(): print “Welcome to Hangman” print “------------------” print “Enjoy the game!” print “---------------”

welcome()

Page 7: © Boardworks Ltd 20131 of 7 Teacher’s notes in the Notes Page Flash activity (these are not editable)Useful web links in the Notes Page Icons: Worksheet

© Boardworks Ltd 20137 of 7

def welcome():

print “Welcome to

Hangman”

print

“------------------”

print “Enjoy the game!”

print “---------------”

welcome()

Explaining a procedure in Python

This tells the computer you are writing a procedure.

This is the name of the procedure.

This is what the procedure should do.

This is written wherever you want the procedure to run.

White space is used to end the procedure.