Skip to content

Summary

Summary

In this chapter, we reviewed a couple of different data types built-in to Python. These data types include the numeric data types: integers, floats, and complex numbers. The string data type is composed of letters, numbers, spaces, and punctuation. Python also has container data types which can store many values. These container data types are lists, tuples, and dictionaries.

Key Terms and Concepts

data type

variable

assignment operator

integer

int

whole number

floating point number

float

scientific notation

complex number

string

boolean

bool

boolean arithmetic

boolean operators

or

and

not

data structure

dictionary

tuple

list

index

indexing

Summary of Python Functions and Commands

Built-in Data Types

Python Object Description
int integer
float floating point number
bool boolean value: True or False
complex complex number, real and imaginary components
str string, sequence of letters, numbers and symbols
list a Python list
dict a Python dictionary
tuple an immutable list

Python Functions

Function Description
type() outputs a variable or objects data type
len() return the length of a string
str() converts a float or int into a str (string)
int() converts a float or str into an int (integer)
float() converts an int or str into an float (floating point number)

Python List Operators

Operator Description Example Result
[ ] indexing lst[1] 4
: start lst[:2] [ 2, 4 ]
: end lst[2:] [ 6, 8 ]
: through lst[0:3] [ 2, 4, 6 ]
: start, step, end+1 lst[0:5:2] [2, 6]