Tuesday, October 14, 2014

Day 140

Python at CodeCademy. Worked on Python tutorial 8 of 13, A Day at the Supermarket: Keeping Track of the Produce! Worked on printing out.

Code used:
prices = {
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
}

stock = {
    "banana": 6,
    "apple": 0,
    "orange": 32,
    "pear": 15
}

for key in prices:
    print key
    print "price: %s" % prices[key]
    print "stock: %s" % stock[key]

Interaction for this code:
orange
price: 1.5
stock: 32
pear
price: 3
stock: 15
banana
price: 4
stock: 6
apple
price: 2
stock: 0

No comments:

Post a Comment