SlideShare a Scribd company logo
Algorithms with Python.
      Array , List , Matrix .
Hardware Array Creation :
import ctypes                  Output :
ArrayType=ctypes.py_object*4   >>>
slots=ArrayType()              4
slots=[4,6,9,2]                6
i=0                            9
for i in range(3):             2
   print data[i]
Hardware Array Creation :
import ctypes
ArrayType=ctype.py_object*5   Output :
slots=ArrayType()             >>>
i=0                           1
for i in range(5):            1
  slots[i]=1                  1
  print slots[i]              1
                              1
Hardware Array Creation :
import ctypes                  Output :
ArrayType=ctypes.py_object*5   >>>
data=ArrayType()               1
i=0                            2
for i in range(5):             3
  data[i]=i+1                  4
  print data[i]                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]
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]
Hardware Array Addion :
import ctypes                  Output:
ArrayType=ctypes.py_object*3   >>>
data=ArrayType()               4
data[0]=4                      2
data[1]=2                      9
data[2]=9
i=0
for i in range(3):
  print data[i]
Hardware Array Deletion :
import ctypes                  Array_creation:
ArrayType=ctypes.py_object*3   1
data=ArrayType()               2
i=0                            3
print ("Array_creation :")
for i in range(3):
  data[i]=i+1
  print data[i]
Hardware Array Deletion :
print ("Array_elemdeletion :")   Array_edeletion:
data[1]=None                     1
for i in range(3):               None
  print data[i]                  3
print ("Array_deletion :")       Array_deletion :
for i in range(3):
  data[i]=None
  print data[i]
Hardware Array Set _Item :
import ctypes
def 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]
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]
Array In itialize,
      H ardware              et item :
      Ad dition, get item, S
import 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]
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]
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]
List : Extending .
>>>A=[1,2,3,4]
>>>B=[5,6,7,8]
>>>A.extend(B)
>>>A
>>>[1,2,3,4,5,6,7,8]
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]
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]
List : Deletion .
>>>data=[1,2,3,4]
>>>data
>>>[1,2,3,4]
>>>#list:delete value from last index)
>>>data.pop()
>>>data
>>>[1,2,3]
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]

More Related Content

PDF
Basic data structures in python
PDF
PDF
Arrays in python
PPTX
Python array
PDF
Cheat Sheet for Machine Learning in Python: Scikit-learn
PPTX
Arrays in Data
PDF
Pandas Cheat Sheet
PDF
Basic data structures in python
Arrays in python
Python array
Cheat Sheet for Machine Learning in Python: Scikit-learn
Arrays in Data
Pandas Cheat Sheet

What's hot (20)

PPTX
งานนำเสนอ1
PDF
Python Pandas for Data Science cheatsheet
PPTX
Deletion of an element at a given particular position
PPTX
งานนำเสนอคอม
PDF
Core Java Programming Language (JSE) : Chapter V - Arrays
PPT
Data Structure and Algorithms Stacks
PPTX
IGraph a tool to analyze your network
PDF
Python programming : Arrays
PDF
Scientific Computing with Python - NumPy | WeiYuan
PPT
Data Structure and Algorithms Queues
PDF
1D Array
PPTX
Frequency count of the Element in an array
PDF
Scikit-learn Cheatsheet-Python
PDF
Pandas,scipy,numpy cheatsheet
KEY
Pointer Events in Canvas
PPTX
Python - Numpy/Pandas/Matplot Machine Learning Libraries
PDF
Python For Data Science Cheat Sheet
PDF
Numpy python cheat_sheet
PPTX
PDF
Introduction to NumPy (PyData SV 2013)
งานนำเสนอ1
Python Pandas for Data Science cheatsheet
Deletion of an element at a given particular position
งานนำเสนอคอม
Core Java Programming Language (JSE) : Chapter V - Arrays
Data Structure and Algorithms Stacks
IGraph a tool to analyze your network
Python programming : Arrays
Scientific Computing with Python - NumPy | WeiYuan
Data Structure and Algorithms Queues
1D Array
Frequency count of the Element in an array
Scikit-learn Cheatsheet-Python
Pandas,scipy,numpy cheatsheet
Pointer Events in Canvas
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python For Data Science Cheat Sheet
Numpy python cheat_sheet
Introduction to NumPy (PyData SV 2013)
Ad

Similar to Algorithms python arraylistmatrix (20)

PPTX
Unit 1 array based implementation
PPTX
第二讲 预备-Python基礎
PPTX
第二讲 Python基礎
PDF
Python Usage (5-minute-summary)
PPTX
Python 101++: Let's Get Down to Business!
PDF
Intro to Python
PDF
Python Cheat Sheet
PDF
PPT
ComandosDePython_ComponentesBasicosImpl.ppt
PDF
Unit-5-Part1 Array in Python programming.pdf
PPT
Array ajjh jhjhj jhjhj jhjhjh jhj jhjhjh
PPTX
ARRAY OPERATIONS.pptx
PPTX
object oriented programing in python and pip
PDF
Datatypes in python
PDF
python_lab_manual_final (1).pdf
PPTX
Introduction To Programming with Python-4
PPT
Python crash course libraries numpy-1, panda.ppt
PDF
Class 5: If, while & lists
PDF
Numpy
Unit 1 array based implementation
第二讲 预备-Python基礎
第二讲 Python基礎
Python Usage (5-minute-summary)
Python 101++: Let's Get Down to Business!
Intro to Python
Python Cheat Sheet
ComandosDePython_ComponentesBasicosImpl.ppt
Unit-5-Part1 Array in Python programming.pdf
Array ajjh jhjhj jhjhj jhjhjh jhj jhjhjh
ARRAY OPERATIONS.pptx
object oriented programing in python and pip
Datatypes in python
python_lab_manual_final (1).pdf
Introduction To Programming with Python-4
Python crash course libraries numpy-1, panda.ppt
Class 5: If, while & lists
Numpy
Ad

Recently uploaded (20)

PDF
Computing-Curriculum for Schools in Ghana
PDF
RMMM.pdf make it easy to upload and study
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Introduction to Building Materials
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
advance database management system book.pdf
PDF
Hazard Identification & Risk Assessment .pdf
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Computing-Curriculum for Schools in Ghana
RMMM.pdf make it easy to upload and study
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
LDMMIA Reiki Yoga Finals Review Spring Summer
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Chinmaya Tiranga quiz Grand Finale.pdf
Weekly quiz Compilation Jan -July 25.pdf
Supply Chain Operations Speaking Notes -ICLT Program
A systematic review of self-coping strategies used by university students to ...
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Introduction to Building Materials
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
History, Philosophy and sociology of education (1).pptx
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
advance database management system book.pdf
Hazard Identification & Risk Assessment .pdf
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Practical Manual AGRO-233 Principles and Practices of Natural Farming

Algorithms python arraylistmatrix

  • 1. Algorithms with Python. Array , List , Matrix .
  • 2. Hardware Array Creation : import ctypes Output : ArrayType=ctypes.py_object*4 >>> slots=ArrayType() 4 slots=[4,6,9,2] 6 i=0 9 for i in range(3): 2 print data[i]
  • 3. Hardware Array Creation : import ctypes ArrayType=ctype.py_object*5 Output : slots=ArrayType() >>> i=0 1 for i in range(5): 1 slots[i]=1 1 print slots[i] 1 1
  • 4. Hardware Array Creation : import ctypes Output : ArrayType=ctypes.py_object*5 >>> data=ArrayType() 1 i=0 2 for i in range(5): 3 data[i]=i+1 4 print data[i] 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. 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. Hardware Array Addion : import ctypes Output: ArrayType=ctypes.py_object*3 >>> data=ArrayType() 4 data[0]=4 2 data[1]=2 9 data[2]=9 i=0 for i in range(3): print data[i]
  • 8. Hardware Array Deletion : import ctypes Array_creation: ArrayType=ctypes.py_object*3 1 data=ArrayType() 2 i=0 3 print ("Array_creation :") for i in range(3): data[i]=i+1 print data[i]
  • 9. Hardware Array Deletion : print ("Array_elemdeletion :") Array_edeletion: data[1]=None 1 for i in range(3): None print data[i] 3 print ("Array_deletion :") Array_deletion : for i in range(3): data[i]=None print data[i]
  • 10. Hardware Array Set _Item : import ctypes def 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. 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. Array In itialize, H ardware et item : Ad dition, get item, S import 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. 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. 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. 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. 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. 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. 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. 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]