Skip to content
Python Notes
Introduction to Python
Run the hidden code cell below to import the data used in this course.
'+' is used to sum numbers and also copy paste strings
type() function is used to find the type of the
Data Types
- float - real numbers
- int - integer numbers
- str - string, text
- bool - True, False
height = 1.73
tall = True
each variable respresents single value
List
- [a,b,c]
[1.73, 1.68, 1.71, 1.89]
fam = [1.73, 1.68, 1.71, 1.89]
print(fam)
print(type(fam))
- Name a collection of values
- contain any type
- contain different type (even a list)
fam = ["liz", 1.73, "emma", 1.68, "mom", 1.71, "dad", 1.89]
print(fam)
print(fam[3])
print(fam[-1])
Now insert lists into list
fam2 = [["liz", 1.73],
["emma", 1.68],
["mom", 1.71],
["dad", 1.89]]
print(fam2)
print(type(fam2))
Slicing
fam[3:5]
fam = ["liz", 1.73, "emma", 1.68, "mom", 1.71, "dad", 1.89]
print(fam[3:7]) #index 3 to before of index 7
print(fam[:4]) #index 0 to before of index 4
print(fam[5:]) #index 5 to last index
# Adding a element into the list
fam_ext = fam + ["me", 1.79]
print(fam_ext)
# Deleting an element from the list
del(fam_ext[2])
print(fam_ext)