Sep 15: Variable Scope, Docstrings
Learning Objectives
After today's class, you should be able to:
- Explain the difference between global and local variables.
- Write a docstring for a function (following Google's Style).
- Use
help()
to explore modules and functions in a shell.
Announcements¶
- Due tomorrow
- Practice Quiz 2 on Wednesday
- Upcoming events
- Tue 9/16 at 5:30 in King 159: First-Year Kickoff
- Fri 9/19 at 11:30 in King 259: What is Research?
Return Examples¶
- Run in Python Tutor
[5 min]
returns.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
Bank of JMU Lab¶
Note
This lab includes topics from later weeks, such as lists and random numbers. We will walk through the lab as a class rather than work individually. If you are absent, please go to TA hours to get help with this lab.
Highlights:
- Thonny debugger's with functions
- Functions that modify parameters
- Writing docstrings for functions
- Using the built-in
help()
function