Quiz Space

Programming in Python · End Term · 31 Aug 2025 · May 2025 term · Set QDF3

Question 7: Consider the following snippet of code:\ t1 = (1, 2, 3)\ …

Question 7

+3 marksOne or more correct options

Consider the following snippet of code:
t1 = (1, 2, 3)
t2 = (4, 5, 6)
t3 = t1 + t2
t4 = (t1, t2)
print(t3[2:5])
print(len(t4))
print(5 in t2)
try:
t1[0] = 10
except:
t1 = t3[0]
print(t1)
Select all that apply.

Select all that apply.

  1. A

    The First Line of output is (3, 4, 5, 6)

  2. B

    The First Line of output is (3, 4, 5)

  3. C

    The Second Line of output is 2

  4. D

    The Third Line of output is True

  5. E

    The Fourth Line of output is 3

Show answer

Correct answers

  • B

    The First Line of output is (3, 4, 5)

  • C

    The Second Line of output is 2

  • D

    The Third Line of output is True

Question 7 of 18 in the IIT Madras BS Programming in Python (Python) End Term paper sat on 31 Aug 2025, in the May 2025 term (IIT M FOUNDATION AN EXAM QDF3 31 Aug 2025). It carries 3 marks.

More questions from this paper

  1. Q1Given the following code snippet, what will be the output?\ if None:\ print("None is True")\ elif 0:\ print("0 is True"…
  2. Q2Consider the below code snippet.\ def updated_val(d, key, val):\ if key in d:\ d[key] += val\ else:\ d[key] = val\ retu…
  3. Q3Given the following code snippet, what will be the output?\ a = (1, 2)\ b = (3, 4)\ c = ((5, 6),)\ d = a + b + c\ e = d…
  4. Q4Consider the below output.\ 1 4 7\ 2 5 8\ 3 6 9\ Select the code snippet that will generate the above output.
  5. Q5Given the following code snippet, what will be the output?\ def update_records(records, updates):\ for key, value in up…
  6. Q6Given the following code snippet, what will be the output?\ def get_square(items, i):\ return items[i]2\ def safe_get_s…
  7. Q8Consider the following snippet of code:\ filename = "test.txt"\ with open(filename, "w") as f:\ f.write("\n".join((f"Li…
  8. Q9Consider the following snippet of code:\ class Shape:\ def init(self):\ pass\ def area(self):\ return "Area not defined…
  9. Q10Consider the below python code.\ lst = []\ for i in range(5):\ lst.append(i)\ lst.append(i10)\ lst[1:4] = [100]\ print(…
  10. Q11Consider the below python code.\ def process_array(arr):\ total = 0\ for i, row in enumerate(arr):\ total += row[i]\ re…
  11. Q12Consider the below python code.\ def procedure(child_dict, i):\ if i not in child_dict.keys():\ return 1\ ans = 1\ for …
  12. Q13Consider the below python code.\ class A:\ def init(self):\ self.value = 5\ def add(self, num):\ self.value += num\ ret…
  13. Q14On executing the given code, how many number of lines will be there in the file example_file.txt ?
  14. Q15What will be printed if we call random_access_read(filename, seek_pos) immediately after running the given code?
  15. Q16What will be the value of the following expression after running the given code snippet?\ sorted(result["cat_1"] \& res…
  16. Q17What will be the value of the following expression after running the given code snippet?\ len(result["cat_1"] | result[…
  17. Q18If result = categorize_numbers([1, 2, 10, 15, 20]) , which of the following expression(s) would be evaluated as True ?