Lab Two

This lab was further introduction to program script writing. The purpose was to create a program that performed the following operations on integers ‘x’ and ‘y’: add, subtract, multiply, divide, find remainder, and determining if ‘x’ is less than, greater than, or equal to ‘y.’

Script Code:

loop_control = 0
while(loop_control != 7):
print (‘1. Addition’)
print (‘2. Subtraction’)
print (‘3. Multiplication’)
print (‘4. Division’)
print (‘5. Remainder’)
print (‘6. Comparison’)
print (‘7. Exit’)
loop_control= input(‘Which operation would you like to perform?’)
#work with response from user
if loop_control== ‘1’:
x = input (‘Enter Number’)
x = int(x)
y = input (‘Enter Another Number’)
y = int(y)
z = x+y
print(z)
elif loop_control== ‘2’:
x = input (‘Enter Number’)
x = int (x)
y = input (‘Enter Another Number’)
y = int (y)
z = x-y
print (z)
elif loop_control== ‘3’:
x = input (‘Enter Number’)
x = int (x)
y = input (‘Enter Another Number’)
y = int (y)
z = x*y
print (z)
elif loop_control== ‘4’:
x = input (‘Enter Number’)
x = int (x)
y = input (‘Enter Another Number’)
y = int (y)
z = x/y
print (z)
elif loop_control== ‘5’:
x = input (‘Enter Number’)
x = int (x)
y = input (‘Enter Another Number’)
y = int (y)
z = x%y
print (z)
elif loop_control== ‘6’:
x = input (‘Enter Number’)
x = int (x)
y = input (‘Enter Another Number’)
y = int (y)
if x > y:
print (‘x is greater than y’)
elif x < y:
print (‘x is less than y’)
elif x == y:
print (‘x is equal to y’)
elif loop_control == ‘7’:
print (‘Program has been terminated!’)
loop_control == ‘7’

Screen Shots of Functioning Program:

dem3333

dem44

dem55

 

Leave a Reply

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