Functions

Ha Khanh Nguyen (hknguyen)

1. What is a Function?

1.1 Defining a function vs. A function call?

2. Function Properties

2.1 Namespaces, scope, and local functions

2.2 Returning multiple values

2.3 Anonymous (labmda) functions

3. Exercise

Write a function to test if x and y (the input) are relatively primes. Return True if x and y are relatively primes, False otherwise.

For example, 6 and 35 are relatively primes.

Notes: I made a mistake in the video. In the for loop, i should go from 2 to min(x, y). So, the range() function should be range(2, min(x, y) + 1.

The correct solution is shown below:

This lecture notes referenced materials from Chapter 3 of Wes McKinney's Python for Data Analysis 2nd Ed.