Programming fundamentals Flashcards
what is a string
a group of characters
what is quotient (DIV)
does the division but cuts off the decimal
what is modulus(mod)
gives the remainder of the
for a and Boolean to work what has to take place
both sides need to be true
what is the code for substring
.substring(start, how many )
what are variables
identifiers that hold value that can be changed
what are constants
identifiers that hold value and connot be changed
const PI = 3.142
what is user input always
a string
what are the 3 fundamental programming constructs
sequence
selection
iteration
what is selection and what code do you use
process of making a decision
if - always checked
elseif - only checked if previous conditions were false
else - no conditions and only checked if all previous conditions were false
during a switch case statement what do you use
switch == if
case
default =else
endswitch
option = input (“select option 1 or 2.”)
switch option:
case “1”:
print(“Welcome to the program.”)
lauchprogram()
case “2”:
settings()
default:
print(“goodbye”)
endswitch
when are switch case useful
where a variable determines the selection
what are count controlled loops
repeaats a set number of time
FOR loop
FOR i = 0 to 5 THEN
print (i)
next i
what is iteration
where code repreats
what is a condition controlled loop
WHILE loop - repeats until a condition is broken
DO UNTIL repeats until a condition is met
password = input(“PW: “)
while password != “123”
password = (“PW: “)
endwhile
what is a subprogram
out of line block of code
what must you do to a sub program
call it so it can be executed
procedure add(num1,num2)
sum = num1 + num 2
print(sum)
endprocedure
print(sum)
endprocedure
print(“welcome”)
add(10,15)
what must you do in a function
must return it
function add(num1,num2)
sum = num1 + num 2
print(sum)
return sum
endfunction
print(sum)
endfunction
print(“welcome”)
add(10,15)
what is a local variable
only exist when the sub program is executing
only accessible inside the subprogram
what is the difference between a function and a procedure
Procedure is a named set of instructions that be can be called upon throughout the code
A function is a procedure that returns a value
Give 4 ways to keep code maintainable
consistent naming convention
many subprograms
consistent indentation
use comments
what is a procedure
a sequence of instruction named by an identifier which can be called anywhere in the program
give two examples of substring handlaing
.substring(start, how many)
concatenation(+)
What are the similarities between a function and a procedure
They both take parameters