<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction to Programming 
Step1:  Question
Step2:  Passing values to functions
Step3:  Conclusion
Step4:  Initialization of variables within function definition
Step5:  * operator
1. Unpacks a list or tuple into positional arguments
** operator
2. Unpacks a dictionary into keyword arguments
Types of parametres
Formal parameters (Done above, repeat)
Keyword Arguments (Done above, repeat)
*variable_name 
<ASSISTANT_TASK:>
Python Code:
#Example_1: return keyword
def straight_line(slope,intercept,x):
    "Computes straight line y value"
    y = slope*x + intercept
    return y
print("y =",straight_line(1,0,5)) #Actual Parameters
print("y =",straight_line(0,3,10))
#By default, arguments have a positional behaviour
#Each of the parameters here is called a formal parameter
#Example_2
def straight_line(slope,intercept,x):
    y = slope*x + intercept
    print(y)
    
    
straight_line(1,0,5)
straight_line(0,3,10)
#By default, arguments have a positional behaviour
#Functions can have no inputs or return.
Explanation: Introduction to Programming : Lecture 5
Agenda for the class
Introduction to functions
Practice Questions
Functions in Python
Syntax
def function_name(input_1,input_2,...):
    '''
    Process input to get output
    '''
    return [output1,output2,..]
End of explanation
straight_line(x=2,intercept=7,slope=3) 
Explanation: Question: Is it necessary to know the order of parametres to send values to a function?
End of explanation
list_zeroes=[0 for x in range(0,5)]
print(list_zeroes)    
def case1(list1):
    list1[1]=1
    print(list1)
    
case1(list_zeroes)
print(list_zeroes)    
#Passing variables to a function
list_zeroes=[0 for x in range(0,5)]
print(list_zeroes)    
def case2(list1):
    list1=[2,3,4,5,6]
    print(list1)
    
case2(list_zeroes)
print(list_zeroes)    
Explanation: Passing values to functions
End of explanation
def calculator(num1,num2,operator='+'):
    if (operator == '+'):
        result = num1 + num2
    elif(operator == '-'):
        result = num1 - num2
        
    return result    
n1=int(input("Enter value 1: "))
n2=int(input("Enter value 2: "))
v_1 = calculator(n1,n2)
print(v_1)
v_2 = calculator(n1,n2,'-')
print(v_2)    
# Here, the function main is termed as the caller function, and the function
# calculator is termed as the called function
# The operator parameter here is called a keyword-argument
Explanation: Conclusion:
If the input is a mutable datatype, and we make changes to it, then the changes are refelected back on the original variable. (Case-1)
If the input is a mutable datatype, and we assign a new value to it, then the changes are not refelected back on the original variable. (Case-2)
Default Parameters
End of explanation
def f(a, L=[]):
    L.append(a)
    return L
print(f(1))
print(f(2))
print(f(3))
# Caution ! The list L[] was initialised only once.
#The paramter initialization to the default value happens at function definition and not at function call.
Explanation: Initialization of variables within function definition
End of explanation
def sum(*values):
    s = 0
    for v in values:
        s = s + v
    return s
s = sum(1, 2, 3, 4, 5)
print(s)
def get_a(**values):
    return values['a']
s = get_a(a=1, b=2)      # returns 1
print(s)
def sum(*values, **options):
    s = 0
    for i in values:
        s = s + i
    if "neg" in options:
        if options["neg"]:
            s = -s
    return s
s = sum(1, 2, 3, 4, 5)            # returns 15
print(s)
s = sum(1, 2, 3, 4, 5, neg=True)  # returns -15
print(s)
s = sum(1, 2, 3, 4, 5, neg=False) # returns 15
print(s)
Explanation: * operator
1. Unpacks a list or tuple into positional arguments
** operator
2. Unpacks a dictionary into keyword arguments
Types of parametres
Formal parameters (Done above, repeat)
Keyword Arguments (Done above, repeat)
*variable_name : interprets the arguments as a tuple
**variable_name : interprets the arguments as a dictionary
End of explanation
<END_TASK>