Book Image

Python Fundamentals

By : Ryan Marvin, Mark Nganga, Amos Omondi
Book Image

Python Fundamentals

By: Ryan Marvin, Mark Nganga, Amos Omondi

Overview of this book

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. 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. 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.
Table of Contents (12 chapters)
Python Fundamentals
Preface

Built-In Functions


The Python interpreter has a number of built-in functions and types that are always available. These are called built-in functions, and they can be used anywhere in your code, without the need of any importation.

Some of the built-in functions that we have already encountered in this book are as follows:

  • input([prompt]): This optionally prints the prompt to the terminal. It then reads a line from the input and returns that line.

  • print(): Prints objects to the text stream file or the terminal.

  • map(): Returns an iterator that applies a function to every item of the iterable, yielding the results.

For example, we recently used the built-in print() function to output results; the following is another simple demonstration:

print("Hello world")

This results in the following:

Hello world