random DEMO

来源:互联网 发布:数据透视表求和项为0 编辑:程序博客网 时间:2024/06/07 10:52
#quote from MIT 'introduction to computation and programming using python, Revised'import randomdef rollDie():    """Returns a random int between 1 and 6"""    return random.choice([1,2,3,4,5,6])    def rollN(n):    result = ''    for i in range(n):        result += str(rollDie())    print result    for i in range(10):    rollN(10)


%run "C:\Users\Administrator\test.py"
6116233436
3262112336
2216354654
6315621216
1444332142
3641155656
1141415133
5461363651
3214644263
2112262534

0 0
原创粉丝点击