Do you want to learn Python but you’re unsure where to start? develop spoke to Mike Driscoll, Python pro and computer programming author, for his tips on learning Python. We know that when you start to learn a new programming language it can be overwhelming - there’s so many articles, resources and communities to talk to, and learn from.
develop asked Mike for his top 5 tips on learning Python from zero and we think these tips will help any beginner to start their journey.
Learn about introspection
Python provides tools that you use to learn Python! For example, the dir() function will tell you about a module or object's attributes and functions. You can use the help() function to get more details about functions or modules, such as what their arguments are. The type() function can be helpful in debugging because it tells you what type an object is.
Learn the basic data types
Python has strings, ints, floats, dictionaries, sets, lists, and tuples. Once you understand how these work and what they can contain, you have the building blocks to build anything. Your only limit is your imagination!
Use an IDE that has syntax highlighting and autocomplete
Learn what syntax highlighting means and you'll quickly learn what Python's keywords and built-in functions are. This will help you immensely. Autocomplete is great for when you create long variable or function names. You don't have to type it out yourself if you have autocomplete.
Learn how to debug
You can start with print() functions or by using logs. But eventually, you will need to learn how to set breakpoints and step through a debugger. This is a great way to learn how a programme works. You can learn how variables change in a loop. You'll be able to stop the code right before an exception is thrown and inspect your code's state to determine why the exception will happen.
Don't give up!
Practice is what makes you a better programmer. I don't know all the terminology even after completing four years of university! You just need to practice and try new things. Take a break and come back to your project. You'll be surprised how a break is often all you need to solve that 'impossible' problem!