Lab 2

This lab is about control flow and while loop statement. Throughout, this lab# 2 i learned how to make a while loop satement and sequential statement. I had little difficulties with sequential statement and while loop.

Source code: m = 1
while m==1:
x = input(‘Enter a number: ‘)
print x
m = input (‘Do you want to continue? (enter 1 is Yes)’)
if x == 2:
break

x = input (‘Enter thr first number: ‘)
y = input (‘Enter thr second number: ‘)
print ‘Enter 1 to add the numbers’
print ‘Enter 2 to subrtract the numbers’
print ‘Enter 3 to multiply the numbers’
print ‘Enter 4 to divide the numbers’
print ‘Enter 5 for remainder of the numbers’
print ‘Enter 6 is for less, equal, greater numbers’

z = input(‘Enter a selection: ‘)
if z == 1:
result = x+y
print ‘The sum of ‘,x,’ and’, y, ‘ is: ‘,result
elif z ==2:
result = x-y
print ‘The difference of ‘,x,’ and’, y, ‘ is: ‘,result
elif z == 3:
result = x*y
print ‘The product of ‘,x,’ and’, y, ‘ is: ‘,result
elif z == 4:
result = x/y
print ‘The quotient of ‘,x,’ and’, y,’ is: ‘, result
elif z == 5:
result == x%y
print ‘ The remainder of ‘,x,’and’, y,’ is: ‘, result
elif z == 6:
result = x<y
print ‘The value of ‘,x,’ and’, y,’ is: ‘, result