0
0
Data Analysis Pythondata~15 mins

Array indexing and slicing in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Array indexing and slicing
📖 Scenario: You work in a small bakery that tracks daily sales of different types of bread. You have a list of daily sales numbers for a week, and you want to analyze specific days or parts of the week.
🎯 Goal: Learn how to use array indexing and slicing to select specific sales data from a list.
📋 What You'll Learn
Create a list with exact daily sales numbers
Create a variable to select a specific day using indexing
Use slicing to select a range of days
Print the selected sales data
💡 Why This Matters
🌍 Real World
Selecting specific days' sales helps businesses analyze performance on particular days or periods.
💼 Career
Data analysts often use indexing and slicing to extract relevant data from larger datasets for reports and insights.
Progress0 / 4 steps
1
Create the daily sales list
Create a list called daily_sales with these exact values: 20, 35, 30, 25, 40, 50, 45 representing sales for each day of the week.
Data Analysis Python
Need a hint?

Use square brackets [] to create a list and separate numbers with commas.

2
Select sales for Wednesday using indexing
Create a variable called wednesday_sales that gets the sales number for Wednesday from daily_sales using indexing. Remember, the list starts at index 0 for Monday.
Data Analysis Python
Need a hint?

Wednesday is the third day, so use index 2.

3
Select sales from Tuesday to Thursday using slicing
Create a variable called midweek_sales that slices daily_sales to get sales from Tuesday to Thursday (inclusive). Use slicing with the correct start and end indexes.
Data Analysis Python
Need a hint?

Slicing includes the start index but excludes the end index.

4
Print the selected sales data
Print the variables wednesday_sales and midweek_sales to display the sales for Wednesday and the midweek range.
Data Analysis Python
Need a hint?

Use two print statements, one for each variable.