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
after pseudocode structures
ENDWHILE ENDIF
26
checks character is lower
character.islower()
27
checks character is digit
.isdigit()
28
make list of 1-4
list = [1, 2, 3, 4] list <- [1, 2, 3, 4]
29
make empty list - with 6 slots in
list = [0]*6 list <- [6]
30
append to a list - add to end
list.append(7)
31
declaring empty list
list = [ ] list <- [ ]
32
accesing a character in a list
print(list[0]) outputs whatever is in slot 0
33
replacing a number in a certain slot with another number
list[5]<- 17 list[5] = 17 slot 5 in the list is not 17
34
print items in list
for x in list: print(x)
35
inserts an element in-between 2 elements in a list
list.insert(2, "A") adds A in space 2 after item one before item two
36
data structure
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
2d list
list of lists represent tables people = [["Bibi" , "15"], ["Amber", "14"], ["Milan", "15"]]
38
indexing a 2d list
people = [["Bibi" , "15"], ["Amber", "14"], ["Milan", "15"]] people[0][1] - evaluates to "15" people[2][0] - evaluates to "Milan"
39
validation (check number is in certain range and forces user to type number in that range)
Number <- USERINPUT WHILE Number < 0 or Number > 200 DO OUTPUT “Number is out of range” Number <- USERINPUT END WHILE
40
subroutines
break up large complicated problems into smaller self contained subprograms - functions or procedures
41
function vs procedure
function RETURNS a value procedures just perform a task/execute code
42
built in subroutines
exist and can be called in programming languages eg print(), str(), int(), input(), len()
43
parameters
variables in a function - assigned value when you call it
44
why use a subroutine
- 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
local variable
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
global variable
accessible anywhere in the program - make something global by writing global in front of it
47
why use a function over a procedure
- 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
how to call a procedure
nameofprocedure()
49
normal data
acceptable data
50
boundary data
lowest and highest values accepted and numbers either side of the boundary
51
erroneous data
unacceptable data
52
repeat vs while loop
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
how to reduce errors
- comment on lines - use subroutines - test code - use meaningful variable names - use trace tables to document what’s happening
54
syntax error
dont follow programming rules - code stops (error message) eg dotn close brackets
55
logic errors
program still runs but won’t work properly incorrect operator or symbols used by the programmer eg > instead of <
56
database
structured persistent collections of data on a computer stored in tables - flat file / relational
57
field
column
58
record
row
59
+ databases
- efficient processing - searching is easier and more organised - Reduces storage requirements - Reduces data redundancy
60
flat file databases
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
primary key
Unique identifier each entity in a table
62
foreign key
when a primary key of one table is used in a different table to link the two tables
63
relational database
contains multiple tables, - each table holds data for one entity - tables are related by common field
64
redundancy
when the same thing is repeated twice and given two separate primary keys
65
inconsistency
The same data is inputted twice but differently or incorrectly
66
relationship types
one to one one to many many to mant
67
SQL
structured query language - allows you to create query update and delete data from data bases
68
writing a selecting query
SELECT FROM use * to mean all fields
69
writing a selecting query with a condition
SELECT FROM
WHERE
70
writing a select query for things between a range or search of patterns
BETWEEN in a range LIKE search for pattern SELECT FROM
WHERE (BETWEEN 5 AND 7) (LIKE ‘H’)
71
writing a select query and sorting data
SELECT FROM
WHERE ORDER BY ASC/DESC
72
changing a database
UPDATE
SET = WHERE =
73
deleting records from a database
DELETE FROM
WHERE =
74
inserting in a record
INSERT INTO
VALUES (“value1”, “value2”) always put “ ” but for a date use a # #
75
querying a relational database
SELECT FROM
WHERE ( = ) BOOLEAN ( )