Skip to content
1 hidden cell
Introduction to Python
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.
- In order to execute a command and create output, the command 'print()' must be used
- Variables can be created using e.g. varibale = value
- bool = True or False functions (caps is important)
- float = whole or fractional integers
- int = integer/whole numbers
- str = a type to represent text
- These behave differently
- To find out the type of a value or a variable that refers to that value, you can use the type() function.
# Addition, subtraction
print(5 + 5)
print(5 - 5)
# Multiplication, division, modulo, and exponentiation
print(3 * 5)
print(10 / 2)
print(18 % 7)
print(4 ** 2)
# How much is your $100 worth after 7 years?
print(100 * (1.1 ** 7))
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'
)?