Professional Documents
Culture Documents
Loops that iterate while or until a specific condition is met. It does not run for a set number of times.
1. WHILE - DO Loop (The condition is checked at the start, invalid data cannot execute in the loop)
2. REPEAT - UNTIL Loop (The condition is checked at the end, all data gets atleast a single chance to execute
in the loop)
WHILE DO LOOP
SET X TO 1
WHILE X <= 5 DO
SEND “Enter a number less than or equal to 5 to continue” TO DISPLAY
RECEIVE X FROM (INTEGER)KEYBOARD
ENDWHILE
REPEAT UNTIL LOOP (Python doesn’t allow to construct this type of loop)
SET X TO 1
REPEAT
SEND “Enter a number less than or equal to 5 to continue” TO DISPLAY
RECEIVE X FROM (INTEGER)KEYBOARD
UNTIL X > 5
( The above loops stop when the value input for X is more than 5)
Q)Write a pseudocode to enter some words and the program stops when “end” is entered.
(NOT EQUAL in pseudo code is < >)
SET Word TO “ “
Random Numbers
It is a function which allows to handle some random events, such as to guess a number from a set of
numbers which are generated automatically, flip a coin, roll a dice, etc..
Most high level programming languages have an inbuilt function to perform this, which is called the
Random Number Generator.
Python Code
2. Use meaningful / descriptive names for identifiers(variables, constants, arrays, sub programs) which
helps to know the purpose of the usage of identifiers used in the program.
3. Use of indentation to make it easier to spot where the loops and conditions begin and end.
4. Leave some white spacez or blank lines to separate the different blocks or parts of the code to recognise
easily.
Example:
// Initialise Num
SET TO 0