Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

This program prompts the user for two numbers, calls a function to determine the smaller number and prints the smaller number that is returned from the function

# This program prompts the user for two numbers,
# calls a function to determine the smaller number
# and prints the smaller number that is returned from the function

def getSmaller(num1, num2):
    if num1<num2:
        smaller = num1
    else:
        smaller = num2
    return smaller

def main():
    userInput1 = int(input("Enter a number: "))
    userInput2 = int(input("Enter a second number: "))
    
    smallerNumber = getSmaller(userInput1,userInput2)
    print("The smaller of the two numbers is", smallerNumber)


###call to main program####
main()
print("Done!")
Source by ioct.tech #
 
PREVIOUS NEXT
Tagged: #This #program #prompts #user #calls #function #determine #smaller #number #prints #smaller #number #returned #function
ADD COMMENT
Topic
Name
2+6 =