186k views
0 votes
Create a Python program as described below and save it in a file named bool. You should use IDLE or similar environment to create your program. First develop a conceptual model and document it using either pseudo code or a flowchart to meet the requirements of the program described as follows.

User Ivoba
by
8.2k points

1 Answer

4 votes

PYTHON CODE

# function to compare a and b
def compare(a,b):

# if a is greater than b , return 1
if a > b:
return 1

# if a and b are equal, return 0
elif a == b:
return 0

# if a less than b , return -1
elif a < b :
return -1


# testing
if __name__=="__main__":

# calling the compare function with a and b
print('compare(5,2) %d'%compare(5,2))
print('compare(2,5) %d'%compare(2,5))
print('compare(3,3) %d'%compare(3,3))

# getting values for a and b
a=int(input("Enter the value for a: "))
b=int(input("Enter the value for b: "))

print('compare(%d,%d) %d'%(a,b,compare(a,b)))

(see attachment for output)

Create a Python program as described below and save it in a file named bool. You should-example-1
User Wilth
by
8.1k points