一个朋友问的,排三热门号码组号Python代码
import random# 历史数据historical_data = [ [4, 3, 4], [8, 1, 6], [1, 8, 4], [3, 6, 8], [9, 1, 6], [1, 8, 8], [4, 3, 0], [3, 5, 6], [3, 7, 6], [9, 5, 4], [2, 7, 5], [4, 9, 8],]# 统计每个位置上的数字出现的频率frequency = {'百位': {}, '十位': {}, '个位': {}}for draw in historical_data: for i, number in enumerate(draw): key = '百位' if i == 0 else '十位' if i == 1 else '个位' frequency[key][number] = frequency[key].get(number, 0) + 1# 选择每个位置上出现频率最高的四个数字hot_numbers = {'百位': [], '十位': [], '个位': []}for position, nums in frequency.items(): hot_numbers[position] = sorted(nums, key=nums.get, reverse=True)[:4]# 打印热门号码print("热门号码:")for position, nums in hot_numbers.items(): print(f"{position}: {nums}")# 利用热门号码随机组合出10组新号码new_combinations = []while len(new_combinations) < 10: new_combination = [] for position in ['百位', '十位', '个位']: numbers = hot_numbers[position] number = random.choice(numbers) new_combination.append(number) new_combinations.append(new_combination)# 打印新组合的号码print("\n新组合的号码:")for combo in new_combinations: print(combo)数字型统计与组号
代码运行热门号码:
百位: [4, 3, 1, 9]
十位: [3, 1, 8, 5]
个位: [6, 4, 8, 0]
排三组号
新组合的号码:
[4, 1, 4]
[1, 3, 4]
[9, 8, 8]
[9, 6, 8]
[4, 1, 0]
[1, 3, 6]
[9, 5, 0]
[4, 1, 0]
[1, 5, 0]
[9, 8, 4]
排列三号码统计
历史数据那里可添加更多期的数据。
注意:这个只是简单的统计与组号,仅供娱乐!
排三直选 987
3D单选 598