Re: back with more issues

2013-08-12 Thread Steven D'Aprano
On Mon, 12 Aug 2013 20:13:31 -0700, Kris Mesenbrink wrote: > the Classes and __init__ still don't make much sense actually. i have > tried and tried again to make it generate numbers between 0 and 5 in a > while statement but it just doesn't seem to be working. Hi Kris, You might also find that

Re: back with more issues

2013-08-12 Thread MRAB
On 13/08/2013 04:13, Kris Mesenbrink wrote: the Classes and __init__ still don't make much sense actually. i have tried and tried again to make it generate numbers between 0 and 5 in a while statement but it just doesn't seem to be working. import random class Player(): This sets an attrib

Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
the Classes and __init__ still don't make much sense actually. i have tried and tried again to make it generate numbers between 0 and 5 in a while statement but it just doesn't seem to be working. import random class Player(): hp = 10 def __init__(self, patt): self.att = rando

Re: back with more issues

2013-08-12 Thread random832
On Mon, Aug 12, 2013, at 10:56, Rotwang wrote: > No! A function should have *four* well-defined pieces: what are its > parameters, what does it do, what are its side-effects, what does it > return, and an almost fanatical devotion to the Pope [etc.] To be fair, I can't think of what "what does i

Re: back with more issues

2013-08-12 Thread Rotwang
On 12/08/2013 06:54, Dave Angel wrote: [...] This function makes no sense to me. A function should have three well-defined pieces: what are its parameters, what does it do, what are its side-effects, and what does it return. No! A function should have *four* well-defined pieces: what are its

Re: back with more issues

2013-08-12 Thread Dave Angel
Kris Mesenbrink wrote: > darn i was hoping i could put off learning classes for a bit, but it seems > that is not the case. i have tested it a bit and it seems to be working > correctly now. > > > import random > > class player(): > hp = 10 > speed = 5 >

Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
import random class player(): hp = 10 attack = random.randint(0,5) class monster(): hp = 10 attack = random.randint(0,4) def battle(): print ("a wild mosnter appered!") print ("would you like to battle?") answer = input() if answer == ("yes"): while monst

Re: back with more issues

2013-08-11 Thread Kris Mesenbrink
darn i was hoping i could put off learning classes for a bit, but it seems that is not the case. i have tested it a bit and it seems to be working correctly now. import random class player(): hp = 10 speed = 5 attack = random.randint(0,5) print (player.

Re: back with more issues

2013-08-11 Thread Dave Angel
Kris Mesenbrink wrote: > import random > > def player(): > hp = 10 > speed = 5 > attack = random.randint(0,5) > The net resut of this function is nothing. It assigns values, then they're lost when the function returns. A function is the wrong way to deal with these three names. > de

Re: back with more issues

2013-08-11 Thread Joel Goldstick
On Mon, Aug 12, 2013 at 12:35 AM, Kris Mesenbrink wrote: > the idea was to store variables for later use, but you are correct i don't > understand functions or if that is even the best way to do it. i guess i'd > want to be able to call the HP and ATTACK variables of player for when the > battl

Re: back with more issues

2013-08-11 Thread Kris Mesenbrink
the idea was to store variables for later use, but you are correct i don't understand functions or if that is even the best way to do it. i guess i'd want to be able to call the HP and ATTACK variables of player for when the battle gets called. i would then use the variables in battle to figure

Re: back with more issues

2013-08-11 Thread Joel Goldstick
On Sun, Aug 11, 2013 at 11:33 PM, Kris Mesenbrink wrote: > import random > > def player(): > hp = 10 > speed = 5 > attack = random.randint(0,5) # add the following line to return attack value: return attack > > def monster (): > hp = 10 > speed = 4 > > def battle

back with more issues

2013-08-11 Thread Kris Mesenbrink
import random def player(): hp = 10 speed = 5 attack = random.randint(0,5) def monster (): hp = 10 speed = 4 def battle(player): print ("a wild mosnter appered!") print ("would you like to battle?") answer = input() if answer == ("yes"): return player(