BLACK FRIDAY SALE – Unlock Up to 25% OFF on All Exam Prep! - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Python Institute PCAP-31-03 Exam - Topic 5 Question 28 Discussion

Posted by Kimbery on May 04, 2022 at 11:52 AM

How many elements will the list2 list contain after execution of the following snippet?

list1 = [False for i in range (1, 10) ]

list2 = list1 [-1:1:-1]

Suggested Answer: C


Get Premium PCAP-31-03 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
12 comments · newest first
RA
Raina 1 year ago
Definitely zero elements in list2!
AU
Audrie 1 year ago
Wait, how does slicing work here?
IV
Ivette 1 year ago
I think it should be three elements.
RO
Rozella 1 year ago
list2 will be empty, right?
JE
Jerry 1 year ago
list1 has 9 elements.
RY
Ryan 1 year ago
I feel like the answer could be zero since the start index is greater than the stop index when slicing backwards.
MA
Malinda 1 year ago
If I recall correctly, negative slicing starts from the end, so maybe it will return a few elements? I’m a bit confused.
AL
Albina 1 year ago
I remember practicing a similar question, and I think the slice [-1:1:-1] might give us an empty list.
CA
Carlene 1 year ago
I think list1 will have nine elements, but I'm not sure how slicing works with negative indices.
KI
Kiley 1 year ago
Okay, let's think this through. The company has 30 vCPUs and 512GB RAM available, but the new application needs to handle up to 24,000 sessions. That's a huge increase in demand, so I think adding more capacity to the private cloud (option D) might be the best long-term solution, even if it's not the quickest.
TA
Tamesha 1 year ago
Okay, let me see... The Posse Comitatus Act, that's the one, right? I remember learning about that in my government class. I'm feeling confident about this one.
JE
Jennifer Burke 4 years ago
[False, False, False, False, False, False, False] The correct answer is 7
0/2000 characters

Save Cancel