2.2 Programming Fundamentals Flashcards

1
Q

Operators

A

Special characters that perform specific functions

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

Common arithmetic operators

A

Addition
Subtraction
Multiplication
Division
Exponentiation
Quotient
Remainder

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

Exponential Operator

A

**
to the power of e.g. X**3
= X cubed

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

Quotient Operator

A

DIV
gives whole number product of division
e.g. 20 DIV 3 = 6

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

Remainder operator

A

MOD
gives remainder product of division
e.g. 20 MOD 3 = 2

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

What rule do computers follow?

A

BODMAS

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

Assignment Operator

A

’=’
assigns values to variables

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

Comparison Operator

A

Compare left hand expression to right hand expression

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

Common Boolean Operators

A

AND
OR
NOT

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

What does each boolean operator have?

A

Logic Gate

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

Logic Gate

A

Receive binary data, apply a Boolean operation, output a binary result
Has a truth table -> shows the possible input combinations and corresponding outputs

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

AND gate

A

Take 2 inputs, give 1 output
If both inputs are 1, the output is 1
If not, output is always 0

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

OR gate

A

2 inputs, give 1 output
If at least one of the inputs is 1, output is 1
If not, input is 0

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

NOT gate

A

1 input, 1 output
Output value is opposite to input value

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

5 main data types

A

Integer
Real
Boolean
Character
String

Using the correct data type makes code more efficient + robust

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

Data type: Integer

A

Whole number
‘int’

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

Data type: Real

A

Decimals
‘real’

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

Data type: Boolean

A

Can take one of two values: e.g. true or false
‘bool’

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

Data type: Character

A

A single letter, character, symbol
‘char’

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

Data type: String

A

To represent text
‘string’

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

Size of integer

A

2 bytes

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

Size of real

A

4 bytes

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

Size of boolean

A

1 byte

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

Size of character

A

1 byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Size of string
1 byte per character
26
Casting
Functions to manually convert between data types e.g. int(), real(), bool(), str()
27
Basic String Manipulation
Allows strings to be sliced (extract a single character), joined or modified
28
Basic String Manipulation actions
* .length - count no. of characters * .substring(x,y) - extract character from middle of x and y * .left(x) - extract x no. of characters from the left * .right(x) - extract x no. of characters from right * .upper - convert string to uppercase * .lower - convert string to lowercase
29
Basic File Handling Operations
* open() - open file into variable * read - read line from data of contents * write - write line at the end of file * .close - close file
30
Use of records to store data
Record = data structure which allows multiple data items to be stored. Difference to arrays: different data types can be stored Use fieldnames to identify each item
31
What is SQL?
Structured Query Language - used to access data on a database
32
Commands in SQL
SELECT * FROM (table) WHERE
33
Uses of 1D and 2D arrays
1D - To store multiple terms under 1 identifier 2D - store multiple terms of data using 2 identifiers
34
What is an array?
A data structure that can store a collection of data values all under one name
35
Creating a 1D array
e.g. array rowers [3] rower [0] = "sjsfn" rower [1] = "ergg" rower [2] = "tngm"
36
Retrieving element from 1D array
print (rowers[0])
37
Changing element in 1D array
rowers[0] = "Tamal"
38
Random Number Generation
random (x,y) random number between x and y
39
Examples of sub programs
* Functions * Procedures
40
Sub programs: Procedures
set of instructions stored under 1 name
41
Sub programs: Functions
Same as procedures, but return a value Take atleast 1 parameter
42
Features of sub programs
* Parameters * Arguments
43
Features of sub programs: Parameters
Special variables used to pass values into a sub program
44
Features of sub programs: Arguments
Actual values that the parameters take when sub program is called
45
What to do when calling a function
Assign to a variable where the returned value will be stored
46
What can variables be?
* Local * Globa;
47
Local Variables
Used within the structure they're declared in
48
Global Variables
Can be used any time after their declaration
49
Advantages of local variables
Won't affect and are not affected by anything outside the sub program
50
Disadvantage of global variables
Can lose track of its value
51
IF statements
Allows you to check if a condition is true or false, and carry out a different actions depending on the outcome
52
Structure of IF statements
if elseif else endif
53
Switch Statements
same as if statements, but check if a variable has a certain value
54
Structure of SWITCH statements
switch case case case endswitch
55
Disadvantage of SWITCH statements
They only check for the value of 1 variable
56
FOR loops
Repeat the code inside of them for a fixed number of times - depends on initial value, end value, step count for k = 1 to 100 step 3
57
Types of Loops
FOR DO UNTIL WHILE
58
DO UNTIL Loop
Controlled by condition at end of loop - loops until condition is true
59
Structure of DO UNTIL Loop
do until
60
WHILE Loop
Controlled by condition at start of loop - keep going until the condition is not true
61
Structure of While Loop
while endwhile