39 solutions available
Question 1Assertion (A): Tuple in Python is an ordered and immutable data type.Reasoning (R): Tuples can contain heterogenous data and permit...
Question 6Assertion (A): The pop() method can be used to delete elements from a dictionary.Reasoning (R): The pop() method deletes the key-value pair...
Question 8Assertion (A): clear() method removes all elements from the dictionary.Reasoning (R): len() function cannot be used to find the length of a...
Question 3Consider two tuples given below:tup1 = (1, 2, 4, 3) tup2 = (1, 2, 3, 4) What will the following statement print: print (tup1 <...
Question 10Which function is used to remove all items from a particular dictionary?clear()pop()delete()rem()
Question 14What will be the output?D1 = { "Rahul":56, "Virat":99} print("virat" in D1)TrueFalseNo outputError
Question 2What are the similarities and differences between tuples and lists?
Question 4What are the differences between tuple and dictionary?
Question 5What are the differences between strings and tuples?
Question 7What is nested tuple? Explain with example.
Question 9Write a Python program to create a tuple with different data types and display.
Question 11Write a Python program to combine first 3 elements and last 3 elements from a tuple.T1 = ('a', 1, 2, 3, 4, 'b', 'c', 'book', 10)Output...
Question 12(b)Find errors and rewrite the same after correcting the following code:d1(9) = 90
Question 12(d)Find errors and rewrite the same after correcting the following code:pop d1[4]
Question 12(e)Find errors and rewrite the same after correcting the following code:d1.item()
Question 12(f)Find errors and rewrite the same after correcting the following code:d1.key()
Question 12(g)Find errors and rewrite the same after correcting the following code:d1.value()
Question 12(h)Find errors and rewrite the same after correcting the following code:d1.gets(4, 80)
Question 12(i)Find errors and rewrite the same after correcting the following code:d1.len()
Question 12(j)Find errors and rewrite the same after correcting the following code:d1.clears()
Question 13(a)Suppose>>> d1 = { 1 : 'one' , 2: 'two' , 3: 'three' , 4: 'four'} >>> d2 = { 5 :'five', 6:'six' }Write the output of...
Question 13(b)Suppose>>> d1 = { 1 : 'one' , 2: 'two' , 3: 'three' , 4: 'four'} >>> d2 = { 5 :'five', 6:'six' }Write the output of...
Question 14(a)Consider the following code and find out the error:tup1 = (10, 20, 30) tup2 = tup1 * (3, )
Question 14(b)Consider the following code and find out the error:tup1 = ('a', 'b', 'c') tup1 = tup1 + d
Question 14(c)Consider the following code and find out the error:tup1 = ("Riya", ) * '4'
Question 14(d)Consider the following code and find out the error:t1 = (10, 20, 30, 40) X, Y, Z = t1
Question 14(e)Consider the following code and find out the error:tup1=('A', 'school', 10.5, 70) print max(tup1)
Question 14(f)Consider the following code and find out the error:t = (10, 20, 30, 40) t[1] = 'o'
Question 14(g)Consider the following code and find out the error:T1 = ('A') T2 = ('B', 'C', 3) T3 = T1 + T2
Question 14(h)Consider the following code and find out the error:T1 = (10, 20, 30, 40) T2 = (40, 50, 60) T1, T2, T3 = T1, T2
Question 15t1 = (100, 200, "Global", 3, 3.5, "Exam", [1, 2], (30, 40), (3, 5, 3)) :Consider the above tuple 't1' and answer the following...
Question 16Write the output of the following statements:(a) >>> tuple([10,20,40])(b) >>> ("Tea",)*5(c) >>> tuple ("Item")
Question 17Consider two tuples t1 & t2 given below:t1 = (100, 200, 300) t2 = (10, 20, 30, 40)Write the output of the following statements:(a)t1,...
Question 18WAP to accept values from a user. Add a tuple to it and display its elements one by one. Also display its maximum and minimum...
Question 19Write a Python program to input any values for two tuples. Print it, interchange it, and then compare them.Solutiont1 = eval(input("Enter...
Question 20Write a Python program to input 'n' classes and names of their class teachers to store it in a dictionary and display the same. Also,...
Question 21Write a program to store students' names and their percentage in a dictionary, and delete a particular student name from the dictionary....
Question 22Write a Python program to input names of 'n' customers and their details like items bought, cost and phone number, store it in a...
Question 12A tuple cannot store list as an element.