The document contains a series of Python programming exercises focused on tuples, including operations such as finding maximum and minimum values, counting elements, and understanding tuple characteristics compared to lists. It also includes questions about tuple creation, indexing, and manipulation. Additionally, it provides code snippets for practical applications of tuples in Python.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
16 views2 pages
Tuple Full Lesson
The document contains a series of Python programming exercises focused on tuples, including operations such as finding maximum and minimum values, counting elements, and understanding tuple characteristics compared to lists. It also includes questions about tuple creation, indexing, and manipulation. Additionally, it provides code snippets for practical applications of tuples in Python.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
TUPLE >>> print (t)
>>> print (max(t))
ONE MARKS >>> print (t.count(20)) 1. What will be the output of the following code: >>> print (t[0]+5) Employee=(‘rajesh’,100,23,[1,2,3]) >>> print (t.index(40)) len(Employee) >>> print (min(t) + len(t)) 2. How tuple is different from list? 2. Write a program that inputs two tuples and creates a third, 3. which of the following creates a tuple? that contains all elements of the first followed by all (a)t1=("a","b") (b) t1[2]=("a","b") elements of the second. Create a tuple names as given here: (c) t1=(5)*2 (d) None of the above names = ('jai', 'rahul', 'maya', 'kia', 'Dav', 'Lalit') 4. What is the length of the tuple shown Write proper code for getting : below: (a) ('maya', 'kia', 'Dav') T = ( ( ( ( ‘a’, 1 ), ’b’ , ’c’ ), ’d’ , 2 ) , ’e’ , 3 ) (b) ('jai') 5. What is the difference between (30) and (30,)? (c) ('kia', 'Dav', 'Lalit') TWO MARKS 3. TypeError occurs while statement 2 is running. Give reason. 1. Write a python program to create tuple of 10 integer type How can it be corrected? elements and find the largest element in tuple. >>> tuple1 = (5) #statement 1 2. t1 = (3, 4) >>> len(tuple1) #statement 2 t2 = ('3', '4') FOUR MARKS print(t1 + t2) 1. What will be stored in variables a, b, c, d, e, f, g, h after 3. t2 = (4, 5, 6) following statements? t3 = (6, 7) perc = (88, 85, 80, 88, 83, 86) t4 = t3 + t2 a = perc[2:2] t5 = t2 + t3 b = perc[2:] print(t4) c = perc[:2] print(t5) d = perc[:-2] THREE MARKS e = perc[-2] 1. Find the output of the following Python f = perc[2:-2] Code: g = perc[-2:2] t=(10,20,30,40,50,60,70,20,30,50) h = perc[:] 2. Write a program to input n numbers from the user. Store these numbers in a tuple. Print the maximum and minimum number from this tuple. 3. Consider the following tuples, tuple1 and tuple2 and find the output of the following statements: tuple1 = (23,1,45,67,45,9,55,45) tuple2 = (100,200) i. print(tuple1.index(45)) ii. print(tuple1.count(45)) iii. print(tuple1 + tuple2) iv. print(len(tuple2)) v. print(max(tuple1)) vi. print(min(tuple1)) vii. print(sum(tuple2)) viii. print( sorted ( tuple1 ) ) ix. print(tuple1) 4.