Skip to content

resolve conflinct whatever- odette #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 93 additions & 30 deletions 2022/python_workshop/notebooks/02_basic_data_types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,27 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x_int = 10, y_int = 10\n",
"type of x_int: <class 'int'>\n",
"type of y_int: <class 'int'>\n",
"x_initial_identity = 2696870193744\n",
"y_initial_identity = 2696870193744\n",
"are they the same? True\n",
"x_int is y_int? True\n",
"does x_int have the same value as y_int? True\n",
"assigning new value to x\n",
"x_int = 11, y_int = 10\n",
"does x_int have the same value as y_int? False\n",
"x_initial_identity; 2696870193744\n",
"x_final_identity: 2696870193776\n"
]
}
],
"source": [
"# assign x a value and then assign x to y\n",
"x_int = 10\n",
Expand Down Expand Up @@ -138,7 +158,15 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)\n"
]
}
],
"source": [
"import sys\n",
"print(sys.float_info)"
Expand All @@ -164,7 +192,10 @@
"try:\n",
" x = 1 / 0\n",
"except ZeroDivisionError:\n",
" print(\"you can't divide by zero!\")"
" print(\"you can't divide by zero u dummy!\")\n",
" raise ZeroDivisionError\n",
"finally:\n",
" print(\"damn son, where did u find this ?_?\")"
]
},
{
Expand All @@ -180,25 +211,24 @@
"x = 2.8\n",
"print(int(x))\n",
"print(math.floor(x))\n",
"print(math.ceil(x))\n",
"print(\"result: {}; integer part: {}\".format((x / 2), (x // 2)))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# powers of x\n",
"print(0**0)\n",
"print(x**2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'int'>\n",
"<class 'float'>\n"
]
}
],
"source": [
"# type default conversion\n",
"print(type(2*2))\n",
Expand Down Expand Up @@ -271,23 +301,28 @@
"source": [
"one_liner = \"Peter Pan is a terrible boxer.\\nWhenever he throws a punch, it Neverlands\"\n",
"print(one_liner)\n",
"\n",
"list_last = one_liner.split(' ')\n",
"print(list_last[:-1])\n",
"multi_liner = \"\"\"\n",
"I was wondering why the frisbee kept getting bigger and bigger.\n",
"But then it hit me.\n",
" Ba-dum tss.\n",
"\"\"\"\n",
"print(multi_liner)\n"
"print(multi_liner)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# get the last word of that one-liner\n",
"\n",
"# hint: look for the last space position\n",
"last_space_at = ...\n",
"\n",
Expand Down Expand Up @@ -316,15 +351,23 @@
"SELECT * FROM my_table WHERE date >= $$start_date$$;\n",
"\"\"\"\n",
"start_date = \"'2022-07-01 20:22:07'\"\n",
"replaced_statement = ...\n",
"replaced_statement = statement.replace('$$start_date$$',start_date)\n",
"print(replaced_statement)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ellipsis\n"
]
}
],
"source": [
"# split the following string based on the comma\n",
"s = \"\"\"\n",
Expand Down Expand Up @@ -359,9 +402,29 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"x evaluated to False\n"
]
},
{
"ename": "NameError",
"evalue": "name 'unstringrandom' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mc:\\Users\\Laptop 15\\Desktop\\test\\bootcamp\\2022\\python_workshop\\notebooks\\02_basic_data_types.ipynb Cell 20\u001b[0m in \u001b[0;36m<cell line: 12>\u001b[1;34m()\u001b[0m\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/Laptop%2015/Desktop/test/bootcamp/2022/python_workshop/notebooks/02_basic_data_types.ipynb#ch0000019?line=9'>10</a>\u001b[0m \u001b[39mbool\u001b[39m(\u001b[39m1\u001b[39m)\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/Laptop%2015/Desktop/test/bootcamp/2022/python_workshop/notebooks/02_basic_data_types.ipynb#ch0000019?line=10'>11</a>\u001b[0m \u001b[39m# what does a random string evaluate to?\u001b[39;00m\n\u001b[1;32m---> <a href='vscode-notebook-cell:/c%3A/Users/Laptop%2015/Desktop/test/bootcamp/2022/python_workshop/notebooks/02_basic_data_types.ipynb#ch0000019?line=11'>12</a>\u001b[0m \u001b[39mbool\u001b[39m(unstringrandom)\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/Laptop%2015/Desktop/test/bootcamp/2022/python_workshop/notebooks/02_basic_data_types.ipynb#ch0000019?line=12'>13</a>\u001b[0m \u001b[39m# what does an empty string evaluate to?\u001b[39;00m\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/Laptop%2015/Desktop/test/bootcamp/2022/python_workshop/notebooks/02_basic_data_types.ipynb#ch0000019?line=13'>14</a>\u001b[0m \u001b[39mbool\u001b[39m(\u001b[39m'\u001b[39m\u001b[39m'\u001b[39m)\n",
"\u001b[1;31mNameError\u001b[0m: name 'unstringrandom' is not defined"
]
}
],
"source": [
"# an empty (None) variable evaluates to False\n",
"x = int()\n",
Expand All @@ -370,19 +433,19 @@
" print('x evaluated to False')\n",
"\n",
"# what does 0 evaluate to?\n",
"\n",
"bool(0)\n",
"# what does 1 evaluate to?\n",
"\n",
"bool(1)\n",
"# what does a random string evaluate to?\n",
"\n",
"bool(unstringrandom)\n",
"# what does an empty string evaluate to?\n",
"\n"
"bool('')\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.5 64-bit",
"display_name": "Python 3.9.12 ('base')",
"language": "python",
"name": "python3"
},
Expand All @@ -396,12 +459,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
"version": "3.9.12"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
"hash": "d31b83e9610685068a0fe73b54051d44dc1110027bef1c52e64b671e72faac45"
}
}
},
Expand Down
Loading