Lab #3

Description: Using python script mode to create a sequence of commands and after running the script, it should ask for two integers then execute the sequence of commands which follow it.  This was similar to the second lab but I learned a better way of executing the program.  Keeping it organized helped so much.

Code: Creating a follow up sequence for the user using run on python IDLE


def add(x, y):
sum = x + y
return sum

def subtract(x, y):
difference = x – y
return difference

def product(x, y):
multiply = x * y
return multiply

def division(x, y):
divide = x / y
return divide

def whatisleft(x, y):
remainder = x % y
return remainder

def comparison(x, y):
if (x < y):
print(x, ‘is less than’, y)
elif (x > y):
print(x, ‘is greater than’, y)
print(x, ‘is equal to’, y)

while True:
y = (x + 3/x) / 2
if y == x:
x = y

x = int(input(“enter a value: “))
y = int(input(“enter a value: “))
print(add(x, y))
print(subtract(x, y))
print(product(x, y))
print(division(x, y))
print(whatisleft(x, y))
print(comparison(x, y))

import sys


Screenshots:Lab #3 screenshot part 1  Lab #3 screenshot part 2         after running it on IDLE >>>>Lab #3 screenshot after running it

Leave a Reply

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