The Self-Taught Computer Scientist. Cory Althoff
Чтение книги онлайн.

Читать онлайн книгу The Self-Taught Computer Scientist - Cory Althoff страница 8

СКАЧАТЬ then a code assessment, and soon after an in-person interview. During my interview, the web development director and two senior developers sat down and reviewed my answers for the code assessment. I felt good because they were blown away by some of my answers and pleasantly surprised when I told them I was self-taught. They told me some of my answers were better than ones given by senior developers that they had previously given the same code assessment. Two weeks later, they hired me.

       If you can put in the work and get through the pain, then you can make your dreams come true as I did.

      for i in range(100): print("Hello, World!") >> Hello, World! >> Hello, World! >> Hello, World!

      The text # http://tinyurl.com/h4qntgk contains a URL that takes you to a web page that contains the code from it, so you can easily copy and paste it into Python's IDLE text editor if you are having problems getting the code to run. The text that comes after >> is the output of Python's interactive shell. Ellipses after an output ( ) mean “and so on.” If there is no >> after an example, it means either the program doesn't produce any output or I am explaining a concept, and the output is not important. Anything in a paragraph in monospaced font is some form of code or code output or programming jargon.

      Installing Python

      To follow the examples in this book, you need to have Python version 3 installed. You can download Python for Windows and Unix at http://python.org/downloads . If you are on Ubuntu, Python 3 comes installed by default. Make sure you download Python 3, not Python 2. Some of the examples in this book will not work if you are using Python 2.

      Python is available for 32-bit and 64-bit computers. If you purchased your computer after 2007, it is most likely a 64-bit computer. If you aren't sure, an Internet search should help you figure it out.

      If you are on Windows or a Mac, download the 32- or 64-bit version of Python, open the file, and follow the instructions. You can also visit http://theselftaughtprogrammer.io/installpython for videos explaining how to install Python on each operating system.

      Troubleshooting

      Challenges

      Many of the chapters in this book end with a coding challenge for you to solve. These challenges are meant to test your understanding of the material, make you a better programmer, and help prepare you for a technical interview. You can find the solutions to all of the challenges in this book on GitHub at https://github.com/calthoff/tstcs_challenge_solutions .

      As you are reading this book and solving the challenges, I encourage you to share your wins with the self-taught community by using #selftaughtcoder on Twitter. Whenever you feel like you are making exciting progress on your journey learning to code, send a motivational tweet using #selftaughtcoder so other people in the community can get motivated by your progress. Feel free to also tag me: @coryalthoff .

      There is one last thing I want to cover before you dive into learning computer science. If you are reading this book, you've already taught yourself to program. As you know, the most challenging part about picking up a new skill like programming isn't the difficulty of the material: it is sticking with it. Sticking with learning new things is something I struggled with for years until I finally learned a trick that I would like to share with you, called Don't Break the Chain.

      Jerry Seinfeld invented Don't Break the Chain. He came up with it when he was crafting his first stand-up comedy routine. First, he hung a calendar up in his room. Then, if he wrote a joke at the end of each day, he gave himself a red X (I like the idea of green check marks better) on the calendar for that day. That's it. That is the entire trick, and it is incredibly powerful.

      Once you start a chain (two or more green check marks in a row), you will not want to break it. Two green check marks in a row become five green check marks in a row. Then 10. Then 20. The longer your streak gets, the harder it will be for you to break it. Imagine it is the end of the month, and you are looking at your calendar. You have 29 green check marks. You need only one more for a perfect month. There is no way you won't accomplish your task that day. Or as Jerry Seinfeld describes it:

      After a few days, you'll have a chain. Just keep at it, and the chain will grow longer every day. You'll like seeing that chain, especially when you get a few weeks under your belt. Your only job next is to not break the chain.

      Technical books are hard to get through. I've lost count of how many I've abandoned partway through. I tried to make this book as fun and easy to read as possible, but to give yourself extra insurance, try using Don't Break the Chain to ensure you finish this book. I also partnered with monday.com to create a free Self-Taught Programmer template and app that keeps track of your coding streaks for you. You can try it at https://hey.monday.com/CoryAlthoff .

      With that said, are you ready to study computer science?

      Let's get started!

       Whether you want to uncover the secrets of the universe or you just want to pursue a career in the 21st century, basic computer programming is an essential skill to learn.

      Stephen Hawking

      An algorithm is a sequence of steps that solves a problem. For example, one algorithm for making scrambled eggs is to crack three eggs over a bowl, whisk them, pour them into a pan, heat the pan on a stove, stir them, and remove them from the pan once they are no longer runny. This section of the book is all about algorithms. You will learn algorithms you can use to solve problems such as finding prime numbers. You will also learn how to write a new, elegant type of algorithm and how to search and sort data.

      In this chapter, you will learn how to compare two algorithms to help you analyze them. It is important for a programmer to understand why one algorithm may be better than another because programmers spend most of their time writing algorithms and deciding what data structures to use with them. If you have no idea why you СКАЧАТЬ