📘 Day 01 – Arrays vs Lists in Python | My DSA Journey Begins 💻


Hey everyone! 🙌
Today marks Day 01 of my DSA journey, and I’ve started by diving into something fundamental yet super important — Arrays and Lists in python While they may seem similar, they have distinct use cases and behaviors.
What’s a List in Python?
List is a class
List is mutable
List can grow ( dynamic array)
List can contain different type elements
List elements are indexed
What’s an Array in Python?
Collection of same type of elements
Flexible size
Indexed
Arrays in Python come from the
array
module.
array.array
is resizableDefine Array -
This module defines an object type which can efficiently represent an array of basis values
eg - character, integer, floating point numbers
Creating Array
from array import *
a1 = array(typecode, [,elements])
Typecode | C Type |
‘b’ | signed integer |
‘B’ | unsigned integer |
‘u’ | unicode character |
‘h’ | signed character |
‘i’ | signed integer |
Example
from array import *
a1 = array("i", [23,34,42]
print(a1)
Subscribe to my newsletter
Read articles from Shiva directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Shiva
Shiva
A self taught data scientist