PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 14


Which of the following sentences are true? (Choose two.)

Show Answer
Correct Answer: BD

Tuples may be stored inside lists, as lists in Python can contain elements of various types, including tuples. Additionally, lists may be stored inside lists, as lists can contain any type of element including other lists. These properties allow both nested lists and nested tuples, making statements B and D correct.

Discussion

8 comments
Sign in to comment
palagusOptions: BD
May 24, 2022

B and D are right

DKMOptions: BD
Nov 4, 2021

tuple inside list : L = [(1,2),(2,3),(4,5),(3,4),(6,7),(6,7),(3,8)]

DKM
Nov 4, 2021

lists inside tuple: t = ([1, 2], [3, 4], [5, 6]) for i in t: for j in i: print(j)

macxszOptions: BD
May 3, 2022

B. Tuples may be stored inside lists D. Lists may be stored inside lists

666_mOptions: BD
May 5, 2022

B& D are correct.

naveenbv80Options: BD
Dec 2, 2022

list_inside_tuple = ([1, 2], [3, 4], [5, 6]) print(list_inside_tuple) tuple_inside_list = [(1,2),(2,3),(4,5),(3,4),(6,7),(6,7),(3,8)] print(tuple_inside_list) my answer is B and D

pincholinco
Nov 28, 2023

they are all true nothing stops you from storing anything inside a touple you shouldn't store a list because that defeats the point of tuple since the tuple element (the list) can now be modified but I suppose it will need to remain a list.

TheFivePipsOptions: BD
Dec 6, 2023

A. Lists may not be stored inside tuples This statement is incorrect. In Python, lists can be stored inside tuples. Tuples are immutable, but they can contain mutable elements like lists. B. Tuples may be stored inside lists This statement is correct. In Python, you can have a list that contains elements of various types, including tuples. C. Tuples may not be stored inside tuples This statement is incorrect. Tuples can indeed be stored inside other tuples. Tuples in Python can contain elements of various types, and this includes other tuples. D. Lists may be stored inside lists This statement is correct. In Python, you can have a list that contains elements of various types, including other lists. So, the correct answers are B and D.