Showing posts with label Network. Show all posts
Showing posts with label Network. Show all posts

Test Internet Speed using Python program

import speedtest  

st = speedtest.Speedtest()

option = int(input('''What speed do you want to test in Megabits:  

1) Download Speed  

2) Upload Speed  

Your Choice: '''))

if option == 1:   

    print(st.download())    

elif option == 2:   

    print(st.upload())  

else:  

    print("Please enter the correct choice !")

Python program to shutdown and restart computer

import os;
check = input("Want to shutdown your computer ? (y/n): ");
if check == 'n':
    check = input("Want to restart your computer ? (y/n): ");
    if check == 'y':
        os.system("shutdown /r /t 1");
    else:
        exit();
else:
    os.system("shutdown /s /t 1");

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()))