Python Lesson 3: Creating Variables

  1. Types of Variables
  2. Create an Integer
  3. Create a Float
  4. Create a Boolean
  5. Create a String

Variables in Python are programmer provided (hopefully user friendly) labels that store a value. Python is a dynamically typed language, which means that the variable is not tied to a particular type of data. For example, if you have a variable named “x” it can hold numeric values like (123123) or a string value like (“car”) or a boolean value like (True).

1) Types of Variables

Here is a Table containing the various data types available in Python

Data Type Description Example Values
Integers Numbers without decimal points. Can be any size. It is constrained only by the memory in your computer. 1  100  10000  1000000000000000000000000000000000000000000
Floating Point Numbers Numbers that require a decimal point. Can use scientific notation (eg .4e5 which is the same as 40000.0) 1.0 2.20 4.2022323234 1.2e-4  (same as .00012)
Boolean Can hold one of 2 values: True or False True False
Strings A sequence of characters. Are delimited by either single quotes (‘) or double quotes (“) ‘Hello’ “Hello” ‘Apollo 11’ ‘John\’s computer’ “John\’s computer”

2) Create an Integer

x = 100
Notebook Output

3) Create a Float

#Floating Point
x = 100.23
Notebook Output

4) Create a Boolean

x = True
Notebook Output

5) Create a String

x = "Hello"
Notebook Output