Introduction

A Brief Python History

Python has a rich history that spans several decades. Guido van Rossum began its development in the late 1980s and since then, it has evolved into one of the most popular programming languages.

Guido aimed to create a language that was easy to read, with a clean and intuitive syntax. The name "Python" was inspired by the British comedy group Monty Python's Flying Circus, highlighting Guido's fondness for the show.

Its first public release (version 0.90) was in 1991, with the release of the first production-level version (1.0) in 1994. The language quickly gained popularity due to its simplicity and readability. Since then, new versions have added many new features.

For much of Python's existence, version 2 was the version of choice for many Python programmers. In 2008, the version 3 release made many changes to the language. This version addressed various design flaws and inconsistencies in Python. Since many of these changes were incompatible with version 2, version 3 adoption was slow, mainly limited to new projects and the migration of libraries.

Python 2 support ended in 2020. It no longer receives updates, not even security updates. As of this date, all Python developers should be using Python 3.

Python's Future

Python's future seems rock solid. Its popularity and continued growth suggest that it will continue to be used widely. Its readability, versatility, and extensive ecosystem suit many applications and problem domains.

It seems unlikely there will be a Python version 4 anytime soon. The creators learned much from the painful, decade-long migration from Python 2 to Python 3 and are not eager to repeat that. Instead, there will be slow, steady improvements to the language with new minor versions (e.g., from 3.9 to 3.10) introduced as needed. More importantly, future changes probably won't introduce significant incompatibilities as did version 3.

Abstraction

In programming and computer science in general, there is a concept called abstraction. Abstraction ensures that users don't need to know what's happening "under the hood." A simple example should help illustrate the concept.

Think about the mobile phone you use daily to communicate with your friends and loved ones. You want to make and receive calls, use text messaging, check your Facebook and X (formerly known as Twitter) accounts, and perhaps take photos. Customers use the manufacturer's user interface (UI) to access the phone's essential features. However, most people don't know or care how to repair their phone or write software for it.

On the other hand, a phone technician needs a different type of interface at a lower level of abstraction. She needs to know how the components work together so she can repair phones that aren't working. Software engineers must understand how the software subsystems interoperate. They must also concern themselves with the Operating System and software development tools. That, too, is at another lower abstraction level.

A similar analysis applies to computers. The user uses computers to listen to music, send emails, play games, and more. They interact with the applications that make these tasks possible without knowing the low-level details.

Programmers, however, operate at a lower level of abstraction by using a programming language like Python. Python, in turn, gets processed by a program called an interpreter; the interpreter is written in a lower-level language like C. The interpreter converts Python code to a lower-level code format called byte code. Eventually, the original Python code ends up as a series of 1s and 0s that the computer understands. In effect, every programming language requires lower-level layers of code that make it easy to use.

There are also higher-level abstractions. Some Python programmers use the language to design and build tools that operate at a higher level, including libraries and frameworks like NumPy and Flask, which are popular today. These tools let Python developers build programs on top of existing components without knowing how to implement the features they provide.

As a beginner, you must understand how Python, the programming language, and the tools and frameworks you may have heard about are at two different levels of abstraction. It's possible to learn the basics of some of these tools without understanding Python; however, to fully take advantage of their power, you must understand the fundamentals first. Learning Python in depth helps you better understand frameworks, and reading and maintaining programs that use those frameworks becomes easier. Understanding lower levels of abstraction will help you better use tools with higher abstraction levels. This book teaches you Python so that you can recognize and use higher-level abstractions with more granularity.

Who This Book is For

This book's intended audience is inexperienced or brand-new programmers. If you apply the principles and techniques described here, you'll acquire a solid foundation to build your Python programming career. You may use this knowledge to continue to learn more integrated concepts.

That said, this book goes into sufficient detail that even experienced programmers, including Python programmers, may benefit from reading it. Experienced programmers may find much of the material elementary. However, don't let that stop you from reading the book; you may learn something you didn't know or forgot years ago.

This book guides you through the common pitfalls and time sinks that beginners often experience. It should also provide you with enough practice to commit Python's basic syntax to long-term memory and help you acquire a certain level of muscle memory that will help you as a programmer. With this background, you can focus on solving real-world problems and building applications to solve them.

Software development is often perceived as a difficult discipline. It really isn't. Don't get us wrong; it's not easy. However, it does require a particular temperament: patience, persistence, focus, logic, detail-oriented, etc. When a programmer understands and adopts this temperament, their work becomes less frustrating, more fun, and more rewarding.

Perception of a task's difficulty is often inversely proportional to the patience of the person attempting it. Be patient with yourself and willing to take the time to work through the exercises and apply the concepts. You'll soon develop the temperament you need. Before you realize what's happening, you'll find yourself solving problems with code.

A shift in thinking must take place for most people. That will come with practice. Once it happens, your progress will accelerate. That will, in turn, help you develop the ability to think deeply about any programming problem. Most programmers find that being able to think deeply about issues is satisfying, engaging, and a rewarding perk of programming!

What's Not Covered

While skimming through the contents of this book, you may notice that it doesn't cover many topics that other Python books cover. The omissions are intentional: Python and programming are huge topics, and you'll benefit most from focusing on the fundamentals. Our goal is to introduce you to programming. Python happens to be the vehicle that we are using. As such, it covers the essential information you need to start your journey toward becoming a professional programmer.

Launch School's teaching philosophy centers around Mastery Based Learning, which means, among other things, that we introduce students to a new topic only when they have mastered the concepts needed to understand that topic. Learning the basic grammar of a programming language and solving computational problems with that language is a complex skill in its own right. You don't want to spend time learning peripheral information until you have the background and experience to solve programming problems with code.

Let's take a brief look at some of the topics that we chose to omit from this book but which you may find in some other introductory Python material. We cover many of these topics in depth in our Core Curriculum at Launch School, so we don't ignore them. However, there's a time and a place where a novice programmer is ready to learn about some topics.

3rd Party Libraries

If you've had any prior exposure to Python, you've probably heard of NumPy, Flask, and other libraries and frameworks. We do not cover any of these in this book.

Asynchronous Programming

In the wild, Python often has to deal with asynchronous operations, such as requesting and displaying data from a database. However, this advanced feature is best understood when you have a solid grounding in the basics. Initially, you won't have the context to understand why you need asynchronous operations. For that reason, we don't present it in this book.

Object-Oriented Python

Aside from a brief introduction to Python objects, we'll leave the OOP concepts for the future. You should focus on basic concepts and absorb those concepts before you're ready to tackle OOP. Besides, our Object Oriented Programming with Python book covers OOP.

Testing

Testing is crucial to writing good code; however, we don't believe an "introduction to programming" book is the best place to cover it. Testing is a technique you should learn after facing the problems it attempts to solve. It helps to have written sufficiently large programs to grasp that context. We cover testing in our Core Curriculum.

Intermediate Language Constructs and Concepts

  • Nested Comprehensions
  • Dunder Methods
  • Iterators
  • Decorators
  • File I/O

Unicode and ASCII

You can think of Unicode as a character set that lets computers work with almost any written (non-computer) language. As of 2023, Unicode has nearly half a million characters. Its importance in programming has grown enormously over the last decade or so. However, discussing it any detail piles on a lot of information that really isn't needed by most beginning programmers. Therefore, we will mostly ignore Unicode in this book, though there are a handful of mentions.

Before Unicode, we had the ASCII character set, now called the Standard ASCII character set. ASCII is now a very small subset of Unicode. It contains 128 characters consisting of:

  • the English letters, both upper- and lowercase (A-Z and a-z)
  • the 10 Arabic numerals (0-9)
  • almost 3-dozen control characters like line feeds and carriage returns
  • almost 3-dozen punctuation characters and symbols

You can see the standard ASCII character set here.

How to Read This Book

Reading about programming and writing a program aren't the same things. If you read this entire book but don't write any code, you may understand, intellectually, how to code, but you won't know how to do it. If someone asks you to solve a problem with a computer program, you won't be able to complete the task.

There is a "muscle memory" aspect to programming that books and courses often overlook. With the vast amount of information a programmer must remember, practicing some skills until they become automatic is unquestionably crucial. It doesn't require much effort; it happens naturally through repetition and practice. You can learn with your fingers; when you do, you free up your brain to focus on higher-level abstractions.

If you want a real shot at learning how to code, you should do every exercise in this book. Suppose you're going to learn to play a musical instrument. In that case, you must practice your scales on that instrument and develop proficiency. Both are necessary before you can play the instrument well.

Think of the exercises as though you are a musician practicing musical scales and writing a program as playing the instrument. Use the activities to practice and cement the basics into your fingers. The more you practice, the more coding becomes second nature and subconscious, which helps you learn to program.

This book's target audience is the beginner. In computer programming, you must learn an enormous amount of information. It isn't possible to know everything. We recognize that and intentionally avoid topics that aren't beneficial to the beginner. Trust these omissions; we've had some experience with teaching and know how easy it is to get lost "down the rabbit hole" looking for information on unimportant topics. Instead, stay focused. You'll progress at a much faster rate if you do.

That about covers it. Get ready to build the skills you need to become a computer programmer. Don't worry; we're here to coach you along the way. Buckle up and enjoy the ride!