Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCEP-30-02 All Questions

View all questions & answers for the PCEP-30-02 exam

Exam PCEP-30-02 topic 1 question 2 discussion

Actual exam question from Python Institute's PCEP-30-02
Question #: 2
Topic #: 1
[All PCEP-30-02 Questions]

Assuming that the tuple is a correctly created tuple, the fact that tuples are immutable means that the following instruction:

  • A. is illegal
  • B. may be illegal if the tuple contains strings
  • C. can be executed if and only if the tuple contains at least two elements
  • D. is fully correct
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
consultsk
1 month ago
Selected Answer: A
Explanation: Tuples are immutable: This means that once a tuple is created, its elements cannot be changed. Any attempt to modify an element in a tuple, as shown in the code, will result in an error. Error: The code will raise a TypeError because Python does not allow the modification of elements in a tuple.
upvoted 1 times
...
Poojasr
1 month, 4 weeks ago
option A
upvoted 1 times
...
christostz03
2 months, 1 week ago
a is the correct answer
upvoted 1 times
...
Supatekooma
2 months, 3 weeks ago
my_tuple = (3, 5, 7) new_tuple = (my_tuple[0], my_tuple[1] + my_tuple[0], my_tuple[2]) 3,5 + 3,7 print(new_tuple) # The Given Instruction: # my_tuple[1] = my_tuple[1] + my_tuple[0] # This instruction tries to change the element at index 1 of my_tuple by adding the element at index 0 to it. # Attempting to Modify a Tuple: # Since tuples are immutable, any attempt to directly change an element in a tuple will result in a TypeError.
upvoted 1 times
...
herrmann69
4 months, 4 weeks ago
Selected Answer: A
A is correct. TypeError: 'tuple' object does not support item assignment
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

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.

SaveCancel
Loading ...