Pregunta de entrevista de Trendlyne

"What is a prime number?" "How would you iterate through a list in Python?" "How can you merge two lists in Python using an in-built function?" "What will be the output of the following Python code? my_tuple = (1, 2, 3, 4, 5) my_tuple[2] = 10 print(my_tuple) A) (1, 2, 10, 4, 5) B) (1, 2, 3, 10, 5) C) Error: 'tuple' object does not support item assignment. D) Error: 'tuple' object has no attribute 'insert'."

Respuesta de la entrevista

Anónimo

30 sep 2024

1) prime numbers are those numbers that can be completely divided by 1 and itself. 2) my_list = [1, 2, 3, 4, 5] for item in my_list: print(item) 3) list1 = [1, 2, 3] list2 = [4, 5, 6] list1.extend(list2) merged_list = list1 + list2 print(list1) # Output: [1, 2, 3, 4, 5, 6] print(merged_list) # Output: [1, 2, 3, 4, 5, 6] 4) This is because tuples in Python are immutable, meaning their elements cannot be changed after the tuple is created. option C is correct : TypeError: 'tuple' object does not support item assignment