Exercises
Exercise 1: Creating Household IDs¶
Topic: np.arange
Description: Create a simple list of numbers to serve as ID tags.
Task: Create a list of 10 sequential Household IDs starting from 1 to 10 using np.arange.
# Write solution hereExercise 2: Total Population Calculation¶
Topic: Adding Arrays
Description: Add two lists of numbers together effectively.
Task: You have the counts of Males and Females for 5 different barangays. Add them together to get the Total Population for each barangay.
Males:
[100, 150, 120, 130, 110]Females:
[110, 140, 130, 120, 115]
# Write solution hereExercise 3: Finding the Highest Inflation Rate¶
Topic: np.max
Description: Find the largest number in a list.
Task: Given a list of inflation rates from different months, identify the highest rate recorded using np.max.
Rates:
[3.4, 4.2, 5.1, 8.7, 6.1, 4.5]
# Write solution hereExercise 4: Select the First Region¶
Topic: Indexing (Selecting items)
Description: Pick a specific item from a list using its position.
Task: You have a list of population counts. Select and print only the first number in the list (index 0).
Populations:
[5000, 2000, 3000, 8000]
# Write solution hereExercise 5: Filter Large Households¶
Topic: Filtering (Boolean Indexing)
Description: Find numbers that are bigger than a specific value.
Task: You have a list of household family sizes. Find and print only the family sizes that have more than 5 members.
Family Sizes:
[3, 4, 8, 2, 6, 10, 4]
# Write solution hereLong Exercise: Annual Report on Violence Against Women (VAW)¶
Scenario: You are preparing a report on the Monthly Reported Cases of Violence Against Women (VAW) in a specific municipality for the year 2024.
Your Tasks:
Create the Data: Convert the list of 12 months into a NumPy array.
Total Annual Cases: Calculate the total number of VAW cases reported for the whole year.
Average Monthly Cases: Calculate the average number of cases reported per month.
Peak Incident Month: Identify the highest number of cases recorded in a single month.
Identify High-Risk Months: Find and print all months where the reported cases were greater than 20 (indicating a surge).
Raw Data (Jan-Dec):
15, 18, 12, 14, 25, 28, 10, 8, 30, 22, 15, 19
# Write solution hereExercises for Dataframes in marimo¶
Fertilizer Use and Crop Response Analysis¶
99.1_additional_exercises_01.pyPython basics
NumPy
Pandas
Loops
Groupby, filtering, lambda functions
Basic data visualization
Labor Productivity Analysis¶
99.1_additional_exercises_02.pyPerform computations
Filter and classification
Loop through averages
Use lambda functions
Visualize data
Farm Typology and Survey Prioritization¶
99.1_additional_exercises_dataframes.pyDive into DataFrames