Week 7
Working with IPO Problems
Weekly Summary
This week we will be looking at how we take the various mathematical expressions, variable assignment statements, and print statements that we learned about last week, and putting them together in small algorithms/programs (often referred to as "scripts" in the Python community).
Recall from our prior Scratch Unit that we defined algorithms and programs as:
One of the easiest types of algorithms to look at when we are just starting with Python is the concept of IPO Problems. IPO stands for:
- Input
- Process
- Output
As the name implies, these are basic problems that
- asks the human user for some input
- performs some processing on that input to calculate a result
- displays or outputs that result back to the human user
They tend to be relatively trivial and "simple" problems. But they are a great place for us to get started understanding how individual python statements/expressions can be put together to solve a task (an "algorithm" or "program").
Learning Outcomes
By the end of the week students should be able to:
- Reading Code
- Given a sequence of code using input statements, mathematical expressions, and print statements (IPO problem), determine the results of executing the code.
- Given a problem statement and several segments of code, identify which segment will solve the problem statement.
- Writing Code
- Given an IPO problem statement, 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
Explaining the weekly format for the next few weeks
Getting Started with IPO Problems
- VIDEO: Downloading rectangle.py
- CODE: rectangle.py
- VIDEO: Rectangle - A sample IPO Problem
- ACTIVITY: Writing a python program - paycheck.py
- CODE: End Result (paycheck.py)
- VIDEO: Introduction - How fast are they actually running?
- VIDEO: Input and starting processing by converting Minutes and Seconds to just seconds
- VIDEO: How to make Unit Conversions (If you understand the math in converting meters/seconds to miles/hour you can skip this.)
- VIDEO: Finishing our code - displaying the output
- CODE: End Result
- VIDEO: Using the round() function to clean up SOME of your results. *
Textbook Readings
- Log on to your online textbook
- Read the following sections from your textbook
- 3.1. How to be a Successful Programmer
- 3.2. How to Avoid Debugging
- 3.3. Beginning tips for Debugging
- 3.4. Know Your Error Messages
- These are explicitly linked here so that if you want to look up an error in the future it is a quick jump.
- 3.4.1. ParseError
- 3.4.2. TypeError
- 3.4.3. NameError
- 3.4.4. ValueError
- 3.5. Summary
The Use of AI in computer program
- Review the section titled "Artificial Intelligence Statement" from the syllabus
- VIDEO: Why you shouldn't use ChatGPT in this course
Paired Programming Activity
Please complete the following Paired Programming activity with your assigned partner for the week.
- VIDEO: How to use Replit to Paired Program and test your code
- ACTIVITY: IPO Paired Programing Activity
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 and Individual Program 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.
- IPO 1 Discount Price
- IPO 2 How Far
- IPO 3 Time left to our destination
- IPO 4 Area inside of a racetrack
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 the 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.
- VIDEO: How to use Thonny and Autolab to submit and test your graded activities.
- ACTIVITY: Graded IPO problem set (part of the Unit 2 Problem Set).