Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Python Fix Code Resources

Hello all,

I know there are tonnes of good Python tutorials in the thread, (i have looked through most of them, i think they are class), however i just finished an exercise whereby i was given a .py file that had a load of broken code in it. Only basic stuff, symbols missing, misspelling, definitions not setup correctly... You get the picture, errors that will stop the code from running. After i fixed all the damaged code and played it through, i realized how educational it was. And i found myself going over code and fixing bits until it was use able and working.

I had a look on the internet to see if there was anywhere that might provide similar exercises, essentially just broken code:- as a educational resource. Sadly found nowhere.

If anyone knows any sites that offer something like this or has any ideas on how i can emulate this, or something similar id love to hear about it. I know there are some amazing tutorials already here, but i found that this particular method really helped me to engage and learn/polish my skills in certain areas.

And for anyone just starting off coding like myself, i'd advise trying to do that whenever possible, its so refreshing to fix code and of course that sense of achievement when everything is working again is just amazing!

Hope everyone's staying safe and thanks to anyone who gets back to me on this.

-Harley
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"
Unfortunately broken code as a teaching tool isn't really a thing in my experience. Honestly most IDE's now adays can fix most "broken" things. The real thing is updating badly maintained or poorly written code, as it entails usually rewriting large chunks of codes or just ending up redesigning/engineering the entire thing over anyways. That's good that you feel confident. If that is the case I would recommend undertaking some projects that really challenge you. Right now I am creating an app/UI to solve a problem I run into with my GF using the Kivy framework.

Also, going back and reading/reviewing your own code as well as reading other people's code is a great way to stay sharp aside from doing your own projects. As long as you know what variables, data structures/objects, basic logical statements you should be able to fit broken code. Good design is what is hard for me. I am in school right now for software engineering. All of the intro classes, which I am passed have been in Python.

Try getting into some data structures and algorithms questions by trying out https://leetcode.com/ problems. This has a lot of questions that major tech companies will ask as interview questions.
[Image: Iu0EfTL.gif]
Thats fair enough, i suppose it depends on the learning method too. I have just followed tutorials and bought some books. I have had some nice guidance from HF too which has been really nice. I suppose, IDE's are pretty clever in comparison to 20 years ago. I think going back to things i've already completed like little projects and code from weeks ago and either revamping it or completely rewriting it is a good shout. That sounds pretty cool. Kivy framework is suppose to be amazing. Really looking forward to learning more and progressing in this. I've been super motivated and really encouraged by certain people.

Yes, im at that stage now where i can look at code and see whats missing, or why its not working. At the start i looked at it and had no clue what i was even looking at. Now i see it in a completely different way its nuts. Thank you for your feedback on this, i appreciate it. I will have a look at that website seems pretty interesting too. those practice questions will be good for real world encounters for interviewers etc.

Thanks for the help Lindros!
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"
Why learn to fix other people's code? If you are coding projects that are past "hello world" etc - then you'll have enough of your own broken code to fix through as you write your own code. For example, pick a topic like a web scraper - I can promise you'll end up finding errors along the way between parsing, network errors, etc.
(May 19, 2020 01:35 PM)HSGM Wrote:  Why learn to fix other people's code? If you are coding projects that are past "hello world" etc - then you'll have enough of your own broken code to fix through as you write your own code. For example, pick a topic like a web scraper - I can promise you'll end up finding errors along the way between parsing, network errors, etc.

Hi HSGM

Thank you - You are correct actually, i've done about 20 .py files during the start of my learning phase and i can just go and revisit them. Thank you for replying to this. its important for me to be educated by others on stuff like this. I enjoy web scraping, i will start to delve into that a bit more in my freestyle coding time.

Harley
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"
(May 19, 2020 02:56 AM)Harley Quinn Wrote:  Thats fair enough, i suppose it depends on the learning method too. I have just followed tutorials and bought some books. I have had some nice guidance from HF too which has been really nice. I suppose, IDE's are pretty clever in comparison to 20 years ago. I think going back to things i've already completed like little projects and code from weeks ago and either revamping it or completely rewriting it is a good shout. That sounds pretty cool. Kivy framework is suppose to be amazing. Really looking forward to learning more and progressing in this. I've been super motivated and really encouraged by certain people.

Yes, im at that stage now where i can look at code and see whats missing, or why its not working. At the start i looked at it and had no clue what i was even looking at. Now i see it in a completely different way its nuts. Thank you for your feedback on this, i appreciate it. I will have a look at that website seems pretty interesting too. those practice questions will be good for real world encounters for interviewers etc.

Thanks for the help Lindros!

No problem! Have you gotten into object oriented programming and large scale projects yet? What is some cool projects you have done?
[Image: Iu0EfTL.gif]
Not yet. I'm just starting to earn more about OOP so looking forward to that! Most things I've built at the moment have relied on me using the internet for help so I've not made anything from start to finish on my own. But I'll get there (:
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"
(May 20, 2020 01:34 AM)Harley Quinn Wrote:  Not yet. I'm just starting to earn more about OOP so looking forward to that! Most things I've built at the moment have relied on me using the internet for help so I've not made anything from start to finish on my own. But I'll get there (:

Awesome! I can give you some beginner projects to do that I had to do for school if you wanted.
[Image: Iu0EfTL.gif]
(May 20, 2020 02:13 AM)Lindros Wrote:  Awesome! I can give you some beginner projects to do that I had to do for school if you wanted.

Sounds good to me Lindros, i'd appreciate that.

Harley
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"
(May 20, 2020 03:16 AM)Harley Quinn Wrote:  Sounds good to me Lindros, i'd appreciate that.

Harley

Alright, here is one of the more difficult project in CS 1400, the fundamentals of programming/intro CS course at my school.

Put this data in a CSV or Text file

Spoiler (Click to View)

Now, write a program that can output the minimum and maximum stock prices (along with their corresponding dates), as well as the average and standard deviation of the price for each stock.

The output would look like this if done correctly..

OUTPUT:
Spoiler (Click to View)

If this one is too difficult or easy, let me know. I have ones that are easier and ones that are harder.
You'll have to read the data in from the file, parse it into an adequate data structure to complete this. It is a very good exercise.

If you need my help or want to see my code for it, you can.
[Image: Iu0EfTL.gif]
(May 20, 2020 03:07 PM)Lindros Wrote:  Alright, here is one of the more difficult project in CS 1400, the fundamentals of programming/intro CS course at my school.

Put this data in a CSV or Text file

Spoiler (Click to View)

Now, write a program that can output the minimum and maximum stock prices (along with their corresponding dates), as well as the average and standard deviation of the price for each stock.

The output would look like this if done correctly..

OUTPUT:
Spoiler (Click to View)

If this one is too difficult or easy, let me know. I have ones that are easier and ones that are harder.
You'll have to read the data in from the file, parse it into an adequate data structure to complete this. It is a very good exercise.

If you need my help or want to see my code for it, you can.

Appreciate my man. I'll get back to you with how it goes!

Thank you

Harley
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"
(May 18, 2020 11:45 PM)Lindros Wrote:  Unfortunately broken code as a teaching tool isn't really a thing in my experience. Honestly most IDE's now adays can fix most "broken" things. The real thing is updating badly maintained or poorly written code, as it entails usually rewriting large chunks of codes or just ending up redesigning/engineering the entire thing over anyways. That's good that you feel confident. If that is the case I would recommend undertaking some projects that really challenge you. Right now I am creating an app/UI to solve a problem I run into with my GF using the Kivy framework.

Also, going back and reading/reviewing your own code as well as reading other people's code is a great way to stay sharp aside from doing your own projects. As long as you know what variables, data structures/objects, basic logical statements you should be able to fit broken code. Good design is what is hard for me. I am in school right now for software engineering. All of the intro classes, which I am passed have been in Python.

Try getting into some data structures and algorithms questions by trying out https://leetcode.com/ problems. This has a lot of questions that major tech companies will ask as interview questions.

Hey man!

So after a few months i have actually got to the point where i can create useful programs and scrips using Python. I'm big on web scraping because in Python its such a powerful feature!

I ran into Kivy on my Python Journey and created a handful of functional apps, from game themed hints, tips and tricks to a credential vault with a login system, to a GeoIP locator with Mapview that would take you to the Lon/Lat of the IP that you typed in (to a certain degree of accuracy). I found them all really fun to make, if not challenging at times! I was wondering what sort of things you made and if you had any interesting ideas using the Kivy framework! One of the most challenging things was getting Buildozer installed and working on my Linux VM to create and deploy APKs but got that sorted after a few days and deployment became a breeze!

Hope to hear back from you
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"
(Aug 20, 2020 11:08 PM)Harley Quinn Wrote:  Hey man!

So after a few months i have actually got to the point where i can create useful programs and scrips using Python. I'm big on web scraping because in Python its such a powerful feature!

I ran into Kivy on my Python Journey and created a handful of functional apps, from game themed hints, tips and tricks to a credential vault with a login system, to a GeoIP locator with Mapview that would take you to the Lon/Lat of the IP that you typed in (to a certain degree of accuracy). I found them all really fun to make, if not challenging at times! I was wondering what sort of things you made and if you had any interesting ideas using the Kivy framework! One of the most challenging things was getting Buildozer installed and working on my Linux VM to create and deploy APKs but got that sorted after a few days and deployment became a breeze!

Hope to hear back from you

That's awesome! Good to hear.

Yes I like kivy a lot. I'm made basic stuff with it like a restaurant randomizer and currently trying to do a (all in one) social media scraper.

Sounds like you have come a long way with Python's building blocks. You use the kivy language right? (Kivy's styling language in .kv file extension.) It makes things pretty easy!

What has been your primary resource?
[Image: Iu0EfTL.gif]
(Aug 20, 2020 11:44 PM)Lindros Wrote:  That's awesome! Good to hear.

Yes I like kivy a lot. I'm made basic stuff with it like a restaurant randomizer and currently trying to do a (all in one) social media scraper.

Sounds like you have come a long way with Python's building blocks. You use the kivy language right? (Kivy's styling language in .kv file extension.) It makes things pretty easy!

What has been your primary resource?

Hey man!

Amazing, that sounds awesome!

Things with Kivy can look awesome. I use photoshop to create all ImageButtons for example and like to do all my graphics that way! It makes things really personal but can sometimes take a while! Yes i use the .kv language too and found it to be pretty awesome after learning how to use it. Took me a while to grasp different properties and what they can be used with, but there now. I mostly used the online documentation, i got into it by watching some TechWithTim vids he barely covered anything but i learnt everything he had to offer and built on that! Its interesting actually, i ended up using the Builder and having the KV language inside my .py file using Builder.LoadString(""" KV LANG HERE """) in the end and made things easier especially when compiling for APK using Buildozer. But yeah, mainly the documentation, and youtube but there isnt really anything that covers the more advanced stuff its mostly basics online thus far. So i guess trial and error for me. Its getting the balance of .py widgets and .kv widgets too!

Sorry it took me so long to reply, not been very active recently due to something im working on, but glad to hear your busy!
"Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime"
By reading bad code all of the time, you're also essentially practicing bad coding habits because you start to forget what good code looks like.

Can you improve by reading and fixing broken code? Sure, but how can you make something amazing if you've never seen amazing code? You're better off reading good code from highly rated Python libraries on GitHub and then only fixing bugs in your own personal little projects.

If you want to catch more errors, maybe start using function annotations and type annotations. If you use VSCode, get Pyright and a strict code linter that alerts you whenever you're not following PEP-8. Alternatively, you can use Pycharm which has most a lot more built-in error checking.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by rammstein091Feb 8, 2024 11:44 PM 11 277 Feb 8, 2024 11:44 PM
Last Post: peolsolutions
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by mikehackMay 9, 2022 11:12 AM 2 151 May 9, 2022 11:12 AM
Last Post: mikehack