lab 2

  • LAB DESCRIPTION

In this lab I made a program that  asks you to enter two integer numbers using input function.If one of two numbers is 0 the program will print “the program stopped”and the program will stop (break function).Otherwise, the program will calculate the sum,difference,product,quotient,reminder and tell if whether x is less than, equal, or greater than y.If the two numbers are are different than 0 the program will make a loop(while function) and ask you to enter new set of numbers.

  • CODE:

x=1
y=1
while (x!=0 or y!=0):
   x=int( input('enter integer x value:')) #input  x value
   print('x =',x)
   y=int( input('enter integer y value:')) #input y value
   print('y =',y)
   if  (x==0 or y==0):
       print('the program stopped ')
       break              # if x or y are 0 the program will stop
   else:
     x+y                  # calculate x+y
     print('x+y=',x+y)
     x-y                  # calculate x-y
     print('x-y=',x-y)
     x*y                  # calculate x*y
     print('x*y=',x*y)
     x/y                  # calculate x/y
     print('x/y=',x/y)
     x%y                  # calculate reminder
     print('remainder is',x%y)
 
     if (x>y):            # check if x is greater,less or equal to y
        print('x is greater than y')

     elif x

 


  • SCREENSHOOT: