Code Challenges
Notebook-based Python and Data Science Code Challenges with Solutions
Difficulty / 10
Mean of a List
1 / 10
Write a function that calculates the mean (average) of a list of numbers.
Vector Dot Product
1 / 10
Use Python (or NumPy if you really *have* to) to calculate the dot product of two vectors represented as Python Lists.
Standard Deviation of a List
2 / 10
Write a function that calculates the *sample* Standard Deviation of a list of numbers.
Random Matrix
2 / 10
Can you write a function that will generate a matrix (2D Python List or NumPy Array) of integers - with an indicated dimensionality? We'll tell you the number of rows and columns that the matrix should have, you do the rest.
FizzBuzz
2.5 / 10
FizzBuzz is one of the best-known code challenges in the world. Solving it with vanilla Python is fine. But things get spicy when other Python packages get involved.
Median of a List
3 / 10
Write a function that calculates the median of a list of numbers.
Variance of a List
3 / 10
Write a function that calculates the *sample* variance of a list of numbers.
Sample Covariance
3 / 10
Try your hand at calculating the sample covariance between two random variables (lists of integers).
Correlation Coefficient
3 / 10
Write a function to calculate the sample correlation coefficient (r). This task will be very approachable if you have already completed the Standard Deviation and Covariance code challenges.
Simple Linear Regression
4 / 10
Demonstrate that you can calculate the correct slope and intercept coefficient using a simple linear regression model in Python.