LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Python Random number (https://www.linuxquestions.org/questions/programming-9/python-random-number-191517/)

sethgeekx86 06-09-2004 10:19 AM

Python Random number
 
I am trying to write a python script that asks a user for a number and then picks a random whole number betwen 1 and the imputed number , including 1. Heres what i have i need help on the random part
Code:

#!/usr/bin/python
# Filename : number.py
from random import Random
guess = int(raw_input('Enter a Number  : '))
print guess


jim mcnamara 06-09-2004 12:40 PM

Boy, this sounds like homework. :)

sethgeekx86 06-09-2004 12:43 PM

If someone could just point me to a tutorial on random it would be help full

Hko 06-09-2004 07:46 PM

From the obvious place:

http://docs.python.org/lib/module-random.html

sethgeekx86 06-10-2004 08:55 AM

Code:

#!/usr/bin/python
# Filename : r.py
import random
p = int(raw_input('Enter a number: '))
number = random.randint(1,p)
print "and the number is" , number



All times are GMT -5. The time now is 01:12 AM.