diff --git a/day22.ipynb b/day22.ipynb new file mode 100644 index 00000000..87caeb42 --- /dev/null +++ b/day22.ipynb @@ -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 +}