Session 5

16
Session 5 Teaching Computing to GCSE Level with Python Pseudocode & Flowcharts

description

Session 5. Teaching Computing to GCSE Level with Python Pseudocode & Flowcharts. In this session:. Theory (linked to programming so overlap!) Pseudocode & Flowcharts Types of errors Example examination question. Specification – Programming languages. AQA Data types - PowerPoint PPT Presentation

Transcript of Session 5

Page 1: Session 5

Session 5

Teaching Computing to GCSE Level with Python

Pseudocode & Flowcharts

Page 2: Session 5

In this session:

Theory (linked to programming so overlap!)- Pseudocode & Flowcharts- Types of errors- Example examination question

Page 3: Session 5

Specification – Programming languages

AQA Data typesData structures (1 and 2 dimensional arrays)FlowchartsStructure diagramsProceduresFunctionsParametersSyntax, run-time and logical errors

This is a summary of headings – text available as handout

OCR PseudocodeFlowchartsSelection and iterationData types1-dimensional arraysGenerations of languagesAssembly language/machine codeCompilers and interpretersSyntax, run-time and logical errors

Page 4: Session 5

Task 1: debugging a program

Handout: average function in Python

Can you find the errors?

Page 5: Session 5

Program with errors

There are 8 errors!

Page 6: Session 5

Answers!

Page 7: Session 5

Pseudocode

• Many exam questions involve working with pseudocode – for example, working through an algorithm written in pseudocode

• Being able to translate from pseudocode to a real language and back is a key skill

• AQA have guidelines for the specification of pseudocode

• http://filestore.aqa.org.uk/subjects/AQA-GCSE-COMPSCI-W-TRB-PSEU.PDF

Page 8: Session 5

Task 2

output “How many numbers do you want to average”)howManyNums UserInputrunningTotal 0FOR count 1 to HowManyNums Output “Enter the next number” nextNumber UserInput runningTotal runningTotal + nextNumber endFORAverage runningTotal/howManyNumsoutput “The average of these”output HowManyNumsoutput “is “output Average

Convert the average program to pseudocode

Answer (following AQA handout):

Page 9: Session 5

Task 3: AQA Question(convert to pseudocode)

Page 10: Session 5

Task 3 Answer

Page 11: Session 5

FlowchartsSymbols for

- A process(e.g. calculation)

– Input or output(e.g. user input)

– Terminator(start/finish)

–Decision(condition of if statement or loop)

Page 12: Session 5

Task 4

Convert average program to a flowchart

Page 13: Session 5

Task 4: Answer (one of many possible?!)

Start

Finish

Input nextNum

Input howManyNums

Set count,runningTotal to 0

Add nextNum to runningTotalIncrement count Calculate average

Is count =howmanyNums YES

NO

Page 14: Session 5

Task 5: convert to flowchart

Page 15: Session 5

Task 5 Answer

Page 16: Session 5

Summary

• Pseudocode and flowcharts enable us to represent/explain/design a program in a language-independent way

• They allow students to focus on the logic and the program control

• Students will need lots of practice with these – so start early!

Summary