Week 2 Assignments
Assignment 1: Smart Shopping Cart Calculator
Smart Shopping Cart with Discount Logic (Click to expand)
Assignment Description
Create a shopping cart program that calculates the final price with discount rules and membership status.
Requirements:
- Collect: 3 items (name, price, quantity), customer info
- Calculate: Subtotal, discounts (using boolean arithmetic), tax, shipping
- Display: Itemized receipt with all calculations
- Submit: GitHub repository
Key Technique - Boolean Arithmetic:
# Use True=1, False=0 to control calculations
is_member = True # or False
discount = is_member * 0.10 * subtotal # 10% if member, 0% if not
Important: Display ALL eligibility checks and metrics as True/False values. No if/else statements needed.
Variant 1.1: Electronics Store
Scenario: You’re building a checkout system for an electronics store.
Specific Requirements:
- Collect: Item name, price, and quantity for 3 electronics items
- Get customer information: Name, is_member (yes/no), total_previous_purchases (in sum)
Discount Rules: Calculate eligibility and amounts for each discount type:
- Member discount: 10% off subtotal (eligible if customer is a member)
- Bulk discount: 5% off (eligible if total items > 5)
- Loyalty discount: 3% off (eligible if total_previous_purchases >= 1000000)
- All discounts stack - apply them sequentially using boolean arithmetic
Other Calculations:
- Tax rate: 12% applied to subtotal after all discounts
- Shipping: 25000 sum (but 0 if subtotal > 500000)
- Calculate using:
shipping = (subtotal <= 500000) * 25000
- Calculate using:
Output must show:
- Customer name and membership status
- Itemized list of all 3 purchases (item, quantity, price, total)
- Subtotal before discounts
- Each discount type with:
- Eligibility status (True/False)
- Discount amount (will be 0 if not eligible)
- Total discounts applied
- Subtotal after discounts
- Tax amount
- Shipping cost with free shipping status (True/False)
- Final total
- Total amount saved
Variant 1.2: Restaurant Order System
Scenario: You’re creating an order calculator for a restaurant.
Specific Requirements:
- Collect: Dish name, price, and quantity for 3 dishes
- Get customer information: Name, has_student_id (yes/no), order_time (hour in 24-hour format, e.g., 14 for 2 PM)
Discount Rules: Calculate eligibility and amounts for each discount type:
- Student discount: 15% off subtotal (eligible if customer has student ID)
- Happy hour discount: 20% off subtotal (eligible if order_time >= 14 and order_time <= 17)
- Large order discount: 5% off (eligible if subtotal_before_discounts >= 150000)
Special Rule - Non-stacking discounts:
- Student and Happy Hour discounts do NOT stack (customer gets the better one)
- Calculate both amounts, then use:
main_discount = student_discount * (student_discount >= happy_hour) + happy_hour * (happy_hour > student_discount)
- Large order discount DOES stack with whichever main discount applies
Other Calculations:
- Service charge: 10% of subtotal (applied AFTER all discounts)
- Delivery fee: 15000 sum (but 0 if subtotal < 100000)
- Calculate using:
delivery = (subtotal >= 100000) * 15000
- Calculate using:
Output must show:
- Customer name, student status, and order time
- Itemized list of all 3 orders
- Subtotal before discounts
- Discount eligibility and amounts:
- Student discount eligibility (True/False) and amount
- Happy hour eligibility (True/False) and amount
- Which discount was applied (the larger one)
- Large order discount eligibility (True/False) and amount
- Total discounts
- Subtotal after discounts
- Service charge amount
- Delivery fee with free delivery status (True/False)
- Final total
- Total amount saved
Variant 1.3: Bookstore Purchase System
Scenario: You’re developing a checkout system for a university bookstore.
Specific Requirements:
- Collect: Book title, price, and quantity for 3 books
- Get customer information: Name, is_faculty_staff (yes/no), is_textbook_order (yes/no), number_of_books (total quantity)
Discount Rules: Calculate eligibility and amounts for each discount type:
- Faculty/Staff discount: 20% off subtotal (eligible if is_faculty_staff is True)
- Textbook discount: 25% off subtotal (eligible if is_textbook_order is True)
- Bulk book discount: 8% off (eligible if number_of_books >= 10)
Special Rules:
- Faculty and Textbook discounts do NOT stack (customer gets the better one)
- Calculate:
main_discount = faculty_discount * (faculty_discount >= textbook_discount) + textbook_discount * (textbook_discount > faculty_discount)
- Bulk discount DOES stack with whichever main discount applies
- Small order fee: 10000 sum added if number_of_books < 3
- Calculate using:
small_order_fee = (number_of_books < 3) * 10000
- Calculate using:
Other Calculations:
- Tax: 5% if is_textbook_order is False, 0% if True
- Calculate using:
tax = (is_textbook_order == False) * 0.05 * subtotal_after_discounts
- Calculate using:
- Shipping: 20000 sum (but 0 if total_before_tax >= 200000)
Output must show:
- Customer name, faculty status, and textbook order status
- Itemized list of all 3 books
- Subtotal before discounts
- Discount eligibility and amounts:
- Faculty discount eligibility (True/False) and amount
- Textbook discount eligibility (True/False) and amount
- Which discount was applied (the larger one)
- Bulk discount eligibility (True/False) and amount
- Total discounts
- Small order fee (if applicable) with status (True/False for “fee applied”)
- Subtotal after discounts and fees
- Tax amount with textbook exemption status (True/False)
- Shipping cost with free shipping status (True/False)
- Final total
- Net savings or extra fees (can be negative if fees exceed discounts)
Variant 1.4: Grocery Store Membership System
Scenario: Checkout system for a grocery store with loyalty cards and promotional discounts.
Specific Requirements:
- Collect: Product name, price, and quantity for 3 grocery items
- Get customer information: Name, has_loyalty_card (yes/no), is_senior_citizen (yes/no), day_of_week (1-7, where 1=Monday, 7=Sunday)
Discount Rules: Calculate eligibility and amounts for each discount type:
- Loyalty card discount: 8% off subtotal (eligible if has_loyalty_card is True)
- Senior citizen discount: 12% off subtotal (eligible if is_senior_citizen is True)
- Weekend special: 15% off subtotal (eligible if day_of_week >= 6)
- Large purchase discount: 5% off (eligible if subtotal_before_discounts >= 300000)
Special Rules:
- Loyalty, Senior, and Weekend discounts do NOT stack (customer gets the best one)
- Calculate all three, then use boolean arithmetic to select the largest:
main_discount = loyalty * (loyalty >= senior and loyalty >= weekend) * loyalty_amount + senior * (senior > loyalty and senior >= weekend) * senior_amount + weekend * (weekend > loyalty and weekend > senior) * weekend_amount
- Large purchase discount DOES stack with whichever main discount applies
- Bag fee: 5000 sum added if subtotal < 100000
- Calculate using:
bag_fee = (subtotal < 100000) * 5000
- Calculate using:
Other Calculations:
- Tax: 15% applied to subtotal after all discounts and fees
- Parking validation: Free (0) if subtotal_after_discounts >= 250000, otherwise 10000
- Calculate using:
parking = (subtotal_after_discounts < 250000) * 10000
- Calculate using:
Output must show:
- Customer name, loyalty card status, senior status, and day of week
- Itemized list of all 3 items (item, quantity, price, total)
- Subtotal before discounts
- Discount eligibility and amounts:
- Loyalty discount eligibility (True/False) and amount
- Senior discount eligibility (True/False) and amount
- Weekend special eligibility (True/False) and amount
- Which main discount was applied (show all three booleans for which one was selected)
- Large purchase discount eligibility (True/False) and amount
- Total discounts applied
- Bag fee (if applicable) with status (True/False for “fee applied”)
- Subtotal after discounts and fees
- Tax amount
- Parking fee with validation status (True/False for “free parking”)
- Final total
- Net savings or extra fees (can be negative if fees exceed discounts)
Assignment 2: Personal Finance Analyzer
Monthly Budget and Savings Goal Calculator (Click to expand)
Assignment Description
Create a personal finance analyzer that evaluates monthly income, expenses, and savings goals.
Requirements:
- Collect: Monthly income, expense categories, savings info, goal details
- Calculate: Total expenses, savings rate, projections, gaps
- Display: Comprehensive financial report with status indicators
- Submit: GitHub repository
Key Technique:
# Display all status checks as True/False
below_recommended = savings_rate < 20
print(f"Below Recommended (< 20%): {below_recommended}")
print(f"Savings Rate: {savings_rate:.2f}%")
Important: Show ALL metrics and indicators objectively, including negative values (shortfalls).
Variant 2.1: Young Professional Budget
Scenario: Budget analyzer for a young professional trying to save for an apartment down payment.
Required Inputs:
- Name
- Monthly net income
- Fixed expenses: Rent, utilities, internet, phone bill
- Variable expenses: Groceries, transportation, entertainment
- Current savings amount
- Apartment down payment goal
- Months until desired purchase
Calculations Required:
- Total monthly expenses (sum of all categories)
- Monthly savings (income - expenses)
- Savings rate percentage (savings / income * 100)
- Projected savings after target months (monthly_savings * months)
- Total projected amount (current_savings + projected_savings)
- Monthly savings needed to reach goal (total_needed / months)
- Additional monthly savings needed (can be negative if already sufficient)
- Shortfall or surplus (total_projected - goal, negative = shortfall, positive = surplus)
Financial Health Status Indicators (all displayed as True/False):
- Critical warning: expenses >= income
- Below recommended: savings_rate < 20
- Good position: savings_rate >= 20 and savings_rate < 30
- Excellent position: savings_rate >= 30
- Goal achievable: total_projected >= down_payment_goal
Output Requirements:
- Name and summary
- Income: Monthly net income
- Expense breakdown (all categories itemized)
- Total fixed expenses
- Total variable expenses
- Total monthly expenses
- Savings analysis:
- Monthly savings amount
- Savings rate percentage
- Current savings
- Projected savings in X months
- Total projected
- Goal analysis:
- Target amount
- Monthly savings needed for goal
- Additional monthly savings needed (show actual number, can be negative)
- All financial health indicators (True/False for each)
- Goal achievability status (True/False)
- Numeric gap: shortfall or surplus amount
Variant 2.2: Family Budget Planner
Scenario: Budget analyzer for a family trying to save for a vacation.
Required Inputs:
- Family name
- Combined monthly income
- Fixed expenses: Mortgage/rent, insurance, car payment, utilities
- Variable expenses: Groceries, childcare, family activities
- Current vacation fund balance
- Vacation cost target
- Months until vacation date
Calculations Required:
- Total monthly expenses
- Monthly savings potential (income - expenses)
- Savings rate percentage
- Projected vacation fund at target date (current_fund + monthly_savings * months)
- Total needed (vacation_cost - current_fund)
- Monthly savings needed to reach goal
- Monthly shortfall or surplus (monthly_savings - monthly_needed, negative = need more)
- Total shortfall or surplus at vacation date
Financial Health Status Indicators (all displayed as True/False):
- Emergency status: savings_rate < 10
- Needs improvement: savings_rate >= 10 and savings_rate < 15
- Stable: savings_rate >= 15 and savings_rate < 25
- Strong: savings_rate >= 25
- Vacation affordable: projected_fund >= vacation_cost
Output Requirements:
- Family name
- Income and expense breakdown (itemized)
- Total fixed expenses
- Total variable expenses
- Total monthly expenses
- Savings metrics:
- Monthly savings potential
- Savings rate percentage
- Current vacation fund
- Projected fund at vacation date
- Vacation goal analysis:
- Target vacation cost
- Total amount needed
- Monthly savings needed
- Monthly shortfall/surplus
- All financial health indicators (True/False for each)
- Vacation affordability status (True/False)
- Total gap at vacation date (numeric value)
Variant 2.3: Student Living Expenses Tracker
Scenario: Budget analyzer for a university student managing scholarship money and part-time income.
Required Inputs:
- Student name
- Monthly income (scholarship + part-time job)
- Fixed expenses: Dorm/rent, meal plan, textbooks (monthly average)
- Variable expenses: Personal items, social activities, transportation
- Current savings balance
- Emergency fund goal (recommended: 3 months of expenses)
- Has student loan (yes/no)
Calculations Required:
- Total monthly expenses
- Monthly net savings (income - expenses)
- Savings rate percentage
- Expense-to-income ratio (expenses / income)
- Three months of expenses (for emergency fund)
- Months needed to reach emergency fund (goal / monthly_savings)
- Emergency fund gap (goal - current_savings)
- Recommended minimum savings for loan holders (15% of income)
Financial Health Status Indicators (all displayed as True/False):
- Critical: expense_to_income_ratio > 0.95
- Risky: expense_to_income_ratio > 0.85 and expense_to_income_ratio <= 0.95
- Acceptable: expense_to_income_ratio > 0.70 and expense_to_income_ratio <= 0.85
- Healthy: expense_to_income_ratio <= 0.70
- Emergency fund adequate: current_savings >= emergency_fund_goal
- Has student loan: (from input)
- Savings below recommended for loan holder: has_student_loan and savings_rate < 15
Output Requirements:
- Student name and loan status
- Income and expense breakdown (itemized)
- Total fixed expenses
- Total variable expenses
- Total monthly expenses
- Savings metrics:
- Monthly net savings
- Savings rate percentage
- Expense-to-income ratio
- Current savings balance
- Emergency fund analysis:
- Emergency fund goal (3 months expenses)
- Current progress toward goal
- Gap remaining
- Months needed at current rate
- All financial health indicators (True/False for each)
- Student loan consideration metrics:
- Has loan: True/False
- Recommended minimum savings (15% of income if has loan)
- Meeting recommendation: True/False
Variant 2.4: Freelancer Income Stabilizer
Scenario: Budget analyzer for a freelancer with variable income trying to build an emergency fund.
Required Inputs:
- Freelancer name
- Average monthly income (over last 3 months)
- Lowest monthly income (in last 6 months)
- Fixed expenses: Rent, health insurance, internet, software subscriptions
- Variable expenses: Utilities, groceries, transportation, professional development
- Current emergency fund balance
- Has business debt (yes/no)
- Months of coverage desired for emergency fund (typically 6 months)
Calculations Required:
- Total monthly expenses (sum of all categories)
- Monthly savings (average_income - expenses)
- Savings rate percentage (savings / average_income * 100)
- Emergency fund goal (total_monthly_expenses * months_of_coverage)
- Emergency fund progress percentage (current_fund / goal * 100)
- Months needed to reach goal (remaining / monthly_savings)
- Income volatility (average_income - lowest_income)
- Volatility percentage (income_volatility / average_income * 100)
- Recommended buffer (total_expenses * 1.5 for freelancers)
- Shortfall or surplus (current_savings + projected_savings - goal)
Financial Health Status Indicators (all displayed as True/False):
- Critical warning: monthly_savings <= 0
- High risk: savings_rate < 15
- Moderate position: savings_rate >= 15 and savings_rate < 25
- Strong position: savings_rate >= 25
- High income volatility: volatility_percentage > 30
- Emergency fund adequate: emergency_fund_progress >= 100
- At least 3 months covered: emergency_fund_progress >= 50
- Has business debt: (from input)
- Debt with insufficient savings: has_business_debt and savings_rate < 20
- Buffer threshold met: monthly_savings >= (recommended_buffer / months_of_coverage)
Output Requirements:
- Freelancer name and debt status
- Income analysis:
- Average monthly income
- Lowest recent monthly income
- Income volatility amount
- Volatility percentage
- Expense breakdown (itemized):
- Total fixed expenses
- Total variable expenses
- Total monthly expenses
- Recommended monthly buffer (1.5x expenses)
- Savings metrics:
- Monthly savings
- Savings rate percentage
- Current emergency fund
- Emergency fund goal (X months coverage)
- Emergency fund progress percentage
- Months needed to reach goal at current rate
- All financial health indicators (10 True/False values)
- Gap analysis:
- Amount needed to reach goal
- Whether goal achievable at current rate
Assignment 3: Health and Fitness Metrics Calculator
Personal Fitness Assessment and Goal Tracker (Click to expand)
Assignment Description
Create a fitness tracker that calculates health metrics and tracks progress toward goals.
Requirements:
- Collect: Physical measurements, activity data
- Calculate: BMI, BMR, calorie needs, body composition, progress metrics
- Display: Comprehensive fitness report with status indicators
- Submit: GitHub repository
Key Technique - Gender-Based Calculations:
# Use boolean arithmetic for gender-specific formulas
is_male = gender.upper() == "M"
is_female = gender.upper() == "F"
bmr_male = 88.362 + (13.397 * weight) + (4.799 * height * 100) - (5.677 * age)
bmr_female = 447.593 + (9.247 * weight) + (3.098 * height * 100) - (4.330 * age)
bmr = (is_male * bmr_male) + (is_female * bmr_female)
Important: Display ALL health categories as True/False. Use **
for exponentiation (BMI = weight / height²).
Variant 3.1: Weight Loss Journey Tracker
Scenario: Track a person’s weight loss progress and calculate fitness metrics.
Required Inputs:
- Name
- Current weight (kg), height (m), age (years)
- Gender (M/F)
- Activity level (1-5: 1=Sedentary, 2=Light, 3=Moderate, 4=Active, 5=Very Active)
- Starting weight (kg), goal weight (kg)
- Weeks since started
- Exercise hours per week
Calculations Required:
- Current BMI: weight / (height ** 2)
- Goal BMI: goal_weight / (height ** 2)
- BMR (Basal Metabolic Rate):
- Men: 88.362 + (13.397 × weight) + (4.799 × height × 100) - (5.677 × age)
- Women: 447.593 + (9.247 × weight) + (3.098 × height × 100) - (4.330 × age)
- Use boolean arithmetic to select correct formula
- Activity multipliers by level: 1.2, 1.375, 1.55, 1.725, 1.9
- Use:
multiplier = (level==1)*1.2 + (level==2)*1.375 + ...
- Use:
- TDEE (Total Daily Energy Expenditure): BMR × activity_multiplier
- Weight lost: starting_weight - current_weight
- Average weekly loss: weight_lost / weeks_since_started
- Remaining weight: current_weight - goal_weight
- Weeks to goal: remaining_weight / average_weekly_loss
Health Status Indicators (all displayed as True/False):
Current BMI Category:
- Underweight: current_bmi < 18.5
- Normal: current_bmi >= 18.5 and current_bmi < 25
- Overweight: current_bmi >= 25 and current_bmi < 30
- Obese: current_bmi >= 30
Goal BMI Category: 5. Goal underweight: goal_bmi < 18.5 6. Goal normal: goal_bmi >= 18.5 and goal_bmi < 25 7. Goal overweight: goal_bmi >= 25 and goal_bmi < 30 8. Goal obese: goal_bmi >= 30
Progress Indicators: 9. Goal is healthy: goal_bmi >= 18.5 and goal_bmi < 25 10. Progress rate healthy: average_weekly_loss >= 0.5 and average_weekly_loss <= 1.0 11. Exercise sufficient: exercise_hours >= 3 12. Overall on track: progress_rate_healthy and exercise_sufficient
Output Requirements:
- Personal information (name, gender, age, height)
- Weight information:
- Starting, current, and goal weights
- Weight lost so far
- Remaining to goal
- Current BMI with all 4 category indicators (True/False)
- Goal BMI with all 4 category indicators (True/False)
- Metabolic calculations:
- BMR (calories/day)
- Activity level and multiplier
- TDEE (calories/day)
- Progress metrics:
- Weeks since started
- Average weekly loss
- Exercise hours per week
- Estimated weeks to goal
- All health status indicators (12 True/False values)
Variant 3.2: Athletic Performance Optimizer
Scenario: Analyze an athlete’s metrics for training and nutrition planning.
Required Inputs:
- Name
- Weight (kg), height (m), age (years)
- Gender (M/F)
- Sport type (1-3: 1=Endurance, 2=Strength, 3=Mixed)
- Training hours per week
- Protein intake (grams per day)
- Current body fat percentage
- Target body fat percentage
Calculations Required:
- BMI: weight / (height ** 2)
- BMR: (Use same gender-based formulas as Variant 1)
- Sport multipliers: 1.8, 1.9, 2.0 (for types 1-3)
- Use:
multiplier = (sport==1)*1.8 + (sport==2)*1.9 + (sport==3)*2.0
- Use:
- Athlete TDEE: BMR × sport_multiplier
- Lean body mass: weight × (1 - body_fat_percentage / 100)
- Fat mass: weight - lean_body_mass
- Recommended protein: lean_body_mass × 2.2 (grams/day for athletes)
- Protein adequacy ratio: protein_intake / recommended_protein
- Body fat to lose/gain: (current_body_fat - target_body_fat) × weight / 100
Athletic Status Indicators (all displayed as True/False):
General Metrics:
- BMI appropriate for athlete: bmi >= 20 and bmi <= 27
- Training volume adequate: training_hours >= 5
Body Fat Categories (gender-specific using boolean arithmetic): 3. Current body fat in athlete range:
- Calculate male_range: current_bf >= 6 and current_bf <= 17
- Calculate female_range: current_bf >= 16 and current_bf <= 24
- Result: (is_male * male_range) + (is_female * female_range) gives 1 or 0, convert to bool
- Target body fat realistic:
- Same gender-specific approach for target
Nutrition: 5. Protein intake sufficient: protein_adequacy_ratio >= 0.9 and protein_adequacy_ratio <= 1.2 6. Protein intake low: protein_adequacy_ratio < 0.9 7. Protein intake high: protein_adequacy_ratio > 1.2
Performance Status: 8. Performance ready: (current_bf in range) and training_adequate and protein_sufficient
Output Requirements:
- Athlete profile (name, gender, age, sport type)
- Physical measurements:
- Weight, height, BMI
- Current and target body fat percentages
- Body composition:
- Lean body mass
- Fat mass
- Body fat to lose/gain
- Metabolic calculations:
- BMR
- Sport type and multiplier
- Athlete TDEE
- Nutrition analysis:
- Current protein intake
- Recommended protein
- Protein adequacy ratio
- Training: hours per week
- All athletic status indicators (8 True/False values)
Variant 3.3: Fitness Beginner Progress Tracker
Scenario: Help a fitness beginner track their first month and assess readiness for progression.
Required Inputs:
- Name
- Weight (kg), height (m), age (years)
- Gender (M/F)
- Days exercised in past 30 days
- Average exercise duration per session (minutes)
- Push-ups in one set (number)
- Squats in one set (number)
- Fitness goal (1=Weight loss, 2=Muscle gain, 3=General fitness)
Calculations Required:
- BMI: weight / (height ** 2)
- BMR: (Use same gender-based formulas as Variant 1)
- Sedentary TDEE: BMR × 1.2
- Active TDEE estimate: BMR × 1.375
- Exercise frequency percentage: (days_exercised / 30) × 100
- Total exercise minutes in month: days_exercised × avg_duration
- Fitness score: (push_ups × 2) + (squats × 1.5)
- Calorie targets by goal:
- Calculate all three: weight_loss_target = active_TDEE - 500
- muscle_gain_target = active_TDEE + 300
- maintenance_target = active_TDEE
- Select using boolean arithmetic based on goal value
Beginner Progress Indicators (all displayed as True/False):
Health Basics:
- BMI in reasonable range: bmi >= 18.5 and bmi < 30
Exercise Consistency: 2. Exercise frequency good: exercise_frequency >= 60 (at least 18 days) 3. Exercise frequency excellent: exercise_frequency >= 80 (at least 24 days) 4. Exercise duration adequate: avg_duration >= 30
Strength Baselines: 5. Basic push-up strength: push_ups >= 5 6. Basic squat strength: squats >= 10 7. Good push-up strength: push_ups >= 10 8. Good squat strength: squats >= 20
Overall Progress: 9. Consistency strong: exercise_frequency >= 70 and avg_duration >= 30 10. Basic strength present: push_ups >= 5 and squats >= 10 11. Ready for progression: consistency_strong and basic_strength_present
Output Requirements:
- Beginner profile (name, gender, age)
- Physical measurements:
- Weight, height, BMI
- Metabolic calculations:
- BMR
- Sedentary TDEE
- Active TDEE
- Monthly exercise statistics:
- Days exercised (out of 30)
- Exercise frequency percentage
- Average duration per session
- Total exercise minutes in month
- Strength assessment:
- Push-ups in one set
- Squats in one set
- Fitness score
- Calorie targets for all three goals:
- Weight loss target
- Muscle gain target
- General fitness target
- Fitness goal selected (1, 2, or 3)
- All progress indicators (11 True/False values)
Variant 3.4: Marathon Training Readiness Assessor
Scenario: Assess someone’s readiness to start training for a marathon based on fitness metrics and experience.
Required Inputs:
- Name
- Weight (kg), height (m), age (years)
- Gender (M/F)
- Current weekly running distance (km)
- Longest single run completed in past month (km)
- Running experience (1-4: 1=Beginner 0-6 months, 2=Intermediate 6-12 months, 3=Advanced 1-2 years, 4=Experienced 2+ years)
- Previous injuries in past year (yes/no)
- Resting heart rate (bpm)
Calculations Required:
- BMI: weight / (height ** 2)
- BMR: (Use gender-based formulas from Variant 3.1)
- Experience multipliers: 0.6, 1.0, 1.3, 1.6 (for experience levels 1-4)
- Use:
multiplier = (exp==1)*0.6 + (exp==2)*1.0 + (exp==3)*1.3 + (exp==4)*1.6
- Use:
- Fitness level based on resting heart rate:
- Use boolean arithmetic for gender-specific ranges:
- Male excellent: rhr <= 60
- Male good: rhr > 60 and rhr <= 70
- Female excellent: rhr <= 65
- Female good: rhr > 65 and rhr <= 75
- Calculate:
is_excellent_fitness = (is_male * male_excellent) + (is_female * female_excellent)
- Minimum weekly distance required for marathon training: 30 km
- Minimum long run required: 15 km
- Readiness score: (weekly_distance / 30) * 40 + (longest_run / 15) * 30 + (experience_multiplier) * 30
- Training volume percentage: (current_weekly_distance / 30) * 100
Marathon Readiness Indicators (all displayed as True/False):
Health Basics:
- BMI in athlete range: bmi >= 18.5 and bmi <= 27
- No recent injuries: previous_injuries == False
Cardiovascular Fitness (gender-specific using boolean arithmetic): 3. Excellent heart fitness: is_excellent_fitness (calculated above) 4. Good heart fitness: is_good_fitness (calculated similar to excellent)
Running Volume: 5. Weekly distance adequate: current_weekly_distance >= 30 6. Weekly distance insufficient: current_weekly_distance < 20 7. Long run adequate: longest_run >= 15 8. Long run insufficient: longest_run < 10
Experience Level: 9. Has sufficient experience: running_experience >= 2 10. Beginner level: running_experience == 1
Overall Readiness: 11. Ready for marathon training: readiness_score >= 80 12. Nearly ready: readiness_score >= 60 and readiness_score < 80 13. Not yet ready: readiness_score < 60 14. High risk start: (has_injuries or bmi > 27 or weekly_distance < 20)
Output Requirements:
- Runner profile (name, gender, age)
- Physical measurements:
- Weight, height, BMI
- Resting heart rate
- Cardiovascular fitness assessment:
- Gender-specific heart rate category (excellent/good/needs improvement)
- BMR
- Running experience and volume:
- Experience level (1-4)
- Experience multiplier
- Current weekly distance
- Training volume percentage (vs. 30km baseline)
- Longest recent run
- Marathon training requirements:
- Minimum weekly distance (30 km)
- Minimum long run (15 km)
- Distance gap for weekly (if any)
- Long run gap (if any)
- Readiness analysis:
- Readiness score (out of 100)
- Previous injuries status
- All readiness indicators (14 True/False values)
- Recommendation summary based on readiness score
Submission Instructions (For All Assignments)
Click to expand submission instructions
GitHub Repository Setup
-
Create a new repository named
week2-assignment
or similar - Create a Python file named according to your assignment and variant:
- Examples:
shopping_cart_v1.py
,budget_analyzer_v2.py
,fitness_tracker_v3.py
- Examples:
- Initialize Git and make commits:
git init git add . git commit -m "Initial commit: Add program structure" # ... make changes ... git add . git commit -m "Add input collection and calculations" # ... make more changes ... git add . git commit -m "Add output formatting and final testing"
- Push to GitHub:
- Create a new repository on GitHub
- Follow GitHub’s instructions to push your local repository
- Test thoroughly:
- Run your program with at least 3 different sets of inputs
- Verify all calculations are correct
- Check that all boolean values display properly
- Ensure formatting looks professional
- Submit:
- Make sure your repository is public or accessible
- Copy your GitHub repository URL
- Submit through the Google Form
Tips
Click to expand
Boolean Arithmetic:
is_member = True
discount = is_member * 0.10 * subtotal # 10% if True, 0% if False
Display All Categories:
underweight = bmi < 18.5
normal = bmi >= 18.5 and bmi < 25
print(f"Underweight: {underweight}")
print(f"Normal: {normal}")
Select Between Values:
best_discount = (use_a * discount_a) + (use_b * discount_b)
This content will be available starting October 07, 2025.