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!