2.2 Programming Fundamentals Flashcards
What are programs?
Sequences of instructions for a computer.
What is a variable ?
A named memory address that holds a value.
What is a global variable ?
Variable that can be accessed and changed throughout the program
What is a local variable ?
variables are confined to a loop or subprogram
What are the three basic programming constructs ?
- Sequence
- Selection
- Iteration
What is a sequence ?
A set of instructions that follow on one from another
What is a selection ?
A decision where the program decides to move on based on the results of an event.
What is an iteration ?
The repetition of a block of statements within a computer program.
What are the two types of iteration ?
- Count-controlled
- Condition-controlled
How does a selection work ?
By testing a condition
What is a count-controlled iteration ?
- repeatedly executes a section of code a fixed number of predetermined times
- for loop
What is a condition-controlled iteration ?
- repeatedly executes a section of code until a condition is met - or no longer met
- while loop
What is nesting ?
Including one programming construct within another.
What are the two types of nesting ?
- Nested selection
- Nested Iteration
What is an operator ?
a character that determine what action is to be performed.
What is a data type ?
data is divided up and organised according to type
What are the 5 main data types ?
- Integer
- Float
- Character
- String
- Boolean
What is casting ?
Changing the data type of a variable
How to check length in Python ?
len()
What is concatenation ?
connecting strings of characters next to each other
How to open a file in python ?
- file = open(“FileName.csv”,”a”)
- “a” = append
- “w” = writes
- “r” = read
How to write to a file in python ?
- file.append() = Lists
- file.write() = Files
How to close a file in Python ?
- file.close()
What is SQL ?
Structured Query Language
What is the structure of a SQL query ?
- SELECT
- FROM
- WHERE
What are the two boolean operators that can be used in a SQL query ?
- AND
- OR
What is an array ?
A set of data values of the same type, stored in a sequence
What are the two types of subprograms ?
- Procedures
- Functions
What is a procedure ?
A section of code that performs a specific task.
What is a function ?
code that can be called by another part of the program with the purpose of returning one single value.
What is the difference between a function. and procedure ?
Function requires a return
What is a library ?
A collection of functions stored in a separate file.
How to use a random feature in python ?
- import random
- random.randint(0,9)
What are three common built-in functions ?
- int
- str
- asc
What is a 2D array ?
An array declared using two values