What is the expected output of the following code?
data = [‘Peter’, 404, 3.03, ‘Wellert’, 33.3]
print(data[1:3])
A . None of the above.
B. [‘Peter’, 404, 3.03, ‘Wellert’, 33.3]
C. [‘Peter’, ‘Wellert’]
D. [404, 3.03]
Answer: D
Explanation:
Topic: list indexing
Try it yourself:
data = [‘Peter’, 404, 3.03, ‘Wellert’, 33.3]
print(data[1:3]) # [404, 3.03]
You have a list of five elements of various data types.
[1:3] slices inclusive the first index and exclusive the third index.
Meaning it slices the first and second index.
Latest PCEP-30-01 Dumps Valid Version with 124 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund