Why Use Function?

Lesson Progress
0% Complete
  • However, we can write codes each time for same operation(eg. addition).
  • But, it is more feasible for us to save operation(eg. addition) inside a function and call it n number of times(code re-usability)
  • So, we pass the data(numbers) as parameter(s) to the function.
  • Now, we can use those parameters inside our function to perform operations.(eg. addition)
  • And, now we can either print the result inside the function or
  • Return the result back from where it is being called.
# basic addition
int_x, int_y = 10, 20
print(f'Addition Result of {int_x} & {int_y} = {int_x + int_y}')

Creating/Calling Functions in Python