Learn about Python Program to Subtract Two Numbers using Function in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Python Program to Subtract Two Numbers using Function
# Python program to subtract two numbers #user-defined function def sub_num(num1, num2): #subtract two numbers return num1-num2 num1 = float(input('Enter first number: ')) num2 = float(input('Enter second number: ')) print('The subtraction of numbers = %0.1f' %sub_num(num1, num2))
Enter first number: 5
Enter second number: 3
The subtraction of numbers = 2.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 Subtract Two Numbers given by user