Skip to content

Instantly share code, notes, and snippets.

@jjlumagbas
Last active October 24, 2016 04:57
Show Gist options
  • Save jjlumagbas/7d13fb04d96c6b23b9e2590b545cc1c0 to your computer and use it in GitHub Desktop.
Save jjlumagbas/7d13fb04d96c6b23b9e2590b545cc1c0 to your computer and use it in GitHub Desktop.
CMSC11 Lab 11 - Practice on map and filter

CMSC11 Lab Exercise 11 – Lists

Create the following functions. Don’t forget the design recipe! I’ll be looking for the following:

  • Signature, purpose, stub
  • Examples
  • Template

  1. Create a function bump_up that accepts a list of grades and returns the list with 20% added to each grade

  2. Create a function cold that accepts a list of temperatures in Celsius and returns only those below 20 degrees

  3. Create a function gmail_only that accepts a list of email addresses and returns a list of only those addresses that end with "@gmail.com"

  4. Create a function long_names that, given a list of names, returns a list of all names longer than 8 characters

  5. Create a function can_afford, that Prof. Cheapskate can use to determine which items to buy at the University Bookstore. He will only buy individual items that are less than 100 pesos. But because he's a Professor, he gets a 5% discount for all items at the bookstore. can_afford should take a list of prices (before discount), and produce a list of prices that he can afford with the discount applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment