学了一个月编了个喝酒常玩敲7的小游戏大家来看看
#喝酒的朋友都玩过敲7吧,规则:能被7整除的,和含有7的数都要跳过。否则自罚一杯酒。#妈妈再也不用担心我敲七会输了!
"""
Created on Mon Nov 13 16:05:01 2017
@author: Richard Cheung
"""
import easygui as g
def skipseven(num):
'敲7游戏需要跳过的数'
n = 0
list1 = []
for i in range(1,num):
if i % 7 == 0:
list1.append(i)
n += 1
else:
a = i
while a > 0:
if a % 10 == 7:
n += 1
list1.append(i)
break
else:
a //= 10
g.msgbox(list1,'在%d以内,敲7需要跳过如下一共%d个数'%(num,n))
num = g.enterbox('需要获取多少(整数)以内的答案?','敲7小游戏')
num = int(num)
skipseven(num) 学习了
页:
[1]