2.1 Programming Fundamentals Flashcards

1
Q

Programming Constructs

A

There are three constructs (ideas of programming) that are used to control the flow of a program:
. Sequence
. Selection
. Iteration

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

Sequence

A

Structuring code into a logical, sequential order

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

Selection

A

Decision making using if statements

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

Iteration

A

Repeating code using for or while loops

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

Variables

A

Variables are used to store data in programs. They can be changed as the program runs

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

What are the two parts of a variable

A

The data value such as “Emily”
An identifier such as First_Name

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

How will an efficient program use variables

A

An efficient program will use variables with sensible identifiers that immediately state their purpose in the program

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

Variable names

A

Using variable names like ‘TotalNum’ and ‘Profit’ rather than ‘num1’ and ‘num2’ mean that other programmers will be able to work out the purpose of the code without the need for extensive comments

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

Large programs

A

Large programs are often modular - split into subroutines with each subroutine having a dedicated purpose

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

Local variables

A

Local variables are declared within a specific subroutine and can only be used within that subroutine

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

Global variables

A

Global variables can be used at any point within the whole program

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

What are the advantages of local variables

A

. Saves memory
. Easier to debug
. Can reuse subroutines with local variables

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

What are the advantages of global variables

A

. Variables can be used anywhere in the whole program (and in multiple subroutines)
. Makes maintenance easier as they are only declared once
. Can be used for constants - values that remain the same

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

What is a constant

A

As specified before, a variable is data that can change in value as a program is being run

A constant is data that does not change in value as the program is run - it is fixed and remains the same

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

What is an example of a constant in math’s

A

An example of a constant in math’s programs is pi - it will constantly remain at 3.14159 and never change

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

What are Comparison Operators

A

Comparison operators are used to compare two data values

17
Q

What are Arithmetic Operators

A

Arithmetic operators are used to mathematically manipulate values

18
Q

What are examples of Arithmetic Operators

A

add (+), subtract (-), multiply (*) and divide (/)

19
Q

Modulo divison

A

Modulo division (also known as modulus) reveals the remainder from the last whole number. For example:

​9 % 4 = 1 (4 goes into 9 twice (8) with a remainder of 1)

20
Q

Integer division

A

Integer division (also known as quotient) reveals the ‘whole number of times’ a number can be divided into another number:

9 // 4 = 2 (4 goes into 9 fully, twice)

21
Q

Exponentiation

A

The symbol ^ represents exponentiation.

For example ‘2^3 = 8’ as it means ‘2³ = 8’.

22
Q

Logical Oeprators

A

Logical operators typically use TRUE and FALSE values which is known as Boolean.