Lab 2

Lab Description:

This Lab concludes basic mathematical calculations but includes an optional input that allows the user to choose from. If the user inputs a number at the beginning, the program with ask for a second number (the numbers a represented by two integers ‘x’ and ‘y’). Then it will calculate the two numbers and at the end will verify which one is greater. If the user inputs exit at the start of the program, it will print ‘goodbye!’

Code:

xti = input (‘enter a number or exit:’)
if xti == ‘exit’:
print(‘goodbye!’)
if xti != ‘exit’:
yti = input (‘enter a second number:’)

x = int(xti)
y = int(yti)

print(x+y)
print(x-y)
print(x/y)
print(x*y)
print(x%y)

if x > y:
print(‘ x is greater than y’)

if x < y:
print(‘x is less than y’)

Screenshots:

Lab 2 Screenshot

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply

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