2.2 Programming Fundamentals Flashcards

1
Q

Sequence

A

Executing one instruction after another

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

Selection

A

A program branching depending on a condition
IF / ELSE statements.

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

Iteration

A

Repeating sections of code - looping.

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

Types of Iteration

A

FOR loops
WHILE loops

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

FOR Loops

A

AKA count-controlled loops are used when the number of iterations needed are known ahead of the iteration executing.

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

Example of FOR loops

A

for i in range(3):
print(“Hello”)

Hello
Hello
Hello

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

WHILE Loops

A

Condition-controlled loops are used when the number of iterations needed are not known beforehand as the variable used to determine that changes.

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

Example of WHILE loops

A

count= 10
while count>0:
print(count)
count = count-1
print(“Blast off”)

10
9
8
7
6
5
4
3
2
1
Blast off

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

The 4 Data Types

A

String
Integer
Float
Boolean

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

Integer

A

A whole number, positive or negative. Used for calculations.

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

Real / Float

A

A number with a decimal point. Used for calculations.

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

String

A

A set of characters.

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

Boolean

A

TRUE or FALSE. Used to check if something has happened.

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

Character

A

A single alphanumeric character.

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

Casting

A

Converting a variable from one data type to another.
x = int(x)

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

Variables

A

A value stored in memory that can change while the program is running.

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

Constants

A

A value that does not change while the program is running and is assigned when the program is designed.

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

Assignment

A

Giving a variable or constant a value.

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

Subprograms

A

small programs that are written within a larger, main program to perform a specific task.

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

Types of Subprograms

A
  • Functions
  • Procedures
21
Q

Functions

A

Manipulates data and returns a result back to the main program.

22
Q

Example of Functions

A

function f_to_c(temperature_in_f)
temperature_in_f= (temperature_in_f –32) * 5/9
return temperature_in_c
endfunction

23
Q

Calling a Function

A

celsius = f_to_c(32)

24
Q

Procedures

A

A subprogram that performs a specific task. When the task is complete, the subprogram ends and the main program continues from where it left off.

25
Q

Example of Procedures

A

procedure clear_screen(x)
for i = 1 to x:
print(“ “)
endprocedure

26
Q

Calling a Procedure

A

clear_screen(5)

27
Q

Advantages of Subprograms

A
  • Easy to write, test and debug as they are very small.
  • Easy to understand.
  • Can be reused throughout the program.
28
Q

Input

A

A value that is read from an input device.

29
Q

Output

A

Data generated by the computer and displayed to the user.

30
Q

==

A

Equal to

31
Q

!=

A

Not equal to

32
Q

//

A

Absolute division.
50 // 4 = 12

33
Q

%

A

MODULUS
50 % 4 = 2

34
Q
A

To the power

35
Q

String Manipulation

A

The use of programming techniques to modify, analyse or extract information from a string.

36
Q

Concatenation

A

Joining two strings together

37
Q

Example of Concatenation

A

word1 = “Computer”
word2 = “Science”
sentence = word1 + word2

= ComputerScience

38
Q

Length

A

word1 = “Computer”
len(word1)

= 8

39
Q

Character Position

A

word1 = “Computer”
word1[2]

= m

40
Q

Choosing certain letters

A

word1 = “Computer”
word1[0,3]
= Com

word1[3,3]
= put

41
Q

Uppercase

A

word1 = “Computer”
word1.upper

= COMPUTER

42
Q

Lowercase

A

word1 - “Computer”
word1.lower

= computer

43
Q

Arrays

A

A set of data values of the same type, stored in a sequence in a computer program. Also known as a list.

44
Q

Example of Arrays

A

score = [“1”, “2”, “3”, “4”, “5”, “6”, “7”]
print(score[2])

= 3

45
Q

2D Arrays

A

A two-dimensional array can hold more than one set of data. It is like a table, with data held in rows and columns.

46
Q

Example of 2D Arrays

A

score [1,9]
Would give the value in the 2nd row and 10th column.

Up the stairs then down the corridor.

47
Q

SQL

A

Structured Query Language. Programming language used for databases.

48
Q

SQL Commands

A

SELECT
FROM
WHERE

49
Q

Example of SQL

A

SELECT “Age”
FROM studentTbl
WHERE “Name” = “Rob” OR “Mia”