亲亲您好[鲜花]:用pythoni写随机产生1到10个整数,并统计每个数字出现的次数:import random# 生成随机整数列表num_list = [random.randint(1, 10) for i in range(random.randint(1, 10))]print("随机整数列表:", num_list)# 统计每个数字出现次数count_dict = {}for num in num_list: ...
产生1到10个随机整数 list_x = [random.randint(1,10) for _ in range(1,10)] print(list_x) # 统计每个数字出现的次数 dict_x = {} for x in list_x: if x not in dict_x: dict_x[x] = 1 else: dict_x[x] += 1 print(dict_x)