Variable Types in Python

Table of Contents for this Page

  1. Common Variable types
  2. Python’s built in type function
  3. Naming Conventions for Variables (snake vs camel case)

Python supports the basic types of variables that  you would expect from a general purpose language. These are listed below.

  1. Number
  2. String (more here)
  3. Boolean
  4. List (more on lists here)
  5. Dictionary
  6. Tuple

Example Code 1

Code Example Python Variables and their Type

As you can see in example code 1 above, you do not need to do anything special to create a string variable versus creating a boolean variable .

Python does classify each variable’s datatype based on its value. You can always check the data type of a variable by using the Python function type as shown in code below.

Example Code 2

Using Python Type on variables

As example code 2 shows, can see above,  the   type  function returns the datatype of a variable. Maybe you’re wondering why there’s even a need for the type  function…we will talk more about that soon.