You don't "code the exploit" unless you were putting a backdoor into software. You find a 0 day vuln. and then write a program that can exploit it in an automated way to reduce the amount of work that pen testers would do themselves.
For example, if there's an SQL injection vulnerability in a WordPress plugin, you might write a Python script that would take the location of the WordPress installation as input from the user and then automatically send the proper query to the vulnerable page. It could include a series of options for doing things like dumping user info or creating a web shell.