Programming - The Basics Flashcards
What is iteration?
Where a block of code repeats
How might iteration be presented in the exam?
Do…Until
While…
For…
What does the term ‘nested’ mean?
A block of code within another block of code.
How could you write a for loop in the exam?
for loop in range (x):
print (“output”)
Follow the process identified in the abstraction phase - where you kept the important information”.
How could you write a while loop in the exam?
count = 0
while count < x:
print(“count”)
count+=1
Follow the process identified in the abstraction phase - where you kept the important information
How might iteration appear on the exam paper using Do…Until?
x = 1
DO
print (“output”)
x = x + 1
UNTIL x = …
What is selection?
When the user has a choice and the program goes down a particular path based on user input.
How might selection appear on the exam paper?
IF … THEN
print (“output A”)
ElSE IF … THEN
ELSE THEN
print (“output B”)
When written in pseudocode, the word THEN is used instead of the colon. The statement after the THEN should always be indented.
How might switch case appear in the exam paper?
SWITCH day:
CASE ‘Saturday’:
print (“I love the weekend”)
CASE ‘Monday’:
print (“A new week!”)
default:
print(“I wish it was the Saturday”)
How could you write a selection statement in the exam?
if x ….:
print(“output a”)
elif x …:
print (“output b”)
else:
print (“output c”)
What is sequence?
The order of the algorithm, e.g. look at the line numbers
What is an algorithm?
A set of instructions, e.g. the lines of code in a program.
What is the difference between a variable and a constant?
A variable can change as the program runs whereas a constant stays the same.
What is the difference between a function and procedure (subprograms)?
In a function, values can change as the program runs whereas in a procedure the values stays the same.