2.2 Programming fundamentals Flashcards
What are the 3 programming fundamentals
Sequence
Selection
Iteration
5 data types
Integer
Real
Float
Boolean
String
What is casting
Changing the data type of something
Cast 1 into int
int(“1”)
Cast 1 into true
bool(1)
Arithmetic operators
*
/
//
%
Assignment operator
=
What is a high-level language
Programming language used by humans
Has to be translated for computers to read
Comparison operators
==
!=
<
>
<=
>=
What is a constant
A variable that does not change
How to concatenate
newString= string1 + “ “ string2
What is concatenation
The conjoining of 2 strings
Example of string manipulation
.upper()
.left()
.length()
What are the boolean operators
And
Or
Not
Not and
Give an example of selection
if then
What does the switch statement do
If statement with one variable
What is sequence
When the code runs from top to the bottom
What is selection
Selects a certain part of the code to run depending on conditions
What is iteration
Looping code
Types of looping
Condition-controlled For
Count-controlled Do until, while
What does a for loop do
Loops for a certain amount of times
What does a do until loop do
Controlled by condition at the end of the loop
What does a while loop do
Control by condition at the start of the loop
Write a random number generator
roll = random(1,4)
What is an array
Data structure used to store data under one name
What is a 1D array
A list
What is a 2D array
A list of lists
Arrays have a fixed
Length
Where is 2D array used
Database
How to open file
file = open(“file.txt”)
How to create a file
newFile(“myfile.txt”)
How to write to a file and how to read
writeLine()
readLine()
Difference between records and arrays
Records can store different data types
How to do SELECT FROM in SQL
SELECT hotelName
FROM hotels
WHERE does in SQL?
Used in SELECT and FROM where you want certain conditions to be met
What are procedures
Set of instructions stored under one name
What are functions
Procedures that always return a value
What are parameters
Special variables used to pass values into a subprogram
Arguments
The values that parameters take
Local variables
Used within the structure they are declared in
Global variables
Can be used any time after their declaration