Black Friday Special Happening Now! Get 25% off all products with code BF2021!

Dunder Data Python Challenge Solutions 1-5

python challenge Nov 17, 2021

The solutions to the five Dunder Data Python Challenges will be presented below. Try these challenges for yourself at python.dunderdata.com before looking at the solutions. Video solutions for all of the challenges are available on YouTube.

Challenge #1 (1pt)

Given a list of integers. Return the difference between the largest and smallest values.

def exercise_1(a_list):
"""
Parameters
----------
a_list : a list of integers

Returns
-------
an integer
"""
# YOUR CODE HERE
return max(a_list) - min(a_list)

Video solution to challenge #1

Challenge #2 (1pt)

Given any number of lists of integers, return the list with the largest total. Check the note below if you do not understand *lists in the function signature.

def exercise_1(*lists):
"""
Parameters
----------
lists : a tuple of lists of integers

Returns
-------
a list
"""
# YOUR CODE HERE
return max(lists, key=sum)

Video solution to challenge #2

def exercise_1(*lists):
"""
Parameters
----------
lists : a tuple of lists of integers

Returns
-------
a list
"""
# YOUR CODE HERE
return max(lists, key=max)

Video solution to challenge #3

Challenge #4 (1pt)

Given any number of lists of integers, return the list with the single largest value.

def exercise_1(*lists):
"""
Parameters
----------
lists : a tuple of lists of integers

Returns
-------
a list
"""
# YOUR CODE HERE
return max(lists, key=max)

Video solution to challenge #4

Challenge #5 (2pts)

Given any number of lists of integers, return the maximum value at each position as a list. Assume all lists are the same length.

def exercise_1(*lists):
"""
Parameters
----------
lists: a tuple of lists of integers

Returns
-------
a list
"""
# YOUR CODE HERE
return list(map(max, zip(*lists)))

Video solution to challenge #5

Lots more challenges!

Dunder Data Python and Pandas are released each weekday and cover a wide variety of topics. They will get more difficult over time. Take them for free at python.dunderdata.com.

Close

Register for a free account

Upon registration, you'll get access to four free courses.