Challenge: Workload Analyzer
Analyzing and optimizing your freelance workload can help prevent burnout and ensure you meet your deadlines without overcommitting. By building a Python program to examine your weekly workload, you can spot weeks where you have taken on too much work and identify ways to balance your schedule more effectively. This approach allows you to make informed decisions about rescheduling projects and managing your time.
To begin, consider a set of hardcoded project data that includes project names, deadlines (as week numbers), and estimated hours required for each project. With this data, you can calculate the total hours of work scheduled for each week. If any week exceeds 40 hours, the program will highlight it and suggest which projects could be moved to another week to distribute the workload more evenly. Finally, the program will output a clear summary for each week, showing the workload and any recommendations for rescheduling.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758# Hardcoded project workload data projects = [ {"name": "Website Redesign", "deadline_week": 1, "estimated_hours": 18}, {"name": "Mobile App", "deadline_week": 1, "estimated_hours": 25}, {"name": "Logo Design", "deadline_week": 2, "estimated_hours": 10}, {"name": "SEO Audit", "deadline_week": 2, "estimated_hours": 12}, {"name": "Content Writing", "deadline_week": 2, "estimated_hours": 20}, {"name": "Data Analysis", "deadline_week": 3, "estimated_hours": 15}, {"name": "Social Media Campaign", "deadline_week": 3, "estimated_hours": 30}, {"name": "Consultation", "deadline_week": 4, "estimated_hours": 8}, {"name": "Bug Fixing", "deadline_week": 4, "estimated_hours": 12}, {"name": "Presentation Prep", "deadline_week": 4, "estimated_hours": 10}, ] # Calculate weekly workload from collections import defaultdict weekly_hours = defaultdict(list) for project in projects: weekly_hours[project["deadline_week"]].append(project) # Analyze workload and suggest rescheduling MAX_WEEKLY_HOURS = 40 summary = {} for week in sorted(weekly_hours): projects_in_week = weekly_hours[week] total_hours = sum(p["estimated_hours"] for p in projects_in_week) summary[week] = { "total_hours": total_hours, "projects": [p["name"] for p in projects_in_week], "overloaded": total_hours > MAX_WEEKLY_HOURS, "reschedule_suggestions": [], } if total_hours > MAX_WEEKLY_HOURS: # Suggest rescheduling: move lowest-priority projects (by hours) until under 40 sorted_projects = sorted(projects_in_week, key=lambda p: p["estimated_hours"], reverse=True) temp_hours = total_hours suggestions = [] for p in sorted_projects: if temp_hours <= MAX_WEEKLY_HOURS: break suggestions.append(p["name"]) temp_hours -= p["estimated_hours"] summary[week]["reschedule_suggestions"] = suggestions # Output summary for week in sorted(summary): print(f"Week {week}:") print(f" Total scheduled hours: {summary[week]['total_hours']}") print(f" Projects: {', '.join(summary[week]['projects'])}") if summary[week]["overloaded"]: print(" Warning: Over 40 hours scheduled!") print(" Suggest rescheduling these projects to balance workload:") print(f" {', '.join(summary[week]['reschedule_suggestions'])}") else: print(" Workload is balanced.") print()
Definition: In this context, a "week" is simply a numbered period (such as week 1, week 2, etc.), not tied to calendar dates. This makes it easier to test and adapt the analysis for your own scheduling needs.
Swipe to start coding
Write a Python program that:
- Uses hardcoded data for at least five projects, each with a project name, deadline week, and estimated hours.
- Calculates total scheduled hours for each week.
- Identifies any week with more than 40 hours of work.
- Suggests which projects in overloaded weeks could be rescheduled to balance the workload.
- Outputs a summary for each week, including any rescheduling suggestions.
Soluzione
Grazie per i tuoi commenti!
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Fantastico!
Completion tasso migliorato a 5
Challenge: Workload Analyzer
Scorri per mostrare il menu
Analyzing and optimizing your freelance workload can help prevent burnout and ensure you meet your deadlines without overcommitting. By building a Python program to examine your weekly workload, you can spot weeks where you have taken on too much work and identify ways to balance your schedule more effectively. This approach allows you to make informed decisions about rescheduling projects and managing your time.
To begin, consider a set of hardcoded project data that includes project names, deadlines (as week numbers), and estimated hours required for each project. With this data, you can calculate the total hours of work scheduled for each week. If any week exceeds 40 hours, the program will highlight it and suggest which projects could be moved to another week to distribute the workload more evenly. Finally, the program will output a clear summary for each week, showing the workload and any recommendations for rescheduling.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758# Hardcoded project workload data projects = [ {"name": "Website Redesign", "deadline_week": 1, "estimated_hours": 18}, {"name": "Mobile App", "deadline_week": 1, "estimated_hours": 25}, {"name": "Logo Design", "deadline_week": 2, "estimated_hours": 10}, {"name": "SEO Audit", "deadline_week": 2, "estimated_hours": 12}, {"name": "Content Writing", "deadline_week": 2, "estimated_hours": 20}, {"name": "Data Analysis", "deadline_week": 3, "estimated_hours": 15}, {"name": "Social Media Campaign", "deadline_week": 3, "estimated_hours": 30}, {"name": "Consultation", "deadline_week": 4, "estimated_hours": 8}, {"name": "Bug Fixing", "deadline_week": 4, "estimated_hours": 12}, {"name": "Presentation Prep", "deadline_week": 4, "estimated_hours": 10}, ] # Calculate weekly workload from collections import defaultdict weekly_hours = defaultdict(list) for project in projects: weekly_hours[project["deadline_week"]].append(project) # Analyze workload and suggest rescheduling MAX_WEEKLY_HOURS = 40 summary = {} for week in sorted(weekly_hours): projects_in_week = weekly_hours[week] total_hours = sum(p["estimated_hours"] for p in projects_in_week) summary[week] = { "total_hours": total_hours, "projects": [p["name"] for p in projects_in_week], "overloaded": total_hours > MAX_WEEKLY_HOURS, "reschedule_suggestions": [], } if total_hours > MAX_WEEKLY_HOURS: # Suggest rescheduling: move lowest-priority projects (by hours) until under 40 sorted_projects = sorted(projects_in_week, key=lambda p: p["estimated_hours"], reverse=True) temp_hours = total_hours suggestions = [] for p in sorted_projects: if temp_hours <= MAX_WEEKLY_HOURS: break suggestions.append(p["name"]) temp_hours -= p["estimated_hours"] summary[week]["reschedule_suggestions"] = suggestions # Output summary for week in sorted(summary): print(f"Week {week}:") print(f" Total scheduled hours: {summary[week]['total_hours']}") print(f" Projects: {', '.join(summary[week]['projects'])}") if summary[week]["overloaded"]: print(" Warning: Over 40 hours scheduled!") print(" Suggest rescheduling these projects to balance workload:") print(f" {', '.join(summary[week]['reschedule_suggestions'])}") else: print(" Workload is balanced.") print()
Definition: In this context, a "week" is simply a numbered period (such as week 1, week 2, etc.), not tied to calendar dates. This makes it easier to test and adapt the analysis for your own scheduling needs.
Swipe to start coding
Write a Python program that:
- Uses hardcoded data for at least five projects, each with a project name, deadline week, and estimated hours.
- Calculates total scheduled hours for each week.
- Identifies any week with more than 40 hours of work.
- Suggests which projects in overloaded weeks could be rescheduled to balance the workload.
- Outputs a summary for each week, including any rescheduling suggestions.
Soluzione
Grazie per i tuoi commenti!
single