r/PythonLearning • u/Acceptable_Simple877 • Aug 18 '25
Day 2 - made this
Made this by myself (for the most part, made dumb errors here and there) after following Bro Codes Python guide for a bit.
5
u/Worried-Ad6403 Aug 18 '25
Good base. Now you can take this to the next level by adding these:
Exception handling ( what if user enter incorrect input, your program will crash. Use try except )
How do you force the user to provide a valid input always( Hint: Try except and while loop and break )
How can you keep this program running infinitely unless the user wants to exit ( Use while loop and break )
You have to start developing the habit of making your code rock solid and crash proof. Always handle the edge cases. Always ask, during execution what could cause the program to crash. Always handle those edge cases. Then with this mindset, you’ll bring quality work to future bigger projects.
2
u/WhiteHeadbanger Aug 18 '25
Slow down, this is day 2. OP doesn't even know loops or functions yet, not even accounting for classes (like Excepttion classes)
1
u/Acceptable_Simple877 Aug 18 '25
Yea I have to Do loops still
2
u/WhiteHeadbanger Aug 18 '25
Take it slow, nobody is rushing you. Have a good journey and keep up the excellent work!
1
2
u/EasyTelevision6741 Aug 18 '25 edited Aug 18 '25
Just a minor thing that's bugging me here. His program will not crash if they enter an incorrect input. Unless of course we mean Ctrl C or similar.
It will simply print the else statement which I keep forgetting even though I've looked twice (damn reddit app and ADHD are such a shit combo).
Normally I wouldn't be asisine like this but feels important to use correct terminology so early on.
Edited to add: nevermind I totally whiffed and missed the internals of each case I was just seeing the outer case statement and not even reading inside them for some damn reason.
1
u/Sebasandrade00 Aug 18 '25
I think what he means is what happens if the user enters a string for the width/height inputs the program will crash
1
u/EasyTelevision6741 Aug 18 '25
Oh shit! Good call not sure how I blanked on those. That's why I should avoid trying to be helpful while half asleep.
0
Aug 19 '25
[removed] — view removed comment
2
u/Worried-Ad6403 Aug 19 '25
If the server crashes because of one user, no user can access it and it’ll cause disruption for all users. Never let it crash.
0
1
u/psuedo_nombre Aug 22 '25
Yeah but we have to deal with Karen and any other user who breaks things in odd ways. So it is better practice to throughly check and sanitize any user input
1
Aug 22 '25
[removed] — view removed comment
0
u/psuedo_nombre Aug 29 '25
Idk, like i get your point but its better to anticipate breaks over assuming its run right and just prevent users from providing broken input if possible
2
u/TacticalGooseLord Aug 18 '25
I am new too! I will try this, Ty for the idea. Any tips from the professional ppl to make it better ?
2
u/EasyTelevision6741 Aug 18 '25
This is like the textbook example of Object oriented programing (OOP) and polymorphism. Thats probably a steep jump up but Id keep those in mind and work towards then. Once you learn about OOP but before polymorphism see if you can see how classes would help you in this example. Sounds like a good exercise to me.
2
1
u/psuedo_nombre Aug 22 '25
Great start! Next try to collapse down into some common functions. Like base height can be used for square rectangle triangle etc, and technically you could pass strings to a get measurements function like def get_measurements(dimension_list): Dimensions= [] For dimension in dimension_list: measurement = input(f"Enter the measurement for the {dimension}: ") dimensions.append(measurement) Return dimensions
Sorry for formatting errors but that is the next kind of step you'll want to take.
And obviously you'll want to check measurement before adding to list
-1
u/Etiennera Aug 18 '25
This is more code but doesn't expand on any concepts you did for day 1. I think the only new thing is formatted strings.
1
2
u/EasyTelevision6741 Aug 18 '25
I'd say you let them progress at their own pace or are they paying you to be a mentor?
How about a suggestion of what could have been added to satisfy your critique.
2
u/Etiennera Aug 18 '25
They are choosing to post online. I did make a suggestion.
Live by your own principles and stop commenting online.
0
u/EasyTelevision6741 Aug 18 '25
And you are choosing to be a dick.
I very much live by my principles and none of them have shit to do with commenting on line.
I think I figured it out. You're just sad so being mean to others online makes you feel better. I'm sorry buddy, i hope it gets better!
2
u/Etiennera Aug 18 '25
Projecting much
0
u/EasyTelevision6741 Aug 18 '25
Keep going and hopefully it'll help. But ultimately I think therapy is a good idea. I'm rooting for you buddy!
3
Aug 18 '25
[removed] — view removed comment
1
u/Etiennera Aug 18 '25
I would he should have done it using functions today. But definitely functions next, before classes.
11
u/No_Statistician_6654 Aug 18 '25
This is a great start. One question to ask yourself: what happens if a user types Rectangle, or triangle, or CiRcLE, or “ circle” <- quotes to show the space.
Would these be invalid shapes?
String trim and upper or lower are good things to look into when dealing with user input usually. There are cases where it isn’t, but you can discover that along the way.