How to take input from user ?
We have to use input function.
variable = input(“Enter Value >”)
How to take arguments from terminal ?
How to Execute Linux System Command ?
How to handel regular expressions ?
How many ways to present list with index value?
By Three Ways we can achieve this.
1. Using enumerate function
2. Using Zi[p Function
3. Usinge range functionFor Code See Juypter Lab - Python Exercise for Practice
How to use subprocess Module.
import subprocess
subprocess.call(“ifconfig”,interface,”hw”,”ether”)
How to capture output of subprocess.
ifconfig_output = subprocess.check_output(“ifconfig”, interface,)
How many types to use subprocess module.
subprocess. call(“ifconfig eth0 down “,shell=True)
subprocess. call(“ifconfig “+ interface + “ down”,shell=True)
subprocess. call(“ifconfig”,”eth0”)
subprocess. call(“ifconfig”, interface)
Which Function is used with subprocess to execute system command.
subprocess.call()
Which Function is used with subprocess to read output of system command.
subprocess.check_output
Which class is used to create optparse object?
optparse.OptionParser()
Which function is used with optparse object to teach object ?
parser.add_options(“-i”, “–interface”, dest = “interface”,help=”Ethernet Interface”)
Which function is used with optparse object to process arguments ?
parser.parse_args()
interface,arguments)=parse.parse_args(
Which function is used with optparse object to handle error ?
parser.error()
Which function is used with optparse object to get arguments ?
parser.parse_args()
How to handel error in optparse ?
if not interface:
parser.error(“[-] Plz Specify interface or –help for more info”)
How to generate number by random module
import random
number = random.randint(startRange,endRange)
How to get a square root of a number
import math
sqrt = math.sqrt(number)
How to get present working directory
os module
print(os.getcwd())
How to import how to import PDF file
PyPDF2