Skip to content

Instantly share code, notes, and snippets.

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
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')
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")
def find_in_list(lst, v):
for i in range(len(lst)):
if lst[i] == v:
return i
break
return -1
l = [1, 2, 3, 4]
print(find_in_list(l, 3)) # 2
print(find_in_list(l, 5)) # -1
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]
cubes_by_four =[x**3 for x in range(1,11) if (x**3)%4==0]
for x in cubes_by_four:
print(x)
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:
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
import pandas as pd
import matplotlib.pyplot as plt
# Bar Graph
df= pd.read_csv("Rainfall.csv")
print(df)
df.plot.bar()
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]