Programming - The Basics Flashcards

1
Q

What is iteration?

A

Where a block of code repeats

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How might iteration be presented in the exam?

A

Do…Until
While…
For…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the term ‘nested’ mean?

A

A block of code within another block of code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How could you write a for loop in the exam?

A

for loop in range (x):
print (“output”)

Follow the process identified in the abstraction phase - where you kept the important information”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How could you write a while loop in the exam?

A

count = 0
while count < x:
print(“count”)
count+=1

Follow the process identified in the abstraction phase - where you kept the important information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How might iteration appear on the exam paper using Do…Until?

A

x = 1

DO
print (“output”)
x = x + 1
UNTIL x = …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is selection?

A

When the user has a choice and the program goes down a particular path based on user input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How might selection appear on the exam paper?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How might switch case appear in the exam paper?

A

SWITCH day:
CASE ‘Saturday’:
print (“I love the weekend”)
CASE ‘Monday’:
print (“A new week!”)
default:
print(“I wish it was the Saturday”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How could you write a selection statement in the exam?

A

if x ….:
print(“output a”)
elif x …:
print (“output b”)
else:
print (“output c”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is sequence?

A

The order of the algorithm, e.g. look at the line numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an algorithm?

A

A set of instructions, e.g. the lines of code in a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between a variable and a constant?

A

A variable can change as the program runs whereas a constant stays the same.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between a function and procedure (subprograms)?

A

In a function, values can change as the program runs whereas in a procedure the values stays the same.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly