代码:
import math
def function_1(num):
if num % 10 == 7:
flag = True
elif num % 7 == 0:
flag = True
elif math.floor(num/10) == 7:
flag = True
elif math.floor(num/100) == 7:
flag = True
elif math.floor(num/10) % 10 == 7:
flag = True
else:
flag = False
return flag
def function(d, num_bao, num):
s = 1
while num_bao < num:
if function_1(s) == True:
if s % 4 == 1:
d['jia'] += 1
elif s % 4 == 2:
d['yi'] += 1
elif s % 4 == 3:
d['bing'] += 1
elif s % 4 == 0:
d['ding'] += 1
s = s+1
else:
s = s+1
num_bao += 1
continue
return d
num = int(input())
num_bao = 0
d = {'jia': 0, 'yi': 0, 'bing': 0, 'ding': 0}
d = function(d, num_bao, num)
print(d['jia'])
print(d['yi'])
print(d['bing'])
print(d['ding'])
结果: