Going to Learn Python Now : Pt. 6

python

PYTHOOOOOOOOOOOOOOOOOOOOOOOOOON GO!

Only did exercies 34->36 today and saw that 37 is going to be a lot of memorization…

Exercise 34: Accessing Elements of Lists

  • -well… this really had nothing to do with python. it was just an explanation about how indexes work in programming.

Exercise 35: Branches and Functions

  • -alright, so everything worked as expected, however I wasn’t satisfied with how the code checked to tell whether or not we were entering in a number for the amount of gold to take from the gold room. I added this function in to do a proper check:

    def get_int():
    while True:
    line = raw_input("> ")
    try:
    return int(line)
    except ValueError:
    print line, "is not a valid number"

    The indenting is obviously not correct in the above code… but figuring out how to fix that in wordpress is not worth the effort… if you’re following along with Python, surely you can figure out the proper indentation, right? Try isn’t something that’s been taught so far here, but… well… there is a thing called the internet that you’re reading right now.

  • -That means I’m able to place the following in my script instead of what I was told to type:

    next = get_int()

    # if “0” in next or “1” in next:
    # how_much = int(next)
    # else:
    # dead(“Man, learn to type a number.”)

    # if how_much < 50:
    if next < 50:

Exercise 36: Designing and Debugging

  • -Alright… so the task for this is to essentially make a shitty text adventure. I’ve done that before. Not with python… but I get it. The idea is to get used to if, else, and elif statements. This is not a new concept to me, and thus I will move on

Exercise 37: Symbol Review

  • -So this one is probably something that’s going to take time to learn… it’s keywords for python. This is just a list. A long list of stuff that needs to be memorized. There really is no short cut to this…
  • -there’s quite a few of these I’m not familiar with, so unforunately I think I’m going to stop here for the night and next time will be looking up the various words in this list :-/