Category Archives: Python

Implement a List in Python

”’ Created on Jul 6, 2018 @author: asharda ”’ class Node: def __init__(self,init_data): self.data=init_data self.next=None def get_data(self): return self.data temp=Node(1) temp.next=Node(2) temp.next.next=Node(3) while temp!=None: print(temp.data) temp=temp.next Advertisements

Posted in Python, Uncategorized | Leave a comment

Linear Search using Python

”’ Created on Jun 18, 2018 Linear Search in Python @author: asharda ”’ def linear(arr,num): for i in arr: if(i==num): return True return False arr=[10,7,12,5] print(linear(arr, 8))

Posted in Data Structures, Python, Uncategorized | Leave a comment

Using Index DataFrame Python

#Using Dataframes import numpy as np import pandas as pd data=[1,2,3,4,5] data=pd.DataFrame(data,index=[‘range’,’range1′,’range2′,’range3′,’range4′]) print(data)

Posted in Python, Uncategorized | Leave a comment

Using Series Pandas

import numpy as np import pandas as pda data=np.array([1,2,3,4]) p=pda.Series(data) print(p)

Posted in Python, Uncategorized | Leave a comment

Using Series in Python

import numpy as np import pandas from pandas import Series,DataFrame obj=Series([3,6,9,12]) print(obj) obj=Series([3,6,9,12],index=[0,1,2,3]) print(obj[1])

Posted in Python, Uncategorized | Leave a comment

Using Classes Python

class Employee: empcount=0; def __init__(self,name,salary,id=780): self.name=name self.salary=salary self.id=id def display(self): print(“Employee name is “,self.name,”Employee salary is “,self.salary,”Id seen is “,self.id) e=Employee(“Ashish”,200) e.display()

Posted in Python, Uncategorized | Leave a comment

Using Dictionary

dict={‘Name’:’Ashish’,’Age’:25} print(dict[‘Name’]) print(‘Age is ‘,dict[‘Age’]) print(len(dict)) dict.clear() #Delete dictionary del dict #print(dict.name)

Posted in Python, Uncategorized | Leave a comment