Skip to main content

Computer networks lab 5 subnetting code

 def findClass(ip):

    if (ip[0]>=0 and ip[0]<=126):

        return "A"

    elif(ip[0]>=128 and ip[0]<=191):

        return "B"

    elif(ip[0]>=192 and ip[0]<=223):

        return "C"

    elif(ip[0]>=224 and ip[0]<=239):

        return "D"

    else:

        return "E"

       

def separate (ip, className):

    if (className=="A"):

        print("Network address is : " , ip[0])

        print("Host address is : ",".".join(ip[1:4]))

       

    elif(className=="B"):

        print("Network address is : ",".".join(ip[0:2]))

        print("Host address is : ",".".join(ip[2:4]))

       

    elif(className=="C"):

        print("network address is :" ,".".join(ip[1:3]))

        print("Host address is :" ,ip[3])

       

    else :

        print("This ip cannot be divided in network and host id")

       

if __name__=="__main__":

    ip=input("enter address :")

    ip=ip.split(".")

    ip=[int(i) for i in ip]

    networkClass=findClass(ip)

    print("the given address belongs to :" ,networkClass)

   

ip=[str(i) for i in ip]

separate(ip,networkClass)

    


Comments

Popular posts from this blog

FIRST YEAR SPPU NOTES

FIRST YEAR SPPU NOTES  ENGINEERING MECHANICS : Unit 1 -  OPEN PDF Unit 2 -  OPEN PDF Unit 3 -  OPEN PDF Unit 4 -  OPEN PDF ENGINEERING GRAPHICS : Unit 1 -  OPEN PDF Unit 2 -  OPEN PDF Unit 3 -  OPEN PDF Unit 4 -  OPEN PDF ENGINEERING MATHEMATICS - 2 : NIRALI PRAKASHAN UNIT 1 TO 4 -  OPEN  PDF ENGINEERING PHYSICS :                                  COMING SOON BASIC ELECTRONICS ENGINEERING :                                  COMING SOON

GEOGRAPHY PRACTICAL VIVA VOICE QUESTIONS

World Geography General Knowledge Questions Q.1 The highest place on the Earth             Ans .  Everest Q.2 The circles which vertically cross the equator             Ans .  Longitudes  Q.3 What is the total weight of the air in the atmosphere?             Ans .  6×10 Tones  Q.4 International space line passes through?             Ans .  180 Greenwich  Q.5 What are the different kinds of rocks found on the Earth? .             Ans .  Igneous rocks, Sedimentary rocks, Metamorphic rocks  Q.6 The metal which form the core of Earth:             Ans .  Iron and Nickel  Q.7 The innermost part of the Earth: . ...

CHEMISTRY IMPORTANT QUESTION 2020 HSC

CHEMISTRY IMPORTANT QUESTION 2020 HSC PLZ DO IT. PART - 1 PART - 2