Week 10
More Functions
Weekly Summary
Last week we introduced functions
All of the code we wrote last week was taking code we had already written as basic IPO problems and converting it to functions. This week we will practice more with functions but we will work with entirely new examples.
Learning Outcomes
By the end of the week students should be able to:
- Reading Code
- Given an existing function, and a set of input parameters to that function, identify the output returned by the function.
- Writing Code
- Given a problem statement that includes the name of a function and the parameters required by that function, write the Python code/definition of the provided function such that it solves the problem by returning correct output values.
- For now, functions will be limited to those using
- Mathematical Operators
- Boolean Operators
- Conditional Expressions
- For now, functions will be limited to those using
- Given a problem statement that includes the name of a function and the parameters required by that function, write the Python code/definition of the provided function such that it solves the problem by returning correct output values.
- Debugging Code
- Given a problem statement and a non-working Python function that attempts to solve the problem, identify where the function is incorrect and explain how to fix it.
Learning Materials
Writing some new functions
- VIDEO - Is a right triangle?, version 1
- VIDEO - Is a right triangle?, version 2
- VIDEO - Is a right triangle?, version 3
- VIDEO - When is Easter?
- Here is the website that explains the "rules" for Easter
- VIDEO - What color is the square?
- Here is the website that explains the "rules" for the colors on a chess board
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
If you want to get some more practice with this material I encourage you to utilize the features in your textbook.
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.
- Func 5 - windchill()
- Func 6 - fahrToCel()
- Func 7 - carFee()
- Func 8 - taxesOwed()
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.
- Graded Functions problem set, part 2 (part of the Unit 2 Problem Set).