DSCI011ProgramminginPythonforDataScience

Module 6: Functions Fundamentals and Best Practices

In this module, you will expand your knowledge on the concept of functions that were introduced in Module 5. This module covers how to develop good habits when writing functions like including docstrings, defensive programming, test-driven development and how to compose useful functions.

0Module Learning Outcomes

1DRY Revisited and Function Fundamentals

2Questions on Scoping

3Side Effects

4Writing Functions Without Side Effects

5Default Arguments

6Will it Output?

7Default Arguments

8Default Argument Practice

9Function Docstrings

10Docstring Questions

11Which Docstring is Most Appropriate?

12Practice Writing a Docstring

13Defensive Programming using Exceptions

14Exceptions

15Documenting Exceptions

16Raising Exceptions

17Unit tests and Corner Cases

18Assert Questions

19Unit Tests Questions

20Unit Tests and Test-Driven Development Questions

21Writing Tests

22Good Function Design Choices

23Function Design Questions

24Improve it!

25Function Design

26What Did We Just Learn?

About this course

Basic programming in Python. Overview of iteration and flow control and data types relevant to data exploration and analysis. When and how to exploit pre-existing libraries. Numerical data types with Numpy and tabular data with Pandas.

About the program

The University of British Columbia (UBC) is a comprehensive research-intensive university, consistently ranked among the 40 best universities in the world. The MDS Mid Career Learners program was launched in September 2020 and is offered by the MDS program who are a collaboration between the UBC Department of Computer Science and Department of Statistics.