{"id":1945,"date":"2022-04-29T08:39:03","date_gmt":"2022-04-29T06:39:03","guid":{"rendered":"https:\/\/labodemaths.fr\/WordPress3\/?p=1945"},"modified":"2022-04-29T08:39:05","modified_gmt":"2022-04-29T06:39:05","slug":"2nde-simuler-des-experiences-aleatoires","status":"publish","type":"post","link":"https:\/\/labodemaths.fr\/WordPress3\/2nde-simuler-des-experiences-aleatoires\/","title":{"rendered":"2nde : simuler des exp\u00e9riences al\u00e9atoires"},"content":{"rendered":"\n<p>Le code :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from random import randint\n\ndef simulation_lancer_2_des(n):\n    resultats=&#91;0 for i in range(13)]\n    for i in range(n):\n        de1=randint(1,6)\n        de2=randint(1,6)\n        somme=de1+de2\n        resultats&#91;somme]=resultats&#91;somme]+1\n    return resultats\n        \ndef simulation_monty_hall_sans_changement(n):\n    gagne=0\n    for i in range(n):\n        tresor=randint(1,3)\n        joueur=randint(1,3)\n        if tresor==joueur:\n            gagne+=1\n    return gagne\n\ndef simulation_monty_hall_avec_changement(n):\n    gagne=0\n    for i in range(n):\n        portes=&#91;1,2,3]\n        tresor=randint(1,3)\n        joueur=randint(1,3)\n        portes.remove(tresor)\n        if joueur!=tresor:\n            portes.remove(joueur)\n        porte_commentateur=portes&#91;0]\n        choix_portes=&#91;1,2,3]\n        choix_portes.remove(joueur)\n        choix_portes.remove(porte_commentateur)\n        joueur=choix_portes&#91;0]\n        if joueur==tresor:\n            gagne+=1\n    return gagne\n\ndef simulation_pile_ou_face(n):\n    simulation=\"\"\n    for i in range(n):\n        alea=randint(0,1)\n        if alea==0:\n            simulation+=\"F\"\n        else :\n            simulation+=\"P\"\n    return simulation\n        <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Le code :<\/p>\n","protected":false},"author":2,"featured_media":1946,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[60],"tags":[],"_links":{"self":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/1945"}],"collection":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/comments?post=1945"}],"version-history":[{"count":1,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/1945\/revisions"}],"predecessor-version":[{"id":1947,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/1945\/revisions\/1947"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/media\/1946"}],"wp:attachment":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/media?parent=1945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/categories?post=1945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/tags?post=1945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}