SLR 2.2 Programming Techniques Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is iteration?

A

‘iteration’ is repeating the same code more than once (looping).

Iteration is one of three main constructs in programming

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

What type of programming construct is demonstrated by the following pseudocode:

for i=0 to 7
print(i)
next i

A

This is an example of iteration

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

How many times would the following pseudocode print?

for i=0 to 7
print(i)
next i

A

8 times - 0 1 2 3 4 5 6 7

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

What would the following pseudocode do?

for i=0 to 7
print(i)
next i

A

it would print the numbers 0 1 2 3 4 5 6 7

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

Which programming construct is shown by the following pseudocode?

if entry == ”a” then
    print(“You selected A”)
elseif entry == ”b” then
    print(“You selected B”)
else
    print(“Unrecognised selection”)
endif
A

This is an example of selection

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

Which programming construct is shown by the following pseudocode?

while answer!=”computer”
answer=input(“What is the password?”)
endwhile

A

This is an example of iteration

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

What does the following pseudocode do?

while answer != ”computer”
answer=input(“What is the password?”)
endwhile

A

repeatedly asks the user to input the password until they enter “computer”

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

Is the user automatically shown the request for the password to be entered?

while answer != ”computer”
answer=input(“What is the password?”)
endwhile

A

no - if the variable answer is already == “computer” then the request is not shown.

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

What is the condition to trigger the request for the password to be entered?

while answer != ”computer”
answer=input(“What is the password?”)
endwhile

A

if the variable answer is not equal to “computer”

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

What is sequence?

A

‘sequence’ is about the ordering of the steps in an algorithm.

sequence is one of 3 main constructs in programming.

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

Which programming construct is shown by the following pseudocode?

print(“Welcome to my program”)
username = input(“What is your username?”)
password = input(“What is your password?”)

A

sequence

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

What is an integer?

A

A data type that represents whole number values

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

What is a real?

A

A data type that represents number values that contain decimal points

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

What is a Boolean?

A

A data type that represents only True or False (these are sometimes used to represent on/off or yes/no)

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

What does alphanumeric mean?

A

Either a letter or a number

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

What is a character?

A

A single alphanumeric value or a symbol (e.g. ! , ? # & etc.)

17
Q

What is a string?

A

A series of characters (alphanumeric or symbols) e.g. a sentence or word.

18
Q

What is an array?

A

A set of data items of the same type grouped together using a single identifier. Each of the data items is addressed by the variable name and an index e.g. my_index[3] would access the fourth item in the array.

19
Q

What is a record?

A

A data structure which consists of a collection of elements, typically in fixed number and sequence and typically indexed by names. The elements of records may also be called fields.

20
Q

What is selection?

A

One of the 3 basic programming constructs where a Boolean expression is analysed and the code executed depends on the result of the anaylsis.

21
Q

What is branching?

A

It is another name for selection - it is when the code executed depends on a Boolean expression being analysed and the result of the analysis directs what code is executed.

22
Q

What is a global variable?

A

A global variable is one which can be used anywhere in a program

23
Q

What is a local variable?

A

A local variable is one which is defined and can only be used within one part of a program (usually a function or procedure)

24
Q

What is modularity?

A

Modularity is building code in a modular way (in sections).

25
Q

Give three reasons why a modular approach to coding is a good idea

A

It allows the task of coding to be split between a team of people, it allows code to be reused (thus shortening the amount of code and thus the time needed to produce it), it is easier to maintain as the code is in one place and reused not repeated throughout the program

26
Q

What is a module?

A

A block of code that is reused

27
Q

What is a procedure?

A

A module of code that may or may not take parameters but which does not return a value. The procedure should carry out one task or action that is clearly indicated by its name.

28
Q

What is a function?

A

A module of code that may or may not take parameters and which returns a value. The function should carry out one task or action that is clearly indicated by its name.

29
Q

What is a parameter?

A

A value (or data structure containing a set of values) that are passed to a module of code when it is called.

30
Q

List the key words for SQL you need to know for GCSE

A

SELECT, FROM, WHERE, LIKE, AND, OR

31
Q

In an SQL search how is an asterisk (*) used?

A
An asterisk (*) is used to select all fields e.g.
SELECT * FROM customers WHERE customer_id = 1
32
Q

In an SQL search how is a percent sign (%) used?

A

A percent sign (%) is used as a wildcard (to match anything) e.g.
SELECT name, address FROM customers WHERE customer_name LIKE ‘J%’
This would show the name and address of all customers whose name starts with J

33
Q

What is the difference between a for loop and a while loop?

A

A for loop will execute a fixed number of times e.g. For x in range(0, 5) will execute 5 times. This is count controlled iteration.
A while loop will execute until the Boolean expression it is based on evaluates to False e.g. While goals < 10 will execute until goals is not less than 10. This is condition controlled iteration.