def xf(keyOpt,n):

The function xf has multiple variables as input. One of them is a string KeyOpt and one of them is an integer n. This illustrates that the input variable can be not only a simple numeric variable but also a string, float, integer, array.. etc.

        x= np.linspace(0, 180, n)
        y= np.linspace(0, 580, n)
        x= np.linspace(0, 18, n)
        y= np.linspace(0, 58, n)

  • The if condition inside the function. If the string keyOpt == 'Yes' than assign the value x and y to be these arrays. If on the other the value of keyOpt == 'No' than assign the value of x and y to be these arrays. A reminder that you used two == signs not one = for the equal operator (Lab03-Ex2).
  • The value of the string can be used in the function xf either by using ' ' or " ". Note that it is case sensetive.

        return x,y
    x1,y1 = xf('Yes',150)

  • Also note that the output here is multiple arrays x and y which are read by simply assigning them to the arrays x1 and y1.
  • Note that the output not only can be multiple variables but can also be arrays, string, integers, simple variables...etc