This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def enqueue(queue,x): | |
queue.append(x) | |
def dequeue(queue): | |
global front #using global variable to modify front | |
t=queue[front] | |
front +=1 #Front is incremented, thus there is no shifting | |
return t | |
l=[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cubes_by_four =[x**3 for x in range(1,11) if (x**3)%4==0] | |
for x in cubes_by_four: | |
print(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import matplotlib.pyplot as plt | |
# Bar Graph | |
df= pd.read_csv("Rainfall.csv") | |
print(df) | |
df.plot.bar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |