contestada

Define a function called min that takes two parameters containing integer values and returns the smaller integer of the two. If they have equal value, return either one.

Respuesta :

Answer:

Complete Pyhton code with explanatory comments and output results is given below

Python Code:

def min():

# get input from the user, two integers

   num1=int(input("Please enter 1st integer: "))

   num2=int(input("Please enter 2nd integer: "))

# using if elif conditional statements compare the two integers

   if num1<num2:

       return print("Smallest integer is: ",num1)

# if num1 is less than num2 than print the num 1

   elif num2<num1:

       return print("Smallest integer is: ",num2)

# if num2 is less than num1 than print the num 2

   else:

# if both of the above conditions are not true then it means they are equal

       return print("They are equal: ",num1)

# call the min() function

min()

Output:

Test 1:

Please enter 1st integer: 6

Please enter 2nd integer: 1

Smallest integer is: 1

Test 2:

Please enter 1st integer: 5

Please enter 2nd integer: 5

They are equal:

Ver imagen nafeesahmed
Ver imagen nafeesahmed