Function

Course Name: Python for Machine Learning in Finance, Section No: 4, Unit No: 7, Unit type: Exercise

 multiplication = multiply_two_numbers(10,7) why you don't put def after =  ? or before mutiply  ?

       print(multiplication)

Hi Nirinasoa,



In python, there is a certain way to create a function. This way of creating a function, commonly referred as syntax, requires using 'def' (an abbreviation for define) before the name of the function. After you create the function, to execute the calculations you put into, you need to call the function and calling a function is nothing more than just typing its name. That's why we didn't use 'def' because we are calling the function there in order to perform the calculations this function includes.



In brief, 'def' is put only during function creation and in order to reach out the algorithm this function includes, using the name of the funcition is all you need. If you would like to get more detail on python functions, you can also review this blog.



Hope this helps.