88 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 2Consider the given two statements:Statement 1: t1 = tuple('python')Statement 2: t1[4] = 'z'Assertion (A): The above code will generate an...
Question 3Assertion (A): In Python, tuple is an immutable sequence of data.Reasoning (R): Immutable means that any change or alteration in data is...
Question 4Consider the given statements for creating dictionaries in Python:D1 = { 'A' : 'CS' , 'B' : ' IP' }D2 = { 'B' : 'IP', 'A' : 'CS '...
Question 5Assertion (A): Dictionaries are enclosed within curly braces { }.Reasoning (R): The key-value pairs are separated by commas (,).Both A and...
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 7Assertion (A): Keys of the dictionaries must be unique.Reasoning (R): The keys of a dictionary can be accessed using values.Both A and R...
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 1Elements in a tuple can be of Dissimilar type.
Question 2Tuples are indexed by an integer.
Question 3Tuples are immutable, you cannot update or edit the elements.
Question 4tuple() function is used to convert a sequence data type into tuple.
Question 5Like lists, Dictionaries are mutable which means they can be changed.
Question 6A Python dictionary is a mapping of unique keys to values.
Question 7The association of a key and a value is called a Key-Value pair.
Question 8To create a dictionary, key-value pairs are separated by comma.
Question 9In key-value pair, each key is separated from its value by a colon(:).
Question 10keys() function returns the keys of the dictionary.
Question 11The Del<dict> statement removes a dictionary object along with its items.
Question 12popitem() function will delete the last inserted key-value pair from the dictionary.
Question 1Which of the statement(s) is/are correct?Python Dictionary is an unordered collection of items.Python Dictionary is a mapping of unique...
Question 2If tup = (20, 30, 40, 50), which of the following is incorrect?print (tup[3])tup[2] = 56print (max(tup))print (len(tup))
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 4Which function returns the number of elements in the tuple?len()max()min()count()
Question 5To create an empty dictionary, we use the statement as:d1 = {}d1 = []d1 = ()d1 == {}
Question 6In a dictionary, the elements are accessed through:KeyValueIndexNone of these
Question 7Keys of a dictionary must be:SimilarUniqueBoth (i) and (ii)All of these
Question 8To create a new dictionary with no items:Dictdict()d1=[]None of these
Question 9Which function is used to return a value for the given key?len()get()keys()None of these
Question 10Which function is used to remove all items from a particular dictionary?clear()pop()delete()rem()
Question 11Which one of the following is correct to insert a single element in a tuple?T = 4T = (4)T = (4, )T = [4, ]
Question 12Which of the following functions will return key-value pairs of the dictionary?key()values()items()get()
Question 13Which of the following will delete key-value pair for key = "Red" from a dictionary D1 ?delete D1("Red")del.D1("Red")del D1["Red"]del D1
Question 14What will be the output?D1 = { "Rahul":56, "Virat":99} print("virat" in D1)TrueFalseNo outputError
Question 15Which of the following creates a tuple?t1 = ("a", "b")t1 [2]= ("a", "b")t1= (5) *2None of these
Question 1What advantages do tuples have over lists?
Question 2What are the similarities and differences between tuples and lists?
Question 3What is a key-value pair in dictionary?
Question 4What are the differences between tuple and dictionary?
Question 5What are the differences between strings and tuples?
Question 6Can we always have same type of values in a tuple? State True or False with justification.
Question 7What is nested tuple? Explain with example.
Question 8Write the code to create an empty tuple.
Question 9Write a Python program to create a tuple with different data types and display.
Question 10What is the difference between "book" and ('book',)?
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(a)Find errors and rewrite the same after correcting the following code:d1 = {1:10, 2.5:20, 3:30, 4:40, 5:50, 6:60, 7:70}
Question 12(b)Find errors and rewrite the same after correcting the following code:d1(9) = 90
Question 12(c)Find errors and rewrite the same after correcting the following code:del d1(2)
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 1An element in a dictionary is a combination of key-value pairs.
Question 2Internally, dictionaries are indexed on the basis of values.
Question 3We can repeat a key in dictionary.
Question 4In dictionary, two unique keys can have the same values.
Question 5A tuple can be used as the key in a dictionary if it contains immutable elements.
Question 6clear() is used to delete a dictionary.
Question 7A tuple is a mutable data type.
Question 8List can be used as keys in a dictionary.
Question 9Updating an element in a dictionary at runtime is possible.
Question 10We can create immutable dictionaries in Python.
Question 11A tuple can store elements of different data types.
Question 12A tuple cannot store list as an element.
Question 13Creating individual values from a tuple's elements is called packing.
Question 14We cannot delete a dictionary once created.