Latest
Loading...

Python for Ethical Hacking

Command Prompt

Featured Post

#5 Jarvis

Jarvis      Now we are going to create some functions. With the help of this functions we are going to make our Play music Open website...

#2 Use Sub Process Module || MAC Changer || Python for Ethical Hacking

#2 Use Sub Process Module || MAC Changer || Python for Ethical Hacking

Python for Hacking

MAC Changer

2nd Lesson




1.Module

                                 A module is a file that contains a collection of Python code (or) related function. It allows us to logically arrange related code easier to understand and use. It defines functions, classes and variables. Python have lot of modules as pre-built and able to download after installing python. An import statement is used to import Python module in some Python source file.

Syntax

  • import module_name
  • module_name.function_name(parameters)

2. Function

                                 A function is a group of statements that perform a specific task. Each subprogram specifies one or more actions to be performed for the larger program. Such subprograms are called as function

Types:

  • Pre-defined (or) Built-in.
  • User defined

Build-in or predefined functions:

                                Built in functions are functions already built into python interpreter and are readily available for use.

Example:

  • print()           #Print objects to the stream 

User defined function:

                                The function defined by the users according to their requirements are called user-defined functions. The user can modify the function according to their requirements.

Syntax:

                def function_name(parameters):
            "function_docstring"
            function_suite
            return[expression]


                                A function can be executed by calling it from another function or directly from the python prompt by its name

Syntax

                  function_name(parameters)

3. Subprocess

                                  In MAC Changer we use subprocess module. Read the documentation of this module to learn more about the module. We use call function in this function 

Syntax

  • import subprocess
  • subprocess.call("Cammand" , shell=True)
This function is used to execute system commands in python. It depends on the OS of the system.






No comments:

Post a Comment