Skip to content

making list:
name=[a,b,c]
updating data in the list:
name[0]=10.5 -updating first element of the list
deleting elements from the list:
del(name[1])
copying lists:
areas_copy = list(areas)
areas_copy = areas[:]

Functions:
type() - return type of a value
max() - max value of the list
round(value,rounding precision)
help() - info about function
str() - string
int() - integer
bool() - true or false
float() - float number
len() - lenght of the list, number of elements
sorted(name,reverse=False or True)


Methods:

  • for lists:
    fam - name of list
    fam.index("mom") - looking for value "mom" in fam list and returns number of index
    fam.count(1,73) - return number of times 1,73 value is in the fam list
    fam.append("me") - adding value "me" to the fam list
    for strings:
    sister - string variable
    sister.capitalize() - returns first letter capitalized sister value
    sister.replace("z","sa") replace "z" with "sa" in sister value
    upper() - capitalize all letters

python packages
import math - for exaple
math.pi - use constant pi
from math import pi - importing only one function
numpy - additional feature that provides us possibility to do calculations on list
import numpy as np
np.height = np.array(height) convert list to np array
np.mean

matplotlib for drowing plots
import matplotlib.pyplot as plt
plt.plot(x,y)
plt.scatter(x,y)
plt.show()