Skip to content

Instantly share code, notes, and snippets.

View Chap10Q6.py
def enqueue(queue,x):
queue.append(x)
def dequeue_f(queue):
return queue.pop(0) #dequeues element present at front end
def dequeue_r(queue):
return queue.pop() #dequeues element present at rear end
l=[]
front =0
View Chap10Q7.py
def push(stack, pin_code, city_name):
stack.append({'pin':pin_code, 'city':city_name})
pass
def pop(stack):
return stack.pop()
l=[]
push(l,842001, 'Muz')
push(l,110078, 'Delhi')
push(l, 820067,'Patna')
View Chap10Q8.py
def enqueue(queue,x):
queue.append(x)
def search(a,b,c,x):
if x in a:
print(x,"is in HighestPr Queue")
elif x in b:
print(x,"is in NormalPr Queue")
elif x in c:
print(x,"is in LowestPr Queue")
View Chap9Q2.py
def unique(L):
return len(set(L))
L=[]
print(unique(L))
L=[1,3,3,4,4,8]
print(unique(L))
L=[1,2,2]
print(unique(L))
L=[33,33,33]
View Chap9Q3.py
cubes_by_four =[x**3 for x in range(1,11) if (x**3)%4==0]
for x in cubes_by_four:
print(x)
View Chap9Q4.py
a=[1,1,2,3,4,5,8,13,21,34,55,89]
b=[1,2,3,4,5,6,7,8,9,10,11,12,13]
def common_elements(a,b):
a_set=set(a)
b_set=set(b)
if (a_set & b_set):
print(a_set & b_set)
else:
View Chap9Q5.py
V = [[2, 6], [3, 10], [15], [23], [1, 8, 15, 22, 29], [14]]
def Mvisit(l):
c = 0 #Counter
hv = None # the visits
for i in V:
if len(i) > c: # compares numbers of visits
c = len(i)
hv = i
View Chap8Q1a.py
import pandas as pd
import matplotlib.pyplot as plt
# Bar Graph
df= pd.read_csv("Rainfall.csv")
print(df)
df.plot.bar()
View Chap8Q2a.py
import pandas as pd
import matplotlib.pyplot as plt
df= pd.read_csv("/App.csv")
print(df)
x=[75,120,190,245,550,55,175,75,140]
View Chap8Q2b.py
import pandas as pd
import matplotlib.pyplot as plt
fig=plt.figure()
ax=fig.add_axes([0,0,1,1])
apps=['AngryBird','TeenTitan','MarvelComics',
'ColorMe','FunRun','CrazyTaxi','IgramPro',