<jupyter_start><jupyter_text><NAME> 1806554 Python Assignment 6   Graph Theory<jupyter_code>from collections import defaultdict
g = defaultdict(list)
edges = []

def addEdge(g,u,v):
    g[u].append(v)
    g[v].append(u)

def createGraph(g):
    for node in g:
        for neighbour in g[node]:
            edges.append((node,neighbour))

def printGraph():
    for j in g:
        print(j," -> ",end = "")
        for i in g[j]:
            print(i,", ",end = '')
        print()

addEdge(g,'a','c') 
addEdge(g,'b','d') 
addEdge(g,'b','e')  
addEdge(g,'a','d')
printGraph()
from collections import defaultdict
g = defaultdict(list)
edges = []

def addEdge(g,u,v,w):
    g[u].append(tuple({v,w}))

def createGraph(g):
    for node in g:
        for neighbour in g[node]:
            edges.append((node,neighbour))
    return g

def printGraph():
    for j in g:
        print(j," -> ",end = "")
        for i in g[j]:
            print(i,", ",end = '')
        print()
addEdge(g,'a','c',4) 
addEdge(g,'b','c',3) 
addEdge(g,'b','e',2) 
addEdge(g,'c','d',7) 
addEdge(g,'c','e',1) 
addEdge(g,'c','a',11)
printGraph()
#createGraph(g)<jupyter_output>a  -> ('c', 4) , 
b  -> ('c', 3) , ('e', 2) , 
c  -> ('d', 7) , ('e', 1) , ('a', 11) ,<jupyter_text>Class and Data Structure<jupyter_code>class Student: 
    def __init__(self, name, rollno, cgpa): 
        self.name = name 
        self.rollno = rollno 
        self.cgpa = cgpa    
    def readdata(self, Name, Rollno, cgpa ):  
        ob = Student(Name, Rollno, cgpa ) 
        ls.append(ob)        
    def printdata(self, ob): 
            print("Name   : ", ob.name) 
            print("RollNo : ", ob.rollno) 
            print("CGPA : ", ob.cgpa)  
            print("\n")      
ls =[] 
stud = Student('', 0, 0) 
n = int(input())
for i in range(0,n):
    name = input("enter name")
    roll = int(input("enter roll"))
    cgpa = int(input("enter cgpa"))
    stud.readdata(name, roll, cgpa) 
print("\n") 
print("\nList of Students\n") 
for i in range(ls.__len__()):     
    stud.printdata(ls[i])
class Person():
    def __init__(self, name, age, gender): 
        self.name = name 
        self.age = age 
        self.gender = gender 
#     def readdata(self, name, age, gender ):  
#         ob = Person( name, age, gender ) 
#         person.append(ob) 
    def tell(self):
        print('Name : ', self.name,"\nAge : ",self.age, '\nGender : ',self.gender)
        print('Empid :',self.empid,"\nDesignation :",self.desi,"\nSalary :",self.salary)
#     def printdata(self, ob): 
#             print(ob.name) 
#             print(ob.age) 
#             print(ob.gender)  
#             print("\n")
class Employee(Person):
    def __init__(self,name,age,gender, empid, desi, salary): 
        Person.__init__(self, name, age, gender)
        self.empid = empid 
        self.desi = desi 
        self.salary = salary
        Person.tell(self)
#     def readdata(self, name, age, gender ):  
#         ob = Employee(name, age, gender , empid, desi, salary) 
#         employ.append(ob)
Employee('Rahul', 20, 'male',345,"intern", 200000)

class Stack():
    def __init__(self):
        self.stack = []
    def isEmpty(self):
        return self.stack == []
    def PUSH(self,x):
        self.stack.append(x)
    def POP(self):
        return self.stack.pop()
    def printStack(self):
        return self.stack
s = Stack()

while True:
    print('push ')
    print('pop')
    print('quit')
    do = input('What would you like to do? ').split() 
    operation = do[0].strip().lower()
    if operation == 'push':
        s.PUSH(int(do[1]))
    elif operation == 'pop':
        if s.isEmpty():
            print('Stack is empty.')
        else:
            print('Popped value: ', s.POP())
    elif operation == 'quit':
        break
    print(s.printStack(),end = "")
    print()
class Queue():
    def __init__(self):
        self.queue = []
    def isEmpty(self):
        return self.queue == []
    def INSERT(self,x):
        self.queue.append(x)
    def REMOVE(self):
        return self.queue.pop(0)
    def printQueue(self):
        return self.queue
s = Queue()

while True:
    print('push enter value')
    print('pop')
    print('quit')
    do = input('What would you like to do? ').split() 
    operation = do[0].strip().lower()
    if operation == 'push':
        s.INSERT(int(do[1]))
    elif operation == 'pop':
        if s.isEmpty():
            print('Stack is empty.')
        else:
            print('Popped value: ', s.REMOVE())
    elif operation == 'quit':
        break
    print(s.printQueue(),end = "")
    print()<jupyter_output>push enter value
pop
quit
{'fraction_non_alphanumeric': 0.17455173903650897, 'fraction_numerical': 0.008857204579822855, 'mean_word_length': 2.307142857142857, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '13114', 'license': 'MIT', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1608, 'n_words': 377, 'path': 'T&T/python scripts/6_assignment.ipynb', 'repo_name': 'ganeshbhandarkar/College-Labs-And-Projects', 'size': '4640'}