LAB 2

THE LOOP

Description:

This is a small program in python, which shows  a loop and a while statement. This is the first program i make that interacts with the user. The user enters a value for “x” and a value for “y” and the program out puts calculations using the values entered by the user, as long as  neither of the number entered by the user is zero, the program will continue to run and repeating.

 

code:

 

x=int(input (‘please enter a value for x?\n’))

y=int(input (‘please enter a value for y\n’))

while x !=0 and y != 0:

print (x+y)
print (x-y)
print (x*y)
print (x/y)
print (x%y)
if x < y:
print(‘x is less than y’)
elif x > y:
print(‘x is greater than y’)
else:
print(‘x is equal to y’)
x=int(input (‘please enter a value for x?\n’))

y=int(input (‘please enter a value for y\n’))
print

 

Screenshot:

frandylab2

Leave a Reply

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