Answer the following questions:
1. Write an if/else statement to express the following real life situation. Mary likes ice cream and always chooses chocolate unless there is no chocolate in which case she chooses strawberry. But if there’s no strawberry either then she settles for vanilla, which, for some reason, is always available.
Answer
If flavorchocolate = true
Set choice = chocolate
Else if flavorstrawberry = true
Set choice = strawberry
Else if flavorvanilla = true
Set choice = vanilla
2. We didn’t need it for the loop in this lesson, but the number element in the For each number loop is a local variable whose value changes automatically on each iteration of the loop. For example, in this loop number would start at 1 and then go to 2, 3 and 4. And this value can be used in the body of the loop, as shown in this example. Given that, trace through this loop and figure out what value global sum would have when the loop finishes.
Answer
For each number, set global sum to global sum + number. 1+2+3+4=10
3. App Inventor’s random-integer block is an abstract model of randomness -- i.e., an abstraction of real randomness such as flipping a real coin. What would you say about the random-integer block if you ran the coin flipping simulation 10,000 times and the result was that it came up heads 55% of the time?
Answer
If this happened, then i would say that the random integer clock is a good representation of true randomness. In real life, such as flipping a real coin, the number of heads and tails will not always be 50-50. If the appinventor integer block got heads 55% of the time, it reflects real life randomness well.