Answers.Body: <p>There are literally zillions of scenarios. Even before the loops are introduced. For example,</p>
  <ul>
  <li>Min, max, and clipping a value into an interval.</li>
  <li>Figure out whether a year is a leap one.</li>
  <li>Determine if a Queen attacks a given square.</li>
  <li>Solve the quadratic equation in reals (<code>if det &lt; 0:</code>).</li>
  <li>Calculate the value of a blackjack hand (an ace could be 1 or 11, your choice - just don't get busted if possible).</li>
  <li>Find the counterfeit coin with balance scales (you know those puzzles)</li>
  <li>Describe how to diagnose a network outage (is it the problem with your PC, the router, the  ISP, the backbone. or is it an Armageddon already?).</li>
  </ul>
  <p>The last two are nice examples of a problem where the flowchart is more relevant than the code.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-30T13:56:33.333Z
Answers.Text: Thanks! These are good. The quadratic equation will blend right in with our previous  exercises.
Answers.UserDisplayName: Vladimir
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-02T08:44:55.723Z
Answers.Text: @Vladimir If you decide to use solving a quadratic equation as an example, I would suggest to make sure to introduce the numerically advantageous way (e.g. along the lines of what I outlined [here](https://stackoverflow.com/questions/48979861/numerically-stable-method-for-solving-quadratic-equations/50065711#50065711), so as not to proliferate bad practices that one later finds deployed in real-life code. The other proposed exercises do not seem to carry such risk.
Answers.UserDisplayName: njuffa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-03T14:35:32.943Z
Answers.Text: Hi! They are mostly high-school so I'm first concerned about simple formula-code translation, grasping the intuition... I will mention that there are some quirks around floating points though. The previous exercise might be for example coding pythagoras theorem, prompting for whether one is looking for a hypotenuse or a hick.
Answers.UserDisplayName: Vladimir
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-28T23:24:56.583Z
Answers.LastActivityDate: 2021-11-28T23:24:56.583Z
Answers.UserDisplayName: user58697
Body: <p>I want to get my students to <strong>exercise</strong> the <strong>conditional-branching</strong> mind-muscle. [edit: and I need it to be <strong>fun/playful</strong>]</p>
  <p>I will ask them to read pseudo-code, then represent as a branching sketch[^1]. And vice-versa, go from illustration[^2] to pseudo-code.
  Then of course coding practice.</p>
  <p>I wonder whether other teachers have found preferred[^3] conditional-branching exercising scenarios.
  For &quot;scenarios&quot; I mean the stage-setting one does for an exercise to have meaning or sense beyond the pure technical ability. Real life scenarios are ok but magic fungi that split in half and multiply by two are also ok.</p>
  <p>Do you know any good conditional-branching exercising scenarios?
  [^4]</p>
  <p>I'm right now thinking for a second class' homework. My students at this point are just familiar with assignment, <code>ints</code> <code>strings</code> and <code>floats</code>, and printing and reading input... but of course I'm curious about any other that might have come to your mind.
  Third class is lists and loops. Language is python. This line is mostly anecdotic but could be relevant.</p>
  <p>Sincere thanks
  Let in the poetry
  I'm happy about finding this sx</p>
  <hr />
  <p>## 3/1 Update</p>
  <p>I am now thoroughly convinced that while loops fall into this class, as they are clearly conditional branching. In a longer course they might take a class on themselves, but since I've got eight classes I'd rather include them in this one and take the next one on for loops and lists than simple-mindedly slicing &quot;loops&quot; into its own class, as I feel somewhat inadequate to state that &quot;there are two kinds of loops...&quot; as I often read or hear.
  This opens a lot of room for creative exercise scenarios. For instance offering a recurring menu could lead to fun name-composing.
  Btw my students are high-schoolers mostly.</p>
  <hr />
  <p><em>[^1]: (with no enforced appearance conditions, like the non-cute rhombus and whatnot)</em></p>
  <p><em>[^2]: (patiently drawn by the writer)</em></p>
  <p><em>[^3]: (&quot;my lil battle horse&quot;)</em></p>
  <p><em>[^4]: (I hope you'll spare me asking subjective, since I come with so much joy for my students and passion for the trade)</em></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-20T23:27:45.650Z
Comments.Text: Have you considered implementing [Fizz Buzz](https://en.wikipedia.org/wiki/Fizz_buzz)? I have heard stories (possibly apocryphal) that some Silicon Valley companies use this as a quick check of an interview candidates' basic programming skills. Supposedly (!) more people struggle with this than one might naively assume.
Comments.UserDisplayName: njuffa
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-22T01:54:54.883Z
Comments.Text: Thank you this is a good one definitely
Comments.UserDisplayName: Vladimir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-22T01:57:42.547Z
Comments.Text: This brings nim to mind, perhaps for the quickests
Comments.UserDisplayName: Vladimir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-17T22:33:02.590Z
Comments.Text: Are use programming in assembler/machine code? If so, then in the implementation of a counting loop `repeat n times:`
Comments.UserDisplayName: ctrl-alt-delor
Tags: <student-motivation><introductory-lesson><exercises><branching>
Title: What are some good conditional branching excercise scenarios?
ThreadText: # What are some good conditional branching excercise scenarios?
  
  (Asked by: username_0 on 2021-11-20)
  
  I want to get my students to **exercise** the **conditional-branching** mind-muscle. [edit: and I need it to be **fun/playful**]
  
  I will ask them to read pseudo-code, then represent as a branching sketch[^1]. And vice-versa, go from illustration[^2] to pseudo-code.
  Then of course coding practice.
  
  I wonder whether other teachers have found preferred[^3] conditional-branching exercising scenarios.
  For "scenarios" I mean the stage-setting one does for an exercise to have meaning or sense beyond the pure technical ability. Real life scenarios are ok but magic fungi that split in half and multiply by two are also ok.
  
  Do you know any good conditional-branching exercising scenarios?
  [^4]
  
  I'm right now thinking for a second class' homework. My students at this point are just familiar with assignment, `ints` `strings` and `floats`, and printing and reading input... but of course I'm curious about any other that might have come to your mind.
  Third class is lists and loops. Language is python. This line is mostly anecdotic but could be relevant.
  
  Sincere thanks
  Let in the poetry
  I'm happy about finding this sx
  
  ---
  
  ## 3/1 Update
  
  I am now thoroughly convinced that while loops fall into this class, as they are clearly conditional branching. In a longer course they might take a class on themselves, but since I've got eight classes I'd rather include them in this one and take the next one on for loops and lists than simple-mindedly slicing "loops" into its own class, as I feel somewhat inadequate to state that "there are two kinds of loops..." as I often read or hear.
  This opens a lot of room for creative exercise scenarios. For instance offering a recurring menu could lead to fun name-composing.
  Btw my students are high-schoolers mostly.
  
  ---
  
  *[^1]: (with no enforced appearance conditions, like the non-cute rhombus and whatnot)*
  
  *[^2]: (patiently drawn by the writer)*
  
  *[^3]: ("my lil battle horse")*
  
  *[^4]: (I hope you'll spare me asking subjective, since I come with so much joy for my students and passion for the trade)*
  
  **Tags:** student-motivation, introductory-lesson, exercises, branching
  
  > **Comments:**
  > **username_1**: Have you considered implementing [Fizz Buzz](https://en.wikipedia.org/wiki/Fizz_buzz)? I have heard stories (possibly apocryphal) that some Silicon Valley companies use this as a quick check of an interview candidates' basic programming skills. Supposedly (!) more people struggle with this than one might naively assume.  
  > **username_0**: Thank you this is a good one definitely  
  > **username_0**: This brings nim to mind, perhaps for the quickests  
  > **username_2**: Are use programming in assembler/machine code? If so, then in the implementation of a counting loop `repeat n times:`  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2021-11-28. Score: 3 | Accepted answer
  
  There are literally zillions of scenarios. Even before the loops are introduced. For example,
  
  * Min, max, and clipping a value into an interval.
  * Figure out whether a year is a leap one.
  * Determine if a Queen attacks a given square.
  * Solve the quadratic equation in reals (`if det < 0:`).
  * Calculate the value of a blackjack hand (an ace could be 1 or 11, your choice - just don't get busted if possible).
  * Find the counterfeit coin with balance scales (you know those puzzles)
  * Describe how to diagnose a network outage (is it the problem with your PC, the router, the ISP, the backbone. or is it an Armageddon already?).
  
  The last two are nice examples of a problem where the flowchart is more relevant than the code.
  
  > **Comments:**
  > **username_0**: Thanks! These are good. The quadratic equation will blend right in with our previous  exercises.  
  > **username_1**: @username_0 If you decide to use solving a quadratic equation as an example, I would suggest to make sure to introduce the numerically advantageous way (e.g. along the lines of what I outlined [here](https://stackoverflow.com/questions/48979861/numerically-stable-method-for-solving-quadratic-equations/50065711#50065711), so as not to proliferate bad practices that one later finds deployed in real-life code. The other proposed exercises do not seem to carry such risk.  
  > **username_0**: Hi! They are mostly high-school so I'm first concerned about simple formula-code translation, grasping the intuition... I will mention that there are some quirks around floating points though. The previous exercise might be for example coding pythagoras theorem, prompting for whether one is looking for a hypotenuse or a hick.  
  
  ---
  
  