Lesson 01-01: Datatypes in Python

Learning Target: I can describe the ways in which Python can represent data.

What is data?

Everything you see right now is data. Cellular signals flying through the air is data. A text message, a song, a video, is all data. Even though data comes in many forms, there are some very simple representations of data, called basic datatypes, that we will be learning about. Here’s an example of datatypes in the real world, on the Internet Movie Database’s page for Inside Out, an excellent movie from 2015.

Datatypes on the IMDB page
In Python, the five basic datatypes that we will be learning are:
  • int

    int is short for integer, which means any whole number (a number with no decimals). In Python, a number is an int when it has no decimal point.

    Examples of integers are: 1, -402, 9999999

  • float

    float is short for floating point number, which, simply put, is a more specific way of representing numbers - this allows us to use decimals. In Python, a number is a float when it has a decimal point and a number following the decimal point.

    Examples of floats are: 0.0001, -402.0, 1234.5678

  • string

    A string is another way of saying text - representing letters, digits, and symbols. In Python, data is a string when it is surrounded by single or double quotes.

    Examples of strings are: "x", 'a string', "2#%a  bcd&  *1 *64jed#@ (*S )"

  • boolean

    A boolean is a datatype with only two values - True or False. In Python, boolean values are represented by the words True and False - no quotes - and be sure to capitalize the first letter!

    The only two boolean values are: True, False

  • NoneType

    Interestingly enough, the NoneType in python is a datatype that represents no value. In Python, “no value” is represented by the word None - no quotes - and again, capitalize the first letter!

    The only NoneType value is: None

Practice: Check For Understanding

Q#1

    ch0101-1: What datatype would "Nice to meet you!" be?
  • (A) int
  • int is short for integer, which is a number. Try again! Hint: What datatype uses quotes?
  • (B) float
  • float is short for floating point number. Try again! Hint: What datatype uses quotes?
  • (C) string
  • Great job - only strings will use quotes!
  • (D) boolean
  • There are only two values for boolean - True and False. Try again! Hint: What datatype uses quotes?

Q#2

    ch0101-2: Which of the following datatypes represent types of numbers?
  • (A) boolean
  • Boolean has two values, while there are certainly more than two numbers in existence!
  • (B) int
  • integers are numbers!
  • (C) string
  • Strings use quotes, which numbers don't need..
  • (D) float
  • floats are short for floating point numbers!

Q#3

    Drag the datatypes on the left to the description on the right. You can look back to the notes if you need to!
  • float
  • Decimal number
  • boolean
  • True/False
  • int
  • Whole number
  • NoneType
  • Always None
  • string
  • Text, uses quotes

Q#4

    Drag the datatypes on the left to the example on the right. You can look back to the notes if you need to!
  • float
  • 5.0
  • boolean
  • True
  • int
  • 10
  • NoneType
  • None
  • string
  • "5"
Next Section - Lesson 01-02: Python Operators