The program defines a tuple t containing 10 elements of different data types (strings and integers). Then the print() function is used to output the entire tuple.
Next, the 4th element of the tuple is accessed using indexing, with the expression t[3]. This value is then assigned to the variable i and printed to the console with the message "4th Elements From Tuple :".
Finally, the 4th element from the end of the tuple is accessed using negative indexing, with the expression t[-4]. This value is then assigned to the variable j and printed to the console with the message "4th Elements From Last Tuple :".
t = ("w", 3, "r", "e", "s", "o", "u", "r", "c", "e") print(t) #Get item (4th element)of the tuple by index i = t[3] print("4th Elements From Tuple :",i) #Get item (4th element from last)by index negative j = t[-4] print("4th Elements From Last Tuple :",j)
('w', 3, 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e') 4th Elements From Tuple : e 4th Elements From Last Tuple : u
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions