0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

6つのサイコロを10000回投げたときの5の目がでる確率をPythonでもとめる

Last updated at Posted at 2021-05-30
"""
6つのサイコロを10000回投げたときの5の目がでる確率をもとめる
"""

import random

def sai_no_me():
    return random.randint(1,6)

count5_total=0
for i in range(1,10001):
    saikoro1 = sai_no_me()
    saikoro2 = sai_no_me()
    saikoro3 = sai_no_me()
    saikoro4 = sai_no_me()
    saikoro5 = sai_no_me()
    saikoro6 = sai_no_me()
    result = [saikoro1, saikoro2, saikoro3, saikoro4, saikoro5, saikoro6]
    count5 = result.count(5)
    is_exist=''
    if count5 > 0:
        is_exist = ''
    count5_total += count5
    kakuritsu = count5_total/i
    print('{} {}: {} {} {} {} {} {} 確率{}'.format(is_exist, i, saikoro1,saikoro2,saikoro3,saikoro4,saikoro5,saikoro6,kakuritsu))
.
..
...
○ 9951: 5 3 5 5 1 1 確率1.0048236358154958
☓ 9952: 6 4 2 2 6 4 確率1.0047226688102895
○ 9953: 1 2 2 5 5 3 確率1.0048226665327038
○ 9954: 4 4 2 5 5 3 確率1.0049226441631505
○ 9955: 4 5 6 5 4 4 確率1.0050226017076846
○ 9956: 5 2 1 1 3 3 確率1.0050220972278023
○ 9957: 4 4 2 5 1 2 確率1.0050215928492519
○ 9958: 5 3 6 3 3 1 確率1.0050210885720023
○ 9959: 6 5 1 5 5 1 確率1.0052214077718646
○ 9960: 1 6 5 6 4 6 確率1.0052208835341365
☓ 9961: 4 3 1 2 2 4 確率1.0051199678747114
○ 9962: 5 4 3 2 1 1 確率1.0051194539249146
○ 9963: 1 5 6 2 1 3 確率1.0051189400782896
○ 9964: 2 6 4 2 2 5 確率1.0051184263348052
○ 9965: 6 5 6 6 6 5 確率1.005218263923733
○ 9966: 6 6 5 5 6 4 確率1.005318081477022
○ 9967: 2 1 5 1 4 2 確率1.0053175479080967
○ 9968: 6 6 2 4 5 6 確率1.005317014446228
☓ 9969: 6 2 4 3 2 3 確率1.005216170127395
○ 9970: 6 2 4 4 6 5 確率1.0052156469408224
○ 9971: 5 5 4 1 4 4 確率1.0053154147026377
☓ 9972: 1 3 4 2 1 2 確率1.005214600882471
☓ 9973: 2 1 6 2 6 3 確率1.005113807279655
☓ 9974: 4 3 4 1 2 1 確率1.0050130338881091
○ 9975: 1 2 6 6 5 4 確率1.005012531328321
○ 9976: 2 5 3 3 3 2 確率1.0050120288692863
○ 9977: 2 6 5 2 4 3 確率1.0050115265109751
☓ 9978: 1 2 1 4 3 4 確率1.0049108037682903
○ 9979: 1 5 3 5 4 3 確率1.0050105220964025
☓ 9980: 3 1 2 2 6 6 確率1.0049098196392785
☓ 9981: 4 3 6 2 1 6 確率1.004809137360986
☓ 9982: 3 6 6 6 1 1 確率1.0047084752554598
☓ 9983: 3 3 4 6 1 3 確率1.0046078333166384
○ 9984: 5 5 5 3 5 4 確率1.0049078525641026
○ 9985: 1 2 1 6 6 5 確率1.0049073610415624
☓ 9986: 2 3 4 2 4 6 確率1.0048067294211898
○ 9987: 4 4 2 5 5 2 確率1.0049063782917793
○ 9988: 5 5 2 3 5 2 確率1.0051061273528235
○ 9989: 2 6 6 5 2 1 確率1.0051056161777956
○ 9990: 6 6 5 3 4 6 確率1.0051051051051052
○ 9991: 2 5 1 2 4 2 確率1.0051045941347212
☓ 9992: 1 6 2 1 1 4 確率1.005004003202562
○ 9993: 1 1 6 1 5 1 確率1.005003502451716
○ 9994: 5 6 1 3 1 3 確率1.0050030018010807
○ 9995: 5 4 6 5 3 4 確率1.0051025512756377
☓ 9996: 3 6 2 3 2 3 確率1.0050020008003202
○ 9997: 5 3 6 4 2 4 確率1.0050015004501351
☓ 9998: 4 3 1 2 3 6 確率1.0049009801960391
○ 9999: 4 4 3 1 2 5 確率1.0049004900490048
○ 10000: 5 6 2 6 6 1 確率1.0049
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?