Chapter 1 - Algorithms Flashcards
What is an algorithm?
A step by step procedure for solving problems
What is a list algorithm?
Instructions written in order
What is an iteration
Repeating something a set number of tines or until a condition is met
What is a selection?
A choice or decision
What is a sequence?
A basic instruction
Is “tip 4 large eggs whites into a mixing bowl” a sequence iteration or selection?
Sequence because it is a basic instruction
Is “ keep beating until mixture stands up in stiff peaks” a sequence iteration or selection?
Selection and iteration because its a decision and is repeating until condition met
What is correctness?
How successful it solves the problem
What is efficiency?
How quickly it solves the problem
What is a flow diagram?
Instructions that are written in boxes connected with arrows and pseudo code, where the programmer prepares to write the final script in a code-like language.
What shape is start and end boxes?
An oval
What shape is the simple sequence instruction?
A rectangle
What shape is a user inputs and outputs in a flow diagram?
Rhombus
What shape is selections?
Diamond
Selections have what two options
Yes and no
An algorithm diagram is also called what?
Flow diagrams
What is a selection statement?
A decision is made, leading to one of 2 alternative actions
What is a process
The action that is taken as a result of a decision
What does authenticate mean?
Confirms that a users username and password match the data stored on record
What is a variable?
A container which is used to store data, e.g. numbers or text
What is a constant?
Data that does not change throughout the script
Example of camel-case?
boyAge
girlHeight
Example of Snake-Case
Boy_age
Girl_height
What are 2 variable identifiers?
Snake-case
Camel-case
What are 6 rules for identifiers?
-No spaces
-not start with number
-descriptive
-not too long
-not a keyword
-Camel-Case or Snake-Case
What is pseudo-code?
A language that is similar to a real programming language but is easier to understand. It allows you o plan your script and get the layout and structure right, before coding it for real.
What is an operand?
The data the operators work on
What is the operator?
The symbol that tells the computer what to do
What does + do?
Adds 2 numbers together
What does - do?
Subtracts 1 number from another
What does * do?
Multiplies 2 numbers together
What does / do?
Quotient - divide 1 number by another with decimal
What does // or DIV mean?
Quotient - divide 1 number by another ignoring decimal
What does MOD or % mean?
Modulus - the remainder when 1 number is divided by another
What does ^ or ** mean?
Power - 1 number to the power of another
What does = or == mean?
Checks to see if one operand is the same as another
What does != mean?
Checks to see if one operand is not the same as another
What does < mean
Checks to see if one operand is less than another.
What does > mean?
Checks to see if one operand is greater than another.
What does <= mean
Checks to see if one operand is less than or equal to another
What does >= mean?
Checks to see if one operand is greater than or equal to another
What does AND mean?
Checks to see if the first condition statement AND the second is true
What does or mean?
Checks to see if the first condition statement or second is true
What does Not or != mean?
Checks to see if a condition statement is NOT true
Give an example of relational operators
- = ==
- !=
- <
- >
- <=
- > =
Give an example of Boolean logic operators are
- AND
- or
- not
Give an example of Arithmetic operators
- +
- -
- *
- /
- DIV //
- MOD %
- ^ **