<aside> ‼️ RC Cola is having a promotional contest in order to make a comeback in the soda industry!
They label numbers on the bottom of each soda cap from 1-6. If you happen to get a bottle with the number ‘6’ on it, you win the prize.
This is a prize you NEED: Guaranteed admission to your dream college, a brand new green screen, a new shiny convertible..
You’ve completely lost your mind!! You keep buying sodas until you’ve bought a soda with a ‘6’ on the cap. You go up to an infinite RC Cola machine and do just that. Buy a soda, check the number.. 3? Buy a soda, check the cap to see if it’s a 6... 1? Buy a soda, check the cap to see if it’s a 6–—yes! Out of excitement, you scream out how many bottles you bought in total.
Now suppose 10,000 people line up behind you because they also want this prize. Every one is waiting in this line so that they can do the exact same thing.
Shirley really wants a brand new convertible, but she disgusted at the thought of having to buy any off brand of Coca Cola 🤮. To see how many sodas she'll likely end up buying, she wants to collect data to see which number was most likely to be shouted. She stands next to the RC Cola machine with a clipboard and makes a list of the numbers that people are shouting.
One thing I see different is the value of
winner?, which is set to false. Previously, we've worked primarily with variables that were numbers (num-people, forest-density, money, ...). We've also seen a data type called a string, which is mostly used for "text-based" data (ie
set name "Shirley" or
set shape "person").
false is another kind of data type, called a boolean. A number can take in any...number from -2 billion to 2 billion, a string can take any "string" of letters or characters, a boolean can take in true or false.
So things like
color = green,
money > 100, ... We've seen these all over the place! They're essential to our if and ifelse statements.
Upon each iteration of
go, ask turtles to...