diff --git a/monty-hall.ipynb b/monty-hall.ipynb index ab6278e..d0ab5a4 100644 --- a/monty-hall.ipynb +++ b/monty-hall.ipynb @@ -194,7 +194,12 @@ " # you stick with your original choice:\n", " if doors_d[my_choice] == 'car':\n", " return True # you win!\n", - " return False # you lose :(" + " return False # you lose :(\n", + "\n", + "print(never_switch())\n", + "print(never_switch())\n", + "print(never_switch())\n", + "print(never_switch())" ] }, { @@ -209,13 +214,15 @@ "outputs": [], "source": [ "# ok, let's try this out!\n", - "print(always_switch())\n", - "print(always_switch())\n", - "print(always_switch())\n", + "print(\"\\nAlways Switching results in winning?\")\n", + "print(\" -\", always_switch())\n", + "print(\" -\", always_switch())\n", + "print(\" -\", always_switch())\n", "\n", - "print(never_switch())\n", - "print(never_switch())\n", - "print(never_switch())\n" + "print(\"\\nNever Switching results in winning?\")\n", + "print(\" -\", never_switch())\n", + "print(\" -\", never_switch())\n", + "print(\" -\", never_switch())\n" ] }, { @@ -256,8 +263,10 @@ "for i in range(N):\n", " if always_switch():\n", " won_count += 1\n", - " \n", - "print('With always_switch(), I won', won_count, 'of', N, 'tries')" + "\n", + "percentage = (won_count/N)*100\n", + "\n", + "print('With always_switch(), I won', won_count, 'of', N, 'tries', f\"({percentage}%)\")" ] }, { @@ -279,12 +288,14 @@ "outputs": [], "source": [ "won_count = 0\n", - "N = 1000\n", + "N = 10000\n", "for i in range(N):\n", " if never_switch():\n", " won_count += 1\n", - " \n", - "print('With never_switch(), I won', won_count, 'of', N, 'tries')" + "\n", + "percentage = (won_count/N)*100\n", + "\n", + "print('With never_switch(), I won', won_count, 'of', N, 'tries', f\"({percentage}%)\")" ] }, { @@ -418,13 +429,15 @@ }, "outputs": [], "source": [ - "print(always_switch2(100))\n", - "print(always_switch2(100))\n", - "print(always_switch2(100))\n", + "print(\"\\nAlways Switching results in winning when there are 100 doors?\")\n", + "print(\" -\", always_switch2(100))\n", + "print(\" -\", always_switch2(100))\n", + "print(\" -\", always_switch2(100))\n", "\n", - "print(never_switch2(100))\n", - "print(never_switch2(100))\n", - "print(never_switch2(100))\n" + "print(\"\\nNever Switching results in winning when there are 100 doors?\")\n", + "print(\" -\", never_switch2(100))\n", + "print(\" -\", never_switch2(100))\n", + "print(\" -\", never_switch2(100))\n" ] }, { @@ -452,16 +465,20 @@ "for i in range(N):\n", " if always_switch2(M):\n", " won_count += 1\n", - " \n", - "print('With always_switch2() and', M, 'doors, I won', won_count, 'of', N, 'tries')\n", + "\n", + "percentage = (won_count/N)*100\n", + "\n", + "print('With always_switch2() and', M, 'doors, I won', won_count, 'of', N, 'tries', f\"({percentage}%)\")\n", "\n", "won_count = 0\n", "\n", "for i in range(N):\n", " if never_switch2(M):\n", " won_count += 1\n", - " \n", - "print('With never_switch2() and', M, 'doors, I won', won_count, 'of', N, 'tries')" + "\n", + "percentage = (won_count/N)*100\n", + "\n", + "print('With never_switch2() and', M, 'doors, I won', won_count, 'of', N, 'tries', f\"({percentage}%)\")" ] }, { @@ -684,7 +701,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.10.10" } }, "nbformat": 4,