{ "cells": [ { "cell_type": "markdown", "id": "6838b2de", "metadata": {}, "source": [ "# Hello" ] }, { "cell_type": "code", "execution_count": null, "id": "4200d243", "metadata": {}, "outputs": [], "source": [ "\n", "\"\"\"\n", " Python program to demonstrate basic mathematics by evaluation of a quadratic\n", " and print out the value and the square root of the value.\n", "\n", "\"\"\"\n", "\n", "# Add the additional maths functions\n", "import math \n", "\n", "# Create a main \n", "def main():\n", " \n", " # Create three float variable \n", " a = 4.0\n", " b = -13.5\n", " c = 10.2\n", " \n", " # Ask for a value from the keyboard\n", " x = float(input(\"Give x value : \"))\n", " \n", " # Calcualte the quadratic and the square root ising the math.sqrt() function\n", " # Note you do NOT require brackets.\n", " y = a*x**2 + b*b + c\n", " z = math.sqrt(y)\n", " \n", " # Print out the results as a string\n", " print(\"Value of quadratic is : \" + str(y) +\" and its sqrt root is : \" + str(z))\n", " \n", "\n", "# Run the main()\n", "\n", "main()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }