Share E-Book

Getting Started with Python (Thomas Theis)(Z-Library)

Author Thomas Theis

Python
Language English

If you want to program with Python, you’ve come to the right place! Take your first steps with this Python crash course that teaches you to use core language elements, from variables to branches to loops. Follow expert guidance to work with data types, functions, and modules—and learn how to manage errors and exceptions along the way. Apply Python programming to develop databases, graphical user interfaces, widgets, and more. Practice your skills with example exercises, and start developing your own applications with Python today! In this book, you’ll learn about: a. Language Basics Learn the Python fundamentals, from initial installation to running your first program. Master core concepts including variables, branching, loops, functions, and modules; then work with data types such as integers, strings, and tuples. b. Python in Practice Apply Python programming in key development scenarios. Use Python for object-oriented programming, create and identify threads, manage files and directories, develop databases with SQLite and MySQL, and more. c. Example Exercises Get hands-on experience with practical programming exercises. Follow along with a game development example as you move from chapter to chapter. You’ll be ready to create your own applications with Python in no time! Highlights include: 1) Installation 2) Python language basics 3) Object-oriented programming 4) Error handling 5) Data types 6) Multithreading 7) File processing 8) Databases 10) GUI programming 11) PyQt 12) Example exercises

Format PDF
Size 4.7 MB
21
Views
0
Downloads
0.00
Total Donations
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
Thomas Theis Getting Started with Python
Page 3
Imprint This e-book is a publication many contributed to, specifically: Editor   Megan Fuerst Acquisitions Editor   Hareem Shafi German Edition Editor   Anne Schiebe Copyeditor   Yvette Chin Translation   Winema Language Services, Inc. Cover Design and Illustration   Mai Loan Nguyen Duy Production E-Book   Graham Geary Typesetting E-Book   III-Satz, Germany We hope that you liked this e-book. Please share your feedback with us and read the Service Pages to find out how to contact us. The Library of Congress Cataloging-in-Publication Control Number for the printed edition is as follows: Names: Theis, Thomas, author. Title: Getting started with Python / by Thomas Theis. Description: 1st edition. | Bonn ; Boston : Rheinwerk Publishing, 2024. | Includes index. Identifiers: LCCN 2024018654 | ISBN 9781493225866 (hardcover) | ISBN 9781493225873 (ebook)
Page 4
Subjects: LCSH: Python (Computer program language) Classification: LCC QA76.73.P98 T47 2024 | DDC 005.13/3-- dc23/eng/20240509 LC record available at https://lccn.loc.gov/2024018654 ISBN 978-1-4932-2586-6 (print) ISBN 978-1-4932-2587-3 (e-book) ISBN 978-1-4932-2588-0 (print and e-book) © 2024 by Rheinwerk Publishing Inc., Boston (MA) 1st edition 2024 8th German edition published 2024 by Rheinwerk Verlag, Bonn, Germany
Page 5
Notes on Usage This e-book is protected by copyright. By purchasing this e-book, you have agreed to accept and adhere to the copyrights. You are entitled to use this e-book for personal purposes. You may print and copy it, too, but also only for personal use. Sharing an electronic or printed copy with others, however, is not permitted, neither as a whole nor in parts. Of course, making them available on the internet or in a company network is illegal as well. For detailed and legally binding usage conditions, please refer to the section Legal Notes. This e-book copy contains a digital watermark, a signature that indicates which person may use this copy:  
Page 6
Notes on the Screen Presentation You are reading this e-book in a file format (EPUB or Mobi) that makes the book content adaptable to the display options of your reading device and to your personal needs. That’s a great thing; but unfortunately not every device displays the content in the same way and the rendering of features such as pictures and tables or hyphenation can lead to difficulties. This e-book was optimized for the presentation on as many common reading devices as possible. If you want to zoom in on a figure (especially in iBooks on the iPad), tap the respective figure once. By tapping once again, you return to the previous screen. You can find more recommendations on the customization of the screen layout on the Service Pages.
Page 7
Table of Contents Notes on Usage Table of Contents Materials for This Book 1   Introduction 1.1   Advantages of Python 1.2   Prevalence of Python 1.3   Structure of This Book 1.4   Exercises 1.5   Installation on Windows 1.6   Installation on Ubuntu Linux 1.7   Installation on macOS 2   Getting Started 2.1   Python as a Calculator
Page 8
2.1.1   Entering Calculations 2.1.2   Addition, Subtraction, and Multiplication 2.1.3   Division, Integer Division, and Modulo 2.1.4   Ranking and Parentheses 2.1.5   Exercise 2.1.6   Variables and Assignment 2.1.7   Exercise 2.2   Our First Program 2.2.1   Hello World 2.2.2   Entering a Program 2.3   Saving and Running 2.3.1   Saving 2.3.2   Running on Windows 2.3.3   Running on Ubuntu Linux and on macOS 2.3.4   Comments 2.3.5   Concatenating Outputs 2.3.6   Long Outputs 3   Programming Course 3.1   Programming a Game 3.2   Variables and Operators 3.2.1   Assignment, Calculation, and Output 3.2.2   String Literals 3.2.3   Entering a String 3.2.4   Entering a Number 3.2.5   Our Game: Version with Input
Page 9
3.2.6   Exercises 3.2.7   Random Numbers 3.2.8   Determining a Type 3.3   Branches 3.3.1   Comparison Operators 3.3.2   Branch Using if 3.3.3   Our Game: Version with Input Evaluation 3.3.4   Exercise 3.3.5   Multiple Branches 3.3.6   Exercise 3.3.7   Conditional Expression 3.3.8   Logical Operators 3.3.9   Exercises 3.3.10   Multiple Comparison Operators 3.3.11   Our Game: Version with Exact Evaluation of the Input 3.3.12   Branch with match 3.3.13   Order of Operations 3.4   Loops 3.4.1   Loops with for 3.4.2   Terminating a Loop Using break 3.4.3   Continuing a Loop Using continue 3.4.4   Nested Control Structures 3.4.5   Our Game: Version with for Loop and Abort 3.4.6   Loops with for and range() 3.4.7   Exercises 3.4.8   Our Game: Version with range() 3.4.9   Loop with while
Page 10
3.4.10   Our Game: Version with while Loop and Counter 3.4.11   Exercise 3.4.12   Combined Assignment Expressions 3.5   Developing a Program 3.6   Errors and Exceptions 3.6.1   Base Program 3.6.2   Intercepting Errors 3.6.3   Outputting an Error Message 3.6.4   Repeating an Entry 3.6.5   Exercise 3.6.6   Our Game: Version with Exception Handling 3.7   Functions and Modules 3.7.1   Simple Functions 3.7.2   Functions with One Parameter 3.7.3   Exercise 3.7.4   Functions with Multiple Parameters 3.7.5   Functions with Return Value 3.7.6   Our Game: Version with Functions 3.7.7   Exercises 3.8   Type Hints 3.8.1   Variables and Type Checks 3.8.2   Functions and Type Checks 3.9   The Finished Game 4   Data Types
Page 11
4.1   Numbers 4.1.1   Integers 4.1.2   Numbers with Decimal Places 4.1.3   Exponential Operator ** 4.1.4   Rounding and Conversion 4.1.5   Trigonometric Functions 4.1.6   Other Mathematical Functions 4.1.7   More Precise Figures with Decimal Places 4.1.8   Complex Numbers 4.1.9   Bit Operators 4.1.10   Fractions 4.2   Character Strings 4.2.1   Properties 4.2.2   Operators 4.2.3   Slices 4.2.4   Mutability 4.2.5   Searching and Replacing 4.2.6   Removing Blank Spaces 4.2.7   Decomposing Texts 4.2.8   Constants 4.2.9   The bytes Data Type 4.3   Lists 4.3.1   Properties and Operators 4.3.2   Multidimensional Lists 4.3.3   Mutability 4.3.4   Methods 4.3.5   List Comprehension
Page 12
4.4   Tuples 4.5   Dictionaries 4.5.1   Properties, Operators, and Methods 4.5.2   Dynamic Views 4.6   Sets 4.6.1   Properties, Operators, and Methods 4.6.2   Set Theory 4.7   Truth Values and Nothing 4.7.1   Truth Values “True” and “False” 4.7.2   Nothing and the None Keyword 4.8   Reference, Identity, and Copy 4.8.1   Reference and Identity 4.8.2   Saving Resources 4.8.3   Copying Objects 4.9   Type Hints 4.9.1   A Sequence as a Parameter 4.9.2   Restriction to a List 5   Advanced Programming 5.1   General Remarks 5.1.1   Combined Assignment Operators 5.1.2   Statement in Multiple Lines 5.1.3   Input with Assistance 5.1.4   The pass Statement 5.2   Output and Formatting 5.2.1   The print() Function
Page 13
5.2.2   Formatting Numbers with Decimal Places 5.2.3   Formatting Integers 5.2.4   Formatting Strings 5.2.5   Exercise 5.3   Functions for Iterables 5.3.1   The zip() Function 5.3.2   The map() Function 5.3.3   The filter() Function 5.4   Encryption 5.5   Errors and Exceptions 5.5.1   General Remarks 5.5.2   Syntax Errors 5.5.3   Runtime Errors 5.5.4   Logical Errors and Debugging 5.5.5   Generating Errors 5.5.6   Distinguishing Exceptions 5.6   Functions 5.6.1   A Variable Number of Parameters 5.6.2   Named Parameters 5.6.3   Optional Parameters 5.6.4   Multiple Return Values 5.6.5   Transferring Copies and References 5.6.6   Namespaces 5.6.7   Recursive Functions 5.6.8   Lambda Functions 5.6.9   Functions as Parameters 5.7   Built-In Functions
Page 14
5.7.1   The max(), min(), and sum() Functions 5.7.2   The chr() and ord() Functions 5.7.3   The reversed() and sorted() Functions 5.8   Other Mathematical Modules 5.8.1   Drawing Function Graphs 5.8.2   Multiple Partial Drawings 5.8.3   One-Dimensional Arrays and Vectors 5.8.4   Multidimensional Arrays and Matrices 5.8.5   Signal Processing 5.8.6   Statistics Functions 5.9   Custom Modules 5.9.1   Creating Custom Modules 5.9.2   Standard Import of a Module 5.9.3   Importing and Renaming a Module 5.9.4   Importing Functions 5.9.5   Exercise 5.10   Command Line Parameters 5.11   “Fractions Training” Program 5.11.1   The Program Flow 5.11.2   Main Program 5.11.3   An Easy Task 5.11.4   A Moderately Difficult Task 5.11.5   A Difficult Task 6   Object-Oriented Programming
Page 15
6.1   Basic Principles 6.1.1   What Is Object-Oriented Programming? 6.1.2   Classes, Objects, and Custom Methods 6.1.3   Special Members 6.1.4   Exercise 6.1.5   Operator Methods 6.1.6   Reference, Identity, and Copy 6.1.7   Concatenation 6.1.8   Nesting 6.1.9   Exercises 6.2   Advanced Topics 6.2.1   Inheritance 6.2.2   Exercise 6.2.3   Multiple Inheritance 6.2.4   Data Classes 6.2.5   Enumerations 6.2.6   Our Game: Object-Oriented Version 7   Various Modules 7.1   Date and Time 7.1.1   The time Module 7.1.2   Stopping a Program 7.1.3   The timedelta Class 7.1.4   The datetime Class 7.1.5   The calendar Class 7.1.6   Our Game: Version with Time Measurement
Page 16
7.1.7   Our Game: Object-Oriented Version with Time Measurement 7.2   Queues 7.2.1   The SimpleQueue Class 7.2.2   The LifoQueue Class 7.2.3   The PriorityQueue Class 7.2.4   The deque Class 7.3   Multithreading 7.3.1   What Is Multithreading Used For? 7.3.2   Generating a Thread 7.3.3   Identifying a Thread 7.3.4   Shared Data and Objects 7.3.5   Threads and Exceptions 7.4   Regular Expressions 7.4.1   Finding Text Parts 7.4.2   Replacing Text Parts 7.5   Audio Output 8   Files 8.1   Opening and Closing a File 8.2   Text Files 8.2.1   Writing a Text File 8.2.2   Reading a Text File 8.2.3   Writing a CSV File 8.2.4   Reading a CSV File
Page 17
8.3   Files with a Defined Structure 8.3.1   Formatted Writing 8.3.2   Reading in Any Position 8.3.3   Writing in Any Position 8.4   Serialization Using pickle 8.4.1   Writing Objects to Files 8.4.2   Reading Objects from Files 8.5   Data Exchange Using JSON 8.5.1   Writing Objects to Files 8.5.2   Reading Objects from Files 8.6   Editing Multiple Files 8.6.1   The glob.glob() Function 8.6.2   The os.scandir() Function 8.7   Information about Files 8.8   Managing Files and Directories 8.9   The Morse Code Sample Project 8.9.1   Reading Morse Code from a File 8.9.2   Output on the Screen 8.9.3   Output with Sound Signals 8.10   Our Game: Version with Highscore File 8.10.1   Sample Entries 8.10.2   Structure of the Program 8.10.3   The Code of the Program 8.11   Our Game: Object-Oriented Version with Highscore File
Page 18
9   Databases 9.1   Structure of Databases 9.2   SQLite 9.2.1   Database, Table, and Data Records 9.2.2   Displaying Data 9.2.3   Selecting Data 9.2.4   The LIKE Operator 9.2.5   Sorting the Output 9.2.6   Selection after Entry 9.2.7   Changing Data Records 9.2.8   Deleting Data Records 9.2.9   Exercise 9.3   MySQL 9.3.1   XAMPP and Connector/Python 9.3.2   Database, Table, and Data Records 9.3.3   Displaying Data 9.4   Our Game: Version with Highscore Database 9.5   Our Game: Object-Oriented Version with Highscore Database 10   User Interfaces 10.1   Introduction
Page 19
10.1.1   Our First GUI Program 10.1.2   Setup and Arrangement 10.1.3   Event Methods for Multiple Widgets 10.2   Widget Types 10.2.1   Single-Line Input Field 10.2.2   Hidden Input and Deactivating a Widget 10.2.3   Multiline Input Field 10.2.4   List Box with Simple Selection 10.2.5   List Box with Multiple Selection Option 10.2.6   Spin Boxes 10.2.7   Radio Buttons and the Widget Variable 10.2.8   Check Buttons 10.2.9   Sliders and Scales 10.3   Images and Mouse Events 10.3.1   Embedding and Changing an Image 10.3.2   Mouse Events 10.4   The place Geometry Manager 10.4.1   Window Size and Absolute Position 10.4.2   Relative Position 10.4.3   Changing the Position 10.5   Menus and Dialog Boxes 10.5.1   Menu Bars 10.5.2   Context Menus 10.5.3   Standard Dialog Boxes 10.5.4   Custom Dialog Boxes 10.6   Drawings and Animations 10.6.1   Various Drawing Objects
Page 20
10.6.2   Controlling Drawing Objects 10.6.3   Animating Drawing Objects 10.6.4   Collision of Drawing Objects 10.7   Our Game: GUI Version 10.8   Exercise 11   User Interfaces with PyQt 11.1   Introduction 11.1.1   Our First GUI Program 11.1.2   Setup and Arrangement 11.1.3   Size of the Application Window 11.1.4   Event Methods for Multiple Widgets 11.2   Widget Types 11.2.1   Single-Line Input Field 11.2.2   Hidden Inputs and Disabling Widgets 11.2.3   Multiline Input Field 11.2.4   List with a Single Selection Option 11.2.5   List with Multiple Selection Options 11.2.6   Combo Boxes 11.2.7   Spin Boxes 11.2.8   Radio Buttons 11.2.9   Multiple Groups of Radio Buttons 11.2.10   Checkboxes 11.2.11   Sliders 11.2.12   Images, Formats, and Hyperlinks
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
Back to List