Programming is 2% people telling you what to do and 78-98% you going out figuring how to accomplish it (and depending on necessity, 20% feedback). You won't learn anything if you just read about it - if you show a first-grader arithmetic for a year, they might memorize some of the numbers, but it won't mean anything unless they get to play with them, same with any math activity, and same with programming. Testing and messing around is the way to get to know how something works, and that's when you can apply critical knowledge. I wouldn't bother using only examples that you get from class - unless you're early on in programming and can only use functions that you've been told in class, looking online for relevant answers is very helpful, and has been how I learned to start and I still do that whenever I need to use a language I have never used before. That way, you can at least know of something new to use and try.
To answer the topic title, I first got started in coding indirectly through my brothers. They both introduced me to HTML. HTML is just markup, but it got my fascinated with using what I wrote to organize and draw words on the page, integrated into the browser. I was also introduced to CSS, and when my brother wasn't being helpful I turned to Google. I was also copying bits of JavaScript, mostly because other people made it function and I didn't know how it worked. I just wanted to use it.
Sometime inbetween then and my senior year of highschool, I tried C++. I didn't understand a thing, but I think I tried to make a text-based RPG, inspired by Chuck. It didn't get very far. For my senior year, I convinced my oldest brother to oversee me do a Web Development curriculum, where my final project was to build a forum from scratch with PHP, MySQL, and some AJAX. That introduced me to the world of data structures. That's when everything clicked, and I got pretty far (though, the forum doesn't exist anymore... It was pretty buggy by the end, but it was a ton of fun to work on).
After that, I started college. At that point, it was my introduction to imperative and object-oriented programming, particularly to Java. I learned a lot about data structures, classes, and functions here, and eventually about pointers and references in my most recent semester with C++. My first semester, I had a friend in Purdue's CS program, so I convinced him to give me the lab assignments from their intro to programming course. No surprise there: it was a lot more advanced than my school's, but I learned there too and had fun with the assignments, about scalars and how to create a Sudoku program, and a couple others too, I think. Maybe I'm just cynical, liking coding and all, but if you can have fun on your own time doing assignments that you may not even need to do, it can be helpful and you might learn a new trick.