Lab #2

Lab Description:

In this lab I created a program where I took in input from a user and then gave a result back. The results were either adding,subtracting, multiplying, etc. I was able to do this by using conditional statements,by using the if command,  which are either true or false. If they are true they execute the statement below it otherwise it won’t work and start all over. I also used a while loop which will keep repeating a statement unless you exit it with another condition.

source code:

b=2
while b>0: 
        a= int( input ( " press ( 1 ) to enter or ( 2 ) exit the menu " ) )
        if a==1:
                x= int(input (  ' enter value of x : ' ) ) #user input
                y= int(input (  ' enter value of y : ' ) )
                z= print ( x + y )
                z= print ( x - y )
                z= print ( x * y )
                z= print ( x / y )
                z= print ( x % y )
                z= print ( x <= y )                 z= print ( x >= y )
        else:
                break
                print ( ' It is done ! ' )
Lab 2 running

Leave a Reply

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