HSMA - Programming in Python
Functions, Files and error Handling
29
Exercise: Functions
Attribution and Acknowledgements
How to use this book
An Optional Introduction to Programming Concepts
1
An Introduction to Programming Concepts
Setup for the HSMA Course - Using VSCode, Python and Anaconda
2
An Introduction to Setting Up the Required Software for Python Coding
3
The Terminal in VSCode
4
Creating Environments with Python
Your First Steps in Python
5
Intro to Python
6
Printing
7
Variables
8
Variables and Printing together - the fString
9
User Input and Changing Variable Types
10
Mathematical Operators
11
Exercise: 10 years forward
12
Additional Exercises and Resources - Your First Python
Your Next Python Skills
13
Comments
14
Conditional Logic
15
Exercise: Stepping Up
16
Additional Exercises and Resources - Conditional Logic
Loops, Lists and Dictionaries
17
Loops
18
Exercise: Loops
19
Lists
20
List Comprehensions
21
Dictionaries
22
Exercise: Lists and Dictionaries
23
Additional Exercises and Resources - Loops, Lists and Dictionaries
An Introduction to Libraries
24
Importing Packages
25
The Random Library
26
Exercise: Putting it all together
27
Exercise: Coding Challenge 1
Functions, Files and error Handling
28
Functions
29
Exercise: Functions
30
Exception (Error) Handling
31
File Handling
32
Exercise: Handling errors and files
33
Additional Exercises and Resources - Loops, Lists and Dictionaries
Numpy
34
An Introduction to NumPy
35
Using Numpy
36
Handy Numpy Features
37
Exercise: Numpy
38
Additional Exercises and Resources - Numpy
Pandas
39
An Introduction to Pandas
40
Selecting Rows and Columns in Pandas
41
Extending and Joining Dataframes
42
Dropping Data from Dataframes
43
Aggregating Data in Dataframes
44
Sorting, previewing and more with dataframes
45
Exercise: Pandas
46
Additional Exercises and Resources - Pandas
Object-Oriented Python
47
A recap of object oriented programming
48
An Introduction to Object Oriented Python
49
Inheritance
50
Reusability
51
Exercise: Classes
52
Additional Exercises and Resources - OOP
Graphs
53
An Introduction to Matplotlib
54
Chart types in matplotlib
55
Other Plotting Libraries
56
Cheatsheets
57
Further Reading
Table of contents
29.1
Sample Answers
29.2
Answer Video
Functions, Files and error Handling
29
Exercise: Functions
29
Exercise: Functions
Open this exercise in Google Colab:
29.1
Sample Answers
Click here to view the answers
Open exercise solutions in Google Colab:
29.2
Answer Video
Click here to view a video explaining the solution
29.3
Task 1
29.4
Task 2
28
Functions
30
Exception (Error) Handling