8,49 €
Written as an illustrated, step-by-step guide and workbook for complete beginners, this illustrated, full color book will introduce you to the python programming language using clear explanations, diagrams, coded examples, lab exercises and video demos.
You'll begin by learning how to set up the python interpreter and development environment on your computer, then you'll dive straight into the basics of python such as python language syntax, python keywords, and how to write and execute python program.
Next, you will learn how to work with python variables, basic data types, arithmetic, companion, and boolean operators.
Furthermore, the book covers flow control constructs such as if/else statements and loops in python. You'll also learn how to define and use functions, recursion, and exception handling, as well as a look at the principles of object-oriented programming.
You'll also learn how to use turtle graphics to draw various shapes and patterns, and how to build a graphical user interface using tkinter. The last section covers developing a game using the PyGame module and how to add graphics, create basic animations, and user interactivity.
At the end of each chapter, you'll find various lab exercises to test what you've learned in the chapter. Also included is a growing repository of sample python source code, bonus material for each chapter, videos, and model solutions to lab exercises to further enhance your learning experience.
Absolute Beginner's Python Programming Guide will give you the tools, confidence, and inspiration to start writing Python programs. If you are a beginner, a developer, a student, or someone who wants to learn on their own, this book is for you.
What You Will Learn
Gain an understanding of computer programming with python
Understand different data and data types in python
Work with Classes and OOP in python
Build interfaces, simple games, and web development with Python
This Book Is For
beginners
developers
students
anyone who wants to learn Python programming on their own.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 98
Veröffentlichungsjahr: 2023
Absolute Beginner’s
Python Programming
The Illustrated Guide to Learning Computer Programming
Kevin Wilson
Absolute Beginner’s Python Programming
Copyright © 2024 Elluminet Press
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from the Publisher. Permissions for use may be obtained through Rights Link at the Copyright Clearance Centre. Violations are liable to prosecution under the respective Copyright Law.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
iStock.com/golibo, PeopleImages, ymgerman. Photo 130859010 © Kaspars Grinvalds - Dreamstime.com. Photo 103557713 © Konstantin Kolosov - Dreamstime.com. Yuri Arcurs via Getty Images
Publisher: Elluminet Press
Director: Kevin Wilson
Lead Editor: Steven Ashmore
Technical Reviewer: Mike Taylor, Robert Ashcroft
Copy Editors: Joanne Taylor, James Marsh
Proof Reader: Steven Ashmore
Indexer: James Marsh
Cover Designer: Kevin Wilson
For detailed information about how to locate your book’s resources, go to
www.elluminetpress.com/resources
About the Author
With over 20 years’ experience in the computer industry, Kevin Wilson has made a career out of technology and showing others how to use it. After earning a master’s degree in computer science, software engineering, and multimedia systems, Kevin has held various positions in the IT industry including graphic & web design, programming, building & managing corporate networks, and IT support.
He serves as senior writer and director at Elluminet Press Ltd, he periodically teaches computer science at college, and works as an IT trainer in England while researching for his PhD. His books have become a valuable resource among the students in England, South Africa, Canada, and in the United States.
Kevin’s motto is clear: “If you can’t explain something simply, then you haven’t understood it well enough.” To that end, he has created the Exploring Tech Computing series, in which he breaks down complex technological subjects into smaller, easy-to-follow steps that students and ordinary computer users can put into practice.
Acknowledgements
Thanks to all the staff at Luminescent Media & Elluminet Press for their passion, dedication and hard work in the preparation and production of this book.
To all my friends and family for their continued support and encouragement in all my writing projects.
To all my colleagues, students and testers who took the time to test procedures and offer feedback on the book
Finally thanks to you the reader for choosing this book. I hope it helps you gain a better understanding of Python Programming.
Have fun!
What is a computer program? A computer program is a set of concise instructions written in a programming language that are executed in sequence in order to achieve a task.
A computer program usually takes some data such as a string, or a number and performs some kind of processing to produce results. We usually refer to the data as the program’s input, and the results as the program’s output.
To write computer programs we use a computer programming language. There are many different languages such as BASIC, C, C++ and Python. In this guide, we are going to concentrate on the Python programming language.
Every computer program manipulates data to produce a result, so most languages allow the programmer to choose names for each item of data.
These items are called variables. A variable is as the name suggests is an item that can contain different values as the program is being executed. Variables can store data of different types, and different types can do different things. For example, a variable could be an integer to store a whole number, a float to store numbers with decimal places, a string to store text, or a list to store multiple data items.
If we wrote a program to calculate the area of a triangle, we could have integer or float type variables for the length, the height, and one for the result as they are all numbers. The processing part of the program would use the numbers stored in the length and height variable, then assign the result to the variable for result. We’ll take a look at variables and data types in more detail in chapter 3
In larger programs, we often need to make decisions based on user input, a calculated result or condition. In this case, we use an if statement. This is called selection. Some blocks of code might also need to be repeated, in this case we use a loop. This is called repetition. We’ll take a closer look at this in chapter 4.
Many modern computer programs have fancy graphical user interfaces that allow the user to interact with buttons, windows and menus. These are known as software applications or apps. We’ll take a look at building a simple app with a graphical user interface in chapter 11.
The Python programming language has specific facilities to enable us to implement the concepts outlined above. Many of these will be introduced throughout this guide.
Python is a high level language developed by Guido van Rossum in the late ‘80s and is used in web development, scientific applications, gaming, AI, and is well suited to education for teaching computer programming.
Python is designed to be an easily readable language. Therefore, it uses an uncluttered formatting style, and often uses meaningful English keywords and function names.
Python is an interpreted programming language, meaning Python programs are written in a text editor and then put through a Python interpreter to be executed.
Python is used in the field of artificial intelligence and can be found in many day-to-day applications. Streaming services such as Spotify use Python for data analysis, particularly user’s listening habits in order to offer suggestions on which artist to follow, other music a particular user might be interested in and so on. Python is also used within Netflix’s machine-learning algorithms for recommending relevant content to users, monitoring browsing habits, and marketing.
In the world of games development, Python is used as a companion language, meaning Python scripts are used to add customizations to the core gaming engine, script AI behaviors, or server side elements. The performance of Python isn’t fast enough for coding graphics intensive, higher end games, however you can create simple games with Python using the pygame module. We’ll take a look at this in chapter 12.
Python is used in web development and allows a web developer to develop dynamic web apps very quickly. More in chapter 13.
Python is a multi platform language and is available for Windows, MacOS, Linux and the Raspberry Pi.
To start coding, you’ll need a computer - either Windows, MacOS or Linux, and an Integrated Development Environment (IDE) with the Python interpreter. Let’s install Python.
In our lab, we’re using windows workstations, so we’ll need to install the Python Development Environment for Windows.
Open your web browser and navigate to the following website
www.python.org/downloads/windows
From the downloads page, select the ‘executable installer’ of latest stable release.
Click ‘run’ when prompted by your browser. Or click ‘python-x.x.x-amd64.exe’ if you’re using Chrome.
Once the installer starts, make sure ‘add python 3.x to path’ is selected, then click ‘customize installation’ to run through the steps to complete the installation.
Make sure you select all the tick boxes for all the optional features.
Click ‘next’.
Make sure ‘install for all users’ is selected at the top of the dialog box. Click ‘install’ to begin.
Click ‘disable path length limit’ to make sure Python runs smoothly on Windows and allow long file names.
Click ‘close’ to finish the installation.
You’ll find the Python Development Environment (IDLE) and the Python interpreter, in the Python folder on your start menu.
To install Python 3 with the Official Installer, open your web browser and navigate to the following website
www.python.org/downloads/macos
Click download python.
You’ll find the package in your downloads folder. Double click on the package to begin the installation
Run through the installation wizard. Click ‘continue’.
Once the installation is complete, you’ll find python in the applications folder in finder, or on the launch pad.
If you are running a linux distribution such as Ubuntu or have a Raspberry Pi, you can install python using the terminal. You’ll find the terminal app in your applications. You can also press Control Alt T on your keyboard.
At the terminal command prompt, type the following commands. Press enter after each line.
sudo apt update
sudo apt upgrade
Type the following command to install Python.
sudo apt install python3 -y
Once the Python is installed, we need to install IDLE, the development environment. To do this, type the following command at the prompt
sudo apt-get install idle3 -y
Once installed, you’ll find IDLE in your applications.
Or you can type the following command at the prompt
idle
Arrange your windows so you can see your code window on the left and the shell on the right.
Here, you can write your code in the editor then execute & debug your code. You’ll also notice the code editor provides syntax highlighting meaning keywords and text are highlighted in different colors, making code easier to read.
There are countless development environments and code editors out there such as
Sublime TextIDLEAtomPyCharmThonnyPyDev and Visual Studio CodeFor the purpose of this guide, we’ll be using IDLE, an integrated development environment (IDE) that comes with Python.
You’ll find IDLE on your start menu in Windows, or in Finder/Launch Pad on a Mac.
Once IDLE starts, you’ll see the shell window.
At the ‘>>>’ prompt you can type and execute statements. You can perform mathematical operations, comparisons, take input from user, and the Python interpreter will execute them.
Here, we executed a print statement, and evaluated a mathematical expression. Once you hit enter, you’ll see the output appear in blue underneath.
To create a python file, select ‘file’ menu in the upper left-hand corner of the shell window.
Align the editor window to the left of the shell window as shown below.
Tausende von E-Books und Hörbücher
Ihre Zahl wächst ständig und Sie haben eine Fixpreisgarantie.
Sie haben über uns geschrieben: