#9 Data Types

Previous post: https://codinghelp.site/knowledgebase/python/8-comments/

Next post: https://codinghelp.site/knowledgebase/python/11-loops/

The Data Types

Data Types are a very important concept in Python. Every “data” is one of the data types. You do not need to declare a data type in most cases.

The most important data types are:





There are more data types, but those are the most important ones and the ones you’ll use the most.

Data Types Syntax

The “string” data type is data that can be anything (general text).

The integer (short: int) is a data type that stores decimal numbers.

The float data type stores rational numbers.

The bool stores either True/False values.

To declare a data type, we do pass in the value we want to convert into the declaration or we can just:

  • type a decimal number for a integer
  • type True/False for a boolean
  • type a rational number for a float
  • type a text inside “ “ or ‘ ‘ for a string

In most cases, we do not need to declare a data type, python does it for us! Isn’t that amazing? Here’s a example,

These are the same, no difference whatsoever.

To check a data type we use the function called type(). We pass in the parentheses the value we want to check. Here’s a example,

This would tell us that my_text variable is a string.


Here is a example of using the data types:

These are the same, no difference whatsoever.


Print the following data and make sure they’re the correct data type:

  • 1.1
  • 5
  • True
  • Hello

Answer Key