Lists, Tuples, Sets and Dictionary

Unit 9 > Computer Science > Class 12 > Samacheer Kalvi - English Medium

Objectives


• Understand the basic concepts of various collection data types in python such as List, Tuples, sets and Dictionary. • Work with List, Tuples, sets and Dictionaries using variety of functions. • Writting Python programs using List, Tuples, sets and Dictionaries. • Understand the relationship between List, Tuples and Dictionaries.

Summary


• Python programming language has four collections of data types such as List, Tuple, Set and Dictionary. • A list is known as a “sequence data type”. Each value of a list is called as element. • The elements of list should be specified within square brackets. • Each element has a unique value called index number begins with zero. • Python allows positive and negative values as index. • Loops are used access all elements from a list. • The “for” loop is a suitable loop to access all the elements one by one. • The append ( ), extend ( ) and insert ( ) functions are used to include more elements in a List. • The del, remove ( ) and pop ( ) are used to delete elements from a list. • The range ( ) function is used to generate a series of values. • Tuples consists of a number of values separated by comma and enclosed within parentheses. • Iterating tuples is faster than list. • The tuple ( ) function is also used to create Tuples from a list. • Creating a Tuple with one element is called “Singleton” tuple. • A Set is a mutable and an unordered collection of elements without duplicates. • A set is created by placing all the elements separated by comma within a pair of curly brackets. • A dictionary is a mixed collection of elements