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
Example of Procedures
procedure clear_screen(x) for i = 1 to x: print(" ") endprocedure
26
Calling a Procedure
clear_screen(5)
27
Advantages of Subprograms
- Easy to write, test and debug as they are very small. - Easy to understand. - Can be reused throughout the program.
28
Input
A value that is read from an input device.
29
Output
Data generated by the computer and displayed to the user.
30
==
Equal to
31
!=
Not equal to
32
//
Absolute division. 50 // 4 = 12
33
%
MODULUS 50 % 4 = 2
34
^
To the power
35
String Manipulation
The use of programming techniques to modify, analyse or extract information from a string.
36
Concatenation
Joining two strings together
37
Example of Concatenation
word1 = "Computer" word2 = "Science" sentence = word1 + word2 = ComputerScience
38
Length
word1 = "Computer" len(word1) = 8
39
Character Position
word1 = "Computer" word1[2] = m
40
Choosing certain letters
word1 = "Computer" word1[0,3] = Com word1[3,3] = put
41
Uppercase
word1 = "Computer" word1.upper = COMPUTER
42
Lowercase
word1 - "Computer" word1.lower = computer
43
Arrays
A set of data values of the same type, stored in a sequence in a computer program. Also known as a list.
44
Example of Arrays
score = ["1", "2", "3", "4", "5", "6", "7"] print(score[2]) = 3
45
2D Arrays
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
Example of 2D Arrays
score [1,9] Would give the value in the 2nd row and 10th column. Up the stairs then down the corridor.
47
SQL
Structured Query Language. Programming language used for databases.
48
SQL Commands
SELECT FROM WHERE
49
Example of SQL
SELECT "Age" FROM studentTbl WHERE "Name" = "Rob" OR "Mia"