Python program for reading an excel file

import xlrd
loc=("your own excel path with double slash at drive name like C:\\")
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
print ("The value of Row 0 and Column 0 is", sheet.cell_value(0, 0))
print("No of Rows in the current sheet is",sheet.nrows)
print("No of Columns in the current sheet is",sheet.ncols)
print("Extracting all columns name in the current sheet")
for i in range(sheet.ncols):
    print(sheet.cell_value(0, i))
print("Extracting first column in the current sheet")
for i in range(sheet.nrows):
    print(sheet.cell_value(i, 0))
print("Extracting rowwise content in the current sheet")
for i in range(sheet.nrows):
    print(sheet.row_values(i))

Python programt for finding ports opened in the website domain


import socket;
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('www.example.com', port number))
if result == 0:
   print ("Port is open")
else:
   print ("Port is not open")

Python program to print Hostname, IP, MAC address

import uuid
import socket  
hostname = socket.gethostname()  
IPAddr = socket.gethostbyname(hostname)  
print("The Name of this device is:        " + hostname)  
print("The IP Address of this device is:  " + IPAddr)  
print ("The MAC address of this device is:",hex(uuid.getnode()))

Python programto find Sine and Cosine Values plot using Matplotlib

import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,1)
data1 = np.sin(x)
data2 = np.cos(x)
fig, ax1 = plt.subplots()
color = 'tab:red'
ax1.set_xlabel('x')
ax1.set_ylabel('sine', color=color)
ax1.plot(x, data1, color=color)
ax1.tick_params(axis='y', labelcolor=color)
ax2 = ax1.twinx()
color = 'tab:green'
ax2.set_ylabel('cosine', color=color)
ax2.plot(x, data2, color=color)
ax2.tick_params(axis='y', labelcolor=color)
plt.show()




#Simple Implementation
#---------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-np.pi, np.pi, 256, endpoint=True)
c= np.cos(x)
s= np.sin(x)
plt.plot(x,c)
plt.plot(x,s)
plt.show()