Commits

Ramakrishna Reddy Yekulla committed 9a52b1d

Added exercise 32, 33 and 35 to lpthw

Comments (0)

Files changed (6)

+the_count = [1,2,3,4,5]
+fruits = ['apples','oranges','pears','apricots']
+change = [1,'pennies',2,'dimes',3,'quarters']
+
+# This first kinda for-loop goes through a list
+for number in the_count:
+    print "This is count: %d" % number
+
+#print fruits
+# Same as above
+for fruit in fruits:
+    print "A fruit of type: %s" % fruit
+
+# Also we can go through mixed list too
+# Notice we have to use %r since we don't know what's in it
+for i in change:
+    print "I got %r" % i
+
+# we can also build list, first start with an emptly one
+elements = []
+
+# Theb use the range functions to do 0 to 5 counts
+for i in range(0, 6):
+    print "Adding %d to the list." % i
+    # Append is a function that lists understand
+    print "Element was: %d" % i
+
+
+the_count = [1,2,3,4,5]
+fruits = ['apples','oranges','pears','apricots']
+change = [1,'pennies',2,'dimes',3,'quarters']
+
+# This first kinda for-loop goes through a list
+for number in the_count:
+    print "This is count: %d" % number
+
+print fruits
+# Same as above
+for fruit in fruits:
+    print "A fruit of type: %s" % fruit
+
+# Also we can go through mixed list too
+# Notice we have to use %r since we don't know what's in it
+for i in change:
+    print "I got %r" % i
+
+# we can also build list, first start with an emptly one
+elements = []
+
+# Theb use the range functions to do 0 to 5 counts
+for i in range(0, 6):
+    print "Adding %d to the list." % i
+    # Append is a function that lists understand
+    print "Element was: %d" % i
+
+
+i = 0
+numbers = []
+
+while i < 6:
+    print "At the top i is %d" % i
+    numbers.append(i)
+    
+    i = i + 1
+    print "Numbers now: ", numbers
+    print "At the bottom i is %d" % i
+
+print "The numbers: "
+
+for num in numbers:
+    print num
+
+

Empty file added.

+from sys import exit
+
+def gold_room():
+    print "This room is full of gold, How much do you take ? "
+    
+    next = raw_input("> ")
+    if "0" in next or "1" in next:
+        how_much = int(next)
+    else:
+        dead("Man, learn to type a number.")
+
+    if how_much < 50:
+        print "Nice you are not greedy, you win!"
+        exit(0)
+    else:
+        dead("You greedy Bastard!")
+
+def bear_room():
+    print "there is a bear here"
+    print "The bear has a bunch of honey."
+    print "The fat bear is in from of another door."
+    print "How are you going to movge the bear?"
+    bear_moved = False
+
+    while True:
+        next = raw_input("> ")
+        
+        if next == "take honey":
+            dead("The bear looks at you then slaps your face off.")
+        elif next == "taunt bear" and not bear_moved:
+            print "the bear has moved from the door. You can go through it now."
+            bear_moved = True
+        elif next == "taunt bear" and bear_moved:
+            dead("the bear gets pissed off and chews your leg off.")
+        elif next == "open door" and bear_moved:
+            gold_room()
+        else:
+            print "I got no idea what that means."
+
+def cthulu_room():
+    print "here you see the great evil cthulu."
+    print "He, it, whatever stares at you and you go insane."
+    print "Do you flee for your life ot eat your head?"
+
+    next = raw_input("> ")
+    
+    if "flee" in next:
+        start()
+    elif "head" in next:
+        dead("Well that was tasty!")
+    else:
+        cthulu_room()
+
+def dead(why):
+    print why, "Good job!"
+    exit(0)
+
+def start ():
+    print "You are in a dark room. "
+    print "There is a door to your right and left."
+    print "which one do you take?"
+    
+    next = raw_input("> ")
+    
+    if next == 'left':
+        bear_room()
+    elif next == "right":
+        cthulu_room()
+    else:
+        dead("You stumble around the room until you starve.")
+
+start()
+
+
+    

Empty file added.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.