2.2 - Programming Fundamentals Flashcards
What are the main constructs?
- Sequence
- Selection
- Iteration
What is a variable?
Data that can change in value as a program is being run
What are local variables?
Declared within a specific subroutine
—> Can be only used within that subroutine
What are global variables?
Can be used at any point within the whole program
What are some advantages of local variables?
- Saves memory
- Easier to debug local variables
- You can reuse subroutines with local variables
How do local variables save memory?
Only uses memory when that local variable is needed
—> Global variables use memory whether they are used or not
How are local variables easier to debug?
As they can only be changed within one subroutine.
What are some advantages of global variables?
- Makes maintenance easier
- Can be used anywhere in the whole program
- Can be used for constants
How do global variables make maintenance easier?
As they are only declared once
What does modular mean?
Split into subroutines with each subroutine having a dedicated purpose
What is a constant?
Data that does not change in value as the program is run
What are comparison operators used for?
Compare two data values
What is the function of arithmetic operators?
Used to mathematically manipulate values
What is modulus?
Reveals the remainder from the last whole number
e.g.
9 % 4 = 1 (4 goes into 9 twice (8) with a remainder of 1)
What is the symbol for modulus?
%
What is integer division?
Reveals the ‘whole number of times’ a number can be divided into another number
What is integer division also known as?
Quotient
What are logical operators?
Typically use Boolean or AND, OR, NOT
What are the different data types?
- Character
- String
- Float
- Boolean
What is a float also known as?
Real
What is a string?
A sequence of characters
—> Including letter, numbers & punctation
What is a character?
A single character (e.g. letter, number or punctuation symbol)
What is casting?
Converting the value of one variable from one data type into another
Give some examples of some python commands used for casting?
- str()
- float()
- int()
What is an array?
A static data structure that can hold a fixed number of data elements
What does traverse mean?
Move through
How would you traverse an array?
A for loop can be used to display each data element in order
How would you insert a value in an array?
You can change the value of elements that already exist by overwriting it
—> The size of the array is fixed so you can’t insert new values
How would you delete a value in an array?
You can ‘delete’ an elements by overwriting it as blank by using “”
How would you search an array?
How might a two dimensional array look like in python?
How is each value in an array represented?
By indexes
How would you search a two-dimensional array?
You will need two for loops - one for the row and the other for the values of each row
How would you print a value from a two dimensional array?
Row index then column index
What is each row name in a record called?
Field
What is a key field?
A unique data that identifies each record
How might a record look like?
What is SQL?
A language that can be used to search for data in a database
What does the **symbol * ** represent in SQL?
All fields
What are wildcards in SQL?
Symbols used to substitute characters
What is the format of an SQL statement?