#functions #function is a small code that is responcible for single task #each function will have: name, parameters (could be empty list) #and return value (could be void or no return value) #writing function will involve two steps: #writing function definition and using function (calling function) #write a function that has two parameters and returns sum of the #parameters #write a program that reads 4 integers, and finds sum of first two #number and sum of third and forth input #function definition #sum_two_ints - name of the function #a and b - function parameters def sum_two_ints(a, b): result = a+b return result def main(): num1=int(input("enter first num ")) num2=int(input("enter second num ")) num3=int(input("enter third num ")) num4=int(input("enter forth num ")) #function call result1=sum_two_ints(num1, num2) #1. program will jump to the function we wrote #2. a will be replaced with num1 value #3. b will be replaced with num2 value #4. function will calculate result which is num1+num2 #5. function will return result and that will be assigned to #variable result1 #function call again for num3 and num4 result2=sum_two_ints(num3, num4) print("result1", result1) print("result2", result2) main()