<p><b>With an interesting mix of theory and practicals, explore Python and its features, and progress from beginner to being skilled in this popular scripting language</b><p><b>Key Features</b><p><li>A comprehensive introduction to the world of Python programming<li>Paves an easy-to-follow path for
Python Fundamentals: A practical guide for learning Python, complete with real-world projects for you to explore
โ Scribed by Ryan Marvin, Mark Ng'ang'a, Amos Omondi
- Publisher
- Packt Publishing
- Tongue
- English
- Leaves
- 324
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
With an interesting mix of theory and practicals, explore Python and its features, and progress from beginner to being skilled in this popular scripting language
Key Features
- A comprehensive introduction to the world of Python programming
- Paves an easy-to-follow path for you to navigate through concepts
- Filled with over 90 practical exercises and activities to reinforce your learning
Book Description
After a brief history of Python and key differences between Python 2 and Python 3, you'll understand how Python has been used in applications such as YouTube and Google App Engine. As you work with the language, you'll learn about control statements, delve into controlling program flow and gradually work on more structured programs via functions.
As you settle into the Python ecosystem, you'll learn about data structures and study ways to correctly store and represent information. By working through specific examples, you'll learn how Python implements object-oriented programming (OOP) concepts of abstraction, encapsulation of data, inheritance, and polymorphism. You'll be given an overview of how imports, modules, and packages work in Python, how you can handle errors to prevent apps from crashing, as well as file manipulation.
By the end of this book, you'll have built up an impressive portfolio of projects and armed yourself with the skills you need to tackle Python projects in the real world.
What you will learn
- Use control statements
- Manipulate primitive and non-primitive data structures
- Use loops to iterate over objects or data for accurate results
- Write encapsulated and succinct Python functions
- Build Python classes using object-oriented programming
- Manipulate files on the file system (open, read, write, and delete)
Who this book is for
Python Fundamentals is great for anyone who wants to start using Python to build anything from simple command-line programs to web applications. Prior knowledge of Python isn't required.
Table of Contents
- Introducing Python
- Data Types
- Control Statements
- Functions
- Lists and Tuples
- Dictionaries and Sets
- Object-Oriented Programming
- Modules, Packages, and File Operations
- Error Handling
โฆ Table of Contents
Preface
Introducing Python
Introduction
Python 2 Versus Python 3
Working with the Python Interactive Shell
Exercise 1: Checking our Python Installation
Exercise 2: Working with the Python Interpreter
Activity 1: Working with the Python Shell
Writing and Running Simple Scripts
Exercise 3: Creating a Script
Running a File Containing Invalid Commands
Exercise 4: Passing User Arguments to Scripts
Activity 2: Running Simple Python Scripts
Python Syntax
Variables
Values
Exercise 5: Checking the Type of a Value
Type Conversion
Exercise 6: Assigning Variables
Exercise 7: Using Variables
Multiple Assignment
Activity 3: Using Variables and Assign Statements
Naming Identifiers and Reserved Words
Exercise 8: Python Keywords
Python Naming Conventions
Activity 4: Variable Assignment and Variable Naming Conventions
User Input, Comments, and Indentations
User Input from the Keyboard
Passing in a Prompt to the input Function
Using Different Input Data Types in your Program
Exercise 9: Fetching and Using User Input
Comments
Indentation
Exercise 10: The Importance of Proper Indentation
Activity 5: Fixing Indentations in a Code Block
Activity 6: Implementing User Input and Comments in a Script
Summary
Data Types
Introduction
Numerical Data
Types of Numbers
Exercise 11: Converting Between Different Types of Number Systems
Operators
Order of Operations
Activity 7: Order of Operations
Activity 8: Using Different Arithmetic Operators
Strings
String Operations and Methods
Indexing
Slicing
Activity 9: String Slicing
Length
String Formatting
String Methods
Activity 10: Working with Strings
Escape Sequences
Exercise 12: Using Escape Sequences
Activity 11: Manipulating Strings
Lists
List Operations
Exercise 13: List References
Activity 12: Working with Lists
Booleans
Comparison Operators
Logical Operators
Membership Operators
Activity 13: Using Boolean Operators
Summary
Control Statements
Introduction
Control Statements
Program Flow
Control Statement
The if Statement
Exercise 14: Using the if Statement
Activity 14: Working with the if Statement
The while Statement
Exercise 15: Using the while Statement
Exercise 16: Using while to Keep a Program Running
Activity 15: Working with the while Statement
while Versus if
Loops
The for Loop
Exercise 17: Using the for Loop
Using else
The range Function
Activity 16: The for loop and the range Function
Nesting Loops
Exercise 18: Using Nested Loops
Activity 17: Nested Loops
Breaking Out of Loops
The break Statement
The continue Statement
The pass Statement
Activity 18: Breaking out of Loops
Summary
Functions
Introduction
Built-In Functions
User-Defined Functions
Calling a Function
Global and Local Variables
Exercise 19: Defining Global and Local Variables
Function Return
Using main()
Function Arguments
Required Arguments
Keyword Arguments
Default Arguments
Variable Number of Arguments
Activity 19: Function Arguments
Anonymous Functions
Exercise 20: Creating a Lambda Function
Activity 20: Using Lambda Functions
Summary
Lists and Tuples
Introduction
List Syntax
List Methods
list.append(item)
list.extend(iterable)
list.insert(index, item)
list.remove(item)
list.pop([index])
list.clear()
list.index(item [, start [, end]])
list.count(item)
list.sort(key=None, reverse=False)
list.reverse()
list.copy()
Activity 21: Using the List Methods
List Comprehensions
Tuple Syntax
Exercise 21: Creating a Tuple
Accessing Tuple Elements
Indexing
Exercise 22: Accessing Tuple Elements Using Indexing
Slicing
Exercise 21: Creating a Tuple
Accessing Tuple Elements
Indexing
Exercise 23: Accessing Tuple Elements Using Slicing
Tuple Methods
Activity 22: Using Tuple Methods
Summary
Dictionaries and Sets
Introduction
Working with Dictionaries
Activity 23: Creating a Dictionary
Exercise 24: Adding Data to a Dictionary
Exercise 25: Reading Data from a Dictionary
Exercise 26: Iterating Through Dictionaries
Checking for the Existence of Particular Keys
Additional Dictionary Attributes
dict.update()
dict.clear() and dict.pop()
dict.copy()
dict.popitem()
dict.setdefault()
dict.fromkeys()
Activity 24: Arranging and Presenting Data Using Dictionaries
Ordered Dictionaries
Activity 25: Combining Dictionaries
The Basics of Sets
Exercise 27: Creating Sets
Exercise 28: Adding Data to a Set
Exercise 29: Reading Data from a Set
Activity 26: Building a Set
Exercise 30: Removing Data from a Set
Set Operations
Union
Intersection
Difference
Subsets
Equality
Update Methods
Frozen Sets
Activity 27: Creating Unions of Elements in a Collection
Summary
Object-Oriented Programming
Introduction
A First Look at OOP
OOP in Python
Defining a Class in Python
Exercise 31: Creating a Class
Instantiating an Object
Exercise 32: Instantiating a Person Object
Adding Attributes to an Object
The init Method
Exercise 33: Adding Attributes to a Class
Activity 28: Defining a Class and Objects
Methods in a Class
Defining Methods in a Class
Exercise 34: Creating a Method for our Class
Passing Arguments to Instance Methods
Exercise 35: Passing Arguments to Instance Methods
Exercise 36: Setting Instance Attributes within Instance Methods
Activity 29: Defining Methods in a Class
Class Versus Instance Attributes
Exercise 37: Declaring a Class with Instance Attributes
Class Attributes
Exercise 38: Extending our Class with Class Attributes
Exercise 39: Implementing a Counter for Instances of a Class
Activity 30: Creating Class Attributes
Class Versus Instance Methods
Exercise 40: Creating Instance Methods
Class Methods
Exercise 41: Testing our Factory Method
Exercise 42: Accessing Class Attributes from within Class Methods
Encapsulation and Information Hiding
Activity 31: Creating Class Methods and Using Information Hiding
Class Inheritance
Exercise 43: Implementing Class Inheritance
Overriding init()
Exercise 44: Overriding the init Method to Add an Attribute
Commonly Overridden Methods
Activity 32: Overriding Methods
Multiple Inheritance
Exercise 45: Implementing Multiple Inheritance
Activity 33: Practicing Multiple Inheritance
Summary
Modules, Packages, and File Operations
Introduction
Defining Modules
Exercise 46: Creating Modules
Imports and Import Statements
Exercise 47: Importing Modules
Modules and Packages
The Module Search Path
Standard Python Modules
Activity 34: Inspecting Modules
Packages
Absolute Imports
Relative Imports
Activity 35: Listing the Resources Defined in a Package or Module
Activity 36: Using Resources in a Module
File Operations
The file Object
The file Object Methods
Reading and Writing to Files
The open() Method
Exercise 48: Creating, Reading, and Writing to Files
The with Context Manager
Activity 37: Performing File Operations
Handling Structured Data
Working with CSV Data
Activity 38: Working with Files
Working with JSON Data
Summary
Error Handling
Introduction
Errors and Exceptions in Python
How to Raise Exceptions
Built-In Exceptions
SyntaxError
ImportError
KeyError
TypeError
AttributeError
IndexError
NameError
FileNotFoundError
Activity 39: Identifying Error Scenarios
Handling Errors and Exceptions
Exercise 49: Implementing the tryโฆexcept Block
Exercise 50: Implementing the tryโฆexceptโฆelse Block
Exercise 51: Implementing the finally Keyword
Activity 40: Handling Errors
Custom Exceptions
Implementing Your Own Exception Class
Activity 41: Creating Your Own Custom Exception Class
Summary
Appendix A
Index
_GoBack
_GoBack
_GoBack
_GoBack
๐ SIMILAR VOLUMES
<p><span>With an interesting mix of theory and practicals, explore Python and its features, and progress from beginner to being skilled in this popular scripting language</span></p><h4><span>Key Features</span></h4><ul><li><span><span>A comprehensive introduction to the world of Python programming <
1 online resource (1 volume) :
<p>"Python for Machine Learning: From Fundamentals to Real-World Applications" is your comprehensive roadmap to mastering machine learning with Python. Whether you're a beginner looking to enter the exciting world of data science or an experienced programmer aiming to delve deeper into machine learn
Python is one of the most versatile high-level programming languages ever developed. Rather than having to jump into strict syntax rules, Python reads like English and is simple to understand for someone new to programming. This allows you to obtain a basic knowledge of coding practices without havi
<p>Build software that combines Python's expressivity with the performance and control of C (and C++). It's possible with Cython, the compiler and hybrid programming language used by foundational packages such as NumPy, and prominent in projects including Pandas, h5py, and scikits-learn. In this pra