User Profile
Collapse
-
Thanks. That's really neat. I'll let you know how it works out for me! -
Thanks alot. I'm actually trying to teach myself python out of a book, and I'm familiar with __str__ and __init__, but the __cmp__ special method is new to me.
[CODE=python]
def __cmp__(self, other):
return cmp(self.score, other.score)
[/CODE]
When I use this, and say the self.score is 10 while the other.score is 8, what would the returned value be?...Leave a comment:
-
wow. Thanks! I'm not at a machine with python on it, so I cannot test that out, but it sounds like it could work. I am not familiar with the _cmp_ method, though, and I don't know what that is doing. If you could explain that to me, that would be nice!Leave a comment:
-
I'm sorry it's taken me so long to get back on here about this problem, but with school coming to a close, things have been crazy!
Earlier I posted too little code, and now I fear that I'm going to post too much. I think, though, that I'd rather post too much and get a complete answer than post too little and leave feeling confused. Here is the entirety of the program, followed by the two modules that I import.
[CODE=python]...Leave a comment:
-
Calling an object from a list
I don't know how clear my title is, but I can't think of how to title this problem. I am writing a single card game of War. It is very simple. Every round the deck is populated and shuffled. A single card is dealt to each of two players. The card with the higher value wins, and the player gets a point. If there is a tie, nobody earns the point, and a new round begins. I am reusing code from a blackjack program provided in the book I am working out... -
Well, i think that I'm going to tell my "advisor" for this Independant Study that the instructions aren't clear enough and that it doesn't make sense to me and instead I'll just go on to the next chapter. I know how i could adapt this to use in another program that it would actually help in, but that isn't what it asks. Thank you for the help, though. I have learned something, but I still can't read the authors mind. I'll work on it though!...Leave a comment:
-
well, i am to improve ask_number to call the function with a step value, and then i am supposed to use the function ask_number() in this:
Code:# Guess My Number # # The computer picks a random number between 1 and 100 # The player tries to guess it and the computer lets # the player know if the guess is too high, too low # or right on the money import random print
Leave a comment:
-
Calling a function with a step value.
"Improve the function ask_number() so that the function can be called with a step value. Make the default value of step 1."
Those are the directions I have to follow. I dont know what a step function is, so I dont know how to change ask_number() to be called by one.
here is ask_number:
Code:def ask_number(question, low, high): """Ask a yes or no question."""
-
i use a school computer(im doing this as an independent study) and it is a version of XP. I am using python 2.3 and i use IDLE.Leave a comment:
-
Hey everybody. I'm back from spring break and i decided that i should finish this. So i took at look at the suggestions you all made, they were good, except part didnt quite work, and with a few tweaks, this is what i came up with:
Code:# Word Jumble # # The computer picks a random word then "jumbles" it # The player has to guess the original word import random # create
Leave a comment:
-
i'll take a look at that. it does have a few things i havnt been introduced to yet, such as "remove" and "random.choice. " it looks good though, thank you! and thank you also to dshimer....Leave a comment:
-
Thank you for the suggestion. Sorry it took so long for me to get back to this. That sounds like a good idea. I'm not sure how to do that though. How would I integrate that process into the existing code and attach those hints to the words? This probably seems really basic to you, but i guess I'm really new to this. Thanks for everything though!Leave a comment:
-
ok, sorry. i didn't see that earlier. I thought there might be something like that but i wasn't sure. Now i know! thanks.Leave a comment:
-
Adding hints to a basic word jumble game
I am working on learning Python out of a book called Python Programming for the Absolute Beginner. Right now I am working on a challenge at the end of one of the chapters. During the chapter i was walked through the production of a word jumble game. At the end I am asked to add hints for each word and add a scoring system to reward the player for each word he guesses without having to use the hint. im not really sure the best way to go about this....
No activity results to display
Show More
Leave a comment: