© 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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.