1. Android Mash presents a new type of event which you haven't encountered before. What is that new event? How often is it triggered? The new event encountered in this app is the timer. It is triggered every 1000 milliseconds (every 1 second).
2. Consider the apps you've developed so far. Can you list all the different events your apps have responded to? What other events do you think an app can respond to? Explore some of the components in App Inventor and see what event handlers they have. Events that my apps have respond to are clicking a button, moving a slider, shaking the accelerometer, speaking to activate the speech recognizer, clicking a list picker, taking a picture on a camera, making a selection from a list picker, tapping on a canvas, dragging on the canvas, tapping on an image sprite, initializing a screen, and having a timer go off. An app can also respond to using a location sensor and using a barcode scanner.
3. What are the advantages of writing procedures in programming? Consider the procedures you wrote for your Android Mash app. Procedures shorten code and make it easier to read. It reduces redundancies and if you make a mistake you only have to change the procedure, not every occurrence of the code in the procedure.
4.5 Coin Flip Simulation Reflections
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. (HINT: You may need to put together more than 1 if/else statement to do this.) -If chocolate is available -Then she gets chocolate -Else she get strawberry -If no strawberry -Then she gets vanilla
2. Give another example from real life where you use if/else logic to make a decision. If I am getting a bagel at Einstein's I get cinnamon sugar. If they are out of cinnamon sugar, I get an Asiago bagel.
3. What enables us to simulate coin flipping in this app is App Inventor’s random-integer block. These blocks constitute a model of randomness — an abstraction of real randomness such as really flipping a coin. How might we use the CoinFlip app test whether this is a good model of randomness? We could test it by doing 100 coin flips on multiple devices. If everybody gets 50/50 then it is not random, but if there are different results across the board then it is truly random.
4.6 Coin Flip Experiment Reflections
1. (POGIL) According to your results, does App Inventor's PRNG provide a good model of randomness? Yes, App Inventor's PRNG is a good model of randomness because it provides multiple results and is not always 50/50.
2. (POGIL) A friend claims that flipping a coin 100 times and finding that it comes up heads only 45% of the time shows that the coin is biased. How should you reply? You should reply telling them that it is random, thus it will not always be 50/50.
3. Because we are using a coin flip app, this experiment really tests only that App Inventor's random integer block generates a 1 around half the time. Is this a sufficient test for App Inventor's PRNG? What other experiments might you do to increase your confidence in App Inventor’s PRNG? You could do experiments with more than just two results, including an app that does a dice roll.
4.7 Pseudorandom Numbers
1.Consider the following Dilbert cartoon? Would it be possible for a PRNG to spit out 6 NINEs in a row? Yes, it would be possible, but it would be a very rare occurrence.
2. Are slot machines fair? Why or why not? Slot machines are fair in the sense that they are completely random.
3. Is it possible to devise a method that would allow you to win consistently on a slot machine? No, there is no way to consistently win without going into the computer and changing the PRNG formula.
4.9 Real World Models Reflections
1. What are the main differences between Bill Nye's solar system model and the Second Life model? Bill Nye's model focused on showing the distance between the planets while the second model focused on the orbits of the planets.
2. (POGIL) What would happen if there were lots more wolves than there are bunnies? Would the wolves live forever? Record your hypothesis, prediction and experiment results. If there are more wolves than bunnies, the wolves will kill off the bunnies and then die off due to a lack of food.
4.10 Inside the CPU Reflections
1.Which generation of the 4-bit simulators above is the most abstract? Why? Generation 2 is the most abstract because it substitutes machine language with assembly language, symbolic names for instructions and data.
2. Explain the purpose or function of the RAM and the CPU. The RAM stores data, the CPU executes the stored data.
3. Describe in your own words the difference between the fetch and execute steps. The fetch command loads procedures for the CPU to do, while the execute command actually causes the CPU to perform those procedures.
4. Summarize the differences between assembly language and machine language programming. Assembly language is abstract and uses English characters to represent binary digits, while machine language is composed of binary digits.