PYTHON PROGRAMMING LAB Exp 6

Published: 12 January 2024
on channel: DIWAKAR TIWARY
49
1

Exp No 6 Write a program to demonstrate working with tuples in python.
empty tuple
my_tuple = ()
print(my_tuple)
Output: ()

tuple having integers
my_tuple = (1, 2, 3)
print(my_tuple)
Output: (1, 2, 3)

tuple with mixed datatypes
my_tuple = (1, "Hello", 3.4)
print(my_tuple)
Output: (1, "Hello", 3.4)

nested tuple
my_tuple = ("mouse", [8, 4, 6], (1, 2, 3))
print(my_tuple)
Output: ("mouse", [8, 4, 6], (1, 2, 3))

tuple can be created without parentheses
also called tuple packing
my_tuple = 3, 4.6, 'dog'
print(my_tuple)
Output: 3, 4.6, 'dog'

tuple unpacking is also possible
a, b, c = my_tuple
print(a)
print(b)
print(c)
Output:
3
4.6
dog

INPUT AND OUTPUT:
()
(1, 2, 3)
(1, 'Hello', 3.4)
('mouse', [8, 4, 6], (1, 2, 3))
(3, 4.6, 'dog')
3
4.6
dog


On this page of the site you can watch the video online PYTHON PROGRAMMING LAB Exp 6 with a duration of hours minute second in good quality, which was uploaded by the user DIWAKAR TIWARY 12 January 2024, share the link with friends and acquaintances, this video has already been watched 49 times on youtube and it was liked by 1 viewers. Enjoy your viewing!