In this tutorial, you will learn about Python’s tuple data type:
If you prefer to read rather than watch, then you should check out Python 101 – Learning About Tuples
Get the Jupyter Notebook on Github
There are times when you are writing an application and you need to run another application. For example, you may need to open Microsoft Notepad on Windows for some reason. Or if you are on Linux, you might want to run grep. Python has support for launching external applications via the
subprocess module has been a part of Python since Python 2.4. Before that you needed to use the
os module. You will find that the
subprocess module is quite capable and straightforward to use.
In this article you will learn how to use:
Let’s get started! Continue reading Python 101 – Launching Subprocesses with Python
Application developers are always working with files. You create them whenever you write a new script or application. You write reports in Microsoft Word, you save emails or download books or music. Files are everywhere. Your web browser downloads lots of little files to make your browsing experience faster.
When you write programs, you have to interact with pre-existing files or write out files yourself. Python provides a nice, built-in function called
open() that can help you with these tasks.
In this chapter you will learn how to:
Let’s get started! Continue reading Python 101 – Working with Files
In this video tutorial, you will learn all about Python’s list data type.
If videos aren’t your thing, then you can read the same content here:
Creating software is hard work. To make your software better, your application needs to keep working even when the unexpected happens. For example, let’s say your application needs to pull information down from the Internet. What happens if the person using your application loses their Internet connectivity?
Another common issue is what to do if the user enters invalid input. Or tries to open a file that your application doesn’t support.
All of these cases can be handled using Python’s built-in exception handling capabilities, which are commonly referred to as the
In this article you will learn about:
Let’s get starting by learning about some of the most common exceptions. Continue reading Python 101 – Exception Handling
There are many times when you are writing code that you will need to find a way to iterate over something. Perhaps you’ll need to iterate over the letters in a string or the objects in a
list. The process of iterating over something is done via a loop.
A loop is a programming construct that allows you to iterate over chunks. Those chunks could be the letters in the string or the lines of a file.
In Python, there are two types of loop constructs:
Besides iterating over sequences, you can use a loop to do the same thing multiple times. One example is a web server that is basically an infinite loop. A server waits, listening for a client to send it a message. When it receives the message, the loop will call a function in response.
Another example is the game loop. When you beat a game or lose a game, the game doesn’t usually exit. Instead, it will ask you if you want to play again. This is also done by wrapping the entire program in a loop.
In this chapter you will learn how to:
Let’s get started by looking at the
for loop! Continue reading Python 101 – Learning About Loops
Type checking or hinting is a newer feature of Python that was added in Python 3.5. Type hinting is also known as type annotation. Type hinting is adding special syntax to functions and variable declarations that tell the developer what type the argument or variable is.
Python does not enforce the type hints. You can still change types at will in Python because of this. However some integrated development environments, such as PyCharm, support type hinting and will highlight typing errors. You can also use a tool called Mypy to check your typing for you. You will learn more about that tool later on in this article.
You will be learning about the following:
Let’s get started! Continue reading Type Checking in Python
You will be using strings very often when you program. A string is a series of letters surrounded by single, double or triple quotes. Python 3 defines string as a “Text Sequence Type”. You can cast other types to a string using the built-in
In this article you will learn how to:
Let’s get started by learning the different ways to create strings!
Dictionaries are another fundamental data type in Python. A dictionary is a key, value pair. Some programming languages refer to them as hash tables. They are described as a mapping object that maps hashable values to arbitrary objects.
A dictionary’s keys must be immutable, that is, unable to change. Starting in Python 3.7, dictionaries are ordered. What that means is that when you add a new key, value pair to a dictionary, it remembers what order they were added. Prior to Python 3.7, this was not the case and you could not rely on insertion order.
You will learn how to do the following in this chapter:
Let’s start off by learning about creating dictionaries! Continue reading Python 101 – Learning About Dictionaries