Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# HEADING"
  8. ]
  9. },
  10. {
  11. "cell_type": "code",
  12. "execution_count": 1,
  13. "metadata": {},
  14. "outputs": [
  15. {
  16. "data": {
  17. "application/vnd.jupyter.widget-view+json": {
  18. "model_id": "bdb3764b4f734318b8cccd0361a42251",
  19. "version_major": 2,
  20. "version_minor": 0
  21. },
  22. "text/plain": [
  23. "interactive(children=(IntSlider(value=0, description='example_num'), Output()), _dom_classes=('widget-interact…"
  24. ]
  25. },
  26. "metadata": {},
  27. "output_type": "display_data"
  28. }
  29. ],
  30. "source": [
  31. "from ipywidgets import interact\n",
  32. "import numpy as np\n",
  33. "import random\n",
  34. "\n",
  35. "PRIZES = ['Car', 'Goat 1', 'Goat 2']\n",
  36. "\n",
  37. "def monty_hall(example_num=0):\n",
  38. " '''\n",
  39. " Simulates one round of the Monty Hall Problem. Outputs a tuple of\n",
  40. " (result if stay, result if switch, result behind opened door) where\n",
  41. " each results is one of PRIZES.\n",
  42. " '''\n",
  43. " pick = random.choice(PRIZES)\n",
  44. " opened = random.choice(\n",
  45. " [p for p in PRIZES if p != pick and p != 'Car']\n",
  46. " )\n",
  47. " remainder = next(p for p in PRIZES if p != pick and p != opened)\n",
  48. " return (pick, remainder, opened)\n",
  49. "\n",
  50. "interact(monty_hall, example_num=(0, 100));\n"
  51. ]
  52. },
  53. {
  54. "cell_type": "code",
  55. "execution_count": null,
  56. "metadata": {},
  57. "outputs": [],
  58. "source": []
  59. }
  60. ],
  61. "metadata": {
  62. "kernelspec": {
  63. "display_name": "Python 3",
  64. "language": "python",
  65. "name": "python3"
  66. },
  67. "language_info": {
  68. "codemirror_mode": {
  69. "name": "ipython",
  70. "version": 3
  71. },
  72. "file_extension": ".py",
  73. "mimetype": "text/x-python",
  74. "name": "python",
  75. "nbconvert_exporter": "python",
  76. "pygments_lexer": "ipython3",
  77. "version": "3.7.4"
  78. }
  79. },
  80. "nbformat": 4,
  81. "nbformat_minor": 2
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement