Exam JN0-223 Topic 3 Question 29 Discussion
Actual exam question for Juniper's JN0-223 exam
Question #: 29
Topic #: 3
Question #: 29
Topic #: 3
What is the difference between a list and a tuple in Python?
Suggested Answer: B Vote an answer
In Python, the distinction between lists and tuples is essential for efficient programming:
* Lists:
* Mutable (B): This means that once a list is created, its elements can be changed, added, or removed. Lists are versatile and commonly used when the data is expected to change.
* Square Brackets: Lists are defined using square brackets[].
Example:
my_list = [1, 2, 3]
my_list[0] = 10 # Modifying the first element
* Tuples:
* Immutable (B): Once a tuple is created, it cannot be altered. Tuples are used when a fixed collection of items is needed, providing more integrity to the data.
* Parentheses: Tuples are defined using parentheses().
Example:
my_tuple = (1, 2, 3)
# my_tuple[0] = 10 # This would raise an error because tuples are immutable
* Python Official Documentation: The Python Language Reference provides detailed information on data types like lists and tuples, including their mutability and syntax.
* Automation Scripts: In the context of automation, understanding when to use mutable or immutable data structures can significantly impact script performance and reliability.
References:
* Lists:
* Mutable (B): This means that once a list is created, its elements can be changed, added, or removed. Lists are versatile and commonly used when the data is expected to change.
* Square Brackets: Lists are defined using square brackets[].
Example:
my_list = [1, 2, 3]
my_list[0] = 10 # Modifying the first element
* Tuples:
* Immutable (B): Once a tuple is created, it cannot be altered. Tuples are used when a fixed collection of items is needed, providing more integrity to the data.
* Parentheses: Tuples are defined using parentheses().
Example:
my_tuple = (1, 2, 3)
# my_tuple[0] = 10 # This would raise an error because tuples are immutable
* Python Official Documentation: The Python Language Reference provides detailed information on data types like lists and tuples, including their mutability and syntax.
* Automation Scripts: In the context of automation, understanding when to use mutable or immutable data structures can significantly impact script performance and reliability.
References:
by Abraham at Oct 16, 2026, 03:26 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).