Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Deadline Reminder System | Automating Freelance Workflow
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Freelancers

bookChallenge: Deadline Reminder System

Managing multiple projects as a freelancer can be challenging, especially when deadlines are approaching. Automating deadline reminders helps you stay organized and ensures you never miss a critical due date. In this challenge, you will create a Python program that manages a list of freelance projects with their respective deadlines. The program will highlight projects that are due soon, display which projects are completed, and allow you to mark projects as finished. You will use hardcoded data for simplicity, focusing on the core logic for tracking and displaying reminders.

To begin, you will represent each project as a dictionary containing the project's name, deadline, and completion status. You will then use Python's datetime module to compare deadlines with the current date and determine which projects are due within the next five days. The program will print reminders for urgent projects and indicate which projects have already been completed.

12345678910111213141516171819202122232425262728293031323334353637383940414243
import datetime # Hardcoded list of projects projects = [ {"name": "Website Redesign", "deadline": "2024-07-05", "completed": False}, {"name": "Logo Creation", "deadline": "2024-07-01", "completed": False}, {"name": "SEO Audit", "deadline": "2024-06-28", "completed": True}, {"name": "Content Writing", "deadline": "2024-07-03", "completed": False}, {"name": "Social Media Campaign", "deadline": "2024-06-30", "completed": False}, ] def display_reminders(projects): today = datetime.date.today() print("Project Deadlines and Reminders:\n") for project in projects: deadline = datetime.datetime.strptime(project["deadline"], "%Y-%m-%d").date() days_left = (deadline - today).days status = "Completed" if project["completed"] else "Pending" if project["completed"]: print(f"✔️ {project['name']} - {status} (Deadline: {project['deadline']})") elif 0 <= days_left <= 5: print(f"‼️ {project['name']} - Due in {days_left} day(s)! (Deadline: {project['deadline']})") else: print(f" {project['name']} - {status} (Deadline: {project['deadline']})") def mark_project_completed(projects, project_name): for project in projects: if project["name"].lower() == project_name.lower(): project["completed"] = True print(f"Marked '{project['name']}' as completed.") return print(f"No project found with the name '{project_name}'.") # Display initial reminders display_reminders(projects) # Example: Mark 'Content Writing' as completed mark_project_completed(projects, "Content Writing") # Display updated reminders print("\nUpdated Project Status:\n") display_reminders(projects)
copy

This program first displays all projects, highlighting those due within five days with a special marker. Completed projects are clearly indicated. You can mark a project as completed by providing its name to the mark_project_completed function. After updating, the reminders are displayed again, showing the updated status for each project.

Note
Note

You can enhance this script by integrating user input for marking projects as completed, or by loading project data from a file or database. For now, hardcoded data keeps the logic focused and easy to follow.

By automating your deadline reminders, you reduce the risk of missing important tasks and can focus more on delivering quality work to your clients. This approach is easily adaptable to more complex project management needs as your freelance business grows.

Opgave

Swipe to start coding

Write a function get_urgent_projects(projects) that takes a list of project dictionaries and returns a new list containing only the projects whose deadlines are within the next 3 days (including today), and are not marked as completed.

  • Use the datetime module to compare each project's deadline with the current date.
  • Only include projects with completed set to False.
  • Return a list of project dictionaries that match the criteria.
  • Do not modify the original project list or dictionaries.
  • Use the provided default_projects list for your tests.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 5

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Can you explain how the program determines which projects are due soon?

How can I add a new project to the list?

What happens if I try to mark a project as completed that doesn't exist?

bookChallenge: Deadline Reminder System

Stryg for at vise menuen

Managing multiple projects as a freelancer can be challenging, especially when deadlines are approaching. Automating deadline reminders helps you stay organized and ensures you never miss a critical due date. In this challenge, you will create a Python program that manages a list of freelance projects with their respective deadlines. The program will highlight projects that are due soon, display which projects are completed, and allow you to mark projects as finished. You will use hardcoded data for simplicity, focusing on the core logic for tracking and displaying reminders.

To begin, you will represent each project as a dictionary containing the project's name, deadline, and completion status. You will then use Python's datetime module to compare deadlines with the current date and determine which projects are due within the next five days. The program will print reminders for urgent projects and indicate which projects have already been completed.

12345678910111213141516171819202122232425262728293031323334353637383940414243
import datetime # Hardcoded list of projects projects = [ {"name": "Website Redesign", "deadline": "2024-07-05", "completed": False}, {"name": "Logo Creation", "deadline": "2024-07-01", "completed": False}, {"name": "SEO Audit", "deadline": "2024-06-28", "completed": True}, {"name": "Content Writing", "deadline": "2024-07-03", "completed": False}, {"name": "Social Media Campaign", "deadline": "2024-06-30", "completed": False}, ] def display_reminders(projects): today = datetime.date.today() print("Project Deadlines and Reminders:\n") for project in projects: deadline = datetime.datetime.strptime(project["deadline"], "%Y-%m-%d").date() days_left = (deadline - today).days status = "Completed" if project["completed"] else "Pending" if project["completed"]: print(f"✔️ {project['name']} - {status} (Deadline: {project['deadline']})") elif 0 <= days_left <= 5: print(f"‼️ {project['name']} - Due in {days_left} day(s)! (Deadline: {project['deadline']})") else: print(f" {project['name']} - {status} (Deadline: {project['deadline']})") def mark_project_completed(projects, project_name): for project in projects: if project["name"].lower() == project_name.lower(): project["completed"] = True print(f"Marked '{project['name']}' as completed.") return print(f"No project found with the name '{project_name}'.") # Display initial reminders display_reminders(projects) # Example: Mark 'Content Writing' as completed mark_project_completed(projects, "Content Writing") # Display updated reminders print("\nUpdated Project Status:\n") display_reminders(projects)
copy

This program first displays all projects, highlighting those due within five days with a special marker. Completed projects are clearly indicated. You can mark a project as completed by providing its name to the mark_project_completed function. After updating, the reminders are displayed again, showing the updated status for each project.

Note
Note

You can enhance this script by integrating user input for marking projects as completed, or by loading project data from a file or database. For now, hardcoded data keeps the logic focused and easy to follow.

By automating your deadline reminders, you reduce the risk of missing important tasks and can focus more on delivering quality work to your clients. This approach is easily adaptable to more complex project management needs as your freelance business grows.

Opgave

Swipe to start coding

Write a function get_urgent_projects(projects) that takes a list of project dictionaries and returns a new list containing only the projects whose deadlines are within the next 3 days (including today), and are not marked as completed.

  • Use the datetime module to compare each project's deadline with the current date.
  • Only include projects with completed set to False.
  • Return a list of project dictionaries that match the criteria.
  • Do not modify the original project list or dictionaries.
  • Use the provided default_projects list for your tests.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 5
some-alt