Introduction to Python
Duration
5 days
Description
The Introduction to Python Programming training course is for students new to Python or students whose use of Python is limited to data analysis with Jupyter Notebooks. This course is not about Jupyter Notebooks, but Jupyter Notebooks is used throughout most of the course since most students are familiar with the environment. For students unfamiliar with Python or Jupyter, Jupyter is an excellent tool to learn Python. Towards the end of the course, Python script programming with a text editor is explored. The course focuses on essential program concepts, syntax, and best practices.
Objectives
- Understand the essential concepts and practices of Python programming.
- Dive into Python syntax and coding styles.
- Discover what it means to be Pythonic and the Zen of Python.
- Learn to create Python environments, install packages, and run tools such as Jupyter Notebooks
- Explore how to write and debug Python scripts.
- Program with key data types, data structures, and control flow features.
- Organize code into functions and modules.
- Learn the basics of class and object-oriented programming.
Prerequisites
All students should have some experience with software development. This is not an introduction to programming class. Students should be familiar with common programming concepts such as variables, control flow, functions, arrays, etc.
Training Materials
All students receive comprehensive courseware covering all topics in the course. Courseware is distributed via GitHub in the form of documentation and extensive code samples. Students practice the topics covered through challenging hands-on lab exercises.
Software Requirements
Students will need a free, personal GitHub account to access the courseware. Students will need permission to install Python and Visual Studio Code on their computers. Also, students will need permission to install Python Packages and Visual Studio Extensions. If students are unable to configure a local environment, a cloud-based environment can be provided.
Outline
- Introduction
- Jupyter Notebooks
- Install Miniconda/Micromamba Python
- Install and Configure Jupyter Notebooks
- Run Jupyter Notebooks
- Edit and Run Cells
- Restarting the Kernel
- Configure Code Completion
- Debugging Python Code
- Python Language
- Brief History
- Compared to Other Languages
- Common Uses
- Pythonic Programming
- PEP-8
- Indented Code Blocks
- Types and Variables
- Static vs. Dynamic Typing
- Strong vs. Loose Typing
- Defining Variables
- Variable Scope
- Built-In
- Global
- Non-Local
- Local
- Naming Conventions
- Variable Metadata
- Type function
- Id function
- Control-Flow
- If-Elif-Else Statement
- Match Statement
- While Loop
- For-In Loop
- Break
- Continue
- Strings
- String Functions
- Formatting Strings
- Multiline Strings
- Raw Strings
- Numbers
- Int vs Float
- Common Math Operations
- Boolean
- Boolean Values
- Truthy/Falsy
- Comparison Expressions
- Sequence Types
- What is a Sequence Type?
- Mutable vs. Immutable Sequences
- List Type
- Create a List
- Add/Remove Items from the List
- List Functions
- Slicing a List
- Iterate over a List with Enumerate
- Using Map and Filter with List
- List Comprehensions
- Tuple Type
- Create a Tuple
- Tuples vs. Lists
- Unpacking a Tuple
- Range Type
- Start Index
- End Index
- Step Value
- Map Type
- What is a Map Type?
- Dictionary Type
- What is a key-value pair?
- Create a Dictionary
- Set a Value to a Key
- Retrieve a Value with a Key
- Handle a Key Error
- Dictionary Functions
- Iterate over a Dictionary
- Dates and Times
- Date Time Module
- Time Module
- Parsing Dates
- Formatting Dates
- Handling Time Zones
- Sorting
- In-Place Sorting
- Immutable Sorting
- Key Functions
- Functions
- What is a Function?
- Functions as Objects
- Global, Non-Local, and Local Variables
- Parameters
- Positional vs. Keyword Arguments
- Default Parameter Values
- Lambda Functions
- Generators
- Classes
- What is a Class?
- Define a Class
- Data Attributes
- Methods
- Basic Inheritance
- Comments
- Commenting Python Code
- Doc Strings
- Working with Data
- Opening and Closing Files
- Accessing Files through the Context Manager
- Download Data from an Http Server
- Read and Write CSV Files
- Read and Write JSON Files
- Programming Scripts
- Program and Run Python Scripts outside of Jupyter Notebooks
- Printing Data to the Console
- Reading Data from the Console
- Configure Visual Studio Code for Python
- Code Linters and Formatters
- Organize Code into Modules
- Conclusion