Page 277 - CTS - CSA TP - Volume 2
P. 277
COMPUTER SOFTWARE APPLICATION - CITS
Explanation:
1 Tuple Initialization:
• tuple1 is initialized with the values (1, 2, 3).
• tuple2 is initialized with the values (‘a’, ‘b’, ‘c’).
2 Tuple Concatenation:
• concatenated_tuple is created by concatenating tuple1 and tuple2. The + operator concatenates the two
tuples.
3 Printing the Tuples:
• These lines print the original tuples (tuple1 and tuple2) and the result after concatenation (concatenated_tuple).
Output:
Related Exercises:
1 Python program to find tuples which have all elements divisible by K from a list of tuples
2 Python program to find Tuples with positive elements in List of tuples
3 Python – Count tuples occurrence in list of tuples
4 Python – Removing duplicates from tuple
5 Python program to sort a list of tuples alphabetically
Dictionaries in Python
Dictionaries in Python are versatile data structures that allow you to store and retrieve data using key-value pairs.
Here’s a brief explanation of dictionaries:
Overview:
• A dictionary is an unordered collection of items.
• Each item in a dictionary consists of a key-value pair.
• Keys must be unique within a dictionary.
• Values can be of any data type, and they can be duplicates.
Creating a Dictionary:
262
CITS : IT & ITES - Computer Software Application - Exercise 128 CITS : IT & ITES - Computer Software Application - Exercise 128