Using blocks to start coding these two conditionals as currently written, might look like this: let CoinAHeads = false It can also help them to visualize and recognize the big picture of their code as well as the details. Visualizing the blocks as they pseudocode can help them with the logical steps of their program. As they think through their algorithms, they may even have started to visualize the blocks they might use. The students are by now familiar with the MakeCode blocks. Note: Just as you do for math expressions with multiple operators, use parentheses to make it clear how the conditions and statements are grouped together. If (Coin A is true AND Coin B is false) OR (Coin A is false AND Coin B is true), add one to Player B score.If (Coin A is true AND Coin B is true) OR (Coin A is false AND Coin B is false), add one to Player A score.Give the students a chance to work this out on their own.Ĭombining the conditions in which each player wins, gives us: Do the same for both conditions in which Player B scores a point. True False If Coin A is true AND Coin B is false, add one to Player B scoreįalse True If Coin A is false AND Coin B is true, add one to Player B scoreįalse False If Coin A is false AND Coin B is false, add one to Player A scoreĬan we make this code more efficient? Can we combine any of these lines? Try using an OR to combine both conditions in which Player A scores a point. True True If Coin A is true AND Coin B is true, add one to Player A score We’ll use it to help us pseudocode our program, by adding a third column describing the results of each outcome. In the study of logic, this is known as a truth table. Have the students copy their Heads/Tails table of possible outcomes, but label the columns “Coin A Heads” and “Coin B Heads” and replace each entry of ‘Heads’ with ‘True’ and ‘Tails’ with ‘False’. Note: Tails = False can also be thought of as Tails = not true. We can create a Boolean variable to represent whether an outcome is heads or tails. How would you represent each of the 4 different possible double coin flip outcomes? So, what does this have to do Boolean variables and operators? Think about how you would code a program a double coin flipper. Just for fun, have them play to a certain total number of rounds. Have students flip their coins together, keeping track of the outcomes, perhaps by adding another column to their table. Students will usually see that this is a fair system. If Person A’s coin flips to heads, she would win if Person B also flipped heads, but lose if Person B flipped tails. With this system, no one person’s outcome, heads or tails, guarantees a win. Therefore, if Person A wins each time the outcomes are the same and Person B wins each time the outcomes are different, both have an equal chance of winning each double coin flip. Both outcomes, coins the same/coins are different have a 2 in 4 or 50% chance of occurring. So, if 2 coins are flipped, the chance that the outcomes will be the same (HH/TT) is equal to the chance that the outcomes will be different (HT/TH). For the other 2 outcomes, the result for each coin is different, heads/tails and tails/heads.For 2 outcomes, the result is the same for both coins, both heads or both tails.Working in pairs, have the students make a table or list of the possible outcomes if each student flipped a coin at the same time. In a double coin toss, both people have a coin and they flip the coins at the same time. Who gets to flip the coin? Who gets to ‘call’ it? What if it’s a ‘faulty’ coin? What’s a common issue with coin tosses? Students may bring up issues of trust and fairness. When you flip a coin the outcome is random. When you flip a coin to decide something there are only two possible outcomes, heads or tails. Who goes first in a game, to break a tie, to decide which activity to do…Ī simple penny is the most common binary decision making tool ever! Most students have used a penny to decide something. Materials: A penny for each student, paper and pencils
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |