Lab#2 Python program

You are currently viewing a revision titled "Lab#2 ", saved on May 12, 2013 at 3:58 pm by Anne Menmou
Title
Lab#2
Content
# Lab2 The program takes two numbers and displays the sum, the difference, #the quotient, the remainder of the division of the first by the second #and compare the two numbers. print("PROGRAM THAT TAKES TWO NUMBERS AND DISPLAYS THE SUM,") print("THE DIFFERENCE, THE PRODUCT, THE REMAINDER AMD COMPARE THE TWO NUMBERS") print("") a_str=input('Enter the first number please !: ') b_str=input('Enter the second number please!: ') x=int(a_str) y=int(b_str) # PROCESSING STAGE choice=1 while choice==1: if x==0 or y==0: print('END OF PROGRAM') choice=0 break else: choice=1 my_sum= x+y my_diff=x-y my_prod=x*y my_quot=int(x/y) my_remaind=x%y # Output display print(' ') print('1- THE SUM :',x, '+ ' ,y, ' = ',my_sum) print(' ') print('2- THE DIFFERENCE : ',x,' - ',y,' = ', my_diff) print(' ') print('3- THE PRODUCT : ',x,' * ',y,' = ', my_prod) print(' ') print('4- THE QUOTIENT : ',x,' / ',y,'=', my_quot) print(' ') print('5- THE REMAINDER ',x,' % ',y,' is ', my_remaind) print(' ') if x>y: print("6- ", x, 'IS GREATER THAN ',y) elif x==y: print(x, 'IS EQUAL to ',y) else : print("6- ", x, 'IS LESS THAN ',y) print("") print("GREAT!!! ENTER TWO NEW VALUES TO REPEAT THE PROCESS!") print("") a_str=input('Enter the first number please !: ') b_str=input('Enter the second number please!: ') x=int(a_str) y=int(b_str)  
Excerpt
Footnotes


Old New Date Created Author Actions
May 12, 2013 at 7:58 pm Anne Menmou