For the first part:
s = raw_input('please enter a number ')
a = int(s)
print 'this is a number', a
Use always raw_input() and convert the read string to the int explicitly. There is a input() function that would convert it automatically; however, it is dangerous. A malicious user could type here a dangerous Python code that would be executed.
For the random, try this:
import random
m = 1
n = 6
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
print random.randint(m, n)
Main Topics
Browse All Topics





by: ghostdog74Posted on 2007-10-09 at 21:08:01ID: 20046231
you take input with raw_input() : http://docs.python.org/lib /built-in- funcs.html /module-ra ndom.html
you do random generators with random module : http://docs.python.org/lib