Python: The Essentials

Learn the essential Python data types and concepts like numbers, text, errors, and comments.

We'll cover the following

This course will go through some Python basics before moving into code examples. You can always learn the most about Python by writing programs instead of just reading about it. Follow along, tweak different parts of the programs in the following chapters, and do not be afraid to think, “Huh, that’s weird…” or “I wonder what would happen if…” or “I wonder if I can do [x] in Python…” (Hint: yes, you probably can.) If you feel that this chapter moves too quickly, I recommend trying another Educative course or some Edpresso shots to get some of the basics down. Thanks to the Freedom of Information Act request, the National Security Agency (NSA) declassified and published its 595 page Introduction to Python course syllabus. This document, and the rest of this course’s example programs, can be found at this course’s GitHub repository [2]. In this section, you will learn some Python basics, and then in the next chapter, you can begin coding. I would recommend at least briefly reviewing this section to really grasp the syntax and language.

Everything in Python is some sort of datatype. It is similar to how everything in the world is some type of thing or has a classification, like a plant, an animal, a car, or a star. It can be hard to explain and conceptualize but easy to understand.

Integers

Numbers are the easiest to explain: the first data type is int, short for integer. An integer is any whole number such as 1, 7, -15, 15415, 801597, or any other whole, non-decimal numbers. In Python, you can perform the four basic mathematical operations of addition, subtraction, multiplication, and division with their usual operators. The addition is represented with +, subtraction is represented with -, multiplication is represented with *, and division is represented with /. For this course, you will need to use print() to see any output. Try those operations in the code field below:

print(1+1)

Get hands-on with 1200+ tech skills courses.