Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 111 additions & 12 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"\"\"\""
]
},
Expand All @@ -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",
"\"\"\""
]
},
Expand All @@ -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",
"\"\"\""
]
},
Expand All @@ -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": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>men</th>\n",
" <th>women</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>yes</th>\n",
" <td>324</td>\n",
" <td>351</td>\n",
" </tr>\n",
" <tr>\n",
" <th>no</th>\n",
" <td>156</td>\n",
" <td>169</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"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"
},
Expand All @@ -137,7 +236,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down