Revisiting Functions
Readings
- Think Python: Functions
- Automate the Boring Stuff: Functions – Stop reading at “Local and Global Scope”
- Learn Python: Functions – practice
Yes, you read these a couple weeks ago. Now that you’ve had some practice with functions, you will learn new things when you read these articles again. Functions are one of the most important concepts in programming. This time through, specifically focus on the ideas of “parameters” and “return values”.
Also read:
- Think Python: Fruitful Functions – Only read section 6.1 on return values
Summary
So far we’ve mainly used functions as a way to simplify code and to allow it to be easily repeated. We’ve also done a little bit with parameters. But functions can be more interesting than that. Not only can they accept parameters that change how the function works, but they can also return values. As you read about these features of functions, try to understand how you might use them.
Summary prompt: What is a return value from a function and when might you want to use one?
Question
As per usual, your question can be one of three types:
- Confusion: what didn’t you understand in the readings?
- Curiousity: what do you want to know more about?
- Connection: how does this topic connect to your own experiences?
Submit your summary+question on D2L under Quizzes before class starts on Tuesday.
NOTE: On Thursday, we’ll have a discussion at the beginning of class about jobs and job options. If you would like, you can write your question this week about jobs, and I’ll use them to start the discussion on Thursday. Or you can bring your question(s) to class on Thursday and ask then.