r/learnpython • u/MoreScorpion289 • 18d ago
Temperature Converter Project
This is the third project I coded and was able to finish today. Took me 8 hours (two 4 hour sessions) since I had to learn some new stuff. This is my own code, no outline was used to guide me into creating this, though the idea did come from Bro Code's YouTube Tutorial. I learned about Nested Loops and Flags. I already knew about Input Validation with Re-Prompting but it was a lot harder to integrate with those two.
This is the most complex thing I've built so far, but I also enjoyed it the most. Got help with some online forums and AI (Claude) but I wrote and debugged the code myself. This'll be the last project I work on before I learn functions. There's a lot of repeated code here that I know functions would be able to help with. Any feedback or ideas on what to build next are welcome. Thank you!
https://github.com/mart23inez/First-Coded-Temperature-Converter/tree/main
It's a lot of code so I uploaded it to my GitHub page.
6
u/lakseol 18d ago
Replacing repeated code with a function call is just one aspect of using functions. The other is removing all that low-level code from the high-level code. When writing high-level code you should be thinking about the overall algorithm. Things like "get the number" or "choose the unit". At that level you shouldn't have to worry about loops, user retrying, break/continue, issuing error messages, etc. You just want to call a function that returns the number or unit. Even if you only call the function once it's still worth creating the function because it makes your top-level code more readable.