Python Made Easy: A First Course in Computer Programming using Python
By Kevin Wilson
()
About this ebook
Python Made Easy: A First Course in Computer Programming is a full color, step by step, hands-on introduction to the world of computer programming using Python.
With a focus on practical application, this book is designed to equip anyone seeking an interactive introduction to Python with the essential skills and knowledge needed to start their programming journey.
This book adopts a "learn by doing" approach, providing a rich set of lab exercises at the end of each section and larger programming projects for you to try. By actively engaging with coding exercises along with step-by-step guidance, illustrations, and video demos, you'll develop a solid understanding of Python and build your skills. Here's what you'll learn
Install Python on Windows, Mac, and Linux
Python syntax and basics
Data types and Data structures
File Handling
Python Functions
Exception and Error Handling in Python
Object Oriented Programming
Using Modules and Libraries in your Python Programs
Building GUIs and using Graphics
Turtle Graphics
Game Development
Testing and Debugging your Programs
How to deploy your Python Programs
Web Development using Python Frameworks
Python Made Easy: A First Course in Computer Programming using Python is the ideal companion for anyone seeking an interactive introduction to Python programming. Whether you are a student, an aspiring programmer, or a professional from a non-technical background, this book will empower you to master the fundamentals of Python and the world of computer programming.
Have Fun!
Kevin Wilson
Kevin Wilson is the New York Times bestselling author of five novels, including Now Is Not the Time to Panic, Nothing to See Here, and The Family Fang, as well as two story collections. His work has received the Shirley Jackson Award and been selected as a Read with Jenna book club pick. He lives in Sewanee, Tennessee, with his wife and two sons.
Read more from Kevin Wilson
The Family Fang: A Novel Rating: 4 out of 5 stars4/5The AMA Handbook of Business Writing: The Ultimate Guide to Style, Grammar, Punctuation, Usage, Construction and Formatting Rating: 0 out of 5 stars0 ratingsNothing to See Here: A Novel Rating: 4 out of 5 stars4/5The Bird's Nest Rating: 0 out of 5 stars0 ratingsEssential Computing: Concepts of ICT Rating: 0 out of 5 stars0 ratingsAdministrative Assistant's and Secretary's Handbook Rating: 4 out of 5 stars4/5The Gospel Singer Rating: 4 out of 5 stars4/5The Way of Chai: Recipes for a Meaningful Life Rating: 0 out of 5 stars0 ratingsThe AMA Handbook of Business Documents: Gudielines and Sample Documents That Make Busienss Writing Easy Rating: 0 out of 5 stars0 ratingsHandbook of Strategic Account Management: A Comprehensive Resource Rating: 0 out of 5 stars0 ratingsBlood and Fears Rating: 4 out of 5 stars4/5Exploring Windows 11 - 2023 Edition Rating: 5 out of 5 stars5/5Gospel Shaped Emotions: Learning to Lay Our Emotions Down at the Cross of Jesus Rating: 0 out of 5 stars0 ratingsExploring Windows 11 - 2024 Edition: The Illustrated, Practical Guide to Using Microsoft Windows Rating: 0 out of 5 stars0 ratingsEssential Android Tablets: The Illustrated Guide to Using Android Rating: 0 out of 5 stars0 ratingsExploring Apple Mac - Sequoia Edition: The Illustrated, Practical Guide to Using MacOS Rating: 0 out of 5 stars0 ratingsMen of Air Rating: 0 out of 5 stars0 ratingsUsing Excel - 2023 Edition: The Step-by-step Guide to Using Microsoft Excel Rating: 0 out of 5 stars0 ratingsEssential Office 365 Third Edition: The Illustrated Guide to Using Microsoft Office Rating: 5 out of 5 stars5/5Computer Jargon: The Illustrated Glossary of Basic Computer Terminology Rating: 0 out of 5 stars0 ratingsExploring Apple Mac - MacOS Sonoma Edition: The Illustrated, Practical Guide to Using MacOS Rating: 0 out of 5 stars0 ratingsExploring Microsoft Office - 2023 Edition: The Illustrated, Practical Guide to Using Office and Microsoft 365 Rating: 0 out of 5 stars0 ratingsEssential iPad iOS 12 Edition: The Illustrated Guide to Using your iPad Rating: 5 out of 5 stars5/5Essential Computer Hardware: Understanding the Building Blocks of Modern Technology and Securing Your Digital World Rating: 0 out of 5 stars0 ratingsAirborne in 1943 Rating: 4 out of 5 stars4/5Essential iPhone X iOS 12 Edition: The Illustrated Guide to Using iPhone X Rating: 5 out of 5 stars5/5Exploring Apple Mac - Ventura Edition: The Illustrated, Practical Guide to Using MacOS Rating: 0 out of 5 stars0 ratings
Related to Python Made Easy
Titles in the series (1)
Python Made Easy: A First Course in Computer Programming using Python Rating: 0 out of 5 stars0 ratings
Related ebooks
Python: Beginner's Guide to Programming Code with Python: Python Computer Programming, #1 Rating: 0 out of 5 stars0 ratingsPython 3 Programming: A Beginner Crash Course Guide to Learn Python 3 in 1 Week Rating: 3 out of 5 stars3/5Introduction to Python 2018 Edition Rating: 4 out of 5 stars4/5A Guide to Python Mastery: Python Rating: 0 out of 5 stars0 ratingsPython Programming Techniques: The Art of Coding and Programming Explained Rating: 0 out of 5 stars0 ratingsPROGRAMMING WITH PYTHON: Master the Basics and Beyond with Hands-On Projects and Expert Guidance (2024 Guide for Beginners) Rating: 0 out of 5 stars0 ratingsSQL Mastery: The Masterclass Guide to Become an SQL ExpertMaster The SQL Programming Language In This Ultimate Guide Today! Rating: 0 out of 5 stars0 ratingsPython Made Simple: Learn Python programming in easy steps with examples Rating: 5 out of 5 stars5/5Python for Developers: Learn to Develop Efficient Programs using Python Rating: 0 out of 5 stars0 ratingsTiny Python Projects: Learn coding and testing with puzzles and games Rating: 4 out of 5 stars4/5Touchpad Prime Ver. 1.2 Class 7: Windows 7 & MS Office 2010 Rating: 0 out of 5 stars0 ratingsPython Bees Rating: 0 out of 5 stars0 ratingsPython for Beginners: A Crash Course to Learn Python Programming in 1 Week Rating: 0 out of 5 stars0 ratingsPython: Beginner's Guide to Programming Code with Python Rating: 0 out of 5 stars0 ratingsPython Programming for Beginners Rating: 3 out of 5 stars3/5Python Interview Questions You'll Most Likely Be Asked Rating: 2 out of 5 stars2/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Python For Data Science Rating: 0 out of 5 stars0 ratingsPython Mini Manual Rating: 0 out of 5 stars0 ratingsPython from the Very Beginning Rating: 0 out of 5 stars0 ratingsPython Programming For Beginners: Python Programming Language Tutorial Rating: 0 out of 5 stars0 ratingsPython: Programming For Beginners: Learn The Fundamentals of Python in 7 Days Rating: 3 out of 5 stars3/5Python Essentials Rating: 5 out of 5 stars5/5Python for Beginners: An Introduction to Learn Python Programming with Tutorials and Hands-On Examples Rating: 4 out of 5 stars4/5#1 Book on Python Programming Rating: 0 out of 5 stars0 ratingsPython programming for beginners: Python programming for beginners by Tanjimul Islam Tareq Rating: 0 out of 5 stars0 ratingsThe Ultimate Python Programming Guide For Beginner To Intermediate Rating: 4 out of 5 stars4/5
Programming For You
Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsSQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsHTML in 30 Pages Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5Python Data Structures and Algorithms Rating: 5 out of 5 stars5/5Coding with JavaScript For Dummies Rating: 0 out of 5 stars0 ratingsLearn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 5 out of 5 stars5/5A Slackers Guide to Coding with Python: Ultimate Beginners Guide to Learning Python Quick Rating: 0 out of 5 stars0 ratingsJavaScript All-in-One For Dummies Rating: 5 out of 5 stars5/5
Reviews for Python Made Easy
0 ratings0 reviews
Book preview
Python Made Easy - Kevin Wilson
Getting Started
The aim of this book is to provide a first course in the use of a methodical and effective approach to the development of computer programs using the Python Programming Language.
Chapters have been deliberately kept short with a learn by doing approach. Along the way, you’ll find various video tutorials and demonstrations you can access using the various links throughout the book.
Chapter by chapter, we’ll explore the ins and outs of Python with illustrations, worked examples, lab exercises and projects for you to complete yourself. For this purpose, we’ve included all the source code for this book in the following repository:
elluminetpress.com/python2
Have Fun!
What is Python
Python is a high-level programming language created by Guido van Rossum and first released in 1991. The name Python
was inspired by Guido’s love for the British comedy series Monty Python’s Flying Circus
.
Python emphasizes code readability and aims to provide a clear and concise syntax, making it easier for programmers to express concepts and ideas in fewer lines of code compared to other programming languages. There is also a comprehensive library that provides a wide range of built in modules and functions for common programming tasks. This philosophy encourages the reuse of existing code and reduces the need for developers to rely heavily on third-party libraries for basic functionalities. Over the years, Python has attracted a large community of developers who contribute to its extensive ecosystem of third-party libraries and frameworks, further expanding its capabilities.
Python is designed to be a versatile language and is widely used in web development, data analysis, artificial intelligence, scientific computing, and automation.
Installing Python
In this section, we’ll take a look at how to install the python interpreter and development environment.
Python has multiple versions available, such as Python 2.x and Python 3.x. It is recommended to install the latest stable version, which is Python 3.x. Python 2.x is no longer actively supported, and most new projects and libraries are designed for Python 3.x.
You can install python on Windows, Mac, or linux.
Install on Windows
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.
Install on MacOS
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.
Install on Linux
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
Setting up a Development Environment
A good development environment enhances productivity by providing features such as code editing, debugging, and testing capabilities.
There are several code editors and Integrated Development Environments (IDEs) available for Python programming. Once you have installed the python interpreter as discussed above, you should install a code editor or IDE. What you choose is personal preference and depends on the specific requirements of your project.
Try a few difference ones until you find the one that suits your needs the best.
Code Editor vs IDE
A code editor is a lightweight tool focused primarily on editing code. It provides features such as syntax highlighting, code completion, and basic code formatting. Some popular code editors are Visual Studio Code and Sublime Text.
An IDE is a comprehensive software suite that combines a code editor with additional tools and features specifically designed for software development. In addition to code editing capabilities, IDEs typically provide features like debugging, code refactoring, project management, and version control integration. Examples of popular IDEs include PyCharm, IDLE and Eclipse.
You should also consider an interactive computing environment. This is a software environment that allows you to interactively write and execute code while providing immediate feedback and results. Within this environment you can write code, run it, and see the output in real-time, facilitating an iterative and exploratory approach to programming.
Jupyter Notebook is a popular interactive computing environment that allows you to create and share documents containing live code, visualizations, and explanatory text.
Visual Studio Code (VS Code)
Visual Studio Code is a lightweight and highly customizable code editor developed by Microsoft.
code.visualstudio.com
It has excellent Python support with features such as IntelliSense which provides context-aware suggestions for functions, methods, variables, and modules as you type, helping you write code faster and with fewer errors.
VS Code also offers debugging tools and a wide range of extensions that enhance Python development experience.
PyCharm
PyCharm is a powerful IDE specifically designed for Python development. You can download the software here:
www.jetbrains.com/pycharm
It provides advanced features like intelligent code completion, refactoring tools, debugging, testing frameworks integration, and support for web development frameworks like Django and Flask.
PyCharm is available in both free Community Edition and paid Professional Edition versions.
Sublime Text
Sublime Text is a popular cross-platform code editor known for its speed and simplicity. You can download the software here:
www.sublimetext.com
It supports Python development through various community-developed packages. Sublime Text offers a distraction-free writing mode, multiple cursors, and powerful search and navigation features.
IDLE
IDLE (Integrated Development and Learning Environment) is a basic Python IDE that comes bundled with the Python installation. It provides a simple and beginner-friendly environment for writing and running Python code.
While IDLE is a convenient option for beginners or when you need a lightweight and straightforward development environment, however it lacks some advanced features and customization options compared to other IDEs. As your Python programming skills and projects become more complex, you may want to explore other IDEs mentioned earlier to leverage additional functionalities and tools for efficient development.
Jupyter Notebook
Jupyter Notebook is an open-source web-based interactive computing environment that allows users to create and share documents called notebooks. To install jupyter notebook, open the command prompt, then run the following command.
pip install jupyter
Run the following command to run Jupyter Notebook.
jupyter notebook
Notebook will pop up in your web browser. If it doesn’t open your browser and navigate to
http://localhost:8888/tree
You’ll land on the jupyter page.
Anaconda is a popular Python distribution that comes bundled with Jupyter Notebook. You can download this here.
www.anaconda.com/products/individual
Once you download the installer, run through the setup process.
You’ll find Anaconda Navigator, and Anaconda Spyder. Anaconda Navigator allows you to create and manage isolated Python environments, switch between different versions of Python, and install/uninstall packages. Spyder is an integrated development environment specifically designed for scientific Python programming and data analysis. It provides a powerful and feature-rich environment for writing, testing, and debugging Python code.
Summary
Python is a high-level programming language created by Guido van Rossum in 1991, known for its readability and concise syntax.
Python has a comprehensive library that includes built-in modules and functions for common programming tasks, reducing the need for third-party libraries.
Python is versatile and widely used in web development, data analysis, artificial intelligence, scientific computing, and automation.
Code editors such as Visual Studio Code and Sublime Text offer lightweight tools for editing code.
Integrated Development Environments (IDEs) such as PyCharm, IDLE, and Eclipse provide additional features like debugging, code refactoring, and project management.
Visual Studio Code is recommended in the book, with excellent Python support, debugging tools, and a wide range of extensions.
PyCharm is a powerful IDE specifically designed for Python development, available in both free and paid versions.
Sublime Text is a popular cross-platform code editor with support for Python development through community-developed packages.
IDLE is a basic Python IDE bundled with the Python installation, suitable for beginners or lightweight development but lacking advanced features.
Jupyter Notebook is an open-source web-based interactive computing environment that allows users to create and share documents called notebooks.
Anaconda is a popular Python distribution that comes bundled with Jupyter Notebook.
Python Basics
Python is an interpreted programming language, meaning the source code is executed line by line at runtime without the need for prior compilation into machine code.
When you run a Python program, the interpreter translates the source code into bytecode which is then executed by the Python Virtual Machine (PVM). The PVM is responsible for executing the bytecode and managing the memory, objects, and other runtime aspects of the Python program.
Python’s appeal lies in its simplicity and readability. The syntax emphasizes code clarity, using indentation rather than traditional braces or keywords to delimit blocks of code.
For this chapter, you’ll need to download the source code files from:
elluminetpress.com/pyb
You’ll also find various video demos and tutorials.
Language Syntax
Syntax refers to the set of rules and structure that define the correct arrangement and usage of elements in a programming language. The rules specify how the code should be structured, including the order and placement of keywords, operators, variables, and other elements. Adhering to the syntax rules is crucial because even small deviations can result in code that produces syntax errors.
Reserved Words
Reserved words, also known as keywords, are words that have special meaning and are reserved for specific purposes. These words cannot be used as variable names or other identifiers because they are already used by the language itself.
Indentation
Python uses indentation to define code blocks instead of using braces or keywords like begin
and end
as in other languages. Code blocks are usually indented using spaces or tabs (eg use four spaces per indentation level).
Consistent indentation is crucial in Python because it determines the grouping and hierarchy of code. It is important to note that mixing spaces and tabs for indentation can lead to errors, so it’s best to choose one and stick to it. In the example below, notice how the indentation is used to define the code blocks within the greet function.
The lines of code inside the if and else blocks are indented, indicating that they are part of those blocks.