beginner Python Programs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • printedinusa
    New Member
    • Nov 2006
    • 7

    #1

    beginner Python Programs

    Hey everyone, I am very new to all of this programing stuff, but I love it all the same. I am currently taking a intro python class, but due to illness I wasn't able to attend class for a week and a half. I came back to find out we have two assignments do tooday and I am not sure how to complete them, so any hints or code would be greatly appricated.

    #1 create a word list and have it print out in a random order.
    #2 create a RPG using a points value system for your characters stats.

    the book I have is very clear on certain matters yet very unclear on these inparticular, thankyou for any help that you can give!
  • printedinusa
    New Member
    • Nov 2006
    • 7

    #2
    Sorry for the bad post. I am running on both MAC OSX and Windows Xp.
    I tried I can create the list and have it print:

    Code:
    import random
    index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
    
    print index
        
    raw_input("\nPress Enter to Exit")
    I tried a random.randrang e such as

    Code:
    import random
    index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
    index=random.randrange(10)
    print index
        
    raw_input("\nPress Enter to Exit")


    on it but it kept printing out numbers instead of the words that I wanted. Like this:
    {output from code}
    >>>
    4

    Press Enter to Exit
    {/output from code}


    As to the RPG Program, I am without words. I looked at other texts and was very impressed with the complicated coding, although I didn't understand it very well. I am not asking for anyone to create the code for me, just to give me a int or push in the right direction as to where i can learn at a step by step pace.


    Originally posted by printedinusa
    Hey everyone, I am very new to all of this programing stuff, but I love it all the same. I am currently taking a intro python class, but due to illness I wasn't able to attend class for a week and a half. I came back to find out we have two assignments do tooday and I am not sure how to complete them, so any hints or code would be greatly appricated.

    #1 create a word list and have it print out in a random order.
    #2 create a RPG using a points value system for your characters stats.

    the book I have is very clear on certain matters yet very unclear on these inparticular, thankyou for any help that you can give!

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      This is a great post!

      Originally posted by printedinusa
      Sorry for the bad post. I am running on both MAC OSX and Windows Xp.
      I tried I can create the list and have it print:

      Code:
       
      import random
      index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
       
      print index
       
      raw_input("\nPress Enter to Exit")
      I tried a random.randrang e such as

      Code:
       
      import random
      index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
      index=random.randrange(10)
      print index
       
      raw_input("\nPress Enter to Exit")

      on it but it kept printing out numbers instead of the words that I wanted. Like this:
      {output from code}
      >>>
      4

      Press Enter to Exit
      {/output from code}


      As to the RPG Program, I am without words. I looked at other texts and was very impressed with the complicated coding, although I didn't understand it very well. I am not asking for anyone to create the code for me, just to give me a int or push in the right direction as to where i can learn at a step by step pace.

      This is a general idea of how I'd arange this. Please forgive errors, I'm doing this on the fly...
      Code:
      import random
      index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
      size = len(index)
      usedindexList = []	# an empty list
      while len(usedindexList) < size:
      	i = random.randomint(size)
      	if i not in usedindexList:
      		usedindexList.append(i)
      		print index[i]
       
      raw_input("\nPress Enter to Exit")

      Comment

      • printedinusa
        New Member
        • Nov 2006
        • 7

        #4
        that is great, thankyou so very much! I am hopefully going to be able to post what I have for the RPG program, and maybe you could give some insight on that as well. Once again thanks, it was a great help!




        Originally posted by bartonc
        This is a great post!




        This is a general idea of how I'd arange this. Please forgive errors, I'm doing this on the fly...
        Code:
        import random
        index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
        size = len(index)
        usedindexList = []	# an empty list
        while len(usedindexList) < size:
        	i = random.randomint(size)
        	if i not in usedindexList:
        		usedindexList.append(i)
        		print index[i]
         
        raw_input("\nPress Enter to Exit")

        Comment

        • bartonc
          Recognized Expert Expert
          • Sep 2006
          • 6478

          #5
          Originally posted by printedinusa
          that is great, thankyou so very much! I am hopefully going to be able to post what I have for the RPG program, and maybe you could give some insight on that as well. Once again thanks, it was a great help!
          You are very welcome. So what is RPG, anyway.

          Comment

          • printedinusa
            New Member
            • Nov 2006
            • 7

            #6
            Role Playing Game, I didn't have a chance to set it up last night though, but I am sure I can get a grace day. The project is: I have to create a program that give the user a character and yet allow the user to spend 30 point on 4 different stats, (health, stength, armor, defense). The user will be able to add to and take away from the stats he or she has creat until the end when they select finished. I may not be complicated to some people on here, but for a new noobie like me, hahaha sounds near impossible. But I am giving it a try!

            Comment

            • bartonc
              Recognized Expert Expert
              • Sep 2006
              • 6478

              #7
              Originally posted by printedinusa
              Role Playing Game, I didn't have a chance to set it up last night though, but I am sure I can get a grace day. The project is: I have to create a program that give the user a character and yet allow the user to spend 30 point on 4 different stats, (health, stength, armor, defense). The user will be able to add to and take away from the stats he or she has creat until the end when they select finished. I may not be complicated to some people on here, but for a new noobie like me, hahaha sounds near impossible. But I am giving it a try!
              That's great! I'm going to go ahead and call you fist question "solved" and close this thread. You can go ahead and start a new thread for "role playing game", OK.

              Comment

              Working...