Teach Yourself VISUALLY Python

Book description

A simple, straightforward, and hands-on roadmap to the world of computer programming with Python

Teach Yourself VISUALLY: Python is your personal guide to getting you started in programming. As one of the world's most popular—and most accessible—coding languages, Python is your gateway into the wide and wonderful world of computer science. This hands-on guide walks you through Python step by clearly illustrated step, from writing your very first Python code in a terminal window or the VS Code app through to creating your own lists, dictionaries, and custom classes.

In the book, you’ll learn to:

  • Install Python and the tools you need to work with it on Windows, macOS, and Linux
  • Work with files and folders, manipulate text, and create powerful functions that do exactly what you want
  • Write clean code that makes decisions effectively, repeats actions as needed, and handles any errors that occur

A must-have resource for aspiring programmers starting from the very beginning, Teach Yourself VISUALLY: Python is also an indispensable handbook for programmers making a transition from another language.

Table of contents

  1. Cover
  2. Title Page
  3. Copyright
  4. Chapter 1: Getting Ready to Work with Python
    1. Understanding What Python Is and Does
    2. Choose the Right Version of Python
    3. Install Python on Windows
    4. Install Python on the Mac
    5. Install Python on Linux If Necessary
    6. Learn About Development Tools for Python
    7. Download and Install Visual Studio Code
    8. Get Started with Visual Studio Code and Apply a Theme
    9. Install Visual Studio Code Extensions for Python
    10. Configure Visual Studio Code for Working with Python
  5. Chapter 2: Writing and Running Your First Python Code
    1. Understanding the main() Function
    2. Create and Save a New Script in Visual Studio Code
    3. Write and Run Code in Visual Studio Code
    4. Execute Python Commands in a Terminal Window
    5. Run a Python Script in a Terminal Window
    6. Understanding Comments in Python
    7. Add Comments to Your Code
    8. Grasp Importing Modules and Objects
    9. Import Modules and Use Their Methods
  6. Chapter 3: Getting Started with Variables
    1. Understanding Variables and Their Usage
    2. Understanding Python’s Data Types
    3. Work with Integers
    4. Work with Floating-Point Values
    5. Work with Boolean Values
    6. Work with Tuples
    7. Work with Sets
    8. Start Working with Strings
    9. Start Working with Lists
    10. Start Working with Dictionaries
    11. Convert Data from One Type to Another
  7. Chapter 4: Working with Files and Directories
    1. Understanding Working with Files and Directories
    2. Load the os Module and List Files and Directories
    3. Navigate Among Directories
    4. Create and Delete Directories
    5. Rename, Move, and Copy Files and Directories
    6. Get Information About the User and System
    7. Split a File Path into Its Components
    8. Understanding Python’s open() Function
    9. Understanding Python’s Ways of Closing Files
    10. Open a File If It Exists; If Not, Create It
    11. Check an Open File’s Status and Close It
    12. Write Data to a File
    13. Open a File for Both Reading and Writing
    14. Append Data to a File
    15. Read a Text File
  8. Chapter 5: Working with Python’s Operators
    1. Meet the Arithmetic Operators
    2. Work with the Arithmetic Operators
    3. Meet the Assignment Operators
    4. Work with the Assignment Operators
    5. Meet the Comparison Operators
    6. Work with the Comparison Operators
    7. Meet the Logical Operators
    8. Work with the Logical Operators
    9. Meet the Identity Operators
    10. Work with the Identity Operators
    11. Meet the Membership Operators
    12. Work with the Membership Operators
    13. Meet the Bitwise Operators
    14. Work with the Bitwise Operators
  9. Chapter 6: Making Decisions with if Statements
    1. Learn the Essentials of if Statements
    2. Understanding the if Statement
    3. Create an if Statement
    4. Understanding the if… else Statement
    5. Create an if… else Statement
    6. Understanding the if… elif Statement
    7. Create an if… elif Statement
    8. Understanding the if… elif… else Statement
    9. Create an if… elif… else Statement
    10. Understanding Nested if Statements
    11. Create Nested if Statements
  10. Chapter 7: Repeating Actions with Loops
    1. Understanding Python’s Loops
    2. Understanding How for Loops Work
    3. Create for Loops
    4. Understanding How while Loops Work
    5. Create while Loops
    6. Understanding break Statements in Loops
    7. Using a break Statement to Exit a Loop Early
    8. Understanding continue Statements in Loops
    9. Using a continue Statement in a Loop
    10. Understanding else Statements in Loops
    11. Using an else Statement in a Loop
    12. Understanding Loop Nesting
    13. Nest Loops to Create Complex Repetition
  11. Chapter 8: Working with Functions
    1. Understanding Functions and Their Syntax
    2. Understanding Function Parameters and Returns
    3. Using Python’s Built-In Functions
    4. Create a Function with Parameters and a Return
    5. Create a Function with a Parameter But No Return
    6. Create a Function with No Parameters But a Return
    7. Create a Function with No Parameters and No Return
    8. Create a Function That Returns Multiple Values
    9. Create a Function with Optional Parameters
  12. Chapter 9: Working with Text
    1. Learn the Essentials of Strings
    2. Create Single-Line Strings
    3. Create Multiline Strings
    4. Meet Python’s String Methods
    5. Return Information About a String
    6. Transform and Clean Up a String
    7. Return Part of a String via Slicing
    8. Concatenate and Repeat Strings
    9. Search for One String Inside Another String
    10. Check and Change String Capitalization
    11. Meet Python’s Tools for Building Strings
    12. Build Strings with the Interpolation Operator
    13. Build Strings with the .format Method
    14. Build Strings with f-Strings
    15. Build Strings with Template Strings
  13. Chapter 10: Handling Errors
    1. Understanding the Various Types of Errors
    2. Identify Common Python Errors
    3. Meet the try… except Block
    4. Cause Errors and Trap Exceptions
    5. Raise an Exception Manually
    6. Add an else Block or a finally Block
    7. Create Nested try… except Blocks
    8. Create Custom Exceptions
  14. Chapter 11: Working with Lists and Dictionaries
    1. Understanding Lists and Their Use
    2. Create a List
    3. Meet Python’s List Methods
    4. Add Items to a List
    5. Remove Items from a List
    6. Locate Items and Access Data in a List
    7. Sort the Items in a List
    8. Understanding Dictionaries and Their Use
    9. Create a Dictionary and Return Values
    10. Meet Python’s Dictionary Methods
    11. Create a Dictionary from an Existing Iterable
    12. Add Key/Value Pairs to a Dictionary
    13. Remove Key/Value Pairs from a Dictionary
    14. Return Keys and Values from a Dictionary
  15. Chapter 12: Working with Classes
    1. Understanding Classes and Instances
    2. Create a Class and Instantiate Instances
    3. Understanding Class and Instance Attributes
    4. Set Class and Instance Attributes
    5. Grasp Class, Instance, and Static Methods
    6. Create an Instance Method
    7. Create a Class Method
    8. Create a Static Method
    9. Review the Class’s Code
  16. Index
  17. End User License Agreement

Product information

  • Title: Teach Yourself VISUALLY Python
  • Author(s): Ted Hart-Davis, Guy Hart-Davis
  • Release date: September 2022
  • Publisher(s): Wiley
  • ISBN: 9781119860259