Search Header Logo
[IGCS] Pseudocode

[IGCS] Pseudocode

Assessment

Presentation

Computers

9th - 10th Grade

Practice Problem

Hard

Created by

Andy tsui

Used 20+ times

FREE Resource

15 Slides • 10 Questions

1

[IGCS] Pseudocode - 1

Variable, If, Conditional Loop

Slide image

2

Pseudocode

helps us to express computer algorithms

3

Fill in the Blank

What is the name of the graphical method for expressing algorithm?

4

Pseudocode is...

  • Not a programming language

  • The syntax (rules of the language) is loosely defined

  • Python is very much similar to Pseudocode

5

Comments

# Same as Python, comment starts with a hashtag

# Which means that these statements are ignored by computer

# Very useful to help people read your code

6

Variables

# The following statment assigns 1 to a variable called variable_name

variable_name ← 1


# When you write, you write ←, but sometimes I will type <- to represent the same thing

7

Fill in the Blank

What is the name for ?

8

Open Ended

Describe what is this program doing:

INPUT name

INPUT age

PRINT "Hello", name, "you will be", age + 10, "years old in 10 years"

9

Logical Operator

# A = 5 means that to evaluate if A equals to 5

# And the result is a boolean type - i.e. either True or False, so:

A = 1

C <- A < 5

# C will be False

10

= or == or ← ?

In Math, if we write a=b means that a equals to b

Pseudocode is the same as math


In Python and many other languages (e.g. Java, C), we use = to represent assignment, so to represent logical test, we have to use ==, i.e. the above statement became a==b

11

Multiple Choice

In Pseudocode, what is the meaning of :

A = 5

1

Assign 5 to A

2

Test if A equals to 5

3

A equals to 5

4

None of the rest

12

Fill in the Blank

What will be the value of C:

A <- 10

C <- A = 5

13

IF-THEN-ELSE

# Pseudocode conditional statement:

IF score > 50 THEN

⠀PRINT "Pass"

ELSE

⠀PRINT "Fail"

ENDIF

14

Fill in the Blank

What will be printed on screen:

A <- 10

IF A=5 THEN

⠀PRINT "Good"

ELSE

⠀PRINT "Not good"

15

Multiple Select

In Pseudocode, which of the following statements check if variable X is not zero?

1

IF x <- 0 THEN

2

IF x 0 THEN

3

IF x <> 0 THEN

4

IF not x=0 THEN

5

IF x != 0 THEN

16

Chaining IFs

IF score > 90 THEN

⠀PRINT "A+"

ELSE IF score > 80 THEN

⠀PRINT "A"

ELSE IF score > 70 THEN

⠀PRINT "B"

ELSE

⠀PRINT"C"

ENDIF

17

Conditional Loops

  • There are two types of conditional loops in Pseudocode

  • Pre-condition

  • Post-condition

18

Pre-condition loop

# Pre condition means that the exit condition appears at the start of loop

19

Fill in the Blank

In Python, what is the name of the pre-condition loop?

20

Pre condition loop in pseudocode

WHILE count < 10 DO

⠀count <- count + 1

ENDWHILE

21

Post condition loop

# There's no post condition loop in Python, but Pseudocode or languages like Java they have:


REPEAT

⠀count <- count + 1

UNTIL count > 10


# We sometimes called them REPEAT-UNTIL loop

22

Open Ended

Describe what is the following code doing:

REPEAT

⠀INPUT age

UNTIL age>0

23

Open Ended

Rewrite the following code using a while loop:

REPEAT

⠀INPUT weight

UNTIL weight > 10

24

Common validation pattern

Previous slide is common pattern for validation - Homework

25

Summary

Pseudocode is another way to express algorithm

We learnt about variables, condition and conditional loops in Pseudocode

[IGCS] Pseudocode - 1

Variable, If, Conditional Loop

Slide image

Show answer

Auto Play

Slide 1 / 25

SLIDE