2.2 Programming fundamentals Flashcards

1
Q

What are the 3 programming fundamentals

A

Sequence
Selection
Iteration

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

5 data types

A

Integer
Real
Float
Boolean
String

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

What is casting

A

Changing the data type of something

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

Cast 1 into int

A

int(“1”)

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

Cast 1 into true

A

bool(1)

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

Arithmetic operators

A

*
/

//
%

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

Assignment operator

A

=

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

What is a high-level language

A

Programming language used by humans
Has to be translated for computers to read

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

Comparison operators

A

==
!=
<
>
<=
>=

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

What is a constant

A

A variable that does not change

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

How to concatenate

A

newString= string1 + “ “ string2

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

What is concatenation

A

The conjoining of 2 strings

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

Example of string manipulation

A

.upper()
.left()
.length()

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

What are the boolean operators

A

And
Or
Not
Not and

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

Give an example of selection

A

if then

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

What does the switch statement do

A

If statement with one variable

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

What is sequence

A

When the code runs from top to the bottom

18
Q

What is selection

A

Selects a certain part of the code to run depending on conditions

19
Q

What is iteration

A

Looping code

20
Q

Types of looping

A

Condition-controlled For
Count-controlled Do until, while

21
Q

What does a for loop do

A

Loops for a certain amount of times

22
Q

What does a do until loop do

A

Controlled by condition at the end of the loop

23
Q

What does a while loop do

A

Control by condition at the start of the loop

24
Q

Write a random number generator

A

roll = random(1,4)

25
What is an array
Data structure used to store data under one name
26
What is a 1D array
A list
27
What is a 2D array
A list of lists
28
Arrays have a fixed
Length
29
Where is 2D array used
Database
30
How to open file
file = open("file.txt")
31
How to create a file
newFile("myfile.txt")
32
How to write to a file and how to read
writeLine() readLine()
33
Difference between records and arrays
Records can store different data types
34
How to do SELECT FROM in SQL
SELECT hotelName FROM hotels
35
WHERE does in SQL?
Used in SELECT and FROM where you want certain conditions to be met
36
What are procedures
Set of instructions stored under one name
37
What are functions
Procedures that always return a value
38
What are parameters
Special variables used to pass values into a subprogram
39
Arguments
The values that parameters take
40
Local variables
Used within the structure they are declared in
41
41
Global variables
Can be used any time after their declaration