Introduction to Python 3 (basics) - Learning to Program with Python 3




What you will need for this tutorial series:
  1. Python 3+, downloaded from Python.org
  2. A willingness to learn!

Welcome to an introduction to Python and Programming. My goal with this series is to do things a bit different than you usually see with programming tutorials. The problem with most basics tutorials is they just cover the syntax of a language and use a toy example per new concept, repeating this through up to 100s of things like statements, methods and other paradigms of programming.

For one, this is boring. Two, this isn't how anyone I have ever met actually learns to program, it's certainly not the way I did it, and my goal with this website and youtube channel has always been to produce content in the way that I wish I had been taught. With my current basics series, I typically tell people to follow the basics until part 13 (it's a 70 part series), but even to part 13 isn't quite how I think one should learn to program or Python.

If you find this series too fast-paced, as some have, you can view the older one, which moves much slower and is more basic original Python 3 basics tutorial. Save/bookmark it if you want, or you can just come back here if you're feeling overwhelmed with this series.

The way you will actually learn to program with a language like Python is the culmination of 3 things:

  1. What's "Programming" - what programming actually is, including the proper terms to describe what you're doing.
  2. Your tool set - An understanding of the language you're working with specifically, including things like built-in functions, syntax...etc.
  3. How to put these things together to achieve some task - This is something that sits outside of the programming language. Most projects, applications...etc are not language specific, they can be made in *any* language. The art of going from idea to code is something you have to learn as well.

So, here's the deal. If you're looking for some sort of, step by step, reference guide to the language, look no further than the official Python 3 tutorial. All other Python 3 tutorials that I have ever seen are just versions of that, including the old ones I have done. This is why I don't see much point in doing that again. If you already know a programming language well, then you should be just fine going through the official docs. If you're new to programming or you still want to follow along for whatever reason, let's do it!

Python is a general-purpose programming language, built on top of C. What can you do with Python? Just about anything, and most things quite easily. Topics like data analysis, machine learning, web development, desktop applications, robotics, and more are all things that you can immediately begin doing with Python without much effort. Personally, I've used Python to create various websites, including this one! I've used Python to train an AI to play Grand Theft Auto 5, to help companies detect diseases, to help detect fraud and abuse against servers, to create games, to trade stocks, and I've built and helped to build multiple businesses with Python. Python and programming is life-changing, and it's my honor to share it with you!

While raw Python is single-threaded and slow, Python in practice is actually quite fast, far faster than any code most of the people telling you that Python is slow could write on their best day. That said, if you were seeking out the absolute quickest execution time, you would still likely be going with C variant, no question about that. The beauty of Python is in just how quickly and easily you can create things. Most of us aren't writing operating systems, not because we're too stupid, but because we don't need millions of operating systems. We do need millions of apps in this world, however.

Python has a robust and ever-growing community of people who build what are called "packages," "libraries," "wrappers", "frameworks," or any of the other names people might give them. Where speed counts, the heavy-lifting of these packages is done in C/C++, but you interface with them in Python. So when you're doing data analysis with Python, you get the ease and speed of development that we know and love with Python, but the number crunching, under the hood, is happening in C/C++.

Alright, let's make some stuff. Your operating system is not important. I will be using Windows, because that's what works best with my recording and editing software. You can use whatever OS you like!

To get Python, download Python 3+ from Python.org.

I will be doing this series in Python 3.7. You should be able to follow along in future versions of Python 3 as well. If you're having trouble, just ask! Either post a comment on the related YouTube video, or join our Python Discord. If you're on a 32-bit machine, go to downloads, and download Python 3. If you're on a 64-bit machine, make sure you get 64-bit Python. You want 64 bit Python so you don't have a 2gb memory limit. At the moment, the path to get 64-bit Python on Windows, for example, is to hover downloads, choose "All releases," scroll down, choose the latest Python version, click on the version # part, scroll all the way down to the bottom, and choose the 64-bit version that matches your operating system. For me, I am going with Windows x86-64 executable installer.

Now, run this. You can either "install now" or customize the installation. I prefer to customize the install path to a simpler-than-default path. So I am going to choose the custom install, after checking the box for Add Python 3.7 to PATH. Hit next, I am going with all of the defaults except for the installation path. I am going to go with C:/Python37 instead. Nice and short. I have multiple versions of Python on my system. As you continue with Python, you probably will too. it's nice to be able to quickly reference one or the other. With that, install it!

Next, you're going to need an editor. Which editor isn't really all that important, just find one you like. You could write your Python in notepad or a Word document if you wanted. I wouldn't suggest it, but you could.

Everyone is going to tell you that their editor is the best for whatever reasons. It just doesn't matter all that much. I personally prefer simpler editors. I used IDLE, the editor that comes with Python for about 5 years, and still often use that to this day. I like simple editors *because* they don't do things for me. As time has gone on, I've moved more towards Sublime-Text, which is what I am using for this series. Probably the most popular editor is PyCharm at the moment. For a full list, check out all of the Python Editors. There are quite a few! Because there are so many editors, I do not wish to spend much time on setting them up. I suspect, however, a large portion of people will want to use sublime-text since that's what I am using here. My setup of Sublime-text is super basic, so that wont take long!

Once you've installed sublime, you can right-click a file and open in sublime, or just open sublime-text, start typing, and file > save as. To run a file in sublime, you can press ctrl+b. It will ask you the first time here how you want to run, choose Python. Simple as that. You can also run python from the terminal/command line. More on that later too.

For now, you can write the following in sublime-text:

print()

The print() is a built-in function (more on these later too) that outputs whatever you pass to the console. You can pass something as simple as a string here. A string is a type of object that is between quotes and generally is used to represent actual written text. This might be words, password hashes, names of people...etc. So let's print a string:

print("Hello Universe")

Now do ctrl+b to run it and you should see "Hello Universe" is output in the console. In sublime, this is at the bottom of the window.

Alright, so we've made our very first Python program, and it works! Woo! In the next tutorial, we're going to see one more basic example of the simplicity of Python before we dive in to our overarching project for this series.

The next tutorial:





  • Introduction to Python 3 (basics) - Learning to Program with Python 3
  • Tuples, Strings, Loops - Learning to Program with Python 3 (basics)
  • Lists and Tic Tac Toe Game - Learning to Program with Python 3 (basics)
  • Built-in Functions - Learning to Program with Python 3 (basics)
  • Indexes and Slices - Learning to Program with Python 3 (basics)
  • Functions - Learning to Program with Python 3 (basics)
  • Function Parameters and Typing - Learning to Program with Python 3 (basics)
  • Mutability Revisited - Learning to Program with Python 3 (basics)
  • Error Handling - Learning to Program with Python 3 (basics)
  • Calculating Horizontal Winner (tic tac toe) - Learning to Program with Python 3 (basics)
  • Vertical Winners - Learning to Program with Python 3 (basics)
  • Diagonal Winners - Learning to Program with Python 3 (basics)
  • Bringing Things Together - Learning to Program with Python 3 (basics)
  • Wrapping up Tic Tac Toe - Learning to Program with Python 3 (basics)
  • Conclusion - Learning to Program with Python 3 (basics)