Articles → PYTHON → Arrays In Python

Arrays In Python






What Are Arrays?





Syntax


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


  1. ‘b’ → Represents a signed integer of size 1 byte
  2. ‘B’ → Represents an unsigned integer of size 1 byte
  3. ‘c’ → Represents character of size 1 byte
  4. ‘u’ → Represents a Unicode character of size 2 bytes
  5. ‘h’ → Represents a signed integer of size 2 bytes
  6. ‘H’ → Represents an unsigned integer of size 2 bytes
  7. ‘i’ → Represents signed integer of size 2 bytes
  8. ‘I’ → Represents an unsigned integer of size 2 bytes
  9. ‘w’ → Represents a Unicode character of size 4 bytes
  10. ‘l’ → Represents a signed integer of size 4 bytes
  11. ‘L’ → Represents an unsigned integer of size 4 bytes
  12. ‘f’ → Represents a floating point of size 4 bytes
  13. ‘d’ → Represents a 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



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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250