python请输入两个整数m和n_python分别输入2个正整数m和n(m < n)?

展开全部

具体代码如下,已32313133353236313431303231363533e58685e5aeb931333433656634测试可以正常运行

import random

def func(m, n):

random.seed(50)

result = {}

least_count_num = {'num': 0, 'count':1000}

most_count_num = {'num': 0, 'count':0}

for i in range(1000):

x = random.randint(m, n)

count = result.get(str(x), 0)

result[str(x)] = count + 1

for k, v in result.items():

if v > most_count_num["count"]:

most_count_num["num"] = int(k)

most_count_num["count"] = v

if v < least_count_num["count"]:

least_count_num["num"] = int(k)

least_count_num["count"] = v

print('出现最多的数字是%d出现了%d次,出现最少数字是%d,出现了%d次' % (most_count_num["num"], most_count_num["count"], least_count_num["num"], least_count_num["count"]))

你可能感兴趣的:(python请输入两个整数m和n_python分别输入2个正整数m和n(m < n)?)