Programming Flashcards
What is a data type?
Specification is what type of value a variable has.
What are the five data types?
Integer
Real/float
Character
String
Boolean
What is an integer?
A numerical data type for whole numbers
2/4 bytes
What is a real/float ?
A numerical data type for decimal numbers
4/8 bytes
What is a character?
A single alphanumerical symbol
1 byte
What is a string?
A data type for one or more alphanumerical characters.
* can be a number or string
1 byte for each character
What is a Boolean?
A data type that can only take one of two values - TRUE or FALSE
1 bit-1 byte
What is the difference between constants and variables?
Variables can be changed throughout out the program.
What is iteration?
Loops controlled by conditions
What are types of indefinite iteration?
Only rely on a condition(can be infinite):
Repeat until- condition at end, run at least once
While- condition at the start of loop
Do while
What is selection?
Causes the program to make a choice and flow in a given direction
What is a variable?
A named piece of memory that holds a value , can change as the program is running
What is a constant?
A named piece of memory where the value cannot be changed while a program runs
What is a type of selection?
An if else statement
What is definite iteration?
A loop that repeats a set number of times - usually a for loop
What is a nested statement ?
An iteration or selection made up of multiple statements inside each other
What is the need for meaningful identifiers?
Suitable names for variables, makes it easier for the next person to work on the code to understand
How do you find the length of a string?
LEN(string)
*starts from 1
🐍len(string)
How do you find the position of a string?
POSITION(string,character)
*includes the 0
🐍 string.index(‘x’)
How do you take a certain part of the string?
SUBSTRING(x ,y ,string)
*includes the 0
*does include last number
🐍string[x : y]
*does not include last number
How do you concatenate strings?
+
Does not include spaces
Normally done with variables
🐍everything has to be a string
How do you change one data type to another?
STRING_TO_INT (“your mom”)
STRING_TO_REAL (“your mom “)
INT_TO_STRING (69)
REAL_TO_STRING (9.58)
🐍
str()
int()
float()
How do you get the quotient (whole number)?
DIV
🐍//
How do you get the remainder?
MOD
🐍%
What is not equal to
!=
What is equal to , comparatively?
==
What are subroutines?
A set of code within a program , that can be called any time from the man program
What are the advantages of subroutines?
✅can be tested individually, making it easier to debug
✅can be used throughout the program repeatedly, however code only has to be written once = shorter programs
✅can be saved separately as modules , and reused in other programs = saving time
How are subroutines done in Python and pseudocode ?
What are global and local variables?
Global = can be used throughout the program , at any time
Local = can only be used within the structure they are declared in
*less memory
What are parameters ?
A special variable , that passes data into the subroutine
*local scope
1-D |rrays in python and pseudocode
Used to store multiple data values.
A a variable with a single identifier
*index begins at zero for both python and pseudocode
How do you calculate the length of an array in pseudo code and python ?
2D arrays
How do you calculate length in arrays?
How do you access all values within a 2D array?
How do you write a for loop in python and pseudocode ?
What are records?
Basically an array , that can store items with different data types
Each record is an individual list in the list of lists 9rows’0
Columns are known as fields, each field is declared with a variable
How do you make a record in python (dictionary) and pseudocode?
What is a data structure ?
A format, for storing multiple data values under one variable name
What is validation?
Checking that data meets certain criterias before passing the program.
It reduces the data entry errors , and prevents the ro gram from crashing if inalienable data is input
What are the types of validation?
Presence check
Format check
Range check
Look up table
Length check
What is authentication?
Checking the identity of a user
What is a syntax error?
When the compiler/interpreter doesn’t understand something , because it doesn’t follow the rules or grammar of the programming language
What is a logic error
When the compiler/ interpreters are able to run the code, but the code does something unexpected
What are the types of data ?
Normal
Erroneous
Boundary/ extreme:
Boundary valid & boundary invalid
What are some benefits of the structured approach ?
what are some benefits of arrays
Arrays help maintain large sets of data under a single variable name to avoid confusion that can occur when using several variables
What are the two search algorithms?
🟢Binary search
🟢Linear search
What are the two sort algorithms?
🔵bubble sort
🔵merge sort
describe binary search
Binary search pseudocode code and python
What is the pseudo code for binary search
Describe merge sort
Describe bubble sort
What is the pseudo code for a bubble sort
Merge sort advantages and disadvantages
FOR loop (definite iteration )
Python V pseudocode
Subroutines (procedures and functions)
Python V pseudocode
Arrays (1D & 2D)
Pseudocode vs Python