By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

beginner Python Programs

P: 7
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!
Nov 17 '06 #1
Share this Question
Share on Google+
6 Replies


P: 7
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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. import random
  3. index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
  4.  
  5. print index
  6.  
  7. raw_input("\nPress Enter to Exit")
  8.  
  9.  
I tried a random.randrange such as

Expand|Select|Wrap|Line Numbers
  1.  
  2. import random
  3. index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
  4. index=random.randrange(10)
  5. print index
  6.  
  7. raw_input("\nPress Enter to Exit")
  8.  
  9.  


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.


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!
Nov 17 '06 #2

bartonc
Expert 5K+
P: 6,596
This is a great post!

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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. import random
  3. index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
  4.  
  5. print index
  6.  
  7. raw_input("\nPress Enter to Exit")
  8.  
  9.  
I tried a random.randrange such as

Expand|Select|Wrap|Line Numbers
  1.  
  2. import random
  3. index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
  4. index=random.randrange(10)
  5. print index
  6.  
  7. raw_input("\nPress Enter to Exit")
  8.  
  9.  

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...
Expand|Select|Wrap|Line Numbers
  1. import random
  2. index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
  3. size = len(index)
  4. usedindexList = []    # an empty list
  5. while len(usedindexList) < size:
  6.     i = random.randomint(size)
  7.     if i not in usedindexList:
  8.         usedindexList.append(i)
  9.         print index[i]
  10.  
  11. raw_input("\nPress Enter to Exit")
  12.  
Nov 17 '06 #3

P: 7
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!




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...
Expand|Select|Wrap|Line Numbers
  1. import random
  2. index="billy, george, joe, bob, milly, molly, text, tj, tod, jess, fran"
  3. size = len(index)
  4. usedindexList = []    # an empty list
  5. while len(usedindexList) < size:
  6.     i = random.randomint(size)
  7.     if i not in usedindexList:
  8.         usedindexList.append(i)
  9.         print index[i]
  10.  
  11. raw_input("\nPress Enter to Exit")
  12.  
Nov 17 '06 #4

bartonc
Expert 5K+
P: 6,596
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.
Nov 17 '06 #5

P: 7
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!
Nov 18 '06 #6

bartonc
Expert 5K+
P: 6,596
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.
Nov 18 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.