1.2.3 Intro to Programming [OUT OF SERVICE] Flashcards
Programming construct: Sequence
Code is executed line-by-line from top to bottom
Programming construct: Selection
Certain block of code is run if a specific condition is met, using IF, ELSE IF and ELSE statements
Programming construct: Iteration
A block of code is executed a certain number of times or while a condition is met, using FOR, WHILE or DO UNTIL loops
What is a variable?
A name used to refer to a particular memory location used to store data.
What operator is this: =
Assignment
What is the difference between constants and variables?
Value of a constant cannot be edited by the program during execution.
What might we use a constant for?
Values that don’t need changing.
EG: VAT, Pi
Programming construct: Subroutine
Named blocks of code that perform a specific task.
How many values can a function return?
One.
What are parameters?
Values passed into a subroutine.
Arithmetic operator: **
Exponentiation (raising a number to a power)
Arithmetic operator: DIV or //
Integer division
Whole number of times a number goes into another
Arithmetic operator: MOD
Remainder when a number is divided by another
What are arithmetic and relational operators used for?
Arithmetic: Carrying out mathematical functions
Relational: Making comparison between 2 values
Boolean operator: AND
Returns true when both values true
Boolean operator: OR
Returns true when at least one value is true
How do you get the length of a string?
stringname.length
What is a substring?
A section within a string
How do you get a substring?
stringname.subString(startPos, numOfChar)
How can you open a file to read?
myFile = openRead(“filename.txt”)
How can you read a line from a file?
fileContent = myFile.readLine()
How can you close a file?
myFile.close()
How can you open a file to write?
myFile = openWrite(“filename.txt”)
How can you write a line to a file?
myFile.writeLine(“Lovely weather outside”)