6th Jul 2024, 8:33 AM
Edwin
7 Answers
+ 2
Seems fine to me. What about if a user doesn't enter a number?
6th Jul 2024, 9:02 AM
Ausgrindtube
Ausgrindtube - avatar
+ 4
Edwin , no errors but just some comments for some basic improvements. > you can take the 2 input values just after the program has started. you can use them in *all* your arithmetical operations. > you could also do the conversion from string to float direct in combination with the input() function. > the output with print() function can be done without conversion to string. see (reworked) sample: https://sololearn.com/compiler-playground/cGb7lb8o2o1X/?ref=app
6th Jul 2024, 12:09 PM
Lothar
Lothar - avatar
+ 4
John , thanks for giving your comments to my post. as I have already said, my comments are intended for further use. we should also take into account that the person asking the question is probably still in a beginner phase. my intend was to point out things like the print() output.instead of using: print("Ans: " + str(sum)) i recommended this improvement: (this is basic knowledge that should be mastered before working on anything more advanced.) print("Addition:", sum) it avoids using string conversion and concatenation. you are absolutely right that you can do this with an f-string, but that requires a bit more experience.
8th Jul 2024, 3:23 PM
Lothar
Lothar - avatar
+ 3
Lothar I understand what you’re saying. I understand your intention also. It would be a good inprovement and I get it. It’s just I was looking out for him, most likely because I didnt want him to fall trap into using that strategy as a main method as it can become horrible to manuever with bigger ints or floats or even text. Looking back, my previous comment was a tad aggresive. Apologies and happy coding, John
8th Jul 2024, 9:03 PM
[Astro E] 王李
[Astro E] 王李 - avatar
+ 1
Reason i didnt do this is because i wanted people to be a ble to add differeent numbers as i ahd originally developed this on replit and not on sololearn i didnt realise that tou give input first
7th Jul 2024, 2:48 PM
Edwin
0
Edwin, Seems fine. I would not recommend running it on sololearn, do it on a more suitable place.
7th Jul 2024, 5:23 PM
[Astro E] 王李
[Astro E] 王李 - avatar
0
Lothar, His code is fine, he doesnt need to include things like this: print("Division:", division) And if he were to do it, he should do it like this Print(f”Division: {division}”) Its an f string if your wondering, much easier and much more efficient than doing that, which would later cause trouble with bigger intergers and more strings etc. Edwin, cheers.
7th Jul 2024, 5:29 PM
[Astro E] 王李
[Astro E] 王李 - avatar