This paper explores how to provide high-quality programming tasks to students using generative AI. Existing generative AI suffers from issues such as low-quality generated tasks, difficulty for students to understand, and errors. To address these issues, we present a novel synthesis technique, PyTaskSyn. PyTaskSyn simulates expert and student agents using strong and weak generative models, and generates high-quality programming tasks through a multi-step verification process. Experimental results demonstrate that PyTaskSyn significantly improves task quality compared to existing techniques. User research using a public web application demonstrates that PyTaskSyn delivers tasks of comparable quality to those designed by experts. Furthermore, PyTaskSyn reduces workload and costs while increasing student engagement.