473,503 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

beginner Python Programs

7 New Member
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
6 1796
printedinusa
7 New Member
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
6,596 Recognized Expert Expert
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
printedinusa
7 New Member
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
6,596 Recognized Expert Expert
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
printedinusa
7 New Member
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
6,596 Recognized Expert Expert
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2850
by: Art | last post by:
NEWBIE ALERT! Esteemed List Participants and Lurkers: (System: P-II 350, 192 meg, Win98 SE, Python 2.2.3, wxPythonWIN32-2.4.1.2-Py22.exe) I'm having a lot of fun getting started with Python...
38
3701
by: kbass | last post by:
In different articles that I have read, persons have constantly eluded to the productivity gains of Python. One person stated that Python's productivity gain was 5 to 10 times over Java in some in...
114
9691
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
6
2628
by: Todd_Calhoun | last post by:
I'm trying to learn Python (and programming), and I'm wondering if there are any places where I can find small, simple programs to study. Thanks.
0
1440
by: Alf P. Steinbach | last post by:
The seventh part of my attempted Correct C++ tutorial is now available, although for now only in Word format (use free Open Office if no Word), and also, it's not yet been reviewed at all -- ...
14
4248
by: Mark Dufour | last post by:
After nine months of hard work, I am proud to introduce my baby to the world: an experimental Python-to-C++ compiler. It can convert many Python programs into optimized C++ code, without any user...
2
2116
by: enquiring mind | last post by:
I read the posting by Rehceb Rotkiv and response but don't know if it relates to my problem in any way. I only want to write German to the screen/console for little German programs/exercises in...
7
6529
by: Linus Cohen | last post by:
Hi all, I'm a newbie to python and programming in general, so I wanted a simple project to start off. What I'm trying to do here is write a python command-line ping program, much like the Unix and...
9
1507
by: SMALLp | last post by:
Hy! I have error something like this TypeError: unbound method insert() must be called with insertData instance as first argument (got str instance instead) CODE: File1.py...
1
5755
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7006
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.