Introduction to Python
Run the hidden code cell below to import the data used in this course.
1 hidden cell
Take Notes
Add notes about the concepts you've learned and code cells with code you want to keep.
generate data using np.random.norma(mean, std, number of samples)
list manipulation
assuming a list called cars containing different cars models in a car agency cars["Toyota", "Merceds", "Lexus", "Audi", "Jeep"]
-updating cars[3] = "Honda"
-adding cars + "VolksWagen" -removing del(cas[2])
lists when created are refereed to a memory address that contains its values (referred by reference).
Diffeternt types, different behavior!!
python types: 1- integers (e.g 1,2,3) 2- floats (e.g 1.5, 2.82939) 3- strings (e.g 'hi', "pass_8449dk") 4- boolean (True, False) 5- list (e.g ['clean car', [1, 'clean car'], True])
List Type:
lits are zero indexing e.g scores = [18, 5, 1.67, 78] To access element 5: scores[1]
you can access list from right by using negative index e.g scores[-1] returns 78 list slicing: to take only certain elements use the syntax [ start: end] scores[1 : 3] returns [5, 1.67] scores [:] return [18, 5, 1.67, 78]
# Add your code snippets here
Explore Datasets
Use the arrays imported in the first cell to explore the data and practice your skills!
- Print out the weight of the first ten baseball players.
- What is the median weight of all baseball players in the data?
- Print out the names of all players with a height greater than 80 (heights are in inches).
- Who is taller on average? Baseball players or soccer players? Keep in mind that baseball heights are stored in inches!
- The values in
soccer_shooting
are decimals. Convert them to whole numbers (e.g., 0.98 becomes 98). - Do taller players get higher ratings? Calculate the correlation between
soccer_ratings
andsoccer_heights
to find out! - What is the average rating for attacking players (
'A'
)?