Repeat Actions and Test for Conditions
Boolean variable
Can be assigned one or two possible values, true or false
For loop
Contains three parts: an iterative (i) variable, a conditional test, and an iterative stop. This is a good option if you have a set condition or number of times you need a loop to repeat. It is also possible to nest loops inside each other
GPS sensors
Detect location
Accelerometer
Detects motion
Barometer
Detects pressure and altitude
What are the three ways to modify/change an array?
1. Access a specific item - using its element index number, change the value that is stored within it. 2. Add items - you can add an item to the end by pushing an item to the end of the array. 3. Shorten the array - section off or splice away the section you want to keep
Array
A group of individual values referred to using a single name. Each value can be referred to using a unique integer as the element index
Which logical operator would you use to evaluate if two tests are both true?
AND
What cannot be used to create a Boolean value?
An integer
While loop
At the top you ask a question as a conditional statement that evaluates as either true or false. If true, the loop will run. If false, the loop will stop
Equality operators
Give you a true or false answer. There are 6 to choose from: values are equal (==); one value is not equal (!=); one value is greater than (>); one value is greater than or equal to (>=); one value is less than (<); one value is less than or equal to (<=)
AND Logical Operator
If A is true and B is true, then it is true
OR Logical operator
If A is true or B is true, then it is true
Do while loop
Instead of testing the condition first, it tests it last. This way the loop is ran at least once
What is the phrase used to refer to the number of items in an array?
Length
User input
Not automatic, you as the programmer define how the user and program work together
What problems can an infinite loop cause?
Program to crash, run out of memory, or generate multiple errors that prevent the program running correctly
NOT operator
Reverses the Boolean value, so not true is false and not false is true
Synchronous input
Some inputs happen while the program runs. The programming and input capturing happen in parallel
If I have an array with the values 23, 55, 16; to splice off the 55 & 16, what two numbers do I need to know?
Start index: 1; number of items: 2
Asynchronous input
The program stops and waits for you to provide input to contine
Conditional
Using a conditional, the programmer can define a limit to the number of times a loop runs
Loops
Ways a programmer can take a section of code and have a program run them multiple times
Infinite loop
When there are conditions that are always true, your program could be stuck in an infinite loop
What is the first element index in an array?
Zero