Python Lab Manual Answers (22616)
Practical 7 : Write Python program to perform following operations on Tuples: Create Tuple, Access Tuple, Update Tuple, Delete Tuple
* Practical Related Question.
1) Define empty tuple. Write syntax to create empty tuple.
Ans=> 1)Tuples are used to store multiple items in a single variable.
2)A tuple is a collection which is ordered and unchangeable.
3) A Tuple with no single item is called empty tuple
4)We can create an empty tuple in Python in two ways. The first one providing no elements in the parenthesis, and the second is providing no iterable to the tuple() builtin function.
5)Syntax :
2) Write syntax to copy specific elements existing tuple into new tuple.
Ans=>
t1 = (1, 2, 3, 4, 5)
newt1 = t1
t1[0] = 5
newt1t1
3)Compare tuple with list
Ans=>
List Tuple
List are Mutable Tuple are Unmutable
List Consume Tuple Consume
More Memory less memory
List Have Tuples have
many methods less methods
List enclosed in Tuple Enclosed in
square bracket parenthesis
*Exerecise
1. Create a tuple and find the minimum and maximum number from it.
Ans=>
2. Write a Python program to find the repeated items of a tuple.
Ans=>
3. Print the number in words for Example: 1234 => One Two Three Four
Ans=>
*Practical Outcome(PrOs)
Write Python program to perform following operations on Tuples:
1. Create Tuple
2. Access Tuple
3. Update Tuple
4. Delete Tuple
.
.
.
.
keep Growing ......
0 Comments