Articles → PYTHON → Arrays In Python

Arrays In Python






What Are Arrays?





Syntax


Array_object = array(typecode,[elements separated by comma])


  1. ‘b’ → Represents signed integer of size 1 byte
  2. ‘B’ → Represents unsigned integer of size 1 byte
  3. ‘c’ → Represents character of size 1 byte
  4. ‘u’ → Represents unicode character of size 2 bytes
  5. ‘h’ → Represents signed integer of size 2 bytes
  6. ‘H’ → Represents unsigned integer of size 2 bytes
  7. ‘i’ → Represents signed integer of size 2 bytes
  8. ‘I’ → Represents unsigned integer of size 2 bytes
  9. ‘w’ → Represents unicode character of size 4 bytes
  10. ‘l’ → Represents signed integer of size 4 bytes
  11. ‘L’ → Represents unsigned integer of size 4 bytes
  12. ‘f’ → Represents floating point of size 4 bytes
  13. ‘d’ → Represents floating point of size 8 bytes

Example


from array import *

my_array = array('i',[1,2,3,4])


for element in my_array:
    print(element)



Output


Picture showing the output of arrays in python

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Saturday, June 1, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250