The license you put on code when working through book examples varies depending on the book and the license that it comes with. For example, if you are working through an GPL-licensed book, then the code you produce must also be licensed under the GPL. However, if you are working through a book that is released under a more permissive license, such as the MIT license, then you are free to choose any license you wish for the code you produce.