Dissecting Pseudocode

Pseudocode
1 / 56
volgende
Slide 1: Tekstslide
ICTSecondary Education

In deze les zitten 56 slides, met interactieve quizzen, tekstslides en 1 video.

Onderdelen in deze les

Pseudocode

Slide 1 - Tekstslide

Objective
  1. To be familiar with the data types in pseudocode.
  2. To revise the function of Sequence
  3. To write a Sequence pseudocode

Slide 2 - Tekstslide

Data Types in Pseudocode

Slide 3 - Tekstslide

String
The String data type is used for data that can be used to store a number of letters, digits and symbols.

"...."

Slide 4 - Tekstslide

String
When assigning data to a string it should be placed within quotes e.g. name = "Dave"

Slide 5 - Tekstslide

Strings
Strings are printable, Mathematical operations cannot be performed on strings even if they only contain numbers.

e.g. if you have the following code:

x = "7" 
y = "3"
OUTPUT x + y

The result that is output for the user would be "73" NOT 10. This is known as concatenation, 2 or more strings can be joined together using the + symbol.

Slide 6 - Tekstslide

Integer
An Integer can be used to store a positive whole number (No decimals numbers)

You'll see this in Exams as Int

Slide 7 - Tekstslide

REAL
The Real data type will allow you to store decimal numbers (Positive or negative) e.g. Cost = 5.50

​Real data can be used in mathematical operations

Slide 8 - Tekstslide

CHAR
The Char data type can be used to store one single character.

​e.g. Gender = "M"

Slide 9 - Tekstslide

BOOLEAN
The Boolean data type can have only two possible values, these are TRUE or FALSE.

​E.g. Accepted = true

Slide 10 - Tekstslide

Any questions on Data Types for Pseudocode?

Slide 11 - Open vraag

Sequence

Slide 12 - Tekstslide

Sequence refers to
A
code or sections of code that run line by line, in sequential order without deviation.
B
code that repeats a certain number of times.

Slide 13 - Quizvraag

Question 1
Write a SEQUENCE pseudocode to instruct a user to input their age and name.

Make sure to use OUTPUT,INPUT, and don't forget to use "..." for sentences

Slide 14 - Tekstslide

SEQUENCE Syntax Instructions in IGCSE
INPUT - prompting your user to put in text or numbers. 

"..." - Strings marks or quotation marks is to indicate the TEXT ONLY sentences in your pseudocode.

OUTPUT/PRINT - To display or show the outcome instructions.

Slide 15 - Tekstslide

Write a SEQUENCE pseudocode to instruct a user to input their age and name.

Make sure to use OUTPUT,INPUT, and don't forget to use "..." for sentences

Slide 16 - Open vraag

Objective
  1. To be familiar with the data types in pseudocode.
  2. To revise the function of Sequence
  3. To write a Sequence pseudocode

Slide 17 - Tekstslide

Objective
  1. To revise the function of Selection
  2. To write a IF pseudocode
  3. To write a CASE pseudocode

Slide 18 - Tekstslide

In programming, the term selection means
A
that the program can choose to run different commands based on a condition being true or false.
B
follows a set of instructions that with the order it is given.
C
code that repeats a certain number of times.

Slide 19 - Quizvraag

Write a pseudocode to instruct a user to input their age and name. If then person is older than 18 then your pseudocode should allow the person input their address and telephone number, else you have to let them know they are too young to drive.

Slide 20 - Open vraag

Slide 21 - Tekstslide

IF and Case - Selection

Slide 22 - Tekstslide

Slide 23 - Tekstslide

Slide 24 - Tekstslide

Slide 25 - Tekstslide

Create a CASE pseudocode that shows 3 different fruits and their pricing. Output an error message if the user did not select 3 of the options.

Slide 26 - Open vraag

Slide 27 - Tekstslide

Theory Questions

Slide 28 - Tekstslide

Explain the difference between the programming concepts of sequence and selection.

Include an example of a programming statement for each concept in your explanation (4m)

Slide 29 - Open vraag

Objectives
1.  To revise on the function of IF statement.
2. To practice on the function of CASE statement.
3. To distinguish the function between Sequence and Selection.

Slide 30 - Tekstslide

Objectives
1.  To revise on Selection.
2. To define Iteration 
3. To practise writing FOR...TO...NEXT

Slide 31 - Tekstslide

A programmer wants to test that the readings from 2000 electricity meters are greater than 400 units and less than 900 units.

Explain, using programming statements, how selection could be used n this program. (2m)

Slide 32 - Open vraag

IF... THEN... ELSE... ENDIF is one type of conditional statement used when writing pseudocode

Identify and describe another type of conditional statement that you could use when writing pseudocode. Give a reason why you would use this type of conditional statement.

(4M)

Slide 33 - Open vraag

Objectives
1. To revise on Iteration
2. To define Iteration 
3. To practise writing FOR...TO...NEXT

Slide 34 - Tekstslide

Iteration means
A
that the program can choose to run different commands based on a condition being true or false.
B
it does nothing
C
to repeat something over and over like a loop
D
follows a sequence order

Slide 35 - Quizvraag

Slide 36 - Tekstslide

Slide 37 - Tekstslide

Types of Iteration
For loop
While loop
Repeat until loop

Slide 38 - Tekstslide

For loop is used when
A
code needs to be repeated a specified number of times
B
will repeat forever while a set condition is true. also known as pre-condition loops.
C
will repeat forever UNTIL a condition becomes true. also known as a Post-condition loop.

Slide 39 - Quizvraag

Slide 40 - Tekstslide

Objective
1. Revise on Iteration
2. Practise a few iteration questions

Slide 41 - Tekstslide

Bob opens his business for 7 days. Create a For loop to calculate the total money made for the 7 days.

Slide 42 - Open vraag

WHILE LOOPS
While loops are also known as pre-condition loops. This is because a while loop will repeat forever WHILE a set condition is true. This condition is checked at the start of the loop hence the name "pre-condition".

Slide 43 - Tekstslide

While loops are particularly useful when you do not know specifically how many times you want the code to repeat.

Slide 44 - Tekstslide

Example Uses
  • A user should be able to use a program as many times as they like until they choose to quit
  • A dice game will allow the user to roll the dice until they choose to quit
  • A program should repeat forever (No way for the condition to be false)
  • Validating a user input e.g. not accepting a password if it is less than 8 characters long.

Slide 45 - Tekstslide

REPEAT UNTIL LOOPS
A REPEAT UNTIL loop is also known as a Post-condition loop. This type of loop will repeat forever UNTIL a condition becomes true.

Slide 46 - Tekstslide

REPEAT...UNTIL is one type of loop structure.

Identify and describe TWO other types of loop structure that you could use when writing pseudocode.

What are the two loop structures? Describe them.

Slide 47 - Open vraag

Objective
  1. Revise on Iteration
  2. Practice on For Loops
  3. Practice on While Loops
  4. Practive on Repeat Loops

Slide 48 - Tekstslide

Describe the purpose of each statement in this algorithm.

For X <- 1 TO 300
INPUT NAME
NEXT X

Slide 49 - Open vraag

Explanation
The instructions requires 300 loops to input Names at each round.

Slide 50 - Tekstslide

Create a loop, that Input 10 numbers and print out their total

Slide 51 - Open vraag

Slide 52 - Video

Input some numbers and calculate their total, stop when the total is greater than 20.

Slide 53 - Open vraag

An algorithm has been written in pseudocode to input 100 numbers and print out the sum. A REPEAT...UNTIL lopp has been used.

Slide 54 - Tekstslide

Find the error in the pseudocode and suggest a correction

Slide 55 - Open vraag

Rewrite the correct algorithm using a more suitable loop structure.

Slide 56 - Open vraag