Lab 2

Lab description:

In this lab, I was told to write a program that would asks a user to enter two integer numbers that would perform some operations that would give an result. I found this hard to do but after awhile I got it.

source code:

def main():
choice = input(‘Do you wish to start the program?\n Please enter y or n …’)
if choice == ‘n’ or choice == ‘N’:
quit
elif choice == ‘y’ or choice == ‘Y’:
x = input(‘What is the first integer \n’)
y = input(‘What is the second integer \n’)
x = int(x)
y = int(y)
print(x+y,’ is the sum of the two integers’)
print(x-y,’ is the difference between two integers’)
print(x*y,’ is the product of two integers’)
if y==0:
print(‘undefine’)
else:
print(x/y,’is the quotient of two integers’)
print(x%y,’is the remainder when dividing x by y’)
if x>y:
print(‘%d is larger than %d’%(x,y))
elif x==y:
print(‘%d is equal to %d’%(x,y))
else:
print(‘%d is less than %d’%(x,y))
main()
else:
print(‘Its either y or no’)
main()

main()

Screenshot:

picture

Leave a Reply

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