Python: Data Types
Fundamentals of Python Contents
Review the fundamentals of Python with 1: Variables and Strings
this short e-book. Check out the table of 2: Integers, Floats, and Booleans
contents to navigate to each topic. 3: Lists
4: Tuples and Sets
5: Dictionaries
Variables
A variable is a name associated with a value. It can be named anything, but
It cannot start with a number
It cannot contain spaces
The only symbol it can contain is the underscore.
Correct Incorrect
Strings
A string is a sequence of characters surrounded by quotation marks: single
quotes '' or double quotes ""
Anything surrounded by the quotation marks indicate a string
Every opening quote must have a closing quote to form a string
If opening a string with a single quote, the closing quote must be a single
quote as well.
The Complete Python Course on Udemy Page 1 of 5
Python: Data Types
Correct
Incorrect
Integers
An integer is a whole number of any Examples
length that can be positive or negative, -1 0 1 86400
written without a fractional element.
Floats
A float is a number that can be positive Examples
or negative written with a fractional -100.54 1.0 59.1
element.
Booleans
One of two values: True and False .
Extra Resources
What are variables
Strings and number
String formattin
Strings, Variables, and Getting Input from Users
The Complete Python Course on Udemy Page 2 of 5
Python: Data Types
Lists
An ordered, sequential data type
Used to store multiple elements in one variable
Defined by using a pair of square brackets.
Lists can contain different data types.
Each element in a list has a position (index) through which it can be accessed.
Extra Resources
What is a list
Split, join, and slice
Extending Python lists
The Complete Python Course on Udemy Page 3 of 5
Python: Data Types
Tuples
Similar to lists, but are immutable
Defined by separating multiple values with commas
For better readability, it can be surrounded by parentheses (brackets).
Sets
An unordered data type
Elements cannot be accessed by their indices
Defined by using a pair of curly braces.
Extra Resources
Basic Python collection
Sets - 30 Days of Pytho
Python set operators
The Complete Python Course on Udemy Page 4 of 5
Python: Data Types
Dictionaries
Defined with 3 key components: curly braces, keys, and values
Keys must be strings or other hashable values
Values associated to each key can be anything
Dictionaries can be defined in one line:
Or in multiple lines to aid readability:
Access values in a dictionary by using square brackets and the key:
Extra Resources
What is a dictionary
Updating Python dictionaries
The Complete Python Course on Udemy Page 5 of 5