Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Needs to be in python: In this question, you will write a Python program that wi

ID: 3855900 • Letter: N

Question

Needs to be in python:

In this question, you will write a Python program that will prompt user to enter two numbers, one at a time and then determine which of the two numbers is smaller.

BUT in this question you MUST use function to accomplish the result. The two numbers can be read in your main program as usual but you will need a function called find_min() that will accept the two numbers and then return the number that is smaller of the two.

Also another function called print_result() that will accept the two numbers and one of them is samller than the other. The purpose of this function is just to print the output. Hence, the output shown in the sample run above is done by this function.

NOTE : You must NOT use any built-in function to find minimum of two numbers, that is, you must write your own function.

Explanation / Answer

Answer for Question:

Please try this after indentations are adjusted and tested once again. see my comments also.

This below python code is written as given conditions in the problems statements.

def find_min():
a = 0
b = 0
#print "Enter First Number:",
a = input("Enter a number: ")   
#print "Enter Second Number:",
b = input("Enter a number: ")
small = a
if (a < b):
small = a
else:
small = b
return small
  
def print_result(val3):
print "Smallest of is: ", val3
  
def main():
#print "Hello World!"
val4=find_min()
print_result(val4)
  
if __name__== "__main__":
main()

Output:

sh-4.3$ python main.py                                                                                                                                                               

Enter a number: 3                                                                                                                                                                    

Enter a number: 2                                                                                                                                                                    

Smallest of is:  2                                                                                                                                                                   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote