Welcome to the third of Altitude Foundation’s #MicroChallenges2020
In our third challenge, you will use conditional statements to create multiple outputs – and make a weekend activity planner!
What’s a Micro Challenge?
These challenges are short activities to help you develop, revise or refresh your coding skills, posted every Monday, Wednesday and Friday (although we’re posting this challenge a day early in light of the bank holiday).
Micro Challenge #3
For our slightly longer Friday challenge, we’re going to expand on our sequencing skills (and explore probability!) by using conditional statements to create multiple outputs – and possibly creating a weekend activity planner!
This is another challenge that uses a paper fortune teller as its ‘computer’, so check out yesterday’s challenge to find out how to make one.
Conditional statements are sometimes called ‘if/then’ statements, so for example:
- IF P1=rock AND P2=paper THEN P2=winner!
- IF P1=rock AND P3=scissors THEN P1=winner!
- IF P2=paper AND P3=scissors THEN P3=winner!
However, we could also write the last line as:
- ELSE P3=winner
We can do this because if we’ve already described the other two outcomes, there is only one outcome left – and so we don’t have to describe the process leading to the outcome.
The fortune teller is a useful tool for exploring conditionals in a number of ways. You can use it to tell stories, plan revision, or decide on chores. There are a number of routes to each outcome which can be written up as conditionals, for example:
- IF purple and two THEN ‘doing the washing up’
- IF purple and four THEN ‘make a family member a cup of tea’
This weekend, we would like you to create fortune tellers and write up the conditionals which generate each outcome. Think about what comes first; this is important for the fortune teller model, because your combinations will always start on the outer layer.
Bonus: You can create a micro:bit version of the outcome generator. Using their tutorial for Rock/Paper/Scissor micro:bit code, could you adapt this to your purpose?
Once you’ve completed the challenge, review it:
— How many possible routes are there to the same output? Why might this be?
— If you did yesterday’s challenge, contrast the two programmes: what are the differences between the codes?
— In what other circumstances might you use conditionals?
We would love to see what you have created! Please send any pictures, videos, or files of your activities to us – either via Facebook, Twitter or Instagram using #MicroChallenges2020 or to email@example.com. If you are emailing them to us, please let us know if you are happy for us to share your stuff on our social media platforms (with credit, of course).
Sign-up here to receive a weekly email with Micro Challenges top tips and solutions: