Note that this site is in currently in version 1.0.0-alpha.   Some functionality may be limited.

2. Types

Types are classifications that let the computer know how a programmer intends to use a piece of data. You can just think of them as, well, types of data. We’ve already seen one type in the last section: the integer. In this section, we’ll learn four more: the floating point number, the string, the boolean, and the list. Enter these lines as you see them below:

>>> type(1)
<class 'int'>
>>> type(1.0)
<class 'float'>
>>> type("Hello there!")
<class 'str'>
>>> type(True)
<class 'bool'>
>>> type([1, 2, 3])
<class 'list'>

Each of the responses show how the different types of data registers as different “types” for Python: Integers (like 1 above) are whole numbers. Floats (like 1.0 above) are numbers with decimals, and are treated a little differently than integers. Strings (like "Hello there!" above) are arbitrary sets of characters, such as letters and numbers. You can think of them as a way to store text. Booleans: (like True above) is a fancy term for values representing “true” and “false,” or “truthiness” and “falsiness.” In Python they are always capitalized: True and False. Lists: (like [1, 2, 3] above) are ordered collections of values. You can put any of the other types in a list: ["hello", "goodbye", "see ya later"] is also a valid list. Don’t worry about trying to actively remember these types. We’ll be working with each in turn in the following sections.

What’s the deal with type()?

type() is a function. You can think of functions in Python in a few different ways:

  1. A way of doing something in Python.
  2. A way of saving some code for reuse.
  3. A way of taking an input, transforming that input, and returning an output. The input goes in the parentheses ().

These are all valid ways of thinking about functions. We’ll be learning more about functions in later sections.

Challenges for lesson 2

Assignment: Challenge

Open your web browser, and google the phrase “python function.” Skim through the first few results. What words do you recognize, and which ones look unfamiliar? What do you think the unfamiliar ones mean? Try to rephrase some of this new language, and guess what they mean in your own words.

When you google “python function,” you may see some phrases that look unfamiliar, like “return value” or “pass parameters.” These are advanced terms for inputting and outputting data from a function. It’s important to become familiar with the Python’s terminology about functions, as it will be helpful later on when you start working with these components.


Try again!

Select all the following that accurately describe the data type categories.

(Select all that apply)

Terms Used in Lesson

Can you define the terms below? Hover over each of them to read a preview of the definitions.


A data type in Python that is either “True” or “False” and is often used as a basic building block for logical operations. They are implied in conditional statements (which check if expressions are true …

See term page


A data type in Python that represents numbers with decimal points.

See term page


Functions are ways of doing things in Python. They take some input and do something with it, and can return a value. For example, a function can return the results of a calculation. If your …

See term page


An integer is a data type, like string, list, boolean, and float. It signifies any value that is a whole number. You can check if a value is an integer with the type() function, passing …

See term page


A list is a data type, like string, integer, float, and Boolean. A list holds items in a sequence, separated by commas and contained within square brackets. They can hold different types of data, like …

See term page


A data type in Python that represents a sequence of alphanumeric and/or special characters enclosed within single or double quotes. For example, the following are all strings: "hello world!" "The answer is 3" "!!!"

See term page


Python type() is a function that evaluates the data type of the object within the parenthesis. For a string "hello world", it will return: <str>; for an integer 5, it will return <int> and so …

See term page

Workshop overall progress