diff --git a/your-code/main.ipynb b/your-code/main.ipynb index b8b7a9c..accc7cf 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -24,7 +24,19 @@ "outputs": [], "source": [ "\"\"\"\n", - "your solution here\n", + "The first statement is False:\n", + "P(A U B) = P(A) + P(B) - P(A and B)\n", + "P(A U B) = 0.30 + 0.60 - 0.10\n", + "P(A U B) = 0.80\n", + "\n", + "The second statement is True.\n", + "\n", + "The third statement is False.\n", + "\n", + "The fourth statement is False\n", + "\n", + "The fifth statement is True.\n", + "\n", "\"\"\"" ] }, @@ -49,7 +61,13 @@ "outputs": [], "source": [ "\"\"\"\n", - "your solution here\n", + "Taking a white ball out: 10/30 = 1/3\n", + "\n", + "Taking a white ball out after taking a black ball out: 10/29\n", + "\n", + "Taking a red ball out after taking a black and a red ball out: 11/28\n", + "\n", + "Taking a red ball out after taking a black and a red ball out with reposition: 12/30\n", "\"\"\"" ] }, @@ -75,7 +93,11 @@ "outputs": [], "source": [ "\"\"\"\n", - "your solution here\n", + "P(A|B) = (P(B|A) * P(A)) / P(B)\n", + " = 0.50 * 0.10 / 0.40\n", + " = 0.125 = 12.5%\n", + "\n", + "12.5%\n", "\"\"\"" ] }, @@ -102,28 +124,105 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "import pandas as pd" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
menwomen
yes324351
no156169
\n", + "
" + ], + "text/plain": [ + " men women\n", + "yes 324 351\n", + "no 156 169" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "\"\"\"\n", - "your solution here\n", - "\"\"\"" + "survey = pd.DataFrame({\n", + " \"men\": {\"yes\": 324, \"no\": 156},\n", + " \"women\": {\"yes\": 351, \"no\": 169}})\n", + "\n", + "survey" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "67.5\n", + "67.5\n" + ] + } + ], + "source": [ + "men_yes = 324/480*100\n", + "women_yes = 351/520*100\n", + "\n", + "print(men_yes)\n", + "print(women_yes)\n", + "\n", + "#The gender is irrelevant to the question." ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -137,7 +236,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.10.9" } }, "nbformat": 4,