While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
PYTHON: BEGINNER'S GUIDE TO PROGRAMMING CODE WITH PYTHON
First edition. November 17, 2016.
Copyright 2016 Charlie Masterson.
ISBN: 978-1386290735
Written by Charlie Masterson.
10 9 8 7 6 5 4 3 2 1
Python:
Beginners Guide to
Programming Code
with Python
Charlie Masterson
Table of Contents
Copyright 2017 by Charlie Masterson - All rights reserved.
The following Book is reproduced below with the goal of providing information that is as accurate and reliable as possible. Regardless, purchasing this Book can be seen as consent to the fact that both the publisher and the author of this book are in no way experts on the topics discussed within and that any recommendations or suggestions that are made herein are for entertainment purposes only. Professionals should be consulted as needed prior to undertaking any of the action endorsed herein.
This declaration is deemed fair and valid by both the American Bar Association and the Committee of Publishers Association and is legally binding throughout the United States.
Furthermore, the transmission, duplication or reproduction of any of the following work including specific information will be considered an illegal act irrespective of if it is done electronically or in print. This extends to creating a secondary or tertiary copy of the work or a recorded copy and is only allowed with express written consent from the Publisher. All additional right reserved.
The information in the following pages is broadly considered to be a truthful and accurate account of facts and as such any inattention, use or misuse of the information in question by the reader will render any resulting actions solely under their purview. There are no scenarios in which the publisher or the original author of this work can be in any fashion deemed liable for any hardship or damages that may befall them after undertaking information described herein.
Additionally, the information in the following pages is intended only for informational purposes and should thus be thought of as universal. As befitting its nature, it is presented without assurance regarding its prolonged validity or interim quality. Trademarks that are mentioned are done without written consent and can in no way be considered an endorsement from the trademark holder.
C ONGRATULATIONS ON downloading Python: Beginners Guide to Programming Code with Python and thanks for doing so.
The following chapters will discuss the Python programming language, how to get started, and how to program in Python - starting at the most simple concepts and helping you to create real world applications by the end of the book.
I say it a lot near the end, but its only because its true: programming is the apex of self-expression for a great number of people. There are a great many things you can accomplish using Python, and an even greater number of things if youre looking at the big picture of the all-encompassing everything of computers and programming.
Were going to help you get set and get on the path to being the best programmer that you can possibly be. Even if youre an absolute and total novice, youll find this book easy to comprehend and work through, as well as engaging enough to not be an absolute and total bore as some programming books can very much be.
All in all, there are many things to be said about Python, and we may just scratch the surface - but that surface will be enough to prepare you for any and everything you will encounter going forward in the language.
That is to say, there are plenty of books on this subject on the market, thanks again for choosing this one! Every effort was made to ensure it is full of as much useful information as possible, please enjoy!
Chapter 1:
Hatching Your Python
P YTHON IS ONE OF THE most popular programming languages out there today, full stop. There are few languages as prolific as Python has become. Python is a beautiful and multi-purpose language which can be found everywhere from on web servers to running video games to being the powerhouse behind popular applications.
Learning Python is a huge boon to you as a person in several ways. The largest is, of course, youre learning a programming language. Learning a programming language in general opens up a huge number of possibilities for the things which you can do with a computer. It can be a career skill and a hobby, too.
Python in particular is a fantastic language to learn because it can be used for a multitude of things. Its simple enough for beginners to grasp easily and, though simple, its incredibly powerful.
In order to use Python, you need to set it up. You can set up Python on Windows, Mac, and Linux. For the purposes of this book, I personally will be using a Linux system, but the instructions should be relatively straightforward and apply to every operating system.
In order to set up Python, you first need to grab a text editor. Many will work and many are out there indeed: I personally will be using Atom, which you can download from the website atom.io. Notepad++ and Sublime Text are also fantastic options.
After youve got your text editor, you need to check to be sure you have Python installed. Go to your Terminal (or Powershell in Windows) and try to run the command python . If Python isnt installed (it says something along the lines of command python not recognized ), then you need to install it.
In order to install it, you need to go to Python.org and grab Python 2.7.12 for your respective platform.
After its installed, make sure its working again - it should be.
Youre going to be using your Terminal/PowerShell to navigate and execute files, so you need to know how to navigate using those. If you dont know, I highly suggest doing a Google search on the topic. There are a ton of very simple tutorials on the subject, but for brevitys sake, Id like to avoid going to in-depth on extraneous things as such.
Now were going to work on writing and running your first program.
Go into your text editor and create a new file. Save it before you even start writing code, because then youll have access to syntax highlighting which will help you out a fair amount. You can save it under whatever name youd like going forward, but for the purpose of this example, you need to save it as first.py .
In the text file, type the following:
print hello world
Then head back to your Terminal or PowerShell and navigate to where you saved the file.