coding Flashcards
integer
whole number
float/real
numbers with a decimal/fractional part
char
single ascii character
string
text - characters in quotes
boolean
true or false
variable
stores data
can change as program is executed
pseudocode - a<- 3
python a = 3
MOD
% in python
finds remainder
DIV
// in python
integer division
constants
declared in programming
value doesn’t change
pseudocode - all caps - space is _
eg A_VALUE
casing
converting to other data types
diff data types are represented diff in binary
string> int
int()
STRING_TO_INT()
casting to string
str()
INT_TO_STRING()
REAL_TO_STRING()
slicing a string
- SUBSTRING(start, end, str)
e.g. word = algorithm
SUBSTRING (3,6,word) = “orit” - print(word[3:7]) (stops before 7)
get letter at a certain position
x = word[0]
x = ‘w’
(python counts from 0)
length of a word
LEN(word)
len(word)
get position of a letter
POSITION(word, ‘r’)
word.index(‘r’)
word.find(‘r’)
make it upper case
UPPER(word)
word.upper()
make it lower case
LOWER(word)
word.lower()
flow chart
start/end - oval
process - rectangle
input/output - parallelogram
condition - diamond
structures
- sequence - all executed in order
- selection - if/else - next executed depends on if condition is true/false
- iteration - loops - repeat until condition met
selection structures
IF THEN - if :
ELSE THEN - else:
ENDIF
(or ELIF)
python comparison operators
not equal !=
greater than/equal to >=
less than/equal to <=
for loop
count controlled - run for a set no. times
for i in range(0,5):
FOR i<- 0 TO 5 DO
while loop
condition controlled - run until a condition is met
WHILE condition DO
ENDWHILE
after pseudocode structures
ENDWHILE
ENDIF
checks character is lower
character.islower()
checks character is digit
.isdigit()
make list of 1-4
list = [1, 2, 3, 4]
list <- [1, 2, 3, 4]
make empty list - with 6 slots in
list = [0]*6
list <- [6]
append to a list - add to end
list.append(7)