Course duration
- 4 days
Course Benefits
- How Python works.
- Python's place in the world of programming languages.
- Python literals.
- Python comments.
- Variables and Python data types.
- Simple modules.
- Outputting data with
print()
. - Collecting user input.
- Defining and calling functions.
- Parameters and arguments.
- Variable scope.
- Creating and importing modules.
- Math in Python.
- The
math
andrandom
modules. - String basics.
- Special characters.
- Multi-line strings.
- Indexing and slicing strings.
- Common string operators and methods.
- Formatting strings.
- Built-in string functions.
- Lists, tuples, ranges, dictionaries, and sets.
- The
*args
and**kwargs
parameters. - Virtual environments.
- Installing packages with
pip
. - Conditions and loops.
- Generator functions.
- List comprehensions.
- Exception handling.
- The time and datetime modules.
- Working with files and directories.
- Working with the
os
andos.path
modules. - PEP8 and Pylint.
Private classes are delivered for groups at your offices or a location of your choice.
Learn at your own pace with 24/7 access to an On-Demand course.
Course Outline
- Python Basics
- Getting Familiar with the Terminal
- Running Python
- Running a Python File
- Exercise: Hello, world!
- Literals
- Exercise: Exploring Types
- Variables
- Exercise: A Simple Python Script
- Constants and Deleting Variables
- Writing a Python Module
- print() Function
- Collecting User Input
- Exercise: Hello, You!
- Reading from and Writing to Files
- Exercise: Working with Files
- Functions and Modules
- Defining Functions
- Variable Scope
- Global Variables
- Function Parameters
- Exercise: A Function with Parameters
- Returning Values
- Exercise: Parameters with Default Values
- Returning Values
- Importing Modules
- Methods vs. Functions
- Math
- Arithmetic Operators
- Exercise: Floor and Modulus
- Assignment Operators
- Precedence of Operations
- Built-in Math Functions
- The math Module
- The random Module
- Exercise: How Many Pizzas Do We Need?
- Exercise: Dice Rolling
- Python Strings
- Quotation Marks and Special Characters
- String Indexing
- Exercise: Indexing Strings
- Slicing Strings
- Exercise: Slicing Strings
- Concatenation and Repetition
- Exercise: Repetition
- Combining Concatenation and Repetition
- Python Strings are Immutable
- Common String Methods
- String Formatting
- Exercise: Playing with Formatting
- Formatted String Literals (f-strings) (introduced in Python 3.6)
- Built-in String Functions
- Exercise: Outputting Tab-delimited Text
- Iterables: Sequences, Dictionaries, and Sets
- Definitions
- Sequences
- Lists
- Sequences and Random
- Exercise: Remove and Return Random Element
- Tuples
- Ranges
- Converting Sequences to Lists
- Indexing
- Exercise: Simple Rock, Paper, Scissors Game
- Slicing
- Exercise: Slicing Sequences
- min(), max(), and sum()
- Converting between Sequences and Strings
- Unpacking Sequences
- Dictionaries
- The len() Function
- Exercise: Creating a Dictionary from User Input
- Sets
- *args and **kwargs
- Virtual Environments, Packages, and pip
- Exercise: Creating, Activiting, Deactivating, and Deleting a Virtual Environment
- Packages with pip
- Exercise: Working with a Virtual Environment
- Flow Control
- Conditional Statements
- Compound Conditions
- The is and is not Operators
- all() and any() and the Ternary Operator
- In Between
- Loops in Python
- Exercise: All True and Any True
- break and continue
- Looping through Lines in a File
- Exercise: Word Guessing Game
- The else Clause in Loops
- Exercise: for...else
- The enumerate() Function
- Generators
- List Comprehensions
- Exception Handling
- Exception Basics
- Generic Exceptions
- Exercise: Raising Exceptions
- The else and finally Clauses
- Using Exceptions for Flow Control
- Exercise: Running Sum
- Raising Your Own Exceptions
- Python Dates and Times
- Understanding Time
- The time Module
- Time Structures
- Times as Strings
- Time and Formatted Strings
- Pausing Execution with time.sleep()
- The datetime Module
- datetime.datetime Objects
- Exercise: What Color Pants Should I Wear?
- datetime.timedelta Objects
- Exercise: Report on Departure Times
- File Processing
- Opening Files
- Exercise: Finding Text in a File
- Writing to Files
- Exercise: Writing to Files
- Exercise: List Creator
- The os Module
- os.walk()
- The os.path Module
- A Better Way to Open Files
- Exercise: Comparing Lists
- PEP8 and Pylint
- PEP8
- Pylint
Class Materials
Each student will receive a comprehensive set of materials, including course notes and all the class examples.
Experience in the following would be useful for this Python class:
- Some programming experience.
Instructor-led courses are offered via a live Web connection, at client sites throughout Europe, and at our Geneva Training Center.