section 2-prgramming Flashcards
languages
languages have functions that manually convert between data types (e.g string_to_int)
data types
integer = whole numbers only real(float) =numbers with decimals boolean = true or false values character = a single letter,number,symbol... string = represents texts
operations
+ addition - subtraction
*multiplication / division
div= whole number mod=remainder
assignment operator
the assignment operator arrow or = is used to assign values to to a variable
comparison operators
are things like equal to ,greater than….
data values
data values can be stores as constants or variables ,
constants and variables need to be declared before use
constants
a constant is assigned to a value at design time
variables
a variable on the other hand can be changed which therefore makes them more useful
strings
strings are a data type made up of characters ,when manipulating strings you start at 0
inputs
inputs can be received from many devices (keyboards ,mouses,webcam….)
outputs
outputs are typically displayed (monitors)
if statements
if statements allow you to check if a condition is true or false.
more complex if statements can be made by putting one if statement inside another one
else if statements
else if statements are used to check multiple conditions and if they give out different outputs
case statements
case statements can check is a variable have specific values
repeat until loop
controlled by a condition or until a condition is true, you get an infinite loop if the condition is never true.
(same as ado until loop)
while loops
while loops keep going while the condition is true .while loops are controlled by a condition at the start of the loop
do-while loops
controlled by end of the loop.keep while if the condition is true
for loops
for loops will repeat the code inside a fixed number of times.for loops are a type of definite iteration
nested iteration
is typically having a loop inside another
boolean operators
look in revisions guide!!!
generating random numbers
random.int()
random numbers
random numbers generate random selections(e.g stimulate a coin toss)
using LEN()
the number of elements in an array can be found using the LEN() just like for strings
arrays
arrays are a data structure that can store a group of data values of the came type ,under one name
one-dimensional arrays
one-dimensional arrays are like lists
e.g creating arrays changing elements
retrieving elements number of elements
creating arrays
start of with array name,assign and operator and putting data in [] with commas separating it
retrieving elements
retrieving elements can be done by using the name of the array and elements position(starting at 0 not 1)
changing elements
changing elements is done by reassigning the array position to a different data value
two-dimensional arrays
two-dimensional arrays are like one-dimensional arrays where each element is also one dimensional arrays,you can change element the exact same way (using LEN())
record
a record is a type of data structure like an array,it is used to store data,records can keep related info in one place
fields
each item in a record is called a field ,but you cant add extra fields to a record as they have fixed sizes
file handling
file handling allows for permanent data storage
you can open the file with the OPEN() function
you can close the file with the CLOSE() function
write can be written as WRITE() or WRITELINE() and vice versa with READ()
ENDOFILE()
ENDOFILE() is a useful command that returns true if the cursor is at the end of the file
subroutines
subroutines are a set of instructions stored under one name and it helps to avoid repeating codes.the actual values that the parameters take when the subroutine is called are sometimes named arguments.can be rep
subroutines can be repeated and are very reliable
subroutines that return values are called functions
parameters
parameters are special variables used to pass values into a subroutine. for each parameter you can specify name, data….
local variables
local variables can only be used within the structure they’re declared in (they have a local scope)
global variables
global variables can be used anytime after their declaration (they have global scope)