Intro to Data Types

The code used for this lesson is available here.

While programming, you will be storing and manipulating lots of data. But where does it all go?

Data is stored in something called a variable so that you can use it for something else later. When creating a variable, you give it a name and then tell it what will be stored in it. Like this:

favorite_number = 12

In this case, the variable name is favorite_number and the data that will be stored in it is 12.

Take note that the variable is always on the left side of the equal sign, and the data to be stored in it is on the right side.

You will encounter several different data types. The 3 most common types are integers, floats, and strings.

Integers are whole numbers like 12.

Floats are decimal point numbers like 12.0.

Strings are text like "howdy" or "My favorite number is 12". Note you can use numbers inside strings.

You will use these a lot, so take the time to do the reading below to make sure you are comfortable with them. :)

Reading material

  • Chapter 1 from Automate the Boring Stuff with Python
  • Basics from A Byte of Python

Optional Readings:
Variables, expressions and statements from How to Think Like a Computer Scientist
* Accompanying video
Data Types on Wikibooks