Maximum of Two Values
Write a function named maximum that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two.
Maximum of Two Values Python Code:
#The function named maximum that accepts two integer
#values as arguments and returns the value that is
#the greater of the two.
def maximum(firstNum, secondNum):
if firstNum > secondNum:
return firstNum
else:
return secondNum
# Prompt and read the input from the user
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
# Call the method, maximum
bigNum = maximum(num1, num2)
# Displaying the result
print("The greater value between", num1, "and", num2, "is:", bigNum)
Executed Output:
Enter the first number: 50
Enter the second number:100
The greater value between 50 and 100 is: 100