Lab #2

Lab Description:

I wrote a program that displays a menu to somebody with the options: (1) enter a number (2) exit. When the person enters option 1, the program asks for two numbers defined as x and y. The program will perform the following operations and display the results back.

Code:

option = 1
while option == 1:
     option = input("Menu: (1) Enter numbers (2) Exit")
     print (option)
     if option == 1:
          x = input("Enter x: ")
          y = input("Enter y: ")
          z = x + y
          print "x + y = ", z
          z = x - y
          print "x - y = ", z
          z = x * y
          print "x * y = ", z
          z = x / y
          print "x / y = ", z
          z = x % y
          print "x % y = ", z
          z = x < y
          print "x < y = ", z

jcasillas-scr

Leave a Reply

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