coding Flashcards

1
Q

integer

A

whole number

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

float/real

A

numbers with a decimal/fractional part

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

char

A

single ascii character

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

string

A

text - characters in quotes

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

boolean

A

true or false

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

variable

A

stores data
can change as program is executed
pseudocode - a<- 3
python a = 3

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

MOD

A

% in python
finds remainder

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

DIV

A

// in python
integer division

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

constants

A

declared in programming
value doesn’t change
pseudocode - all caps - space is _
eg A_VALUE

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

casing

A

converting to other data types
diff data types are represented diff in binary

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

string> int

A

int()
STRING_TO_INT()

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

casting to string

A

str()
INT_TO_STRING()
REAL_TO_STRING()

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

slicing a string

A
  • SUBSTRING(start, end, str)
    e.g. word = algorithm
    SUBSTRING (3,6,word) = “orit”
  • print(word[3:7]) (stops before 7)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

get letter at a certain position

A

x = word[0]
x = ‘w’
(python counts from 0)

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

length of a word

A

LEN(word)
len(word)

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

get position of a letter

A

POSITION(word, ‘r’)
word.index(‘r’)
word.find(‘r’)

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

make it upper case

A

UPPER(word)
word.upper()

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

make it lower case

A

LOWER(word)
word.lower()

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

flow chart

A

start/end - oval
process - rectangle
input/output - parallelogram
condition - diamond

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

structures

A
  • sequence - all executed in order
  • selection - if/else - next executed depends on if condition is true/false
  • iteration - loops - repeat until condition met
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

selection structures

A

IF THEN - if :
ELSE THEN - else:
ENDIF
(or ELIF)

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

python comparison operators

A

not equal !=
greater than/equal to >=
less than/equal to <=

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

for loop

A

count controlled - run for a set no. times
for i in range(0,5):
FOR i<- 0 TO 5 DO

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

while loop

A

condition controlled - run until a condition is met
WHILE condition DO
ENDWHILE

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

after pseudocode structures

A

ENDWHILE
ENDIF

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

checks character is lower

A

character.islower()

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

checks character is digit

A

.isdigit()

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

make list of 1-4

A

list = [1, 2, 3, 4]
list <- [1, 2, 3, 4]

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

make empty list - with 6 slots in

A

list = [0]*6
list <- [6]

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

append to a list - add to end

A

list.append(7)

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

declaring empty list

A

list = [ ]
list <- [ ]

32
Q

accesing a character in a list

A

print(list[0])
outputs whatever is in slot 0

33
Q

replacing a number in a certain slot with another number

A

list[5]<- 17
list[5] = 17
slot 5 in the list is not 17

34
Q

print items in list

A

for x in list:
print(x)

35
Q

inserts an element in-between 2 elements in a list

A

list.insert(2, “A”)
adds A in space 2 after item one before item two

36
Q

data structure

A

list - stores multiple data to a single identifier
useful
- can assign to a single identifier (lots of data)
- more efficient and readable - reduces code + organises data

37
Q

2d list

A

list of lists
represent tables
people = [[“Bibi” , “15”], [“Amber”, “14”], [“Milan”, “15”]]

38
Q

indexing a 2d list

A

people = [[“Bibi” , “15”], [“Amber”, “14”], [“Milan”, “15”]]
people[0][1] - evaluates to “15”
people[2][0] - evaluates to “Milan”

39
Q

validation (check number is in certain range and forces user to type number in that range)

A

Number <- USERINPUT
WHILE Number < 0 or Number > 200 DO
OUTPUT “Number is out of range”
Number <- USERINPUT
END WHILE

40
Q

subroutines

A

break up large complicated problems into smaller self contained subprograms
- functions or procedures

41
Q

function vs procedure

A

function RETURNS a value
procedures just perform a task/execute code

42
Q

built in subroutines

A

exist and can be called in programming languages eg print(), str(), int(), input(), len()

43
Q

parameters

A

variables in a function - assigned value when you call it

44
Q

why use a subroutine

A
  • each subroutine can be tested separately - making it easier to debug
  • many programs can work on a large program once - cutting down development time (splitting it up)
  • subroutines can be reused - reducing development time
  • code broken down into meaningful subroutines - easier to maintain
45
Q

local variable

A

only exists whilst a subroutine is executing
can only be used + made + modified in the subroutine
- pass it in the parameter to use in a diff function eg def total(num)

46
Q

global variable

A

accessible anywhere in the program - make something global by writing global in front of it

47
Q

why use a function over a procedure

A
  • returns one value which you can use multiple times anywhere in the code
    (always store a function returned value to a variable to use later) (eg for function cal_total which stores total to use total twice - store to total_var = cal_total()
48
Q

how to call a procedure

A

nameofprocedure()

49
Q

normal data

A

acceptable data

50
Q

boundary data

A

lowest and highest values accepted and numbers either side of the boundary

51
Q

erroneous data

A

unacceptable data

52
Q

repeat vs while loop

A

while - condition is checked at beginning
repeat until - checked at end so will always run once and checks conditions oppositely eg n =0 instead of n!=0

53
Q

how to reduce errors

A
  • comment on lines
  • use subroutines
  • test code
  • use meaningful variable names
  • use trace tables to document what’s happening
54
Q

syntax error

A

dont follow programming rules - code stops (error message) eg dotn close brackets

55
Q

logic errors

A

program still runs but won’t work properly
incorrect operator or symbols used by the programmer eg > instead of <

56
Q

database

A

structured persistent collections of data on a computer stored in tables
- flat file / relational

57
Q

field

A

column

58
Q

record

A

row

59
Q

+ databases

A
  • efficient processing
  • searching is easier and more organised
  • Reduces storage requirements
  • Reduces data redundancy
60
Q

flat file databases

A

stores a single table of data inside a single text file
- stored using CSV
- each record is on a separate line.
- Each field is separated by comma
- hard to manage for complex data sets
- leads to redundancy and inconsistencies

61
Q

primary key

A

Unique identifier each entity in a table

62
Q

foreign key

A

when a primary key of one table is used in a different table to link the two tables

63
Q

relational database

A

contains multiple tables, - each table holds data for one entity
- tables are related by common field

64
Q

redundancy

A

when the same thing is repeated twice and given two separate primary keys

65
Q

inconsistency

A

The same data is inputted twice but differently or incorrectly

66
Q

relationship types

A

one to one
one to many
many to mant

67
Q

SQL

A

structured query language - allows you to create query update and delete data from data bases

68
Q

writing a selecting query

A

SELECT <field>
FROM <table>
use * to mean all fields</field>

69
Q

writing a selecting query with a condition

A

SELECT <field>
FROM <table>
WHERE <condition></condition></field>

70
Q

writing a select query for things between a range or search of patterns

A

BETWEEN in a range
LIKE search for pattern

SELECT <field>
FROM <table>
WHERE <field> (BETWEEN 5 AND 7) (LIKE ‘H’)</field></field>

71
Q

writing a select query and sorting data

A

SELECT <field>
FROM <table>
WHERE <condition>
ORDER BY <field> ASC/DESC</field></condition></field>

72
Q

changing a database

A

UPDATE <table>
SET <field> = <new>
WHERE <field> = <value></value></field></new></field>

73
Q

deleting records from a database

A

DELETE FROM <table>
WHERE <field> = <value></value></field>

74
Q

inserting in a record

A

INSERT INTO <table>
VALUES (“value1”, “value2”)
always put “ ” but for a date use a # #

75
Q

querying a relational database

A

SELECT <field>
FROM <table> <table>
WHERE (<table.> = <table.primarykey>) BOOLEAN (<table.field> <comparison> <table.field>)</table.field></comparison></table.field></table.primarykey></table.></field>