Implement p0 tutorial.

This commit is contained in:
2021-10-11 21:01:31 -04:00
parent a95016431f
commit cd948fe640
15 changed files with 165 additions and 159 deletions

View File

@@ -32,12 +32,15 @@ def buyLotsOfFruit(orderList):
Returns cost of order
"""
totalCost = 0.0
"*** YOUR CODE HERE ***"
return totalCost
try:
return sum([fruitPrices[fruit] * quantity
for fruit, quantity in orderList])
except KeyError:
print("Unexpected fruit!")
return None
# Main Method
if __name__ == '__main__':
"This code runs when you invoke the script from the command line"
orderList = [ ('apples', 2.0), ('pears', 3.0), ('limes', 4.0) ]
print 'Cost of', orderList, 'is', buyLotsOfFruit(orderList)
print('Cost of', orderList, 'is', buyLotsOfFruit(orderList))