Question
You have a Python list of fruits and want to extract a
specific sub-list using slicing. Â Complete the missing part of the code to obtain the sub-list `['banana', 'cherry']`. fruits = ['apple', 'banana', 'cherry', 'date', 'elderberry'] # Extract the sub-list ['banana', 'cherry'] selected_fruits = fruits[___] print(selected_fruits) Which of the following options correctly completes the code to produce `['banana', 'cherry']`?Solution
In Python slicing, `[start:end]` extracts elements from the `start` index up to, but *not including*, the `end` index. Apple is at index 0. Banana is at index 1. Cherry is at index 2. date'` is at index 3. To get `'banana'` (index 1) and `'cherry'` (index 2), you need to start at index 1 and go up to (but not include) index 3. Therefore, `fruits[1:3]` is the correct slice.
Who took Ashoka's pillar inscription of Topra and Meerut to Delhi?
__________ aerospace agency has recently launched its Kalam 100 rockets that will power the Vikram - 1 rocket’s third engine.
Which government scheme has a component called "Recognition of Prior Learning (RPL)"?
Which bank launched a prepaid Sapphiro Forex Card for international students?
When was Wildlife Protection Act was enacted ?
Which organization granted a loan for a 400-megawatt solar power plant in Gujarat?
When is the scheduled period for the 46th session of the UNESCO World Heritage Committee in New Delhi?
Who was the founder of the autonomous Awadh kingdom?
Which of the following work is not credited to Lord Dalhousie?
Which of the following Formula One(F1 ) racers will retire from all types of racing at the end of 2022 season?