Therapies. Interpreting and writing algorithms

Slides:



Advertisements
Similar presentations
30/10/ Iteration Loops Do While (condition is true) … Loop.
Advertisements

Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Algorithms and Pseudocode
Programming revision Revision tip: Focus on the things you find difficult first.
The PiXL Club The PiXL Club The PiXL Club The PiXL Club The PiXL Club The PiXL Club The PiXL Club The PiXL Club The PiXL Club The PiXL Club The PiXL Club.
Chapter 5: Control Structure
Empirical Formula Question
KS1 Therapy: Y1 Maths Commissioned by The PiXL Club Ltd. May 2018
KS1 Priority Therapy: Y2 Maths
Lesson 2: The benefits of being involved
Topic – Rate of reaction
Topic – Periodic table and elements
Lesson 1: What is an organised act of kindness?
Do While (condition is true) … Loop
TODAY’S SESSION – Start as you mean to go on
Lesson 3: Pushing yourself to the limit for others
© Copyright The PiXL Club Ltd, 2017
Topic – Separating substances
Electrolysis Question
© Copyright The PiXL Club Ltd, 2016
© Copyright The PiXL Club Ltd, 2016
Required Practical Guide Specific Heat Capacity
© Copyright The PiXL Club Ltd, 2016
TODAY’S SESSION – Organised leadership
Required Practical Guide IR Radiation and Absorption
Required Practical Guide
Required Practical Guide
Required Practical Guide
Required Practical Guide
Required Practical Guide
© Copyright The PiXL Club Ltd, 2016
Required Practical Guide
Required Practical Guide Force, Mass & Acceleration
TODAY’S SESSION - Introducing organisation: Defining organisation
© Copyright The PiXL Club Ltd, 2016
Balancing Equations Questions
© Copyright The PiXL Club Ltd, 2016
© Copyright The PiXL Club Ltd, 2017
© Copyright The PiXL Club Ltd, 2016
Estimation Reasoning Mental Calculation
Required Practical Guide
© Copyright The PiXL Club Ltd, 2016
© Copyright The PiXL Club Ltd, 2016
Required Practical Guide
Estimation Reasoning Mental Calculation
© Copyright The PiXL Club Ltd, 2016
© Copyright The PiXL Club Ltd, 2016
© Copyright The PiXL Club Ltd, 2016
Required Practical Guide Specific Heat Capacity
Required Practical Guide
Required Practical Guide
Estimation Reasoning Mental Calculation
Required Practical Guide
GCSE Computer Science: OCR Programming Paper
Required Practical Guide
Required Practical Guide IR Radiation and Absorption
Required Practical Guide
Required Practical Guide
Estimation Reasoning Mental Calculation
Required Practical Guide Force, Mass & Acceleration
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Estimation Reasoning Mental Calculation
Presentation transcript:

Therapies. Interpreting and writing algorithms GCSE Computer Science: Programming Paper

Tips for writing Pseudocode Algorithms in an exam You will get marks for different parts of the algorithm you are writing. For example using a loop or naming variable appropriately. So even if you aren’t 100% sure of how to solve the problem, write something as you could get marks for it! Look at the amount of marks on offer. This will give you an idea about the amount of ‘things’ you need to include in the algorithm ‘Things’ could include: Initialising Variables (e.g Var <-0 , Var <- “ “) Using an appropriate iterative structure to repeat sections of code Using an appropriate selection structure to make the code ‘choose’ something Using correct comparator (e.g. <, >, =) and logic statements (e.g AND, OR, NOT). Incrementing or updating variables if necessary Appropriate Inputs Outputting something Using a data structure (array) appropriately Check your endings – If you’ve used an IF make sure there’s an END IF, a WHILE will need an END WHILE If the question doesn’t make it clear what programming constructs to use, read the question and annotate it with what you think you’ll need – you can then use this to write the algorithm and get as many marks as possible.

There is a deliberate mistake that is present here twice. username = smithda password = fLower$ usernameCheck = INPUT passwordCheck = INPUT WHILE username != usernameCheck OR password != passwordCheck OUTPUT “Incorrect Username or Password. Please re-enter: “ ENDWHILE There is a deliberate mistake that is present here twice. What is it? Username and password variables should be assigned a string value. Instead, due to the lack of “” around the words smithda and fLower$ they are being assigned the value of another variable.

The OUTPUT command on line 3 will be executed 12 times. Nested For Loops 1 FOR i = 0 to 2 2 FOR j = 0 to 3 3 OUTPUT i*j 4 NEXT 5 NEXT The OUTPUT command on line 3 will be executed 12 times. Explain why this is.

Nested For Loops – Complete the trace table i j OUTPUT 1 FOR i = 0 to 2 2 FOR j = 0 to 3 3 OUTPUT i+j 4 NEXT 5 NEXT

GCSE Paper 2 examiner’s report, OCR A single record from a database has been read into an array and contains the first name, surname, position and amount of goals scored. The array is zero based. An example of the array is shown below: playerdata=[“Mark”, “Smith”, “Striker” , “8”] What data does playerdata[2] contain? Write an algorithm that will output “top goal scorer” if the amount of goals scored is higher than 5. The algorithm should also output the position of the player (e.g striker). GCSE Paper 2 examiner’s report, OCR Re: question 1c “Where the array was accessed correctly, a common mistake was to access the wrong element, usually index 4 rather than index 3. Arrays in questions on this specification will always be zero based and this fact was also given in the question by means of an example. Candidates should be encouraged to read all parts of a question before beginning to attempt it.”

A friend is programming a shooting computer game and is currently working on a scoring system. The game has three difficulty levels and the choice of difficulty level dictates the scoring rate for the player. The player does not have lives, instead the game ends if the player shoots at but misses a target. Create pseudocode or draw a flowchart that represents this algorithm. [10] Allows the user to input one of the following difficulty levels: “Beginner”, “Intermediate” or “Expert”. If the user inputs a difficulty level of “Beginner” the user will score 2 points for each successful hit. If the user inputs a difficulty level of “Intermediate” the user will score 5 points for each successful hit. If the user inputs a difficulty level of “Expert” the user will score 10 points for each successful hit. While the player’s shots hit the target the score should increase according to the difficulty level. When the player misses, the algorithm should output the score.

Marks awarded as follows (allow any logically equivalent and correct answer). The marks are labelled A-J and are shown in the examples where they are awarded. 1 mark for assigning user input to a variable. (allow any appropriate name, “difficulty” has been used in the example) 1 mark for creating a variable that stores the score (any sensible name permitted, “score” has been used in this example) and assigning the value 0 to the variable. 1 mark for creating a variable that stores if each hit is successful (any sensible name permitted, “succ_hit” has been used in this example) and assigning a Boolean value to the variable. 1 mark for using a loop to iterate the appropriate sequence of code for every shot that is taken (an example is given but there are many logically acceptable methods). 1 mark for using selection to decide if user input is “Beginner”, “Intermediate” or “Expert” 1 mark for using selection within the loop. 1 mark for increasing the score by 2 within the correct selection block. 1 mark for increasing the score by 5 within the correct selection block. 1 mark for increasing the score by 10 within the correct selection block. 1 mark for outputting the score outside of the loop.

Example answer difficulty ←USER INPUT [A] score ← 0 [B] succ_hit ←TRUE [C] WHILE succ­­­_hit = TRUE [D] IF difficulty = “Beginner” Then [E] [F] score = score + 2 [G] ELSEIF difficulty = “intermediate” Then score = score + 5 [H] ELSE score = score + 10 [I] ENDIF ENDWHILE OUTPUT score [J]

You work for a hotel that would like to increase the amount of people staying there at the weekend. You have been asked to write a program that will highlight whether the hotel should advertise if there are still rooms available to book at the weekend. Write pseudocode or draw a flow chart that represents an algorithm that: [9] Allows the user to enter the amount of rooms that are currently not booked. Allows the user to input the text “weekday” or “weekend” and store this in a variable called Day_Type If the user enters “weekend” the program will calculate the value of these rooms by multiplying the amount of rooms not booked by 75, and if the user enters in “weekday” then it is the same but by 50. If the result of the calculation is more than £500 it will output the above calculation and the text “Advertising Recommended”.

Marks awarded as follows (allow any logically equivalent and correct answer). The marks are labelled A-I and are shown in the examples where they are awarded. 1 mark for creating a variable to store the calculated of room price and amount of rooms not booked(allow any appropriate name, “money” has been used in the example) and assigning 0 to the variable. 1 mark for assigning user input to a variable that stores the rooms not booked (any sensible name permitted, “not_booked” has been used in this example). 1 mark for assigning user input to a variable that stores the day type and the name day_type has been used. 1 mark for using selection to decide if the user input is “weekend” or “weekday”. 1 mark for calculating money correctly if the user input is “weekend” or “weekday”. 1 mark for using selection with multiple conditions (ELSE, or ELSEIF). 1 mark for using selection to decide if the calculated amount is greater than £500. 1 mark for outputting the text “Advertising Recommended” within the correct selection block. 1 mark for using selection to decide if the text “advertising recommended” should be output.

Example Answer money ← 0 [A] not_booked ← USERINPUT [B] day_type ← USERINPUT [C] IF day_type = “weekend” THEN [D] money ← not_booked * 75 [E] ELSE [F] money ← not_booked *50 [G] ENDIF IF money > 500 THEN [H] OUTPUT “Advertising Recommended” [I]

Commissioned by The PiXL Club Ltd. This resource is strictly for the use of member schools for as long as they remain members of The PiXL Club. It may not be copied, sold, or transferred to a third party or used by the school after membership ceases. Until such time it may be freely used within the member school.   All opinions and contributions are those of the authors. The contents of this resource are not connected with, or endorsed by, any other company, organisation or institution. These papers were made by teachers in good faith based upon our understanding to date. PiXL Club Ltd endeavour to trace and contact copyright owners. If there are any inadvertent omissions or errors in the acknowledgements or usage, this is unintended and PiXL will remedy these on written notification.