lab 2

Instructions:

Write a program that asks the user to enter two integer numbers x and y. The program should perform the following operations and display the results back:

1-      The sum x + y

2-      The difference x – y

3-      The product x * y

4-      The quotient x/y

5-      The remainder x%y

6-      Whether x is less than, equal, or greater than y

 

import math
x= input ('Enter the 1st number:')
y=input ('Enter the 2nd number:')
print 'Enter 1 to add the numbers.'
print 'Enter 2 to subtract the numbers.'
print 'Enter 3 to multiply the numbers.'
print 'Enter 4 to divide the numbers.'
print 'Enter 5 to remainder the numbers.'
print 'Enter 6 whether x is less than,equal,or greater than y'
z== input ('please enter your selection:')
if z==1:
result = x+y
print 'The sum of ',x,'and ',y,' is:',
elif z==2:
result = x-y
print 'The difference of ',x,' and ',y,' is:',
elif z==3:
result = x*y
print 'The product of ',x,' and ',y,' is:',
else:
result = x/y
print 'The quotient of ',x,' and ',y,' is

if
result = x%y
print 'The remainder of ',x,' and ',y,'is',
else x < y: print 'x is less than y' elif if x > y:
print 'x is greater than y'
else
if x = y
print 'x and y are equal'

After displaying the results, the program should ask again for two integer numbers and repeat the operations for the new values entered. If either the value of x or y entered by the user is 0 (zero), the program should finish.

 

On your OpenLab portfolio post the following items, following the Lab Report Example:

  • Lab description and your experience in your own words.
  • Copy/paste of the code you typed, properly formatted.
  • Screenshots of your results.