This is just a short and simple script that generates a set of random numbers. You enter how many random numbers you want and the program will generate them.
The num is multiplied by 10 in the upper limit within the for loop to give you larger generated integers. Adjust it as needed.
1 2 3 4 5 6 7 8 9 | """Generate a set of random numbers based on the number requested."""
import random
try:
numbers = input("How many numbers do you want generated? ")
for num in range(int(random.random() + 1), int(numbers) + 1):
print(random.randint(num, num * 10))
except ValueError:
print("Input is invalid!")
|
int(random.random() + 1) equals to 1, isn't it ?
Just use this code instead:
import random
number = input("Enter number: ") for num in range(0,int(number)): print random.randint(0, number*10)
I am getting following error after inputing value.
Traceback (most recent call last): File "random.py", line 2, in <module> import random File "/var/www/python/rnd/random.py", line 6, in <module> for num in range(int(random.random() + 1), int(numbers) + 1): TypeError: 'module' object is not callable
What version of python are you using?