Skip to content

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.

Add your notes here

# 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 and soccer_heights to find out!
  • What is the average rating for attacking players ('A')?

Other variable types In the previous exercise, you worked with two Python data types:

int, or integer: a number without a fractional part. savings, with the value 100, is an example of an integer. float, or floating point: a number that has both an integer and fractional part, separated by a point. growth_multiplier, with the value 1.1, is an example of a float. Next to numerical data types, there are two other very common data types:

str, or string: a type to represent text. You can use single or double quotes to build a string. bool, or boolean: a type to represent logical values. Can only be True or False (the capitalization is important!).