ISA 281
Exam 2 Review
Free Python Resources
This material is outside the course and will not be tested upon.
While it's not part of the course, Python for Data Analysis is a great resource for improving your programming skills(plus it’s Free !). It covers some essential Python libraries(Numpy, Pandas and Matplotlib) and I highly recommend reading it. Continuous learning is always better than sprint learning.
Feedback from last session
Agenda
Woohoo!!
How things will work
Slides
Practice Notebook
Slides and practice notebook cover the same topics in order. Make a copy of the exam1_review.ipynb from Canvas/Notion page.
Make a copy of this document
Make a copy of this document
Files > Save a copy in Drive
Collab Link available in Canvas/Notion under Exam Review
Disable Code Completions
Chapter 5
Some things before we begin
Functions
Default Functions
Default Arguments
10 x 10 = 100
5 x 10 = 50
5 x 5 = 25
Local Variables and Scope
Variable that is assigned a value inside a function
Scope: the part of a program in which a variable may be accessed
Scope
Out of Scope
Chapter 6
Opening Files
•open function: used to open a file
–Creates a file object and associates it with a file on the disk
–General format:
– file_object = open(filename, mode)
# Closing the file
file.close()
• close function - Closing a file in Python is important to release the resources tied with the file and to ensure that any changes made to it are properly saved.
with open("example.txt", "r") as file:
data = file.read()
Exceptions�
The try block lets you test a block of code for errors.
The except block lets you handle the error.
The else block lets you execute code when there is no error.
The finally block lets you execute code, regardless of the result of the try- and except blocks.
Pandas Slicing
df[ start:stop , start:stop ]
row
column
Chapter 7
A note on lists
Nvidia is the most valuable company in the world because their machines do Matrix Multiplications really really well.
Source: 3Blue1Brown
A note on lists
Lists
thislist = ["apple", "banana", "cherry"]
print(thislist)
Lists are used to store multiple items in a single variable.
list[start:stop:step]
Feedback