As a beginner wanting to learn to write code you have a few decisions to make such as what language you are going to learn and what you want to do with the language. Many that begin programming have something that they want to do in mind before they start, this may be making games or creating a website and in many cases this will determine what you will learn, because computer science is a vast subject which moves so fast that you have no chance of learning it all so some specialisation is required as well as constant learning. Because of this I will not be teaching you how to write code here but instead attempt to guide you to to where you can find the resources you are looking for to start.
To start with I will split things up based on what you may want to do, into the categories of web (part 1), application (PC) (part 2), mobile (part 3), games (PC) (part 4). From here I will try to narrow things down until you are left with only a few choices. But as one size does not always fit all I will leave you with several options to choose from to start your learning.
Web development is a little different from the others in that if you want to do it all yourself you will need to learn several languages. These can be split into sever-side and client-side languages. (some design knowledge is also useful.)
server-side: PHP or Python or ruby (while there are others these are good ones to start with) and SQL
While you can create a functional website with only the client-side languages as soon as you start to bring databases into the mix with persistent data and user accounts, you will need the help of a server-side language and a server to run it on.
As to where to learn these I have a list of websites an a few books listed below that you may find helpful, it is up to you which you choose to use.
HTML and CSS : design and build websites by Jon Duckett
For sever-side PHP is the go to choice for most people and allows you to write server side code for a website without the need for a web framework, although there are some available. Python and ruby on the other hand are often used with a web framework (you may have heard of ruby on rails). These frameworks have a trade off while it does allow you to create a functional website in a shorter amount of time it does mean that for a beginner there will be the web framework to learn on top of the language itself. Although that being said they do offer a wrapper around the database often removing the need to learn SQL (the language used to communicate with databases) straight away.
As for what these languages allow you to do, they make it possible to save data on the server in a database. This is used for user accounts as well as blogs and various other tasks. These languages then allow you to change and structure this data for the requirements of the website such as displaying certain data for a specific user.
(please note that due to the rate at which books become out of date I have not listed any, instead I recommend you take a look at the documentation of both the frameworks and the languages which often include a tutorial to get you started. If you do want a book to learn from the books from the publishers O’Rilly and Addison Wesley are often of high quality, just make sure it covers a recent version of the language/ framework)