[Tutor] how to print random number multiply

Alan Gauld alan.gauld at btinternet.com
Sat Jan 15 02:09:58 CET 2011


"walter weston" <hacker0100 at hotmail.com> wrote

> I have mostly studied python and now I'm ready to
> start writing code.

Its usually best to study programming languages *by* writing code.
However since you have now reached that stage of readiness
that's irrelevant advice :-)

> I want to print random numbers a certain ammount of times
> I am using the code
>
> import random
> print (random.random())

print just prints once.
It returns None so if you try to assign print to a variable it will 
store None

> I tried bind the print statement to a variable and when
> I call x for example I want it to print new numbers when
> I store the print statement in a variable x everytime I
> call x it's the same number and does change I wanted
> it to change when I call it

Since we are not psychic it would be more usefuil to send your actual
code and output so that we can see exactly what you did and
what Python produced.

It would also be helpful to tell us which Python version you are using
(and OS too).

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list