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:
Syntax:
A function can be executed by calling it from another function or directly from the python prompt by its name
Syntax
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)

No comments:
Post a Comment