2.2 Programming Fundamentals Flashcards
Variable
A changeable named container
Constants
An available value that doesn’t change during the execution of the program
Operators
A character(s) that determine what action is to be performed
Inputs
Data supplied to the computer program by a user
Outputs
A form of interaction between the computer and the user
Assignments
Giving a variable a value
Sequence
A set of program instructions written and executed one after another
Selection
Certain lines of code will only execute if a condition is met
Iteration
- Condition-controlled, when a set of instructions is repeated based on whether a condition evaluates as true or false e.g. while loops
- Count-controlled, when a set of instructions is repeated a specific number of times e.g. for loops
Casting
Converting data types
==
Equal to
!=
Not equal to
<
Less than
<=
Less than or equal to
>
Greater than
> =
Greater than or equal to
+
Addition
-
Subtraction
/
Division
*
Multiplication
DIV or //
Quotient
MOD or %
Modulo
^ or **
Exponentiation (to the power of)
Subroutine
A named block of self-contained code which performs a specific task
Function
A subroutine that returns a value
Procedure
A subroutine that doesn’t return a value
String.length len(string)
Returns the length of a string
String.upper string.upper()
Returns the string in uppercase
String.lower string.lower()
Returns the string in lowercase
String.substring(startingPosition, numberOfCharacters) string[x:i]
Returns parts of a string, starting at the character of the first parameter and counting up by the number in the second parameter (pseudocode) or ending on the character of the last parameter non-inclusive (python)
String.left(i)
Returns the left most characters from a string where the parameter indicates how many to return
String.right(i)
Returns the right most characters from a string where the parameter indicates how many to return
+
Joins separate strings values together
ASC(…) ord(…)
Returns the ASCII value of a character
CHR(…) chr(…)
Returns a character from its ASCII number
Record
A data structure consisting of fields which can all be of different types of data
Field
A single item of data in a record
“r”
Read - Default value, opens a file for reading, returns an error if the file does not exist
“a”
Opens a file for appending, creates the file if it doesn’t exist, appends to the end of the file
“w”
Opens a file for writing, creates a file if it doesn’t exist, will overwrite any existing content
“x”
Creates the specified file, returns an error if the file already exists
f.readline()
Reads the next line of a file
f.close()
Closes a file when you are done with it
f.write(“…”)
Writes to the file
If os.path.exist(“demofile.txt”)
Checks if file exists
os.remove(“demofile.txt”)
Deletes a file
SELECT …
(List the fields to be displayed)
FROM …
(Specify table name)
WHERE
(List the search criteria)
=
Checks the value of a field
AND
Both conditions must be true
OR
Either condition must be true
NOT
Condition must be false
*
Wildcard - meaning “all columns” or remainder of a string