Python Tuple Board Questions


  1. A tuple named subject stores the names of different subjects. Write the Python commands to convert the given tuple to a list and thereafter delete the last element of the list. [2 MARKS] [2024]
  2. subject=list(subject)
    subject.pop()
    
    OR
    
    subject=list(subject)
    subject.pop(-1)
    
    OR
    
    subject=list(subject)
    del(subject[-1])
    
    OR
    
    subject=list(subject)
    del subject[-1]
    
    OR
    
     Any other correct variation of the code
    

  3. Consider the following tuple declaration : [1 MARK] [2023]
    tup1 = (10, 20, 30, (10, 20, 30), 40)

    Write the output of :
    print(tup1.index(20))
  4. 1

  5. Given the following Tuple : [1 MARK] [2023]

    Tup= (10, 20, 30, 50)
    Which of the following statements will result in an error ?

    (a) print(Tup[0])				
    (b) Tup.insert(2, 3)
    (c) print(Tup[1:2])				
    (d) print(len(Tup))
    
  6. (b) Tup.insert (2, 3)