Python Control Structures
Python Control Structures - Important Points
26. | Which of the following statements is used to add an element to the end of a list in Python? |
---|
A. list.add(element)
B. list.insert(index, element)
C. list.append(element)
D. list.push(element)
View Answer Discuss Work SpaceAnswer: option c
Explanation:
27. | Which of the following statements is used to check if a value is in a list in Python? |
---|
A. value in list
B. list.contains(value)
C. list.include(value)
D. value.exists(list)
View Answer Discuss Work SpaceAnswer: option a
Explanation:
28. | Which of the following statements is used to check if a key is in a dictionary in Python? |
---|
A. key in dictionary
B. dictionary.contains(key)
C. dictionary.include(key)
D. key.exists(dictionary)
View Answer Discuss Work SpaceAnswer: option a
Explanation:
29. | Which of the following statements is used to loop through a dictionary in Python? |
---|
A. for key in dictionary:
B. for value in dictionary:
C. for item in dictionary:
D. for key, value in dictionary.items():
View Answer Discuss Work SpaceAnswer: option d
Explanation:
30. | Which of the following statements is used to break out of nested loops in Python? |
---|
A. continue
B. pass
C. break
D. exit
View Answer Discuss Work SpaceAnswer: option c
Explanation: