import randomdef roll_dice():roll = random.randint(1,10)return roll
def main():total_times = 100#初始化列表result_list=[0]*10for i in range(total_times):print(roll_dice())for j in range(1,11):if roll_dice() == j:result_list[j-1] +=1if __name__ =='__main__':main()
结果如下: