© Sanjib Sinha 2017

Sanjib Sinha, Beginning Ethical Hacking with Python, 10.1007/978-1-4842-2541-7_14

14. Functions

Sanjib Sinha

(1)Howrah, West Bengal, India

Let us first define the function and try to know why function is being used in Python. Consider this code :

<code>#!/usr/bin/python3              def main():                  print("This is main function.")        if __name__ == "__main__":                  main()        </code>

And the output is:

<blockquote>This is main function.              </blockquote>

What does that mean? First of all, let us understand what function does mean. A function is used in any programming language to reuse code. Programmers are lazy and so they don't want to write again and again. And it is not a good idea to write the same thing again and again. So the concept of reusability ...

Get Beginning Ethical Hacking with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.