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
Q

Size of string

A

1 byte per character

26
Q

Casting

A

Functions to manually convert between data types
e.g. int(), real(), bool(), str()

27
Q

Basic String Manipulation

A

Allows strings to be sliced (extract a single character), joined or modified

28
Q

Basic String Manipulation actions

A
  • .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
Q

Basic File Handling Operations

A
  • open() - open file into variable
  • read - read line from data of contents
  • write - write line at the end of file
  • .close - close file
30
Q

Use of records to store data

A

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
Q

What is SQL?

A

Structured Query Language - used to access data on a database

32
Q

Commands in SQL

A

SELECT * FROM (table) WHERE

33
Q

Uses of 1D and 2D arrays

A

1D - To store multiple terms under 1 identifier

2D - store multiple terms of data using 2 identifiers

34
Q

What is an array?

A

A data structure that can store a collection of data values all under one name

35
Q

Creating a 1D array

A

e.g.
array rowers [3]
rower [0] = “sjsfn”
rower [1] = “ergg”
rower [2] = “tngm”

36
Q

Retrieving element from 1D array

A

print (rowers[0])

37
Q

Changing element in 1D array

A

rowers[0] = “Tamal”

38
Q

Random Number Generation

A

random (x,y)

random number between x and y

39
Q

Examples of sub programs

A
  • Functions
  • Procedures
40
Q

Sub programs: Procedures

A

set of instructions stored under 1 name

41
Q

Sub programs: Functions

A

Same as procedures, but return a value
Take atleast 1 parameter

42
Q

Features of sub programs

A
  • Parameters
  • Arguments
43
Q

Features of sub programs: Parameters

A

Special variables used to pass values into a sub program

44
Q

Features of sub programs: Arguments

A

Actual values that the parameters take when sub program is called

45
Q

What to do when calling a function

A

Assign to a variable where the returned value will be stored

46
Q

What can variables be?

A
  • Local
  • Globa;
47
Q

Local Variables

A

Used within the structure they’re declared in

48
Q

Global Variables

A

Can be used any time after their declaration

49
Q

Advantages of local variables

A

Won’t affect and are not affected by anything outside the sub program

50
Q

Disadvantage of global variables

A

Can lose track of its value

51
Q

IF statements

A

Allows you to check if a condition is true or false, and carry out a different actions depending on the outcome

52
Q

Structure of IF statements

A

if
elseif
else
endif

53
Q

Switch Statements

A

same as if statements, but check if a variable has a certain value

54
Q

Structure of SWITCH statements

A

switch
case
case
case
endswitch

55
Q

Disadvantage of SWITCH statements

A

They only check for the value of 1 variable

56
Q

FOR loops

A

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
Q

Types of Loops

A

FOR
DO UNTIL
WHILE

58
Q

DO UNTIL Loop

A

Controlled by condition at end of loop - loops until condition is true

59
Q

Structure of DO UNTIL Loop

A

do
until

60
Q

WHILE Loop

A

Controlled by condition at start of loop - keep going until the condition is not true

61
Q

Structure of While Loop

A

while
endwhile