Wednesday, May 28, 2014

Day 53

Explored Python at CodeCademy. Worked on Python tutorial 6 of 16, Strings & Console Output, lower(). Learned how to use lower().

The code used:
parrot = "Norwegian Blue"
print parrot.lower()

The interaction looked like this:
norwegian blue

Tuesday, May 27, 2014

Day 52

Explored Python at CodeCademy. Worked on Python tutorial 5 of 16, Strings & Console Output, String methods. Learned how to change strings using string methods.

The code used:
parrot = "Norwegian Blue"
print len(parrot)

The interaction looked like this:
14

Monday, May 26, 2014

Day 51

Explored Python at CodeCademy. Worked on Python tutorial 4 of 16, Strings & Console Output, Access by Index. Learned about accessing the index.

The code used:
# Assign the variable fifth_letter equal to the fifth letter of the string "MONTY."
x = "MONTY"[4]
fifth_letter = x
print fifth_letter

The interaction looked like this:
Y

Sunday, May 25, 2014

Day 50

Explored Python at CodeCademy. Worked on Python tutorial 3 of 16, Strings & Console Output, Escaping characters. Learned to fix apostrophe problems with backslash or double quotes.

The code used:
# Broken string.
'This isn't flying, this is falling with style!'
# Broken string fixes.
'This isn\'t flying, this is falling with style!'
"This isn't flying, this is falling with style!"

There was no interaction, fixed broken string.

Saturday, May 24, 2014

Day 49

Explored Python at CodeCademy. Worked on Python tutorial 2 of 16, Strings & Console Output, Practice. Created variables to their respective phrases.

The code used:
# Assign variables below
caesar = "Graham"
praline = "John"
viking = "Teresa"
print caesar
print praline
print viking

The interaction looked like this:
Graham
John
Teresa

Friday, May 23, 2014

Day 48

Explored Python at CodeCademy. Worked on Python tutorial 1 of 16, Strings & Console Output, Strings. Created a variable brian and assign it the string "Hello life!"

The code used:
# Set the variable brian.
brian = "Hello life!"

There was no interaction, the code only set a variable to a value.

Thursday, May 22, 2014

Day 47

Explored Python at CodeCademy. Worked on Python tutorial 5 of 5, Tip Calculator, The Total. Created a "total" value to come up with the total cost of the meal.

The code used:
# Assign the variable total
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal + meal * tax
total = meal + meal * tip
print("%.2f" % total)

The interaction looked like this:
54.63

Wednesday, May 21, 2014

Day 46

Explored Python at CodeCademy. Worked on Python tutorial 4 of 5, Tip Calculator, Reassign A Variable. Changed a variable "meal" with itself plus itself times the variable "tax."

The code used:
# Reassign meal to the value of itself + itself * tax
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal + meal * tax

There was no interaction, the code simply changed a variable to a new value.

Tuesday, May 20, 2014

Day 45

Explored Python at CodeCademy. Worked on Python tutorial 3 of 5, Tip Calculator, The Tip. Created a variable tip with a decimal value of 15%.

The code used:
# Assign the variable "tip" the value "15%!"
meal = 44.50
tax = 0.0675
tip = 0.15

There was no interaction, the code simply set the variables to the corresponding values.

Monday, May 19, 2014

Day 44

Explored Python at CodeCademy. Worked on Python tutorial 2 of 5, Tip Calculator, The Tax. Created a variable "tax" and set it equal to the decimal value of "6.75%."

The code used:
# Assign the variable tax the value 67.5%!
meal = 44.50
tax = 0.0675

There was no interaction, the code simply set the variables to the corresponding values.

Sunday, May 18, 2014

Day 43

Explored Python at CodeCademy. Worked on Python tutorial 1 of 5, Tip Calculator, The Meal. Declare the variable "meal" and assign it the value "44.50."

The code used:
# Assign the variable meal the value 44.50!
meal = 44.50

There was no interaction, the code simply set the variables to the corresponding values.

Saturday, May 17, 2014

Day 42

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 13 of 13, put everything I learned together.

The code used:
# single-line comment that starts with #
monty = True
python = 1.234
monty_python = python ** 2

There was no interaction, the code simply set the variables to the corresponding values.

Friday, May 16, 2014

Day 41

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 12 of 13, learned about using a modulo to returns the remainder from a division.

The code used:
#Set spam equal to 1 using modulo on line 3!
spam = 3 % 2
print spam

The interaction looked like this:
1

Thursday, May 15, 2014

Day 40

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 11 of 13, learned about using exponents.

The code used:
#Set eggs equal to 100 using exponentiation.
eggs = 10 ** 2
print eggs

The interaction looked like this:
100

Wednesday, May 14, 2014

Day 39

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 10 of 13, learned about using math.

The code used:
# Set count_to equal to the sum of two big numbers
count_to = 72 + 23
print count_to

The interaction looked like this:
95

Tuesday, May 13, 2014

Day 38

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 9 of 13, learned about multi-line comment.

The code used:
""" multi-line comment in the editor.
No # needed at all!
"""

There was no interaction, the code simply was to test out a multi-line comment.

Monday, May 12, 2014

Day 37

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 8 of 13, learned about single line comment..

The code used:
# Single line comment.
mysterious_variable = 42

There was no interaction, the code simply was to test out a single line comment.

Sunday, May 11, 2014

Day 36

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 7 of 13, learned about the interpreter, how it runs the code line by line, and checks for errors.

The code used:
spam = True
eggs = False

There was no interaction, the code simply set the variables to the corresponding values.

Saturday, May 10, 2014

Day 35

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 5 & 6 of 13, learned about whitespace.

The code used:
Started with
def spam():
eggs = 12
return eggs
print spam()

Ended with
def spam():
eggs = 12
return eggs
print spam()

The interaction looked like this:
12

Friday, May 9, 2014

Day 34

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 4 of 13, learned to change the value of a variable by "reassigning" it.

The code used:
my_int = 7
my_int = 3
print my_int

The interaction looked like this:
3

Thursday, May 8, 2014

Day 33

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 3 of 13, storing and working with different types of data using the “variable” functions, specifically “booleans”.

The code used:
my_int = 7
my_float = 1.23
my_bool = True

There was no interaction, the code simply set the variables to the corresponding values.

Wednesday, May 7, 2014

Day 32

Explored Python at CodeCademy. Worked on, Python Syntax tutorial 2 of 13, storing and working with different types of data using the “variable” function.

The code used:
my_variable = 10

There was no interaction, the code simply set the variable my_variable to stores the number 10.

Tuesday, May 6, 2014

Day 31

Explored some more Python at CodeCademy. Worked on, Python Syntax tutorial 1 of 13, started with a basic “print” function.

The code used:
print "Welcome to Python!"

The interaction looked like this:
Welcome to Python!

Monday, May 5, 2014

Day 30

Explored some Python at Gork Learning. Worked on, Hour of Code: The Dark Tunnel – adventure game! Put all learned functions into a copy of the completed game, with some added elements. Played the game a few times to finished the tutorial.

The code used:
monster_dead = False
has_sword = False
room = 1
end = False

print('The Dark Tunnel')
while not end:
# start room
if room == 1:
print("You are standing at the entrance to a long tunnel.")
if monster_dead == False:
print("You hear a low rumble in the distance.")
print("Actions available: look, forward")
cmd = input("> ")
if cmd == 'look':
if has_sword:
print("You look around in the darkness, but there is nothing here.")
else:
print("You look around in the darkness, and see something shiny.")
print("It is a sword. Would you like to pick it up (yes/no)? ")
get = input('> ')
if get == 'yes':
print('You pick up the sword.')
has_sword = True
else:
print('You leave the sword in the dust.')
elif cmd == 'forward':
room = 2
# monster room
elif room == 2:
if not monster_dead:
print("When you enter the room, a monster jumps out at you,")
print("its fangs white and sharp in the darkness.")
if has_sword:
print("You draw your sword and thrust it towards the leaping body.")
print("Your strike hits true and kills the monster.")
monster_dead = True
else:
print("With no way of defending yourself, the monster crushes")
print("your body and sinks its teeth into your flesh.")
print("You are dead.")
print("Game Over.")
end = True
else:
print("The monster's dead carcass lies on the floor,")
print("the sword still embedded in its flesh.")
# if the player is still alive, they can move
if not end:
print("Actions available: forward, backward")
cmd = input("> ")
if cmd == 'forward':
room = 3
elif cmd == 'backward':
room = 1
# exit - win condition
else:
print("You made it past the monster and have escaped the tunnel.")
print("Congratulations, you win.")
end = True

The interaction looked like this:
The Dark Tunnel
You are standing at the entrance to a long tunnel.
You hear a low rumble in the distance.
Actions available: look, forward
> look
You look around in the darkness, and see something shiny.
It is a sword. Would you like to pick it up (yes/no)?
> yes
You pick up the sword.
You are standing at the entrance to a long tunnel.
You hear a low rumble in the distance.
Actions available: look, forward
> look
You look around in the darkness, but there is nothing here.
You are standing at the entrance to a long tunnel.
You hear a low rumble in the distance.
Actions available: look, forward
> forward
When you enter the room, a monster jumps out at you,
its fangs white and sharp in the darkness.
You draw your sword and thrust it towards the leaping body.
Your strike hits true and kills the monster.
Actions available: forward, backward
> forward
You made it past the monster and have escaped the tunnel.
Congratulations, you win.

Sunday, May 4, 2014

Day 29

Explored some Python at Gork Learning. Worked on, Hour of Code: The Dark Tunnel – adventure game! Spent more time on the while function and expanding on the code that tracks which room the player is in so that the game ends when the player gets to the "end" room.

The code I used:
room = 1
end = False
while not end:

# start room
  if room == 1:
    print("Actions available: look, forward")
    cmd = input("> ")
    if cmd == 'look':
        print("You are standing at the entrance to a long tunnel.")
    elif cmd == 'forward':
      room = 2

  # middle room
  elif room == 2:
    if not end:
      print("Actions available: look, forward, backward")
      cmd = input("> ")
      if cmd == 'look':
        print("You are in the depths of the tunnel.")
      elif cmd == 'forward':
        room = 3
      elif cmd == 'backward':
        room = 1

  # exit room
  else:
    print("You have escaped the tunnel. You win!")
    end = True


The interaction looked like this:
Actions available: look, forward
> backward
Actions available: look, forward
> look
You are standing at the entrance to a long tunnel.
Actions available: look, forward
> forward
Actions available: look, forward, backward
> look
You are in the depths of the tunnel.
Actions available: look, forward, backward
> backward
Actions available: look, forward
> look
You are standing at the entrance to a long tunnel.
Actions available: look, forward
> forward
Actions available: look, forward, backward
> forward
You have escaped the tunnel. You win!

Saturday, May 3, 2014

Day 28

Explored some Python at Gork Learning. Worked on, Hour of Code: The Dark Tunnel – adventure game! Spent more time on the while function to repeat things while a particular condition is true.

The code I used:
mouse_alive = True
while mouse_alive:
print("You better set the trap!")
trap = input("Have we set the trap yet? ")
if trap == "yes":
mouse_alive = False
print("That mouse is toast!")

The interaction looked like this:
You better set the trap!
Have we set the trap yet? no
You better set the trap!
Have we set the trap yet? uh uh
You better set the trap!
Have we set the trap yet? yes
That mouse is toast!

Friday, May 2, 2014

Day 27

Explored some Python at Gork Learning. Worked on, Hour of Code: The Dark Tunnel – adventure game! Learned to use the while function to repeat things while a particular condition is true.

The code I used:
command = input("Enter a command: ")
while command != "quit":
print("Your command was:", command)
command = input('Enter a command: ')

The interaction looked like this:
Enter a command: look
Your command was: look
Enter a command: forward
Your command was: forward
Enter a command: quit

Thursday, May 1, 2014

Day 26

Explored some Python at Gork Learning. Worked on, Hour of Code: The Dark Tunnel – adventure game! Learned to use the elif function to store the user's current location in a variable room, and updating that variable based on their chosen action.

The code I used:
print("Actions available: forward, backward, look")
action = input("> ")
if action == "forward":
room = "end"
elif action == "backward":
room = "start"
elif action == "look":
room = "look"
else:
room = "middle"
if room == "end":
print("You have escaped the tunnel. You win!")
elif room == "start":
print("You are standing at the entrance to a long tunnel.")
elif room == "middle":
print("I don’t know about that but You are in the depths of the tunnel.")
print("A Troll hit you over the head and now you are dead!")
elif room == "look":
print("You can barely see a few feet around you but there is a small light in front of you and behind you.")

The interactions looked like this:
Actions available: forward, backward, look
> forward
You have escaped the tunnel. You win!

Actions available: forward, backward, look
> backward
You are standing at the entrance to a long tunnel.

Actions available: forward, backward, look
> look
You can barely see a few feet around you but there is a small light in front of you and behind you.

Actions available: forward, backward, look
> No
I don’t know about that but you are in the depths of the tunnel.
A Troll hits you over the head and now you are dead!