Answer:
In Python:
def subsmall(num1,num2):
if num1 > num2:
return num1 - num2
else:
return num2 - num1
repeat = True
while(repeat):
num = input("Enter two integers: ")
nums = num.split(" ")
print(subsmall(int(nums[0]),int(nums[1])))
runagain = input("Run program again? ").lower()
if runagain == "y":
repeat=True
else:
repeat = False
Step-by-step explanation:
The function begins here
def subsmall(num1,num2):
This subtracts num2 from num1 if num2 is smaller
if num1 > num2:
return num1 - num2
If otherwise, subtract num1 from num2
else:
return num2 - num1
The main begins here
This initialiazes a boolean variable to true
repeat = True
This loop is repeated until the boolean variable is false
while(repeat):
Prompt to enter two integers
num = input("Enter two integers: ")
Split the string by space
nums = num.split(" ")
This passes the two integers to the function and also prints the differences
print(subsmall(int(nums[0]),int(nums[1])))
Prompt to run the program again
runagain = input("Run program again? ").lower()
If input is Y or y, the loop repeats
if runagain == "y":
repeat=True
The program ends if otherwise
else:
repeat = False