随机性:
import random
a=random.randint(0,100)
print(a)
num=0
if a<39:
for i in range(a,39):
a=a+1
num=num+1
else:
for i in range(39,a):
a=a-1
num=num+1
if a==39:
print('经过%d次找到39'%num)
确定性:
for i in range(0,100):
if i==39:
print('第%d次出现39'%(i+1))
break
else:
i=i+1