Lab 2

This lab demonstrates a short menu with input options and does basic mathematical operations with the number the user provides. It displays the result and shows the menu again giving the option input new numbers or exit.

option = 1
while option == 1:
option = input(“Menu: (1) Enter numbers (2) Exit”)
print (option)
if option == 1:
a = input(“Enter x: “)
b = input(“Enter y: “)
c = a + b
print “a + b = “, c
c = a – b
print “a – b = “, c
c = a * b
print “a * b = “, c
c = a / b
p0rint “a / b = “, c
c = a % b
print “a % b = “, c
c = a < b
print “a < b = “, c

 

lab1pic

Leave a Reply

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