Kubernetes Classroom Series – 21/Sept/2021

Functions

  • 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>):
        pass
    
    • example:
    def add(a, b):
        return a + b
    
    print(add(1,2))
    
    • 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 ReplyCancel reply

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

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%