Array in Python



Arrays can only contain values corresponding to same data opposed to lists which contains value corresponding to different data types.


Syntax
arrayName = array(typecode, [Initializers]>




Code Snippet

arraydata=array('c', 'hello world')
for letter in arraydata:
 print letter


Typecodes

‘b’ -> signed integer of size 1 byte
‘B’ -> unsigned integer of size 1 byte
‘c’ -> character of size 1 byte
‘u’ -> unicode character of size 2 bytes
‘h’ -> signed integer of size 2 bytes
‘H’ -> unsigned integer of size 2 bytes
‘i’ -> signed integer of size 2 bytes
‘I’ -> unsigned integer of size 2 bytes
‘w’ -> unicode character of size 4 bytes
‘l’ -> signed integer of size 4 bytes
‘L’ -> unsigned integer of size 4 bytes
‘f’ -> floating point of size 4 bytes
‘d’ -> floating point of size 8 bytes



Array in Python Reviewed by Rupesh on 08:50 Rating: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.