34 solutions available
Question 8Can you change an element of a sequence? What if a sequence is a dictionary? What if a sequence is a tuple?
Question 9How can you add an extra element to a tuple ?
Question 10When would you prefer tuples over lists ?
Question 12When would sum( ) not work for tuples ?
Question 14Is the working of in operator and tuple.index( ) same ?
Question 1(a)Find the output generated by following code fragments :plane = ("Passengers", "Luggage") plane[1] = "Snakes"
Question 1(b)Find the output generated by following code fragments :(a, b, c) = (1, 2, 3)
Question 1(d)Find the output generated by following code fragments :a, b, c, d = (1, 2, 3)
Question 1(k)Find the output generated by following code fragments :tuple = ( 'a' , 'b', 'c' , 'd' , 'e') tuple = ( 'A', ) + tuple[1: ]...
Question 1(m)Find the output generated by following code fragments :t3 = (6, 7) t4 = t3 * 3 t5 = t3 * (3) print(t4) print(t5)
Question 1(o)What will be stored in variables a, b, c, d, e, f, g, h, after following statements ?perc = (88,85,80,88,83,86) a = perc[2:2] b =...
Question 2What does each of the following expressions evaluate to? Suppose that T is the tuple containing :("These", ["are" , "a", "few", "words"] ,...
Question 3(b)Carefully read the given code fragments and figure out the errors that the code may produce.t = ('a', 'b', 'c', 'd', 'e') t[0] = 'A'
Question 3(c)Carefully read the given code fragments and figure out the errors that the code may produce.t1 = (3) t2 = (4, 5, 6) t3 = t1 + t2...
Question 3(d)Carefully read the given code fragments and figure out the errors that the code may produce.t1 = (3,) t2 = (4, 5, 6) t3 = t1 + t2...
Question 3(e)Carefully read the given code fragments and figure out the errors that the code may produce.t2 = (4, 5, 6) t3 = (6, 7) print(t3 - t2)
Question 3(f)Carefully read the given code fragments and figure out the errors that the code may produce.t3 = (6, 7) t4 = t3 * 3 t5= t3 * (3) t6 =...
Question 3(g)Carefully read the given code fragments and figure out the errors that the code may produce.odd= 1,3,5 print(odd + [2, 4, 6])[4]
Question 3(h)Carefully read the given code fragments and figure out the errors that the code may produce.t = ( 'a', 'b', 'c', 'd', 'e') 1, 2, 3, 4,...
Question 3(i)Carefully read the given code fragments and figure out the errors that the code may produce.t = ( 'a', 'b', 'c', 'd', 'e') 1n, 2n, 3n,...
Question 3(j)Carefully read the given code fragments and figure out the errors that the code may produce.t = ( 'a', 'b', 'c', 'd', 'e') x, y, z, a,...
Question 3(k)Carefully read the given code fragments and figure out the errors that the code may produce.t = ( 'a', 'b', 'c', 'd', 'e') a, b, c, d,...
Question 4What would be the output of following code ifntpl = ("Hello", "Nita", "How's", "life?") (a, b, c, d) = ntpl print ("a is:", a) print ("b...
Question 5Predict the output.tuple_a = 'a', 'b' tuple_b = ('a', 'b') print (tuple_a == tuple_b)
Question 6Find the error. Following code intends to create a tuple with three identical strings. But even after successfully executing following code...
Question 7Predict the output.tuple1 = ('Python') * 3 print(type(tuple1))
Question 8Predict the output.x = (1, (2, (3, (4,)))) print(len(x)) print( x[1][0] ) print( 2 in x ) y = (1, (2, (3,), 4), 5) print( len(y)...
Question 9What will the following code produce ?Tup1 = (1,) * 3 Tup1[0] = 2 print(Tup1)
Question 10What will be the output of the following code snippet?Tup1 = ((1, 2),) * 7 print(len(Tup1[3:8]))
Question 2(b)Write a program that receives a Fibonacci term and returns a number telling which term it is. For instance, if you pass 3, it returns 5,...
Question 4Write a program to create a nested tuple to store roll number, name and marks of students.Solutiontup = () ans = "y" while ans == "y" or...
Question 5Write a program that interactively creates a nested tuple to store the marks in three subjects for five students, i.e., tuple will look...
Question 6Write a program that interactively creates a nested tuple to store the marks in three subjects for five students and also add a function...
Question 15Mean of means. Given a nested tuple tup1 = ( (1, 2), (3, 4.15, 5.15), ( 7, 8, 12, 15)). Write a program that displays the means of...