In this lab, we were supposed to do different things. first off, we had to write a program that could do the following:

1- The sum *x *+ *y*

2- The difference *x – y*

3- The product *x * y*

4- The quotient *x/y*

5- The remainder *x%y*

6- Whether *x* is less than, equal, or greater than *y*

I had A LOT of problems making this, a lot of errors, such as misspelling commands and not properly indenting the sentences when I used the ‘else’ commands.

CODE

#Eridson Trinidad

#Lab 2 – Control Flow

#Date: 2/26/13

#Session:9310

#I am asking the user to give me values for ‘x’ and ‘y’

x = input(‘Enter the value for x: ‘)

y = input(‘Enter the value for y: ‘)

print(‘————————————–‘)

#I am now asking the user for what selections they want

#The selections are

#sum of x+ y

#different x – y

#product x*y

#quotient x/y

#remainder x%y

#whether x is less than, equal, or greater than y

print (‘input 1 to find the sum of x and y’)

print (‘input 2 to find the difference of x and y’)

print (‘input 3 to find the product x and y’)

print (‘input 4 t find the quotient of x and y’)

print (‘input 5 to find the remainder of x and y’)

print (‘input 6 to find the quotient of x and y’)

print (‘input 7 to find out whether x is less than, equal, or greater than y’)

print(‘————————————–‘)

z = input(‘enter what operation you want to do: ‘)

print(‘————————————–‘)

#I am now telling the program what to do when the user inputs a number

if z==1:

result = x + y

print ‘The sum of ‘,x, ‘and’,y, ‘is ‘,result

elif z==2:

result = x – y

print ‘the difference between ‘,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:

if x > y:

print ‘The number’,x, ‘is greatern than ‘,y

elif x < y:

print ‘The number’,x, ‘is less than ‘,y

else:

print ‘The number’,x, ‘is equal to ‘,y

print(‘————————————–‘)

#I was told to remake this again

#so I am doing what I did in the first place

#user is entering his inputs

x = input(‘insert value for x: ‘)

y = input(‘insert value for y: ‘)

print(‘————————————–‘)

print (‘input 1 to find the sum of x and y’)

print (‘input 2 to find the difference of x and y’)

print (‘input 3 to find the product x and y’)

print (‘input 4 t find the quotient of x and y’)

print (‘input 5 to find the remainder of x and y’)

print (‘input 6 to find the quotient of x and y’)

print (‘input 7 to find out whether x is less than, equal, or greater than y’)

print(‘————————————–‘)

z = input(‘enter what operation you want to do: ‘)

print(‘————————————–‘)

if z==1:

result = x + y

print ‘The sum of ‘,x, ‘and’,y, ‘is ‘,result

elif z==2:

result = x – y

print ‘the difference between ‘,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:

if x > y:

print ‘The number’,x, ‘is greatern than ‘,y

elif x < y:

print ‘The number’,x, ‘is less than ‘,y

else:

print ‘The number’,x, ‘is equal to ‘,y