Articles → PYTHON → Arrays In Python
Arrays In Python
What Are Arrays?
Syntax
Array_object = array([type code],[elements separated by comma])
Type Codes
Type Code | Description |
---|
‘b’ | Represents a signed integer of size 1 byte |
‘B’ | Represents an unsigned integer of size 1 byte |
‘c’ | Represents a character of size 1 byte |
‘u’ | Represents a Unicode character of size 2 bytes |
‘h’ | Represents a signed integer of size 2 bytes |
‘H’ | Represents an unsigned integer of size 2 bytes |
‘i’ | Represents signed integer of size 2 bytes |
‘I’ | Represents an unsigned integer of size 2 bytes |
‘w’ | Represents a Unicode character of size 4 bytes |
‘l’ | Represents a signed integer of size 4 bytes |
‘L’ | Represents an unsigned integer of size 4 bytes |
‘f’ | Represents a floating point of size 4 bytes |
‘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
Posted By - | Karan Gupta |
|
Posted On - | Saturday, June 1, 2019 |