Programming Flashcards

1
Q

What are the 3 basic programming constructs?

A

Sequence - the order of instructions
Selection - an instruction is only carried out if a condition is met (if, elif, else)
Iteration - looped section of code

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

What are the 2 types of iteration?

A

Definite iteration - count controlled (for)
Indefinite iteration - condition controlled (while, repeat until)

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

What is nested iteration?

A

When a loop is included inside another loop

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

What is nested selection?

A

When more than one decision needs to be made when carrying out a task

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

What is nesting?

A

The process of including one programming construct within another

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

What is a variable?

A

A named piece of memory which contains a value that can change.

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

What is an identifier?

A

The name of a variable?

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

What is declaration?

A

Giving a variable a name or giving a value to a constant

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

What is assignment?

A

Giving a variable a value

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

What is a constant?

A

A named piece of memory which holds a value that cannot change.

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

What is scope?

A

Refers to where a variable, constant, function or procedure can be used - it can be either local (within a subroutine) or global (the whole program)

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

What are the 5 data types?

A

Integer - number
String - text
Boolean - true/false
Character - a singular letter/number
Float/ float - decimal

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

What is casting?

A

The process of changing the data type of a variable e.g. int(‘54’) returns 54

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

What are the arithmetic operators?

A

*
/
DIV (//)
MOD (%)

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

What are the relational operators?

A

Used for assignment and comparison:
= - assignment
== - equivalence
< - less than
<= - less than or equal to
> - greater than
>= greater than or equal to
!= - not equal to

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

What are the Boolean operators?

A

AND
OR
NOT

17
Q

What is an array?

A

A data structure that holds similar, or related data (a list). Each element has a position (index) within the array and holds a value. They must all be of the same data type.

18
Q

How is an array declared?

A

A programmer gives it 2 properties:
An identifier and
A size

19
Q

How is a 2d array declared?

A

With an identifier and 2 values - a row and a column

20
Q

How can you determine the length of a string?

A

len()

21
Q

How can you determine the position of a character in a string?

A

string[0]
where string = the variable and 0 = the position

22
Q

What is a substring?

A

A set of characters that exists inside of a string.

23
Q

How can a random number be generated?

A

import random
random.randint(range)

24
Q

What is a subroutine?

A

A smaller piece of named code that exists within a larger program - its purpose is to perform a specific task.
(using these is sometimes called structured programming!)

25
Q

Why are subroutines useful?

A

They are smaller in size - thus easier to debug + to understand + they save time as the programmer doesn’t have to write out the whole code, just the identifier
They make the program code shorter

26
Q

What are 2 types of subroutine?

A

Procedures
Functions

27
Q

What is a procedure?

A

A subroutine that performs a specific task - it does not return a value when called

28
Q

What is a function?

A

A subroutine that also performs a specific task, except it manipulates data, and returns a value to the main program

29
Q

What is a parameter?

A

A variable within a subroutine

30
Q

What is the purpose of robust and secure programming?

A

Making sure the correct data type is entered (validation)
Making sure the correct person is using the program (authentication)
Debugging (testing)

31
Q

What are the 5 validation checks?

A

Range check - Does the input fall within the specified range?
Length check - Is it a sensible length?
Presence check - Is something entered at all?
Format check - Is it in the correct format e.g DD/MM/YY
Type check - Is it the correct data type?

32
Q

What are the 3 types of test data?

A

Normal data
Boundary data - data on either end of the accepted range (e.g if its 1,2,3 - boundary would be 1 and 3 (valid) as well as 0 and 4 (invalid)
Erroneous data - data that the program should not accept

33
Q

What is a logic error?

A

An error related to the structure of the program

34
Q

What is a syntax error?

A

An error related to the grammar and the rules of the programming language e.g typing PRINT in all caps

35
Q

What is source code?

A

A set of instructions written in a human readable language

36
Q

What is high level programming language?

A

Language typed directly into the machine which is close to the natural language of humans

37
Q

Why is high level programming language used over low level programming language?

A

It is easier to understand than machine code
It is easier to debug
It provides built in subroutines
It is shorter

38
Q

What is low level programming language?

A

Languages that sit close to the computer’s instruction set e.g. machine code and assembly language