473,657 Members | 2,735 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 1800
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.randrang e 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.randrang e 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
2868
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 ... it is the most elegant and graceful language I have ever used (Fortran, Cobol, Basic, many assemblers, Forth, C, VB, etc.). I don't have the resources or the
38
3725
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 some cases. The strange thing that I have noticed is that there were no examples of this productivity gain (i.e., projects, programs, etc.,...). Can someone give me some real life examples of productivity gains using Python as opposed other...
114
9818
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
2636
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
1451
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 -- comments welcome! "Create beginner's programs" <url: http://home.no.net/dubjai/win32cpptut/w32cpptut_01_07.zip> This part focuses on basic techniques and approaches to programming, so it could have been titled "Basic methodologies and...
14
4311
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 intervention such as adding type declarations. It uses rather advanced static type inference techniques to deduce type information by itself. In addition, it determines whether deduced types may be parameterized, and if so, it generates...
2
2123
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 python. No file w/r will be used. #! /usr/bin/env python # -*- coding: utf-8 -*- # Filename: 7P07png.py # SUSE Linux 10 Python 2.4.1 gedit 2.12.0
7
6539
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 Windows ping programs. I've got this much worked out already: class ping def PING(IP, pings, size): and that's where I stop, because I realize I have no idea how to make
9
1513
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 sql.insertData.insert("files", data)
1
5770
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 example: answer_str = raw_input(' Enter answer ') Herr Üü
0
8407
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8612
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4171
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
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 we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.