Week 8
Conditional Execution

Weekly Summary

How do you write programs when you need to do different things in different situations? The answer is, you use conditionals.

Recall from our prior Scratch Unit that we defined conditionals as:

This week we will begin to consider programs that use conditional statements to modify how code behaves.

 

Learning Outcomes

By the end of the week students should be able to:

  • Reading Code
    • Given a Boolean expression using one of the six Boolean operators (<, <=, >, >=, == or !=), indicate the evaluated output (True or False).
    • Given a compound Boolean expression (one that includes one or more of AND, OR, or NOT, indicate the evaluated output (True or False).
    • Explain the difference in Python between = and ==.
    • Given a small script (including data with values) containing an if statement, indicate the output of the script.
    • Given a small script containing an if/else statement, indicate the output of the script.
    • Given a small script containing an if/else statement with one or more elif statements, indicate the output of the script.
  • Writing Code
    • Given an IPO problem statement that includes conditionals (if, if/else and if/elif/else statements), write the python code that will solve the problem.
  • Debugging Code
    • Given a problem statement and a non-working program that attempts to solve the problem, identify where the code is incorrect and explain how to fix it.

 

Learning Materials

Paired or Small-group Activity

If we were working in a face-to-face classroom I would have you complete the following POGIL activity in groups of 3 or 4 [which is the intention of POGIL activities]. Since we are not face-to-face I give you the option of either:

  • completing this on your own
  • completing this face-to-face with a small group of peers
  • completing this online with a small group of peers

The choice is yours and you don't have to tell me (because I'm not collecting this activity. It's for learning purposes, not grading purposes).

 

 

Textbook Readings

 

Working with Problems that use Conditionals

 

Paired Programming Activity

Please complete the following Paired Programming activity with your assigned partner for the week.

 

Additional Explanations

Think of the following a little bit like podcasts. I will add videos here as I get questions from students or when I decide that I need to say something more beyond what is in the book. These won't "drop" on a particular day like the podcasts did in FCCS but will get added as the need arises. I would suggest you watch this space to see if new stuff has shown up. And if you have questions and feel there is a video that needs to go here PLEASE email me and let me know.

 

Additional Practice

The following problems are entirely optional but are provided here to give you some additional practice if you are interested. You should complete these on your own rather than with a partner.

 

Code Walkthroughs

The following are videos and code solutions for the programs discussed in the Paired Programming Activity. You SHOULD NOT view these until you have either solved the activities yourself - and you want to see how I would do it - or you have tried at least two different times and still are stumped. Don't jump to reading the "correct answer" too quickly. I think it is a GOOD thing to struggle with a problem for a day or two. We improve when we meet and overcome resistance. Learning comes from practice. You need to TRY before jumping to the solutions.

 

Graded Practice

The following programs are formally graded as part of the Unit 2 "Problem Set." You should work on these only as an individual. While working on these problems you may refer to your notes, your textbook, any programs you wrote, and even my videos. However, you should limit your discussion of these programs with classmates. It is acceptable to discuss how you solved a problem in grand scheme of things, but you should never show your code to a classmate either as the person who is struggling or as the person who is helping a struggling classmate. You can talk ideas, but not specific solutions.