what is a variable?
a named space in memory, large enough to store a single piece of data
what is a constant?
a named space in memory with a value that can never change while the program is running
typically shown in uppercase and are separated by underscores
python DOES NOT use constants
what are the different data types?
what is boolean?
what is a character?
what are integers?
what is a real?
what is a string?
what is a declaration?
what is assignment?
what is sequence?
example:
mark 1 <- 78
mark 2 <- 64
total <- mark1 + mark2
average <- total/2
OUTPUT average
what is selection?
example:
IF average >= 80 THEN
OUTPUT “distinction”
ELSE
OUTPUT “pass”
ENDIF
why declare a constant instead of a variable?
can a constant ever change its value?
input statements in python
firstName = input (“what is your first name?”)
what are the arithmetic operators?
*
/
MOD
DIV
what is used to convert data types?
functions
what is casting?
functions being used to convert data types
what are some examples of functions?
how do you allow a user to input a numerical value? (pseudocode)
OUTPUT “please enter the number of cats:”
tickets <- STRING_TO_INT(USERINPUT)
how do you allow a user to input a numerical value in python?
cats = int(input(“please enter the number of tickets:”))
what is concatenating?
joining two string variables together eg.
firstname <- “rose”
surname <- “chan”
fullname <- firstname + “ “ + surname
OUTPUT fullname
how do you identify the length of a string? (string handling functions)
LEN(str): word <- “algorithm”
OUTPUT LEN(word)
the output would be 9 because it is 9 letters long
how do you get a substring? (string handling functions)
SUBSTRING(start, end, str):
word <- “algorithm”
OUTPUT(3,6, word)
the output would be ‘orit’ because those are the letters between index 3 and 6
NOTE: strings always start their index at 0