Schedule > 3. Introduction to Functions
The next two lessons will primarily be dedicated to functions. In this lesson, we will review several different concepts. First, we will go over how to use the command line in order to run our Python files. Next, we will introduce two new data types in the “sequence family” – lists and tuples – which we will use in HW2 and in this week’s tutorial. Finally, we will introduce functions, including some basic terminology and why they are useful. We’ll also take a look at some examples of how to use built-in functions. In the next lesson (Lesson 4), we will practice building our own functions and modules.
This week’s tutorial (Tutorial 1) and homework (Homework 2) will be based on content reviewd in this lesson and the next one. You are strongly encouraged to review the content in these lessons before trying the tutorial/homework.
Please Complete the Following Tasks
1. Download the Exercise Files
Exercise Files2. Review the Slides
3. Watch the Lecture Video(s)
Link | Title | Type | Duration |
---|---|---|---|
Video 1 | Demo: Working with the Command Line | pre-recorded | 12:40 |
Video 2 | Demo: 3 Ways to Execute Python | pre-recorded | 05:59 |
Video 3 | Lists & Tuples | pre-recorded | 10:16 |
Video 4 | Expressions & Intro to Functions | pre-recorded | 10:33 |
Video 5 | More Function Rules | pre-recorded | 11:22 |
Video 6 | Built-In Functions | pre-recorded | 09:24 |
Video 7 | Practice with Built-In Functions | lecture | 01:33:20 |
4. Review / Study the Supplemental Materials
Note: these readings / videos are suggested for additional context / examples, but not required.
-
Severance
Ch4: Functions.
reading • video - Heinold Ch4: Functions.
-
Heinold
Ch12: Modules.
Skim sections 12.1 through 12.4.
5. Review the command line Cheatsheet
For your convenience, we have made you a little cheatsheet to help you get familiar with the command line. Django Girls is a good resource. Note: you will not be tested on this or anything, but navigating the command line can be useful.
DOS (Windows) | Shell (Mac / Linux) | |
---|---|---|
What directory am I in? | > cd |
$ pwd |
Change directories | > cd |
$ cd |
List files & directories | > dir > tree # lists subdirectories |
$ ls $ ls -l |
Navigate to parent directory | > cd .. |
$ cd .. |
Navigate into child directory | > cd cs110 |
$ cd cs110 |
Navigate into descendant directory | > cd lectures\lecture_03 |
$ cd lectures/lecture_03 |
Navigate to sibling directory | > cd ..\lecture_02 |
$ cd ../lecture_02 |
Navigate to ancestor directory | > cd ..\..\ |
$ cd ../../ |
Navigate to home directory | $ cd |
|
Command history | > doskey /HISTORY |
$ history |
Other optional commands you may find useful…
DOS (Windows) | Shell (Mac / Linux) | |
---|---|---|
Create a new file | > echo . > my_file.txt |
$ echo . > my_file.txt $ touch my_file.txt |
Append to a file | > echo "some text" >> my_file.txt |
$ echo "some text" > my_file.txt |
Save history to a file | > doskey /HISTORY > my_history.txt |
$ history > my_history.txt |
Move a file | > move my_history.txt Documents/. |
$ mv my_history.txt Documents/. |
Make a folder | > mkdir my_folder |
$ mkdir my_folder |
Delete a file | > del my_history.txt |
$ rm my_history.txt |
Delete a folder | > rmdir my_folder |
$ rm -r my_folder |