Session 5
description
Transcript of Session 5
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 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
Task 1: debugging a program
Handout: average function in Python
Can you find the errors?
Program with errors
There are 8 errors!
Answers!
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
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):
Task 3: AQA Question(convert to pseudocode)
Task 3 Answer
FlowchartsSymbols for
- A process(e.g. calculation)
– Input or output(e.g. user input)
– Terminator(start/finish)
–Decision(condition of if statement or loop)
Task 4
Convert average program to a flowchart
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
Task 5: convert to flowchart
Task 5 Answer
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