0

I am not able to understand what is function and how it works,and things related to it

Plz help me in understanding this concept

14th Jul 2020, 3:35 PM
Aditya kumar Singh
Aditya kumar Singh - avatar
1 Odpowiedź
+ 1
Basically function is a code block which is called and given value as a arguments and the function returns the value after performing task on the given values for example. 1). def fun_name(a,b): 2). Add = a+b 3). return Add 4). fun_val = fun_name(4,5) 5). print(fun_val) Explanation:— In line one we declare a function with keyword def and kept a name for the function ie fun_name which takes 2 arguments which will be stored in variable "a" and "b" In second line a variable Add will store a value after adding "a" and "b" In third line function returns the added value back In fourth line we called the function after passing value and the return value will finally stored in variable fun_val And finally we printed the value which is 9 So this Is how a function basic structure goes over here
14th Jul 2020, 4:04 PM
Ayush Kumar
Ayush Kumar - avatar