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

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Recently uploaded (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

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]