1/32
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
why should you use the correct data type? (3)
makes code more memory efficient
code is more robust
code is more predictable
define casting
changing the data type of a variable to another data type
what does the ASC() function do?
converts a character into its ASCII number
what does the CHR() function do?
converts an ASCII number into its equivalent character
exponentation operator
^ pseudocode ** python
what does MOD do
returns remainder
what does DIV do
removes remainder to return whole number
define variable
named location in memory which can change during the running of the program
what is a constant
an assigned data value that can’t be changed
what would x.left(2) do on the string x=”Hello”
extract the first 2 characters = “He“
what would x.right(3) do on the string x=”Hello”
extract the last 3 characters = “llo”
what would x.subString(2,2) do on the string x=”Hello”
extract the characters starting at position 2 with a length of 2 = “ll”
NOT gate truth table

AND gate truth table

OR gate truth table

differences between arrays and lists (2)
arrays store data of the same data type, lists can store data of different data types
arrays have a fixed length but lists can change length
array rowers[4]
creates an array called rowers which can hold 4 elements
code to open a file called file.txt stored in a variable myfile for writing
myfile = open(“file.txt”,”w”)code to open a file called file.txt stored in variable myfile
myfile = open(“file.txt”)code to close a myfile
myfile.close()code to read next line of myfile
myfile.readLine()code to add “hello” to the end of myfile
myfile.writeLine(“hello”)code to check if at the end of the file
myfile.endOfFile()code to create a new file called mytext.txt
newFile(“mytext.txt”)code to print on a new line
\n
are records fixed length or static?
fixed length
problems with flat file databases (3)
data redundancy
inaccurate data
inconsistent data
define procedure
sets of instructions stored under one name which are executed when called.
difference between a function and a procedure
functions return a value, procedures do not return a value
procedures don’t always need a parameter, functions always need at least one parameter
functions must be inside print statements or assigned to variables or the value returned is lost.
#procedure
subject()
#function
subject = favourite(computer)when are subprograms useful? (3)
repeating code
better structure and readability of code
reduces the amount of code you have to write
what is the difference between an argument and a parameter?
parameters are used to pass values into a subprogram
arguments are the actual values that parameters take when subprograms are called
# Function definition with parameters
def add(x, y): # x and y are parameters
return x + y
# Function call with arguments
result = add(5, 3) # 5 and 3 are arguments
print(result) # Output: 8define local variable
variables that can only be used in the structure they are declared in
define global variable
variables that can be used anywhere after their declaration