List as Arrays TRB CSI › Python Programming › lists as arrays.

List as Arrays

Python List என்பது multiple values-ஐ ஒரே variable-ல் ordered collection ஆக store செய்யும் mutable data structure. Simple definition: A Python list can be used like an array to store multiple values in a single variable.

Premium — locked Intermediate 23 min 240 cards 50 programs 8 MCQs v3
This is a premium lesson. You can see the shape of every card — unlock to read them. Unlock

LISTS AS ARRAYS IN PYTHON Python-ல் traditional programming languages போல separate built-in array syntax இல்ல……

Premium This card is part of the premium lesson. Unlock
Definition

Python List என்பது multiple values-ஐ ஒரே variable-ல் ordered collection ஆக store செய்ய……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

marks = [80, 75, 90, 88] இங்கே: marks……

Premium This card is part of the premium lesson. Unlock
Simple Explanation

Suppose 5 students marks இருக்கிறது: 80 75 90 88 95 Separate variables பயன்படுத்தலாம்: mark1 = 80 mark2 = 75 ……

Premium This card is part of the premium lesson. Unlock
Explanation

Basic List syntax: list_name = ……

Premium This card is part of the premium lesson. Unlock
Explanation
List structure

numbers = [10, 20, 30, 40] இதன் index: Value 10 20 30 40……

Premium This card is part of the premium lesson. Unlock
Explanation
Why lists are called array-like

Traditional Array-ல்: Multiple values Stored in sequence Acce……

Premium This card is part of the premium lesson. Unlock

அதனால் List-ஐ array மாதிரி பய……

Premium This card is part of the premium lesson. Unlock
Explanation
Program 1 - create a list

numbers = [10, 20, 30, 40, 50]…

Premium This card is part of the premium lesson. Unlock
Explanation

numbers = [10, 20, 30, 40, 50] numbers என்பது list variable. Squ……

Premium This card is part of the premium lesson. Unlock
Explanation
Accessing list elements

List element access செய்ய inde……

Premium This card is part of the premium lesson. Unlock
Real Life Example
More access examples

numbers = [10, 20, 30, 40] print(numbe……

Premium This card is part of the premium lesson. Unlock
Explanation
Negative indexing

Python List-ல் negative index……

Premium This card is part of the premium lesson. Unlock
Explanation

-1 = last element -2 = second……

Premium This card is part of the premium lesson. Unlock
Explanation
List is mutable

List-ன் மிக முக்கியமான property: List is Mutable. அதாவது lis……

Premium This card is part of the premium lesson. Unlock
Explanation
Mutability explanation

Initially: [10, 20, 30] Index 1: 20 Statement: numbers[1……

Premium This card is part of the premium lesson. Unlock
Explanation
List can store different data types

Traditional typed arrays-ல் பொதுவாக same data type values இரு……

Premium This card is part of the premium lesson. Unlock

இதில்: 10 -> int Python -> st……

Premium This card is part of the premium lesson. Unlock
Important

இதுதான் Python List மற்றும் traditional Array இடையே முக்கிய di……

Premium This card is part of the premium lesson. Unlock
Explanation
List length

ஒரு List-ல் எத்தனை elements இருக்கி……

Premium This card is part of the premium lesson. Unlock
Explanation
Adding elements

List-க்கு புதிய element add செய்ய பல methods உள்ளன. Main methods: append() insert() e……

Premium This card is part of the premium lesson. Unlock
Flow
Append flow

Before: [10, 20, 30] Operation: numbers.append(40) ……

Premium This card is part of the premium lesson. Unlock
Explanation
Syntax

list.insert(index, value) num……

Premium This card is part of the premium lesson. Unlock
Explanation
Insert explanation

numbers.insert(1, 20) means: Index = 1 Value = 20 Index 1 position-ல் 20 insert செய்யப்படுகிறது. Exi……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

a = [10, 20] a.append([30, 40……

Premium This card is part of the premium lesson. Unlock

But: a = [10, 20] a.extend([3……

Premium This card is part of the premium lesson. Unlock
Comparison
Difference
Explanation
Removing elements

Important methods: remove() pop() clear() And statement: de……

Premium This card is part of the premium lesson. Unlock
Important

remove() value அடிப்படையில் remove செய்கிறது. numbers.remove(20) என்பது in……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

numbers = [10, 20, 30]…

Premium This card is part of the premium lesson. Unlock
Explanation
Pop without index

numbers = [10, 20, 30] number……

Premium This card is part of the premium lesson. Unlock

Default: Last element removed. [3……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

numbers = [10, 20, 30] del nu……

Premium This card is part of the premium lesson. Unlock

List-ன் all elements remove ச……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

numbers = [10, 20, 30] number……

Premium This card is part of the premium lesson. Unlock

List itself exists. Elements ……

Premium This card is part of the premium lesson. Unlock
Comparison
Remove vs pop vs del
Explanation
List slicing

List-லும் String மாதிரி slicing poss……

Premium This card is part of the premium lesson. Unlock
Remember

Start = Included Stop = Excluded Fo……

Premium This card is part of the premium lesson. Unlock
Real Life Example
Slicing examples

numbers = [10, 20, 30, 40, 50……

Premium This card is part of the premium lesson. Unlock
Explanation
List iteration

List elements one by one access செய்ய ……

Premium This card is part of the premium lesson. Unlock
Flow

numbers = [10, 20, 30] First iterat……

Premium This card is part of the premium lesson. Unlock
Explanation
Index-based loop

numbers = [10, 20, 30] for i ……

Premium This card is part of the premium lesson. Unlock

returns: 3 So:…

Premium This card is part of the premium lesson. Unlock

produces: 0, 1, 2 These are v……

Premium This card is part of the premium lesson. Unlock
Explanation
Sum of list elements

Python built-in sum() பயன்படு……

Premium This card is part of the premium lesson. Unlock
Explanation
Maximum value

numbers = [10, 50, 20, 40] pr……

Premium This card is part of the premium lesson. Unlock
Explanation
Minimum value

numbers = [10, 50, 20, 40] pr……

Premium This card is part of the premium lesson. Unlock
Explanation
Sorting

sort() Original List-ஐ sort செ……

Premium This card is part of the premium lesson. Unlock
Explanation
Descending sort

numbers = [40, 10, 30, 20] nu……

Premium This card is part of the premium lesson. Unlock
Explanation
Sorted function

numbers = [40, 10, 30, 20] new_numb……

Premium This card is part of the premium lesson. Unlock

Important difference: sort() Modi……

Premium This card is part of the premium lesson. Unlock
Explanation
Reverse

reverse() List elements order-ஐ rev……

Premium This card is part of the premium lesson. Unlock
Explanation
Count

ஒரு value எத்தனை times இருக்கிறது ……

Premium This card is part of the premium lesson. Unlock
Explanation
Index method

ஒரு value first time எங்கு உள்ளது ……

Premium This card is part of the premium lesson. Unlock
Explanation
Membership operators

List-ல் value இருக்கிறதா என்ற……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation
List concatenation

Two Lists combine செய்ய + பயன……

Premium This card is part of the premium lesson. Unlock
Explanation
List repetition

- operator பயன்படுத்தி List r……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

a = [1, 2]…

Premium This card is part of the premium lesson. Unlock
Explanation
Nested list

ஒரு List-க்குள் இன்னொரு List ……

Premium This card is part of the premium lesson. Unlock
Program
Example

இதற்கு: Nested List என்று சொல……

Premium This card is part of the premium lesson. Unlock
Explanation
2d array-like list

Nested List-ஐ matrix அல்லது 2……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

Structure: Row 0 -> [1, 2, 3]……

Premium This card is part of the premium lesson. Unlock

First: matrix[0] gives: [1, 2, 3]……

Premium This card is part of the premium lesson. Unlock
Real Life Example
2d array example

matrix = [ [10, 20], [30, 40]……

Premium This card is part of the premium lesson. Unlock
Explanation
Iterating nested list

matrix = [ [1, 2], [3, 4] ] f……

Premium This card is part of the premium lesson. Unlock
Explanation

Outer loop: for row in matrix: First: row = [1,……

Premium This card is part of the premium lesson. Unlock
Explanation
List comprehension

Python-ல் Lists create செய்ய compact ……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation
Square numbers

squares = [x * x for x in ran……

Premium This card is part of the premium lesson. Unlock
Explanation
Without list comprehension

squares = [] for x in range(1……

Premium This card is part of the premium lesson. Unlock

Both same result.…

Premium This card is part of the premium lesson. Unlock
Explanation
Copying list

இந்த concept மிகவும் importan……

Premium This card is part of the premium lesson. Unlock
Explanation

இதில் new independent List create……

Premium This card is part of the premium lesson. Unlock
Real Life Example
Reference example

a = [10, 20, 30] b = a a[0] =……

Premium This card is part of the premium lesson. Unlock

Reason: a and b both refer to……

Premium This card is part of the premium lesson. Unlock
Explanation
True copy

Independent copy create செய்ய: a =……

Premium This card is part of the premium lesson. Unlock
Explanation
Copy using slicing

b = a[:] இதுவும் shallow copy……

Premium This card is part of the premium lesson. Unlock
Comparison
Array vs list

Python List மற்றும் conventio……

Premium This card is part of the premium lesson. Unlock
Important
Important technical point

Beginner level-ல்: List can be used as an array. என்று சொல்லலாம். ஆனால் technically: Python list is not a ……

Premium This card is part of the premium lesson. Unlock
Explanation
Python array module

Python Standard Library-ல் true ……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

இங்கே: 'i' integer type code. இந்த ar……

Premium This card is part of the premium lesson. Unlock
Comparison
List vs array module

List: values = [10, "Python", 3.14] Mixed types possible. Ar……

Premium This card is part of the premium lesson. Unlock
Explanation
Numpy array

Scientific computing-க்கு: Nu……

Premium This card is part of the premium lesson. Unlock
Program
Example

NumPy arrays large numeric ca……

Premium This card is part of the premium lesson. Unlock
Comparison
List vs numpy array
Important
Important numpy difference

List: a = [1, 2, 3] print(a *……

Premium This card is part of the premium lesson. Unlock

List repeats. NumPy:…

Premium This card is part of the premium lesson. Unlock

NumPy performs mathematical mult……

Premium This card is part of the premium lesson. Unlock
Explanation
Program - student marks

marks = [80, 75, 90, 85, 95]…

Premium This card is part of the premium lesson. Unlock
Explanation
Average

marks = [80, 75, 90, 85, 95] ……

Premium This card is part of the premium lesson. Unlock
Real Life Example
Real-time example

Suppose temperatures: temperature = [31, 32, 30, 33, 34] Access today's first recorded temperature: print(t……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Common error 1

numbers = [10, 20, 30] print(……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error

IndexError Why? Valid indexes……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Common error 2

Confusing index and value: numbers = [10, 20, 30] numbers.remove(1) இத……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Common error 3

numbers = [10, 20] numbers.ap……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error.

append() ஒரே argument மட்டுமே எடுக்கு……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Common error 4

numbers = [10, 20, 30] x = nu……

Premium This card is part of the premium lesson. Unlock

Why? sort() list-ஐ in-place modify செய்கி……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Common error 5

a = [1, 2, 3] b = a இதனை independent copy என்று……

Premium This card is part of the premium lesson. Unlock
Important

List characteristics: Ordered Mutable Index……

Premium This card is part of the premium lesson. Unlock
Explanation
Ordered

a = [10, 20, 30] Order mainta……

Premium This card is part of the premium lesson. Unlock
Explanation
Duplicates allowed

a = [10, 20, 10, 30] print(a)…

Premium This card is part of the premium lesson. Unlock

Duplicate 10 allowed.…

Premium This card is part of the premium lesson. Unlock
Explanation
Dynamic size

List size fixed அல்ல. Initially: a = [10, 20] Then:……

Premium This card is part of the premium lesson. Unlock
Comparison
Comparison with c array

C language: int a[3] = {10, 20, 30}; Size: 3 normally fi……

Premium This card is part of the premium lesson. Unlock
Memory Trick

Remember LIST: L = Large number of values I = Indexed S = Seque……

Premium This card is part of the premium lesson. Unlock
TRB Point

TRB, NET, SET exam-க்கு important: Python List uses square brackets. a = [1, 2, 3] List index starts at 0. Ne……

Premium This card is part of the premium lesson. Unlock
Interview Point
Question

Can Python Lists be used as arrays? Answer: Yes. Python Lists are commonly used as dynamic array-like contain……

Premium This card is part of the premium lesson. Unlock
Interview Point
Question

What is the main difference between a Python List and a traditional Array? Answer: A Python List ……

Premium This card is part of the premium lesson. Unlock
Interview Point
Question

Why is a Python List mutable? Answer: Because its elements can be a……

Premium This card is part of the premium lesson. Unlock
Interview Point
Question

Difference between append() and extend()? Answ……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

a = [1, 2] a.append([3, 4])…

Premium This card is part of the premium lesson. Unlock
Output
Result

While: a = [1, 2] a.extend([3……

Premium This card is part of the premium lesson. Unlock
Output
Result
MCQ

Which brackets are used to cr……

Premium This card is part of the premium lesson. Unlock
MCQ

What is the first index of a ……

Premium This card is part of the premium lesson. Unlock
MCQ

Which statement is true about……

Premium This card is part of the premium lesson. Unlock
MCQ

What is the output? a = [10, ……

Premium This card is part of the premium lesson. Unlock
Mcq 5

What is the output? a = [10, ……

Premium This card is part of the premium lesson. Unlock
MCQ

Which method adds an element ……

Premium This card is part of the premium lesson. Unlock
MCQ

Which method removes a value ……

Premium This card is part of the premium lesson. Unlock
Mcq 8

What is the result? a = [1, 2……

Premium This card is part of the premium lesson. Unlock
Mcq 9

What is the result? a = [1, 2]……

Premium This card is part of the premium lesson. Unlock
MCQ

What does len([10, 20, 30]) r……

Premium This card is part of the premium lesson. Unlock
MCQ

Which method sorts the same L……

Premium This card is part of the premium lesson. Unlock
Mcq 12

What is the output? a = [1, 2……

Premium This card is part of the premium lesson. Unlock
Practice

Given: numbers = [10, 20, 30, 40, 50] Find output: print(numbers[0]) print(numbe……

Premium This card is part of the premium lesson. Unlock
Explanation
Complete concept map

Python Lists as Arrays | +-------------------------------+ | +-- Creation | [10, 20, 30] | +-- Access | list[……

Premium This card is part of the premium lesson. Unlock
Summary

Python-ல் Lists arrays மாதிரி multiple values store செய்யப் பயன்படுத்தப்படுகின்றன. Creation: numbers = [10, 2……

Premium This card is part of the premium lesson. Unlock
Explanation
Short description

A Python List is an ordered, mutable and dynamically sized collection that can be us……

Premium This card is part of the premium lesson. Unlock
Text size
17px
Theme
Contents
Print / PDF
Program