loading...

Python coders, what are some exercises/activities that help you quickly get better at the basic coding?

github logo ・1 min read

While I am primarily trained in JavaScript, I also want to double with Python, since it seems to be a very interesting language in and of itself. The problem is I barely know where to start, if at all. I'd like to know how to get started coding in a completely different language.

twitter logo DISCUSS (21)
markdown guide
 

Learning things via "exercises", tutorials, etc. is always a very bad idea. Pick a project idea that you're excited for, which is of reasonable scale, and go ahead and implement it.

Then google for Python best practices, Zen of Python, PEP-8, black, awesome-python, and so on to learn more about details, and fix your project.

Best way to learn is to want to build something. If you don't have anything in mind that you'd want to build with Python, why would you force yourself to "learn" it?

 

how are exercises a bad idea? how is he expected to do something if he doesn't know how? doing exercises can be considered as mini projects... I for one, grabbed the basics from tutorials on sololearn or codecademy and I've learned the more intricate details by doing exercises on codewars, excercism and others, these are very helpful since every time you complete an exercise you get to see how others approached it and I can tell you I always discovered something new this way...

 

Because they are not interesting, they are not useful, and there's no long term benefit to them - you will forget all the useless details you're "practicing" before you will find a use for them.

How do you find out how to cut logs? How do you find out how to use your dish washer? How does anyone learn anything they're interested in? Figure out the bare basics and start doing it. Piano lessons will be a lot more interesting when you start with a simple tune than by reading pure theory and pressing on keys to test out the theories.

How do you find out how to start a project? Google "language boilerplate" etc., take something simple and copy & paste into your own project structure and start changing things. Most languages (esp. Python), are clear enough for the most parts that you can understand the code just by seeing it.

python-boilerplate.com/py3+executable

How do you find out how to e.g. build a web API in a new language? Google "language web framework", etc., look at the options, pick something that looks like something you could work with and try it out.

wiki.python.org/moin/WebFrameworks/

Intricate details are useless to learn and focus on until you have a need for them. What IS important is to focus on your ability to deliver the things you want to work on, to keep your precious energy focused on the project.

Once you have your base in place, start figuring out each step separately. Ok, so you have a request incoming to your web api, how do you parse the JSON in it? How do you respond with JSON? How do you connect to a database, or create requests to a 3rd party API? All simple questions you can get a simple answer to and still produce value on something interesting. Soon you will find yourself having to google less and less, while delivering more and more.

Once you are able to start delivering, you can then start looking into best practices and so on. Knowing how print() works and about it's endl or file arguments is useless for delivering value.

yes, yes, doing projects is good for experience but as a newbie, how do you pick a project to just do? lets assume you fork a repo, you look through the code and you try to replicate it, next thing you're asking why they did this, what are these stuff, how does that work etc. You'll find yourself with tens of tabs of stack overflow open, each question leading to more questions... the project might've not even been that hard, it could've been done in a few hours if you had more knowledge. You might lose interest and give up even though you might've learned a few stuff its not enough to complete the project... Like I said, exercises can be considered as mini projects since you tackle one question at a time, you'll feel more accomplished and most likely you'll learn more things... once you have a better grasp of things you can try a project or why not maybe even contribute to an existing one...

Why on earth would your first step be to fork a repo or start copying other people's work? The problem has already been solved, you can't possibly be all that excited to just re-do the same thing someone else already did, can you?

If you have no idea what you want to write in Python, maybe you don't have a good enough reason to learn Python.

take something simple and copy & paste into your own project
sounds familiar?
even if you start from scratch you can get lost depending on the goals you have set for your project... maybe even more so than forking an existing project

What an ignorant attempt to take a completely unrelated comment out of context.

Taking a BOILERPLATE as a working base, e.g. the one I linked to, which tend to be a few tens of lines at most, is significantly different from forking an existing project or copying someone else's work.

Anyway this discussion is pointless, since your argument boils down to:

If you have no idea what you want to write in Python, maybe you don't have a good enough reason to learn Python.

sheesh... what's with the attitude? someone mature wouldn't behave like that... and how is that my argument?

That's not your argument, it's the answer to your argument.

 

Best way to learn is to want to build something.

I strongly agree with this sentiment based on personal experience.

Do you know how many times I tried to get into frontend dev with tutorial articles, random exercises, and, regrettably, paid courses?

None of those endeavors are interesting enough to be memorable or practical—yet those are the two most important things when it comes to gaining valuable experience with dev!

 

Learning a different language is not so difficult. You just need to know its grammar, syntax, how to write loops, if/else conditions etc.

For example: Python uses indentation (white space) instead of curly braces (like in JavaScript, Java, C/C++) in loops, conditional statements etc.

Go through this 5 part series by Valentino Gagliardi

or w3schools' Python tutorial

You might want to go to Corey Schafer's YouTube Channel. He has amazing videos for newbies.

You may also like this (I highly recommend) playlist and this playlist for some basics like function, tuples etc.

If you want to dive into the basics of Programming. Here's CS50 course on edX.

 

I would suggest you to first do something little and fun.
Like, learn to make games with PyGame
inventwithpython.com/makinggames.pdf

Or read 'Automate the boring stuff with Python'
automatetheboringstuff.com/

Once that, to get bit more serious, you can learn and implement "Data Structures and Algorithms in Python" either through book/Udemy course.

 

For Python specifically, I'd actually suggest you start with the official tutorial in the documentation. You can probably start on the second chapter as the first is largely just a sales pitch to get you to learn Python, but the tutorial itself does a really good job of covering the basic syntax and building upon things step by step.

A decent number of newer languages that have well established ecosystems also provide some 'official' tutorial that you can work from. As a general rule, reading through them may be a bit boring if you already know how to code, but it gives you a solid understanding of the way the people who develop the language itself intend it to be used, which is a valuable thing to have.

As an alternative, if you're confident in your coding skills in an abstract sense, you could read through the language reference and then just start coding, though that may get a bit technical for your tastes.

Python has very good documentation compared to some languages, and an excellent ecosystem surrounding it. There are good third-party tutorials, but the documentation is good enough that they're quite often overkill if you already have solid programming experience.

 

If you have experience already programming in one language, picking up a new language is usually pretty easy. There are 2 things to focus on.

  1. Identify your existing skills and knowledge, so you can apply it to the new language.
  2. Learn the language syntax, and potentially new concepts the language provides

So if you already can build UI's using JS, building UI's using Python becomes less about "how do I build UI's" and more about "how do I build UI's in Python". (I'd recommend looking into something like tkinter for building Python GUI apps)

Python has very simple and straight forward syntax, while still being a very flexible language. Starting with learning the language syntax starts with reading the [official docs] about the language. (docs.python.org/3.8/reference/inde...)

I'd recommend looking into popular "use-cases" for Python to see why its used as such. Probably the biggest reason for Python's recent rise in popularity is due to its use in data science fields, and scripting. The language's simple syntax allows it to be learned even by non-programmers easily.

Python is one of my personal favorite languages. Its probably the first language I learned that I just liked. I don't use it today as much as I like (I use TypeScript for work), but I feel like its one of those languages that is very easy to pick up and go as a secondary language due to its simplicity.

 

I think the best place to start is just to write something you want to write. Programming isn't "perfected" through practice. While a tutorial may help slightly, I think it's just better to try and build something.

Python is an ENORMOUS language. That means that, when it comes to programming projects, there's practically an infinite number of things you can do. Want to build a program to predict home prices using linear regression? Want to compile a bunch of astronomical data into a nice graph? Want to create a web-server that runs super-fast? Literally anything can be made with Python.

Good Luck!!!

 

When I started out with Python I solved a load of coding problems on Codewars. So I'd suggest trying out something like codewars.com/ or hackerrank.com/ are good places to learn any new language.

After you've picked up the basics set a project and build something with it. It's always the best way to find out what you need to know.

 

Koans are a fun way of picking up a new language. If you have a reasonable amount of JS experience, you might find this reference quicker. Check the section on idioms either way - Python is generally more opinionated on what clean code looks like than other languages. exercism.io is great for practicing style, and if you're interested in practice interview questions as well, the solutions to the problems at Interview Cake are all very well written.

 

Project Euler has really helped me not only with programming/mathematic/ concepts but when learning a new language.

 

You can try codewars.com there is a lot exercises different levels. Also is good because you can compare your code with others users who solve same tasks.

 
 

When i want to learn a new language, i rewrite something in a lang i can read in the lang I'm trying to learn

Classic DEV Post from Jul 30 '19

PublishTo.Dev: Scheduling article publishing on dev.to

Corbin Callais profile image
A working beginner computer dev! I work hard on what I like, and keep a positive attitude about (most of) it.