ALIASING IN PYTHON…
Aliasing
Aliasing என்பது ஒரே object-ஐ இரண்டு அல்லது அதற்கு மேற்பட்ட variables reference செய்வது. Simple definition: When two or more variables refer to the same object, it is called aliasing.
Aliasing என்பது ஒரே object-ஐ இரண்டு அல்லது அதற்கு மேற்பட்ட variables re……
இங்கே a மற்றும் b இரண்டு different ……
ஒரு classroom-ல் ஒரு student இருக்கிறார் என்று எடுத்துக்கொள்ளுங்கள். அந்த student-ஐ: Nagarajan Kalviyogi என்ற……
a = [10, 20, 30] Memory concept: a --------> [10, 20, 30] Next: b……
Aliasing-க்கு separate keywor……
Mutable object-ல் இதன் effect……
a = [10, 20, 30]…
இங்கே output same என்பதனால் ம……
a மற்றும் b same object-ஐ reference செய்கின்றன. ALIASING-ன் MAIN……
நாம் b-ஐ மட்டும் change செய்தோம். அப்படியிருக்க ……
Why? b.append(30) same list o……
b மூலம் remove செய்தாலும் a ம……
Again: same object ALIASING vs COPYIN……
இதில்: a ----\ ---> One List ……
இதில்: a ---> [10, 20, 30] b --->……
Python-ல் இரண்டு variables same object-ஐ……
a = [10, 20]…
Because: a and b refer to same object == vs is இது மிகவும் முக்கியமான interview/TRB conce……
a = [10, 20] b = [10, 20]…
Why? Contents same: [10,20] == [10,20] அதனால்: True ஆ……
Because: Same values + Same o……
Case 1 - Aliasing a = [10, 20] b = a a -------\ ---> [10,20] b -------/ Therefore: a is b -> True a == b -> T……
Function உள்ளே: x and outside: a t……
a ----\ ---> [10,20] x ----/ Then: x.append(30) same object becomes: [10,20……
ஏன்? Initially: a ----\ ---> [10,20] x ----/ Inside function: x = [100, 200] இப்போது: a ---> [10,20] x ---> [……
Output conceptually: {1, 2, 3, 4} Again: same set object ALIASING ……
a மற்றும் b same string object-ஐ refer செய்யலாம். ஆனால் string immutable. So: b[0] = "J" செய்ய முடியாது. Ther……
இப்போது: a[0][0] = 100…
Why all three changed? Because: row object ஒன……
a[0] ---\ a[1] ----> [0,0] a[2] ---/ இதுவும் aliasing. VERY IMPORTANT PYTHON ……
a = [[0] * 3] * 3 a[0][0] = 1…
ஏன்? Same inner list repeated……
இங்கே each iteration new inner list create ……
But inner objects shared.…
a ---> [ ---- , ---- ] | | v v [1,2] [3,4……
Because inner list is aliased……
deepcopy() nested mutable obj……
Aliasing பற்றி நினைவில் வைத்திருக்க வேண்டிய main points: Aliasing means multiple variables refer to the same ……
Wrong assumption: a = [10, 20] b = a Student th……
a = [10, 20] b = a b.append(30) print(a) Som……
Confusing: == with: is…
== -> same value? is -> same ……
a = [[0, 0]] * 3 இது three independent inner l……
Aliasing: ONE OBJECT MANY NAM……
a ----\ ---> Same Object b --……
= -> may create alias/reference == -> compare v……
What is aliasing?…
What is the output? a = [1, 2……
a = [10, 20] b = a print(a is……
a = [10, 20] b = [10, 20] pri……
Which statement creates an al……
What is aliasing in Python? Aliasing occurs when multiple variables reference the same object. Why is aliasin……
What does aliasing mean?…
What is the output? x = [1, 2……
Which operator checks object ……
Which checks value equality?…
Which creates a shallow copy ……
Aliasing problems are especia……
Predict the output. 1. a = [10, 20] b = a b[0] = 50 print(a) 2. a = [1, 2, 3] b = a.copy() b[0] = 100 print(a……
Aliasing: a = [10, 20] b = a Memory: a ----\ ---> [10,20] b ----/ Therefor……
b = a -> alias b = a.copy() -> shallow copy b……
Aliasing என்பது Python-ல் இரண்டு அல்லது அதற்கு மேற்பட்ட variables ஒரே object-ஐ reference செய்வது. குறிப்பாக m……