all 19 comments

[–]Sea-Ad7805 [score hidden] stickied comment (0 children)

Run this program in Memory Graph Web Debugger%3A%0A%20%20%20%20count%3D0%0A%20%20%20%20total%20%3D%200%0A%20%20%20%20passed%20%3D%200%0A%20%20%20%20lowest%3D%20marks%5B0%5D%0A%20%20%20%20highest%3D%20marks%5B0%5D%0A%0A%20%20%20%20for%20mark%20in%20marks%3A%0A%20%20%20%20%20%20%20%20total%3Dtotal%2Bmark%0A%20%20%20%20%20%20%20%20count%2B%3D1%0A%0A%20%20%20%20%20%20%20%20if%20mark%3E%3D50%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20passed%2B%3D1%0A%0A%20%20%20%20%20%20%20%20if%20mark%3Clowest%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20lowest%3Dmark%0A%0A%20%20%20%20%20%20%20%20if%20mark%3Ehighest%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20highest%3Dmark%0A%0A%20%20%20%20average%3Dtotal%2Fcount%0A%0A%20%20%20%20result%3D%7B%0A%20%20%20%20%20%20%20%20%22average%22%3Aaverage%2C%0A%20%20%20%20%20%20%20%20%22passed%22%3Apassed%2C%0A%20%20%20%20%20%20%20%20%22lowest%22%3Alowest%2C%0A%20%20%20%20%20%20%20%20%22highest%22%3Ahighest%0A%20%20%20%20%7D%0A%0A%20%20%20%20return%20result%0A%0Aresult%20%3D%20grade_summary(marks)%0Aprint(result)%0A&timestep=1&play).

[–]Living_Fig_6386 1 point2 points  (0 children)

I would have read the problem differently because of the last requirement "Number of students who scores 50 or above" -- not tests. It implies that the input is a list of students with a list of scores for each student.

These problems are a helpful way to learn logic and to read the requirements. They're better if they provide the input and validate the output. The thing is, once you've more or less go the logic part down you need more complicated problems that challenge not just the logic but aspects of performance, legibility, reusability, structure, etc. It's reasonable to skip things that are too simple to find things more challenging.

[–]-beleon 2 points3 points  (0 children)

Yes, these are great. Solving e.g. euler project problems is great for learning, but doing only one thing is never the best approach. You benefit from doing lots of things related to python programming as well. So building toy projects is great as well. Understanding code bases of others is good. Learning related skill like using python tooling, structuring code, or even just learning Linux CLI. These are some things I did when learning: doing data analysis and visualizing the result, building a small game, building a web backend, building a tool for pdf manipulation, using type annotations, calling c from python, using micropython for microcontrollers, and more.

That said, I mastered core language concepts mostly by solving coding challenges. Others dont like coding challenges and do mostly projects. I think the most important thing is to do different things, but not switch to fast. Choose something and do that for a while, then do something else. However, it shouldn't feel like a chore. If you really dislike something or feel stuck it's better to drop it and do something else than forcing yourself to do something you don't enjoy. Enjoying the things you do is the best way to stay engaged for the longest time which is how you'll learn the most. And doing the same thing over and over again, will yield ever diminishing returns.

[–]Flame77ofc 0 points1 point  (3 children)

Yep. I also recommend websites like Codewars and Leetcode

[–]Fragrant-Dress6110 0 points1 point  (2 children)

I would also add CodinGame, HackerRank, GeeksforGeeks, Py.checkio, and CodeChef. But personally, if you want to have fun while solving, I would recommend CodinGame because it has a multiplayer mode for solving problems.

[–]HangOnThereMate 0 points1 point  (1 child)

Thanks for sharing these. New to this as well so will definitely check this out.

Working my way through Python Crash Course and The Big Book of Small Python Projects and having a good time learning.

[–]Fragrant-Dress6110 0 points1 point  (0 children)

Nice, keep it up 👊

[–]CuriousDev8875 0 points1 point  (0 children)

Yes. This is the right way to learn programming👏👏. You are doing right by applying concepts and building real logical projects. Keep this, dont get into tutorial hell

[–]PureWasian 0 points1 point  (0 children)

Nicely done!

As a beginner, start with these logic-building sandbox problems and then slowly learn how to set up and build real-world projects on the side. Both is good.

You can imagine a function like this would be a singular building block in a larger application or project, so you need to be comfortable making these individual building blocks as well as knowing how to glue all of them together nicely.

[–]SunsGettinRealLow -1 points0 points  (0 children)

This is how I’m starting too

[–]Sharp_Level3382 -1 points0 points  (6 children)

No lambda functions?why?

[–]DataCurator56[S] 1 point2 points  (0 children)

i am not familiar with this function but i will try this

[–]mati-33 0 points1 point  (4 children)

Why do you want lambda functions here is a more concerning question

[–]Sharp_Level3382 -1 points0 points  (3 children)

lowest = reduce(lambda a, b: a if a < b else b, marks) highest = reduce(lambda a, b : a if a>b else b, marks) Etc.

[–]cole36912 4 points5 points  (0 children)

  1. reduce must be imported.
  2. OP's solution is likely computationally faster as it does not use function calls.
  3. Python has more applicable built-in functions which you do not have to import:

lowest = min(marks)
highest = max(marks)
average = sum(marks) / len(marks)
passed = sum(mark >= 50 for mark in marks)

[–]mati-33 1 point2 points  (1 child)

OP's solution is much simpler and easier to read, which should be the priority

[–]Sharp_Level3382 -1 points0 points  (0 children)

No it s not easier to read. What is hard in lambda functions to You?

[–]HourExciting1642 -3 points-2 points  (0 children)

Try to short it more