logo_ds

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

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

Learn the fundamentals of programming in Python, including how to clean, filter, arrange, aggregate and transform data. You will learn the foundations of programming in Python while writing human-readable code that sets a foundation of best practices and coding style. You will gain the skills to clean, filter, manipulate (wrangle) and summarize data using Python libraries for more effective data analysis. An overview of data structures, iteration, flow control and program design relevant to data exploration and analysis will be addressed along with fundamental programming concepts such as loops, conditionals and data structures that create a solid foundation in data science programming.

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 Key Capabilities in Data Science program was launched in September 2020 and is developed and taught by many of the same instructors as the UBC Master of Data Science program.