Lab 3

Lab Description: In this lab the program shows the menus with sum, subtract, multiplication, division, remainder etc. At first when the user select the option 1 the programs ask for the integer number for x and perform the operations which are implemented using function and then display results. The program continues until the the option 2 is chosen. if option 2 is chosen then the programs exit.

Source Code:

option=input("select an option(1) enter a number and (2) exit ")
#print (option)
o = int(option)
if (o == 1):
    x=input("enter value x")
    def f(x):
        return x+x
    print ("x+x= ", f(x))
    def f(x):
        return x-x
    print ("x-x= ", f(x))
    def f(x):
        return x*x
    print ("x*x= ", f(x))
    def f(x):
        return x/x
    print ("x/x= ", f(x))
    def f(x):
        return x%x
    print ("x%x= ", f(x))

Screenshot:Capture

Leave a Reply

Your email address will not be published. Required fields are marked *