Lists and Tuples Interview Questions

    Question 1Python Lists - Creation

    Which of the following is a valid way to create a list?

    Question 2Python Tuples - Immutability

    What happens when you execute the following?

    t = (1, 2, 3) t[0] = 10

    Question 3Python Lists - Indexing

    What will this code output?

    lst = [10, 20, 30] print(lst[1])

    Question 4Python Lists - Negative Index

    What does lst[-1] return?

    lst = [1, 2, 3, 4]

    Question 5Python Lists - Append Method

    What is the output?

    lst = [1, 2] lst.append(3) print(lst)

    Question 6Python Tuples - Single Element

    Which of the following correctly creates a tuple with a single element 5?

    Question 7Python Lists - Slicing

    What will this code output?

    lst = [0, 1, 2, 3, 4] print(lst[1:4])

    Question 8Python Lists - Nested Lists

    What is the output?

    lst = [[1, 2], [3, 4]] print(lst[1][0])

    Question 9Python Tuples - Concatenation

    What will this code print?

    t1 = (1, 2) t2 = (3, 4) print(t1 + t2)

    Question 10Python Lists - Length

    What is the output?

    lst = [10, 20, 30, 40] print(len(lst))