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

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
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
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
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
 
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
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
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
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).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
 

Recently uploaded (20)

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
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
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
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
 
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
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
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)
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).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
 

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]