Looks like the following discussion could be the solution.
https://discuss.frappe.io/t/auto-create-task/116616
today = frappe.utils.today()
tomorrow = frappe.utils.add_days(today,1)
task = frappe.get_doc({
"doctype": "Task",
"subject": "New task",
"status": "Open",
"exp_start_date": today,
"exp_end_date": tomorrow
})
task.insert()
The above is by @avc
Thank you for sharing the code.