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
58 changes: 58 additions & 0 deletions day22.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3456.0 divided by 754.0 is equal to 4.5836\n"
]
}
],
"source": [
"\n",
"\n",
"try:\n",
" num=float(input(\"Enter the numerator:\"))\n",
" denom=float(input(\"Enter the denominator:\"))\n",
"\n",
" result=num/denom\n",
" print(f\"{num} divided by {denom} is equal to {result:.4f}\")\n",
"except ValueError as e:\n",
" #split the return error message to only capture the user inout that has an error\n",
" print(f\"You've entered {e.args[0].split(': ')[1]} which is not a number.\")\n",
" \n",
" print(\"Enter a correct value\")\n",
"except ZeroDivisionError:\n",
" print(\"cannot perform division by zero\")\n",
" \n",
"\n"
]
}
],
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}