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

BACHELOR OF ENGINEERING IN ARTIFICIAL INTELLIGENCE AND DATA SCIENCE | B.E. (AI-DS)

Artificial Intelligence and Data Science is an interdisciplinary branch of science, engineering and technology creating a complete ecosystem and a paradigm shift in virtually every sector of the technical industry, academics and research. Artificial Intelligence and Data Science is the future of technology which are changing the world at very high pace. The basic objectives of this course is to train students with the next age of Intelligence and analytics generated by machines, influencing nearly every facet of our lives to help improve efficiencies and augment human capabilities, influencing consumer products with significant breakthroughs in healthcare, manufacturing, finance and retail industries. With the tremendous amount of data generated every day and the computing power available, Data Science plays important role helping every business organisation in identifying business trends and changes through advanced Big Data Analytics with variety of techniques and tools to interpret...