Learn about Program to Divide Two Integers in Python using Function in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Program to Divide Two Integers in Python using Function
# Program to divide two integers using function
#user-defined function
def div_Num(num1, num2):
div = (num1/num2) #divide numbers
return div
num1 = int(input('Enter first number: '))
num2 = int(input('Enter second number: '))
# function call
div = div_Num(num1, num2)
print("The division of {0} and {1} is {2}"
.format(num1,num2,div))
Output:
Enter first number: 8 Enter second number: 2 The division of 8 and 2 is 4.0
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python Program to Divide Two Integers