Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# HEADING"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "bdb3764b4f734318b8cccd0361a42251",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "interactive(children=(IntSlider(value=0, description='example_num'), Output()), _dom_classes=('widget-interact…"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "from ipywidgets import interact\n",
- "import numpy as np\n",
- "import random\n",
- "\n",
- "PRIZES = ['Car', 'Goat 1', 'Goat 2']\n",
- "\n",
- "def monty_hall(example_num=0):\n",
- " '''\n",
- " Simulates one round of the Monty Hall Problem. Outputs a tuple of\n",
- " (result if stay, result if switch, result behind opened door) where\n",
- " each results is one of PRIZES.\n",
- " '''\n",
- " pick = random.choice(PRIZES)\n",
- " opened = random.choice(\n",
- " [p for p in PRIZES if p != pick and p != 'Car']\n",
- " )\n",
- " remainder = next(p for p in PRIZES if p != pick and p != opened)\n",
- " return (pick, remainder, opened)\n",
- "\n",
- "interact(monty_hall, example_num=(0, 100));\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.7.4"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement