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
61 changes: 53 additions & 8 deletions make a calculater.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "c6f8694a",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a + b = 14\n",
"a - b = 6\n",
"a * b = 40\n",
"a / b = 2.5\n"
]
}
],
"source": [
"## TODO : Place your code here"
"## TODO : Place your code here\n",
"\n",
"a = int(input(\"Input integer a =\"))\n",
"b = int(input(\"Input integer b =\"))\n",
"if type(a) != int or type(b) != int:\n",
" print(\"Please input integer only\")\n",
"else:\n",
" print(\"a + b =\", a + b)\n",
" print(\"a - b =\", a - b)\n",
" print(\"a * b =\", a * b)\n",
" if b!=0:\n",
" print(\"a / b =\", a / b)\n",
" else:\n",
" print(\"Can't divide by zero\")"
]
},
{
Expand All @@ -45,18 +69,39 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"id": "d040ccd8",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-215441 + -443040 = -658481\n",
"-215441 - -443040 = 227599\n",
"-215441 * -443040 = 95448980640\n",
"-215441 / -443040 = 0.48627889129649693\n"
]
}
],
"source": [
"## TODO : Place your code here"
"## TODO : Place your code here\n",
"import random\n",
"a = random.randint(-10**6, 10**6)\n",
"b = random.randint(-10**6, 10**6)\n",
"print(f\"{a} + {b} =\", a + b)\n",
"print(f\"{a} - {b} =\", a - b)\n",
"print(f\"{a} * {b} =\", a * b)\n",
"if b!=0:\n",
" print(f\"{a} / {b} =\", a / b)\n",
"else:\n",
" print(\"Can't divide by zero\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -70,7 +115,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down