Lab#2 Python program

  • View document Lab#2  

    Uploaded by Anne Menmou on May 12, 2013

    Description: # Lab2 The program takes two numbers and displays the sum, the difference,<br /> #the quotient, the remainder of the division of the first by the second<br /> #and compare the two numbers.<br /> <br /> print("PROGRAM THAT TAKES TWO NUMBERS AND DISPLAYS THE SUM,")<br /> print("THE DIFFERENCE, THE PRODUCT, THE REMAINDER AMD COMPARE THE TWO NUMBERS")<br /> print("")<br /> a_str=input('Enter the first number please !: ')<br /> b_str=input('Enter the second number please!: ')<br /> x=int(a_str)<br /> y=int(b_str)<br /> <br /> # PROCESSING STAGE<br /> choice=1<br /> <br /> while choice==1:<br /> if x==0 or y==0:<br /> print('END OF PROGRAM')<br /> choice=0<br /> break<br /> else:<br /> choice=1<br /> my_sum= x+y<br /> my_diff=x-y<br /> my_prod=x*y<br /> my_quot=int(x/y)<br /> my_remaind=x%y<br /> # Output display<br /> print(' ')<br /> print('1- THE SUM :',x, '+ ' ,y, ' = ',my_sum)<br /> print(' ')<br /> print('2- THE DIFFERENCE : ',x,' - ',y,' = ', my_diff)<br /> print(' ')<br /> print('3- THE PRODUCT : ',x,' * ',y,' = ', my_prod)<br /> print(' ')<br /> print('4- THE QUOTIENT : ',x,' / ',y,'=', my_quot)<br /> print(' ')<br /> print('5- THE REMAINDER ',x,' % ',y,' is ', my_remaind)<br /> print(' ')<br /> if x>y: print("6- ", x, 'IS GREATER THAN ',y)<br /> elif x==y: print(x, 'IS EQUAL to ',y)<br /> else : print("6- ", x, 'IS LESS THAN ',y)<br /> print("")<br /> print("GREAT!!! ENTER TWO NEW VALUES TO REPEAT THE PROCESS!")<br /> print("")<br /> a_str=input('Enter the first number please !: ')<br /> b_str=input('Enter the second number please!: ')<br /> x=int(a_str)<br /> y=int(b_str)<br />