Python Tuple və Tuple Unpacking | Tuple and Tuple Unpacking in Python #kody_az

Dərs haqqında

Python-da tuple dəyişməz və sıralı elementlər toplusudur. Tuple-lar siyahılara bənzəyir, lakin siyahılardan fərqli olaraq, tuple-lar dəyişdirilə bilməz. Yəni bir dəfə tuple yaradıldıqdan sonra onun tərkibindəki elementləri dəyişmək, silmək və ya əlavə etmək mümkün deyil. Tuple-lar, sıralamanın vacib olduğu, lakin məlumatların dəyişdirilməsini istəmədiyiniz hallarda faydalıdır.

Tuple və Siyahı Seçimi Nə Zaman Edilməli?

• Tuple istifadə edin: Toplunun dəyişdirilməsinin lazım olmadığı hallarda. Məsələn, koordinatlar, həftənin günləri və ya konfiqurasiya dəyərləri tuple üçün yaxşı nümunələrdir.
• Siyahı istifadə edin: Əgər elementləri dəyişmək, əlavə etmək və ya silmək ehtiyacınız varsa, siyahılar daha uyğun olacaq.

====

In Python, a tuple is an immutable, ordered collection of elements. Tuples are similar to lists, but unlike lists, tuples cannot be modified after they are created. Tuples are useful when you need to store a collection of items where the order matters, but you don’t want the collection to be changed.

Tuple Packing and Unpacking

Tuple packing is the process of putting multiple values into a tuple. Tuple unpacking is the reverse process where you extract individual values from a tuple and assign them to variables.

When to Use Tuples vs Lists

• Use tuples when the collection of values should not be modified. For example, coordinates, days of the week, or configuration values are good candidates for tuples.
• Use lists when you need a mutable sequence, where you might want to add, remove, or change elements.

#python #kody_az #kodyaz #viral #viralcode #viralvideo #random #code #coder #azerbaycan #azerbaijan #azərbaycan #baku #baki #programming #programmer #codes #hazırlıq #hazirliq #kurs #kurslar #course #courses #online #onlinecourses #test #quiz

YouTube-da bax · KODY.AZ