curriculum/challenges/english/blocks/daily-coding-challenges-python/694596b0585c11170ac7c7f9.md
Given an array of strings representing items in your shopping cart, and a number for the minimum order amount to qualify for free shipping, determine if the items in your shopping cart qualify for free shipping.
The given array will contain items from the list below:
| Item | Price |
|---|---|
"shirt" | 34.25 |
"jeans" | 48.50 |
"shoes" | 75.00 |
"hat" | 19.95 |
"socks" | 15.00 |
"jacket" | 109.95 |
gets_free_shipping(["shoes"], 50) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(gets_free_shipping(["shoes"], 50), True)`)
}})
gets_free_shipping(["hat", "socks"], 50) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(gets_free_shipping(["hat", "socks"], 50), False)`)
}})
gets_free_shipping(["jeans", "shirt", "jacket"], 75) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(gets_free_shipping(["jeans", "shirt", "jacket"], 75), True)`)
}})
gets_free_shipping(["socks", "socks", "hat"], 75) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(gets_free_shipping(["socks", "socks", "hat"], 75), False)`)
}})
gets_free_shipping(["shirt", "shirt", "jeans", "socks"], 100) should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(gets_free_shipping(["shirt", "shirt", "jeans", "socks"], 100), True)`)
}})
gets_free_shipping(["hat", "socks", "hat", "jeans", "shoes", "hat"], 200) should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(gets_free_shipping(["hat", "socks", "hat", "jeans", "shoes", "hat"], 200), False)`)
}})
def gets_free_shipping(cart, minimum):
return cart
def gets_free_shipping(cart, minimum):
prices = {
"shirt": 34.25,
"jeans": 48.50,
"shoes": 75.00,
"hat": 19.95,
"socks": 15.00,
"jacket": 109.95
}
total = 0
for item in cart:
total += prices[item]
return total >= minimum