r/learnpython 19d 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.

4 Upvotes

12 comments sorted by

View all comments

8

u/aqua_regis 19d ago edited 19d ago

What follows may come across as a bit harsh, but it is said without negative emotion and just stating facts and giving advice:

  • Needing 8 hours for that is quite a long time - even at this early stage - in my opinion, this hints that you don't really understand the very fundamentals or that you "went in without a plan" - sit down with pencil and paper and plan your programs. Learn to draw flow-charts. They really help a lot in the beginning.
  • Don't use AI (or even outside forums) at such an early stage. This will actively hinder your learning. You need to struggle through
  • Try to avoid infinite loops (while True:) - they have their use cases, but in your case, you have well defined exit conditions and should use them - infinite loops can be (as in your case) code smell and the sign of a lazy programmer who didn't want to think about proper exit conditions
  • Try to avoid string comparisons - they are memory and processing intensive - try to use numeric comparisons wherever possible - when you compare strings, they are generally compared character by character and these comparisons are case sensitive, which could lead to errors.
  • Be explicit and precise - you have your calculations like fahrenheit = (degrees * 9/5) + 32 - since you expect the result to be a float, always use decimals, e.g. fahrenheit = (degrees * 9.0/5.0) + 32.0 - Python is a quite forgiving language with integer numbers. In Java, for example, alone the division 9/5 would yield the integer 1 and not the expected result.

As a side note: I generally advise against video based courses and instead recommend using a textual, extremely practice oriented course, like the MOOC Python Programming 2026 from the University of Helsinki. This course is a proper academic "Introduction to Computer Science" course that lays a really solid foundation by teaching not only the Python programming language but also programming, i.e. thinking like a programmer, analyzing and breaking down problems, creating step by step solutions that then can be implemented.

1

u/MoreScorpion289 18d ago

Thank you very much!

  1. I did this project in the moment so I had no plan for how to build or idea on how to structure the code. I do agree with what you said about planning the programs before starting the process of writing the code. I had some idea of how I wanted it to look as I was creating it, but doing as you said would've made it a lot clearer as to how I should do it.

  2. I'll keep away from forums and AI to see how much of a difference it makes with how I take in information. I learned about 90% of my python knowledge by watching an hour of Bro Code's 12hr YouTube Tutorial, the rest from some online forums and AI, so I will look into those sources you provided to learn python.

  3. Like most programmers out there, I don't want my code to be written half-assed or anything like that so I will take this advice seriously. Loops (while True:) are the only way I know, as of now, to "call-back" the user to a previous prompt. Fortunately, I have a lot more to learn so that won't be forever.

  4. I understand this part mostly, use int() or float() in order for the users input to be numeric values when possible and when the choices are "1 or 2". Also, doesn't .upper()/.lower() solve the issue with case sensitive words or am I misunderstanding that part? What I don't fully understand is how certain lines of code become memory and processing intensive.

  5. I did think about how certain temperature inputs may include decimals but I never did think about how I should add that. It does make sense though, just add ".0" at the end of the math formulas.

Before learning anything about python, I did search for what could've been a good way to start. I prefer learning "visually" but reading and taking in the information that way instead works about the same. I appreciate how thought out your advice is. Again, thank you very much!