[Tutor] random equation generator

W W srilyk at gmail.com
Thu Oct 23 12:46:20 CEST 2008


If you would like to develop the game, you should first try to develop the
game, and then ask when you get stuck.

If you can't figure out how to get a user to guess between operands '+',
'-', '*', '/' then my guess is you are very new to programming, and this
question shows you are very new to the tutor list. We're happy to help you
find a solution when you get stuck, but we won't write your program for you.
If you're stuck at the planning phase it seems that you may be trying to
tackle a subject that's a little too deep, and you'll find a lot of
difficulty in learning pyGTK.

Here are some assignments for you. Successfully completing these will not
only show that you're willing to learn and take advice, but they will also
help you in your quest to write your game.

tip: search google for the functions you should use, if you don't already
know them. Using the keyword "python" before the functionality will help
narrow your results.

1) Write a progam that will generate 10 random numbers in a /range/ of 0-3,
and print each one out.
After you do this, allow the user to /input/ the number of numbers (i.e. 5
instead of 10)
sample output:
Random Numbers:

Please enter a number: 4

2) Write a program that allows the user to input a number 0-3, and
determines which operand to print.
Sample output:

Enter a number: 0
Operand: +

Enter a number: 1
Operand: -

Enter a number: 3
Operand: /

Enter a number: 2
Operand: *

Do these things and you'll be well on your way to writing your program!
(also, feel free to use http://pastebin.com to post your code to report on
your progress)

Good luck!

If and only if you get stuck should you read this!

Seriously! Stop reading here! :)

Tip: Once you have searched google and the python docs for raw_input, while
loop, dict, list, if else, random and read all the documentation you can
find, if you cannot figure out the solution, only then should you ask
another question, and only about the topic on which you can't figure out on
your own!

On Thu, Oct 23, 2008 at 5:12 AM, i i <iaidas4 at gmail.com> wrote:

> hi, can u tell me any good tutorial site for pygtk, any that contains
> detail explanation of pygtk.
> i want to develop a game,that will randomly generate the operands,and the
> answer,a user have to chosse from the operators(+,-,*,/).
> which function should i use to randomly generate equation.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081023/18839384/attachment.htm>

More information about the Tutor mailing list