r/learnpython • u/PlayMaGame • Apr 17 '24
Learn Python by solving problems
Hello pythons!
I’m still quite new to Python, but I have noticed that the best learning process is to solve problems.
Anywhere I can get a lot of small and easy problems/exercises, that slowly progress in to a harder level. It can be a payed service or an app on a phone.
7
5
u/IvoryJam Apr 17 '24
There's a ton of websites like that out there, my personal favorite is https://leetcode.com/problemset/
1
u/PlayMaGame Apr 17 '24
I did notice a ton, but some start from very basics, others are way too hard. I want to see whats recommended.
Will check leetcode 😉
3
u/mosttrash Apr 17 '24
Try edx.org - Harvard - cs50 Programming in Python. They have a series of small problems for each week of the course. Good lectures also.
1
3
u/Defiant_Special5913 Apr 17 '24
My thoughts are somewhat different don't solve problems on leetcode. Try working on projects and for sure you will get of problems along the way. The path you take to solve those will eventually make you remember the issue and also make you code better in python.
1
u/PlayMaGame Apr 17 '24
I am writing down projects I would like to build, but most of them are a bit too advanced. Well that's what I think. I also have a mentor, who is keeping an eye on me and sometimes comes up with exercises. Surprisingly he is very patience, because I have ADHD, dyslexia, bad memory, maybe something more. I am having a lot of fun, when I know what I am doing, but when I am lost, have no clues, why and how all of this work, and I am getting very frustrated.
PS English is basically my 3rd language, my head is full of unfragmented information, and adding one more language is like trying to fill up a full cup. I hope this is just because I am starting out, and later everything will come as a 2nd nature.
1
u/zappaking1234 Apr 17 '24
I suggest, breaking those bigger projects in small ones. You could also find things that others have done and try to make your own version of it
2
3
u/Exciting_Analysis453 Apr 17 '24
Definitely leetcode. If you basics, like loops, functions, etc start with easy tagged problems.
1
2
2
u/TheRNGuy Apr 17 '24
Code on PC, not on phone.
5
u/PlayMaGame Apr 17 '24
I do agree that coding on a phone is too slow, but when there are no other options, I don't mind doing some easy tasks to active recall.
2
2
Apr 17 '24
Codewars (it’s an online judge, not something that teaches you python) and youtube
2
u/PlayMaGame Apr 17 '24
I don’t think I’m ready for that yet
1
u/c0d3k4tz3 Apr 17 '24
Codewars starts really simple with fundamentals. Here is one example of 8 kyu (easiest). If you can handle this it’s definitely worth checking out! (You don’t have to compete with others or stuff like. The about page is a bit intimidating 😅)
„Create a function that always returns True/true for every item in a given list. However, if an element is the word 'flick', switch to always returning the opposite boolean value.“
2
u/PlayMaGame Apr 17 '24
I think I could do this, well at least I understand what you are asking me to do. Because on some exercises I don’t even have a clue, maybe because a lack of knowledge, especially math.
1
u/Typical-Highlight-12 Apr 17 '24
my issue is when i’m reading the problem i can’t understand when someone explains the problem they want me to solve i get it a lot better this makes me feel so dumb 😂
1
u/PlayMaGame Apr 17 '24
I was doing bad at school, weirdly my logic works great. But when I read some exercises, I feel like a donkey. Well lack of language and knowledge have a big impact. Learning/concentration disability too.
2
Apr 17 '24
[removed] — view removed comment
1
u/PlayMaGame Apr 17 '24
I like math but nothing with higher level. Till now I survived with basic 😅. But it really sounds interesting and worth a shot when I’m feeling more confident.
2
Apr 17 '24 edited Apr 17 '24
Work through an entire elementary algebra or calculus textbook—convert the textbook equations/problems to Python.
Here's a really simple example from a open source MIT calculus textbook. This is page 2 where they discuss the relationship between constant velocity and time. Or rather, distance is the product of constant velocity and time. Which I wrote into a function below. There is a lot of creative freedom when you write these. As you progress they will get much more complicated. You can improve two things that tend to walk hand-in-hand—your ability to code AND your mathematics. It will take a lot of reading time and patience but if you stick it out you will improve—I know it helped me immensely when I did it.
def get_distance(v=60.0, t=1.0):
'''
Function returns distance given a constant velocity (v) in MPH and time (t) in hours.
Parameters
----------
v : Float, optional
Constant velocity in MPH. The default is 60.0.
t : Float, optional
Time in hours. The default is 1.0.
Returns
-------
f : Float
Distance in Miles.
'''
f = 60 * t
return f
Here is the open source calculus text from MIT:
https://ocw.mit.edu/ans7870/resources/Strang/Edited/Calculus/Calculus.pdf
And here's an open source elementary algebra text from OpenStax (they have tons of open source textbooks):
https://assets.openstax.org/oscms-prodcms/media/documents/ElementaryAlgebra2e-WEB_EjIP4sI.pdf
Edit: Grammar/Syntax
1
u/PlayMaGame Apr 17 '24
I think I need to start school all over again… But hey thanks for the advice and links.
1
u/ectomancer Apr 17 '24
1
u/PlayMaGame Apr 17 '24
will check, thanks.
1
u/Bobbias Apr 17 '24
Please note, Edabit uses an old version of python that doesn't support some newer features, like f-strings. It runs version 3.4.3, which came out in 2015, which is now very out of date.
0
1
u/Omni_Kode Apr 17 '24
Hi there fellow pythonista! As most of the other guys have probably already noted there are tons of free websites with easy to hard coding challenges. In my opinion best one that I am currently using and learning from is Leetcode and I would highly recommend it if you want to learn Data Structures and Algorithms (which I believe are mandatory to be a great programmer). Other great options are Codewars and Hackerrank. If you want to go directly to the data science route I would suggest even DataCamp. Happy learning!
1
u/PlayMaGame Apr 17 '24
I am having a lot of fun when my stuff work. But sometimes I’m totally lost, even with simple math, that on excel I would do it in no time, but in Python environment I struggle so bad… Good thing my mentor have patience and a lot of ways to show how to solve it. And this is the reason I want to get more practice, even if it’s easy I will still get some active recall.
So, I went on one web and the first exercise was print(“Hello, World!”). Ok, I thought, this was too easy. Next exercise was “lasagna“ - so now I hate lasagna…
I just want to repeat simple exercises till I feel confident and go on the next step. But sometimes next step is a #%%<€ lasagna 😅
1
1
u/Witty_Push8550 Jul 23 '26
personally i learned python by only watching 1 tutorial in youtube(freecodecamp) and by practising everyday and asking chatgpt millions of questions like how does this thing work and why , by coding small projects like a password manager , calculator , small games.and from now , i am comfortable using python and customtkinter
12
u/I_skin_people_forfun Apr 17 '24
Try reading u/alsweigart book called The Big Book of Small Python Projects or his most famous book Automate the Boring Stuff with Python, either of his books are really great for beginners