Tuesday, November 25, 2014

Day 141

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]
    
total = 0
for key in prices:
    x = prices[key] * stock[key]
    total = total + x
print total

Interaction for this code:
stock: 15
banana
price: 4
stock: 6
apple
price: 2
stock: 0
117.0
None

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

Day 139

Python at CodeCademy. Worked on Python tutorial 7 of 13, A Day at the Supermarket: Your Own Store! Worked on creating another dictionary .

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

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

There was no interaction for this code:

Day 138

Python at CodeCademy. Worked on Python tutorial 6 of 13, A Day at the Supermarket: Your Own Store! Worked on creating a new dictionary .

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

There was no interaction for this code:

Sunday, October 12, 2014

Day 137

Python at CodeCademy. Worked on Python tutorial 5 of 13, A Day at the Supermarket: String Looping! Worked on looping through strings, like lists.

Code used:
for letter in "Codecademy":
    print letter

print
print

word = "Programming is fun!"

for letter in word:

    if letter == "i":
        print letter

Interaction for this code:

C
o
d
e
c
a
d
e
m
y

i
i

Day 136

Python at CodeCademy. Worked on Python tutorial 4 of 13, A Day at the Supermarket: Lists + Functions! Worked on using lists as inputs to perform various operations on those lists.

Code used:
def fizz_count(x):
    count = 0
    for item in x:
        if item == "fizz":
            count = count + 1
    return count

There was no interaction for this code:

Friday, October 10, 2014

Day 135

Python at CodeCademy. Worked on Python tutorial 3 of 13, A Day at the Supermarket: Control Flow and Looping! Worked on performing different actions depending on the particular item in the list, while looping.

Code used:
a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

for number in a:
    if number % 2 == 0:
        print number


Interaction for this code:
0
2
4
6
8
10
12