Python Essentials Classroom Series – 21/Sept/2021


  • The first step to code reuse is the function.
  • A function is a block of code that can take any number of input parameters and return any number or type of output results
  • Define a function with def
    • syntax:
    def <function>(<parameters>):
    • example:
    def add(a, b):
        return a + b
    • In the function return keyword returns the evaluated result to the caller and it is not necessary that every function needs to have return. The function without return value return None
    • Lets quickly write a program which has some functions
    • Refer Here for the program which has function is_prime and its usage in the same python file (module)
  • Lets try to create reusable functions for calculating
    • simple interest
    • compound interest
    • Refer Here for the solution

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin