Coding in Python
A Comprehensive Beginners Guide to Learn the Realms of Coding in Python
Table of Contents
Copyright 2020 by Robert C. Matthews - All rights reserved.
This document is geared towards providing exact and reliable information in regards to the topic and issue covered. The publication is sold with the idea that the publisher is not required to render accounting, officially permitted, or otherwise, qualified services. If advice is necessary, legal or professional, a practiced individual in the profession should be ordered.
- From a Declaration of Principles which was accepted and approved equally by a Committee of the American Bar Association and a Committee of Publishers and Associations.
In no way is it legal to reproduce, duplicate, or transmit any part of this document in either electronic means or in printed format. Recording of this publication is strictly prohibited and any storage of this document is not allowed unless with written permission from the publisher. All rights reserved.
The information provided herein is stated to be truthful and consistent, in that any liability, in terms of inattention or otherwise, by any usage or abuse of any policies, processes, or directions contained within is the solitary and utter responsibility of the recipient reader. Under no circumstances will any legal responsibility or blame be held against the publisher for any reparation, damages, or monetary loss due to the information herein, either directly or indirectly.
Respective authors own all copyrights not held by the publisher.
The information herein is offered for informational purposes solely, and is universal as so. The presentation of the information is without contract or any type of guarantee assurance.
The trademarks that are used are without any consent, and the publication of the trademark is without permission or backing by the trademark owner. All trademarks and brands within this book are for clarifying purposes only and are the owned by the owners themselves, not affiliated with this document.
Introduction
This book contains proven steps and strategies on how to code in Python. In this book, I have included all the basics of coding in Python, written in a lucid and easy-to-digest form. The book is divided into different chapters, each dealing with a specific topic. I started the book by explaining the process of downloading and installing Python on your operating system. As Windows is the most popular operating system in the world, I focused on Python installation on Windows.
After that, I moved on to Python variables and data types. I have explained them one by one. The most interesting of all the datatypes is the Python string, and it also is the most widely used in different Python programs that you will find in this book and that you will create yourself. Therefore, I emphasized it. Then I moved on to Python lists and tuples. I have tried to create a story in the book so that you find the content coherent, juicy, and highly valuable. To fulfill this purpose, I have created a game zone that is under development. The game revolves around a player who has a mission to equip an office with the cheapest in terms of price and with the most needed items so that the player can sell the office to the highest bidder. You can see the story kicking off with the start of the section on lists and tuples.
I will explain different Python codes regarding the game. As you find yourself inside the game development, you will learn different list methods such as the del method, the pop method, and list slicing. The game then moves on toward Python conditionals and dictionaries and gets more interesting. The conditionals add logic to the game, and dictionaries offer a way to store data most efficiently.
One of the most interesting programs you will see invites user input and integrates it into a while loop. You will also enjoy the chapter on functions that make the code smart and highly engaging. Functions are interesting because they can be easily paired up with different data types, and for and while loops.
Object-oriented programming will introduce to real programming. You will learn how to create classes, inheritance classes, and model real-life objects with the help of programming. You can create some very interesting programs with the help of Python classes.
I have clearly written the codes. Each code is coupled with its results. You can copy the code and paste it in the editor, do the edits of your choice, and get the result. This is how you can easily learn to code. I have written all the codes in Python 3.8 which is why I recommend you to download and install it. The process is already made a part of this book.
I wrote this book with the goal that a person who has to start Python coding from scratch can easily learn to code. The book is for those who are just getting started. I have explained each concept with due depth and comprehensiveness so that you beginners can understand it and digest it well. Even if you are just getting started in the world of coding, you can easily understand the concepts.
I recommend that you keep a notebook and a pen with you when you read this book so that you can note down the important points and code syntax to remember them and practice them. You also can bookmark them on a smart device and jump to the desired pages when you want to read them. Unlike other dry books of coding, this book will explain each step of the code so that you can easily reproduce what you have learned. I hope you have fun reading sessions once you get started. If you have got the fire to learn Python, this book should finish in five to six reading sessions.
Chapter One: Make a Start
This chapter will walk you through the process of making a start in Python coding. You will learn how to download and install Python on your operating system. You will also learn how to start the editor and write a code in Python text editor.
The first thing you should know about is setting up a Python environment on your operating system. Python is installed differently on different operating systems. There are currently two available versions of Python which are Python 2 and Python 3. Each programming language keeps evolving as developers add to it new concepts and ideas. Python developers have taken a step further by making regular developments to the language, making it more powerful and versatile as well. You can install both versions of your operating system.
Python 3 Installation
Python is one of the most widely used programming languages that were first launched in 1991. Since then Python has gained immense popularity. It also is considered one of the most popular as well as flexible programming languages. Unlike Linux, Windows operating systems dont have Python pre-installed by default. However, you always can install Python on the Windows operating system is a very easy step.
The prerequisites of installing Python 3 on your Windows system are that you must have Windows 10 installed on the system and have admin privileges. Also, you should have a command prompt running on the system. The next prerequisite is the availability of a remote desktop app. You can use it if you are planning to install Python on a remote Windows server.
The first step in the installation process is selecting the version you want to install. In this case, we are aiming at downloading Python 3. You should visit the official Python website python.org and download Python 3 installer for Windows. Now run the same on your system. As you are just getting started on learning the Python language, I recommend that you download and install Python 2 and Python 3 versions to test old and new projects simultaneously.