Book Image

Python Fundamentals

By : Ryan Marvin, Mark Ng’ang’a, Amos Omondi
Book Image

Python Fundamentals

By: Ryan Marvin, Mark Ng’ang’a, Amos Omondi

Overview of this book

<p>After a brief history of Python and key differences between Python 2 and Python 3, you'll understand how Python has been used in applications such as YouTube and Google App Engine. As you work with the language, you'll learn about control statements, delve into controlling program flow and gradually work on more structured programs via functions.</p> <p>As you settle into the Python ecosystem, you'll learn about data structures and study ways to correctly store and represent information. By working through specific examples, you'll learn how Python implements object-oriented programming (OOP) concepts of abstraction, encapsulation of data, inheritance, and polymorphism. You'll be given an overview of how imports, modules, and packages work in Python, how you can handle errors to prevent apps from crashing, as well as file manipulation.</p> <p>By the end of this book, you'll have built up an impressive portfolio of projects and armed yourself with the skills you need to tackle Python projects in the real world.</p>
Table of Contents (12 chapters)
Python Fundamentals
Preface

Preface

Note

About

This section briefly introduces the author, the coverage of this book, the technical skills you’ll need to get started, and the hardware and software requirements required to complete all of the included activities and exercises.

About the Book

Python Fundamentals takes you from zero experience to a complete understanding of the key concepts, edge cases, and how to use Python for real-world application development. You'll move progressively from the basics to work with larger, more complex applications. After completing this book, you'll have the skills you need to dive into an existing application or start your own project.

After a brief history on the Python language and the key differences between Python 2 and Python 3, you'll learn how Python has been used in applications such as YouTube and Google App Engine. As we work with the language, you'll learn about control statements, delve into controlling program flow, and gradually work on more structured programs via functions.

As you settle into the Python ecosystem, you'll learn about data structures and study ways to correctly store and represent information. By working through specific examples, you'll learn how Python implements OOP concepts of abstraction, encapsulation of data, inheritance, and polymorphism. You'll be given an overview of how imports, modules, and packages work in Python, how you can handle errors to prevent apps from crashing, as well as file manipulation. By the time you complete this book, you'll have built up an impressive portfolio of experience and armed yourself with the skills you need to tackle Python projects in the real world.

About the Authors

Ryan Marvin is a software developer with extensive experience in Python. He has also worked with JavaScript and a bit of PHP. He has built web scrapers, built APIs, and worked on frontend apps using React and Angular. In his own time, he works on mobile applications and likes to contribute to open source. Currently, he is working with Andela and specializes in building smart water grid software for one of their partners.

Mark Ng'ang'a is a software developer who specializes in web technologies. He has a bachelor's degree in computer science from Jomo Kenyatta University of Agriculture and Technology, Kenya. He has been programming for 6 years in Python, PHP, and JavaScript. Mark runs a software development and consultancy firm, Builtapp Ltd., that designs, plans, and builds software solutions for diverse business needs.

Amos Omondi is a software developer, who specializes in building applications for the web. He has a bachelor's degree in computer science from Kenyatta University, Kenya. He has several years of experience working with Python, and he has dabbled in languages such as PHP, Java, C, and built products using the MEAN stack.

Learning Objectives

  • Understand how to use control statements

  • Manipulate primitive and non-primitive data structures

  • Use loops to iterate over objects or data for accurate results

  • Write encapsulated and succinct Python functions

  • Build Python classes using object-oriented programming

  • Manipulate files on the file system (open, read, write, delete)

Audience

The Python Fundamentals course is great for anyone who wants to start using Python to build anything from simple command-line programs to complex scripts. You do not need any prior knowledge of Python.

Approach

This book takes a hands-on approach to demonstrate how Python can be used in production environments. It contains multiple activities that use real-life business scenarios for you to practice and apply your new skills in a highly relevant context.

Minimum Hardware Requirements

For an optimal student experience, we recommend the following hardware configuration:

  • Processor: Intel Core i5 or equivalent

  • Memory: 8 GB RAM

  • Storage: 4 GB available space

  • Internet connection

Software Requirements

You'll also need the following software installed in advance:

  • Operating system: Windows 7 or Windows 10

  • Browser: Google Chrome (latest version)

  • Python 3.6+

  • A text editor

Conventions

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Create a new file named binary_converter.py."

A block of code is set as follows:

>>> question = "Who was the first Beatle to leave the group?"
>>> len(question)
44

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "You can then click on Download Data."

Installation

Before we start, we’re going to have to install Python on our machines first. You can go to https://www.python.org/downloads/windows/ and can click on the latest Python 3.6.x release download link. In our case, it’s the Python 3.6.4 link.

Installing the Code Bundle

Copy the code bundle for the class to the C:/Code folder.

Additional Resources

The code bundle for this book is also hosted on GitHub at: https://github.com/TrainingByPackt/Python-Fundamentals.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!