python 学习(一)
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import random
def rand7():
return random.randint(1,7)
def rand10():
result=0
while True:
a1=rand7()-1
a2=rand7()-1
r=a1*7+a2
if r<40:
result=r/4+1
break
return result
print rand10()
"""
Spyder Editor
This is a temporary script file.
"""
import random
def rand7():
return random.randint(1,7)
def rand10():
result=0
while True:
a1=rand7()-1
a2=rand7()-1
r=a1*7+a2
if r<40:
result=r/4+1
break
return result
print rand10()
评论
发表评论