Write a code for a software
- User
Write a code for a software
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Write a code for a software
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
I'd be happy to write code for a simple software application. Since you haven't specified what type of software you're looking for, I've created a basic but functional to-do list application in Python. This program allows you to add, view, complete, and delete tasks.
import os
import json
from datetime import datetime
class TodoApp:
def __init__(self):
self.tasks = []
self.filename = "tasks.json"
self.load_tasks()
def load_tasks(self):
"""Load tasks from JSON file if it exists"""
if os.path.exists(self.filename):
try:
with open(self.filename, 'r') as file:
self.tasks = json.load(file)
except json.JSONDecodeError:
print("Error reading tasks file. Starting with empty task list.")
self.tasks = []
else:
self.tasks = []
def save_tasks(self):
"""Save tasks to JSON file"""
with open(self.filename, 'w') as file:
json.dump(self.tasks, file, indent=2)
def add_task(self, description, due_date=None):
"""Add a new task to the list"""
task = {
"id": len(self.tasks) + 1,
"description": description,
"completed": False,
"created_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"due_date": due_date
}
self.tasks.append(task)
self.save_tasks()
print(f"Task added: {description}")
def view_tasks(self):
"""Display all tasks in the list"""
if not self.tasks:
print("No tasks found.")
return
print("\n===== YOUR TASKS =====")
for task in self.tasks:
status = "✓" if task["completed"] else "○"
due = f" (Due: {task['due_date']})" if task["due_date"] else ""
print(f"{task['id']}. [{status}] {task['description']}{due}")
print("=====================\n")
def complete_task(self, task_id):
"""Mark a task as completed"""
for task in self.tasks:
if task["id"] == task_id:
task["completed"] = True
self.save_tasks()
print(f"Task '{task['description']}' marked as completed!")
return
print(f"Task with ID {task_id} not found.")
def delete_task(self, task_id):
"""Delete a task from the list"""
for i, task in enumerate(self.tasks):
if task["id"] == task_id:
deleted_task = self.tasks.pop(i)
self.save_tasks()
print(f"Task '{deleted_task['description']}' deleted!")
return
print(f"Task with ID {task_id} not found.")
def run(self):
"""Run the main application loop"""
while True:
print("\n==== TO-DO LIST MANAGER ====")
print("1. Add a new task")
print("2. View all tasks")
print("3. Mark a task as completed")
print("4. Delete a task")
print("5. Exit")
choice = input("\nEnter your choice (1-5): ")
if choice == "1":
description = input("Enter task description: ")
due_date = input("Enter due date (optional, YYYY-MM-DD): ")
if due_date and not self._validate_date(due_date):
print("Invalid date format. Task added without due date.")
due_date = None
self.add_task(description, due_date)
elif choice == "2":
self.view_tasks()
elif choice == "3":
self.view_tasks()
task_id = input("Enter the ID of the task to mark as completed: ")
if task_id.isdigit():
self.complete_task(int(task_id))
else:
print("Please enter a valid task ID (number).")
elif choice == "4":
self.view_tasks()
task_id = input("Enter the ID of the task to delete: ")
if task_id.isdigit():
self.delete_task(int(task_id))
else:
print("Please enter a valid task ID (number).")
elif choice == "5":
print("Thank you for using the To-Do List Manager. Goodbye!")
break
else:
print("Invalid choice. Please enter a number between 1 and 5.")
def _validate_date(self, date_str):
"""Validate the date format (YYYY-MM-DD)"""
try:
datetime.strptime(date_str, "%Y-%m-%d")
return True
except ValueError:
return False
if __name__ == "__main__":
app = TodoApp()
app.run()
todo_app.pypython todo_app.pyThe application stores your tasks in a JSON file called tasks.json so they persist between sessions.
If you need a different type of software or want this code modified, please let me know with more specific requirements!