Skip to content

Intermediate 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.

plt.plot = line chart and plt.scatter = scatter plot. follow each with plt.show()

need to bring in subpackage like: import matplotlib.pyplot as plt

histograms = bins x and ylabel functions title function does just what you think yticks - decide where the vertical tick marks are (list of ticks, list of display names for the ticks)

c and alpha arguments within plt.scatter function identify colors and opacity

  • the function np.nditer iterates over all elements in a numpy array
  • use the method items to iterate over elements of a dictionary
  • itterrows method is used to iterate over rows in pandas data frame

Explore Datasets

Use the DataFrames imported in the first cell to explore the data and practice your skills!

  • Create a loop that iterates through the brics DataFrame and prints "The population of {country} is {population} million!".
  • Create a histogram of the life expectancies for countries in Africa in the gapminder DataFrame. Make sure your plot has a title, axis labels, and has an appropriate number of bins.
  • Simulate 10 rolls of two six-sided dice. If the two dice add up to 7 or 11, print "A win!". If the two dice add up to 2, 3, or 12, print "A loss!". If the two dice add up to any other number, print "Roll again!".