ipython - How to define a python function -


so new python , have take class in college credits. given assignment @ home (we allowed go online etc) , part of involved defining function. i'm not @ coding/computers in general , i'm having lot of difficulty in trying so.

how go defining function cos(a,b,c) = cos(a - c) - ab? i've tried everything, , wouldn't outright asking people if wasn't desperate.

i know function may seem easy i'm not @ @ all. tried (don't laugh!)

def np.cos(a, b, c):    """ given 3 variables, rearrange them create new equation >>>np.cos(d,e,f) np.sin(d - f) - e*d >>>np.cos(1,2,3) np.cos(1 - 3) - 2*3 """ if np.cos(a, b, c):     return np.cos(a - c) - b*a  

as can see, i'm not sure i'm doing. advice/tips appreciated. thank :)

you can use math.cos() determine cosine value of in function.

import math  def cos(a,b,c):     return math.cos(a-c) - a*b  print cos(1,2,3)  

two things here:

  1. although have named function cos show difference between cos , math.cos, should name function else cosofthree avoid naming conflicts.
  2. always @ indentation in python code. instructions inside function definition should indented.

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -