SlideShare a Scribd company logo
1 of 19
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

What's hot

งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1EveEim Elf
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Dr. Volkan OBAN
 
Deletion of an element at a given particular position
Deletion of an  element  at a given particular positionDeletion of an  element  at a given particular position
Deletion of an element at a given particular positionKavya Shree
 
งานนำเสนอคอม
งานนำเสนอคอมงานนำเสนอคอม
งานนำเสนอคอมEveEim Elf
 
Core Java Programming Language (JSE) : Chapter V - Arrays
Core Java Programming Language (JSE) : Chapter V - ArraysCore Java Programming Language (JSE) : Chapter V - Arrays
Core Java Programming Language (JSE) : Chapter V - ArraysWebStackAcademy
 
Data Structure and Algorithms Stacks
Data Structure and Algorithms StacksData Structure and Algorithms Stacks
Data Structure and Algorithms StacksManishPrajapati78
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your networkPushpendra Tiwari
 
Scientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanScientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanWei-Yuan Chang
 
Data Structure and Algorithms Queues
Data Structure and Algorithms QueuesData Structure and Algorithms Queues
Data Structure and Algorithms QueuesManishPrajapati78
 
Frequency count of the Element in an array
Frequency count of the Element in an arrayFrequency count of the Element in an array
Frequency count of the Element in an arrayKavya Shree
 
Scikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-PythonScikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-PythonDr. Volkan OBAN
 
Pandas,scipy,numpy cheatsheet
Pandas,scipy,numpy cheatsheetPandas,scipy,numpy cheatsheet
Pandas,scipy,numpy cheatsheetDr. Volkan OBAN
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvasdeanhudson
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesAndrew Ferlitsch
 
Python For Data Science Cheat Sheet
Python For Data Science Cheat SheetPython For Data Science Cheat Sheet
Python For Data Science Cheat SheetKarlijn Willems
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)PyData
 

What's hot (20)

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

Similar to Algorithms python arraylistmatrix

Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfarishmarketing21
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfeyewatchsystems
 
Arrays in python
Arrays in pythonArrays in python
Arrays in pythonmoazamali28
 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docxdavinci54
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab filesNitesh Dubey
 
Chapter 7.3
Chapter 7.3Chapter 7.3
Chapter 7.3sotlsoc
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3Abdul Haseeb
 
ARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptxARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptxDarellMuchoko
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
 
Python_cheatsheet_numpy.pdf
Python_cheatsheet_numpy.pdfPython_cheatsheet_numpy.pdf
Python_cheatsheet_numpy.pdfAnonymousUser67
 
Numpy python cheat_sheet
Numpy python cheat_sheetNumpy python cheat_sheet
Numpy python cheat_sheetZahid Hasan
 
Aj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructuresAj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructuresArthik Daniel
 

Similar to Algorithms python arraylistmatrix (20)

Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdf
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docx
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
Chapter 7.3
Chapter 7.3Chapter 7.3
Chapter 7.3
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
ARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptxARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptx
 
Ada file
Ada fileAda file
Ada file
 
C programs
C programsC programs
C programs
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
Python_cheatsheet_numpy.pdf
Python_cheatsheet_numpy.pdfPython_cheatsheet_numpy.pdf
Python_cheatsheet_numpy.pdf
 
Numpy python cheat_sheet
Numpy python cheat_sheetNumpy python cheat_sheet
Numpy python cheat_sheet
 
Aj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructuresAj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructures
 
Exp 5-1 d-422
Exp 5-1  d-422Exp 5-1  d-422
Exp 5-1 d-422
 
Pnno
PnnoPnno
Pnno
 
SlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfSlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdf
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
 

More from Faculty of Science , portsaid Univeristy (8)

Library Management System
Library Management SystemLibrary Management System
Library Management System
 
compiler vs interpreter
compiler vs interpretercompiler vs interpreter
compiler vs interpreter
 
الحسن بن الهيثم
الحسن بن الهيثمالحسن بن الهيثم
الحسن بن الهيثم
 
الحسن بن الهيثم
الحسن بن الهيثمالحسن بن الهيثم
الحسن بن الهيثم
 
Html course
Html courseHtml course
Html course
 
Teach yourself html_ar
Teach yourself html_arTeach yourself html_ar
Teach yourself html_ar
 
GUI
GUI GUI
GUI
 
Algorithms.
Algorithms. Algorithms.
Algorithms.
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

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]