Upcoming SlideShare
×

# Algorithms python arraylistmatrix

420 views

Published on

Published in: Education, Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
420
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Algorithms python arraylistmatrix

1. 1. Algorithms with Python. Array , List , Matrix .
2. 2. Hardware Array Creation :import ctypes Output :ArrayType=ctypes.py_object*4 >>>slots=ArrayType() 4slots=[4,6,9,2] 6i=0 9for i in range(3): 2 print data[i]
3. 3. Hardware Array Creation :import ctypesArrayType=ctype.py_object*5 Output :slots=ArrayType() >>>i=0 1for i in range(5): 1 slots[i]=1 1 print slots[i] 1 1
4. 4. Hardware Array Creation :import ctypes Output :ArrayType=ctypes.py_object*5 >>>data=ArrayType() 1i=0 2for i in range(5): 3 data[i]=i+1 4 print data[i] 5
5. 5. Hardware Array Creation :import ctypes Output :def arr(n): >>>arr(3) ArrayType=ctypes.py_object*n 1 data=ArrayType() 3 i=0 5 for i in range(n): data[i]=2*i+1 print data[i]
6. 6. import ctypes Output :def add(n): >>>add ArrayType=ctypes.py_object*n (3) data=ArrayType() None i=0 4 for i in range(n): None data[i]=None data[1]=4 for i in range(n): print data[i]
7. 7. Hardware Array Addion :import ctypes Output:ArrayType=ctypes.py_object*3 >>>data=ArrayType() 4data[0]=4 2data[1]=2 9data[2]=9i=0for i in range(3): print data[i]
8. 8. Hardware Array Deletion :import ctypes Array_creation:ArrayType=ctypes.py_object*3 1data=ArrayType() 2i=0 3print ("Array_creation :")for i in range(3): data[i]=i+1 print data[i]
9. 9. Hardware Array Deletion :print ("Array_elemdeletion :") Array_edeletion:data[1]=None 1for i in range(3): None print data[i] 3print ("Array_deletion :") Array_deletion :for i in range(3): data[i]=None print data[i]
10. 10. Hardware Array Set _Item :import ctypesdef setitem(n,index,value): Output : ArrayType=ctypes.py_object*n <<<setitem(3,1,1) data=ArrayType() None i=0 1 for i in range(n): None data[i]=None for i in range(n): data[index]=value print data[i]
11. 11. Hardware Array Get Item :import ctypes:def getitem(n,index): >>>getitem(3,1) ArrayType=ctypes.py_object*n data=ArrayType() 2 i=0 for i in range(n): data[i]=i+1 return data[index]
12. 12. Array In itialize, H ardware et item : Ad dition, get item, Simport ctypes Output :def ini_add__seti(n,index,value): <<<ini_add_set ArrayType=ctypes.py_object*n i(3,1,10) data=ArrayType() None i=0 None for i in range(n):#1 None data[i]=None print data[i]
13. 13. e Array I nitialize,H ardwar t item :Add ition, ge t item, Se print ("data = ") data = for i in range(n):#2 1 data[i]=2*i+1 3 print data[i] 5 print ("data = ") data = print data[index]#3 1 for i in range(n):#4 10 data[index]=value 5 print data[i]
14. 14. List : Creation , Appending .>>># list creation:>>>data=[1,2,3,4]>>>data>>>[1,2,3,4]>>># list appending (add at last index)>>>data.append(10)>>>data>>>[1,2,3,4,10]
15. 15. List : Extending .>>>A=[1,2,3,4]>>>B=[5,6,7,8]>>>A.extend(B)>>>A>>>[1,2,3,4,5,6,7,8]
16. 16. List : Insertion .>>>data=[1,2,3,4]>>>data>>>[1,2,3,4]>>># list insertion (add value at certain index)>>>data.insert(0,10)>>>data>>>[10,1,2,3,4]
17. 17. List : Deleting .>>>data=[1,2,3,4]>>>data>>>[1,2,3,4]>>>#list deletion:(delete value from certain index )>>>data.pop(1)>>>data>>>[1,3,4]
18. 18. List : Deletion .>>>data=[1,2,3,4]>>>data>>>[1,2,3,4]>>>#list:delete value from last index)>>>data.pop()>>>data>>>[1,2,3]
19. 19. List : Slices .>>>data=[2,4,6,8,10,12]>>>aSlice=data[0:2]>>>data>>>[2,4,6,8,10,12]>>>aSlice>>>[2,4]>>>aSlice=data[2:5]>>>aSlice>>>[6,8,10]