Perform addition and subtraction using CherryPy Last Updated : 01 Oct, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report CherryPy also known as a web application library is a Python web framework that provides a friendly interface to the HTTP protocol for Python developers. It allows developers to build web applications the same way as in traditional object-oriented Python programs. Thereby, resulting in smaller source code developed in no time. This framework is mainly for the developers who want to create a portable database-driven web application using Python, as it provides Create, Retrieve, Update and Delete functionalities. The basic requirements for the installation of CherryPy include: Python with version 2.4 or aboveCherrypy 3.0Installation To install cherrypy run the following command in terminal: pip install cherrypy Approach: Create user interface to take input from user.Write cherrypy program to perform required operations HTML code to take input from the user- HTML <html> <head> </head> <body> <div class="container"> <h2><u><i>Operation</i></u></h2> <form action="store" id="form" method="GET"> <input type="number" name="number1" /><br /> <input type="number" name="number2" /><br /> <input style="margin-left: 250px;" id=" submit" type="submit"/></div> </div> </form> </div> </body> </html> Cherrypy code for addition Python3 import cherrypy class Root(object): @cherrypy.expose def index(self): return """<html> <head> </head> <body> <div class="container"> <h2><u><i>Addition</i></u></h2> <form action="store" id="form" method="GET"> <input type="number" name="number1" /><br /> <input type="number" name="number2" /><br /> <input style="margin-left: 250px;" id=" submit" type="submit"/></div> </div> </form> </div> </body> </html>""" @cherrypy.expose def store(self, number1, number2): num1=int(number1) num2=int(number2) answer=num1+num2 out= """<html> <body> <p> Sum: %s</p> <a style="color:red; font-size:35px;" id="shutdown"; href="./shutdown"><i>Shutdown Server</i></a> </body> </html> """ return out % (str(answer)) @cherrypy.expose def shutdown(self): cherrypy.engine.exit() if __name__=="__main__": cherrypy.config.update({'server.socket_port': 8087}) cherrypy.quickstart(Root()) Output: Code for subtraction Python3 import cherrypy class Root(object): @cherrypy.expose def index(self): return """<html> <head> </head> <body> <div class="container"> <h2><u><i>Subtraction</i></u></h2> <form action="store" id="form" method="GET"> <input type="number" name="number1" /><br /> <input type="number" name="number2" /><br /> <input style="margin-left: 250px;" id=" submit" type="submit"/></div> </div> </form> </div> </body> </html>""" @cherrypy.expose def store(self, number1, number2): num1=int(number1) num2=int(number2) answer=num1-num2 out= """<html> <body> <p> Result: %s</p> <a style="color:red; font-size:35px;" id="shutdown"; href="./shutdown"><i>Shutdown Server</i></a> </body> </html> """ return out % (str(answer)) @cherrypy.expose def shutdown(self): cherrypy.engine.exit() if __name__=="__main__": cherrypy.config.update({'server.socket_port': 8087}) cherrypy.quickstart(Root()) Output: Comment More infoAdvertise with us Next Article How to perform multiplication using CherryPy in Python? R romy421kumari Follow Improve Article Tags : Misc Python python-utility python-modules Practice Tags : Miscpython Similar Reads Adding and Subtracting Matrices in Python In this article, we will discuss how to add and subtract elements of the matrix in Python. Example: Suppose we have two matrices A and B. A = [[1,2],[3,4]] B = [[4,5],[6,7]] then we get A+B = [[5,7],[9,11]] A-B = [[-3,-3],[-3,-3]] Now let us try to implement this using Python 1. Adding elements of 4 min read Subtract two numbers without using arithmetic operators Write a function subtract(x, y) that returns x-y where x and y are integers. The function should not use any of the arithmetic operators (+, ++, â, -, .. etc). The idea is to use bitwise operators. Addition of two numbers has been discussed using Bitwise operators. Like addition, the idea is to use 8 min read How to subtract one polynomial to another using NumPy in Python? In this article, let's discuss how to subtract one polynomial to another. Two polynomials are given as input and the result is the subtraction of two polynomials. The polynomial p(x) = C3 x2 + C2 x + C1  is represented in NumPy as : ( C1, C2, C3 ) { the coefficients (constants)}.Let take two polynom 2 min read How to perform multiplication using CherryPy in Python? CherryPy also known as a web application library is a Python web framework that provides a friendly interface to the HTTP protocol for Python developers. It allows developers to build web applications the same way as in traditional object-oriented Python programs. Thereby, resulting in smaller sourc 2 min read numpy.subtract() in Python numpy.subtract() function is used when we want to compute the difference of two array.It returns the difference of arr1 and arr2, element-wise.Syntax : numpy.subtract(arr1, arr2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj], ufunc 'subtract' 3 min read Add, subtract, multiple and divide two Pandas Series Let us see how to perform basic arithmetic operations like addition, subtraction, multiplication, and division on 2 Pandas Series. For all the 4 operations we will follow the basic algorithm : Import the Pandas module. Create 2 Pandas Series objects. Perform the required arithmetic operation using t 2 min read Like