{ "metadata": { "kernelspec": { "name": "python", "display_name": "Python (Pyodide)", "language": "python" }, "language_info": { "codemirror_mode": { "name": "python", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8" } }, "nbformat_minor": 5, "nbformat": 4, "cells": [ { "id": "6ba892ba-3b99-452b-8bde-bc024199862a", "cell_type": "markdown", "source": "
The code below has several errors that prevent it from functioning properly.
\nFix each of the errors and add comments below to explain how you fixed them
\nBuild a program that executes like this
\n\nThe program should run for all four mathematical operations
\nLets make your calculator a bit more useful for higher level maths\n
At the very beginning of your code add the following command
import math
This connects your program to something called a library\n
Libraries allow us to add more functions into python, many of them specialist
Now in the code cell below, add this code
\n\nnum1 = int(input(\"Enter a number to see its square root\")\nanswer = math.sqrt(num1) \nprint(f\"The square root of {num1} is {answer}\")\n\n \nLet's take it further!
\nAdd this library import to top of the code (bef\n
import fractions
Now add this code to the cell below
\n\nfraction1 = fractions.Fraction(1,2)\nfraction2 = fractions.Fraction(1,3)\n\nanswer = fraction1 * fraction2\n\nprint(f\"{fraction1} X {fraction2} = {answer}\")\n\nYou can now calculate with fractions!
\nAdd a further option into your calculator program to include square roots and fractions
\n