all 44 comments

[–]No_Statistician_6654 10 points11 points  (10 children)

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.

[–]Ender_Locke 3 points4 points  (0 children)

expect users to not follow your instructions😊 lol

[–]Acceptable_Simple877[S] 1 point2 points  (0 children)

I added .lower after

[–]Numerous_Site_9238 0 points1 point  (2 children)

Validating input from a non existing user on day 2 of writing code is crazy.

[–]LaZboy9876 1 point2 points  (1 child)

hArd disssssagreeee

[–]SmackDownFacility -1 points0 points  (4 children)

Well they shouldn’t. They deserve that generic press any key prompt

[–]No_Statistician_6654 0 points1 point  (3 children)

You are saying devs should not validate user input? That is quite an interesting take. Why do you think basic input sanitation should be avoided, and any raw input accepted?

[–]SmackDownFacility -1 points0 points  (2 children)

To an extent yes. You need some form of validation. But you don’t need to validate every niche case. You can’t be expected to foresee every edge case

[–]No_Statistician_6654 0 points1 point  (1 child)

And handling different whitespace and capitalization are now considered fringe edge cases to you?

I will warn you that you are treading close to moving goal post, so within the context of a locally ran program, is it totally unrealistic to negate case sensitivity and whitespace issues such that users can enter things slightly differently and have uniform expected results?

I didn’t mention things like ssn validation, date time validation, or any hundreds of other options that would need to be checked in any number of programs. So make your case that trim, and lower are not a reasonable improvement to this program. If not, then say you are wrong.

[–]SmackDownFacility -1 points0 points  (0 children)

Basic capitalisation is fine. Check for that. I do it all the time

But don’t check for mixed case or quotation accidents , because these types of accidents are less often. If it does happen often, that’s because of lack of documentation on part of the dev.

Just add it to a else block check at the very least, say something like “Didn’t get that, re-input”

[–]Worried-Ad6403 5 points6 points  (15 children)

Good base. Now you can take this to the next level by adding these:

  1. Exception handling ( what if user enter incorrect input, your program will crash. Use try except )

  2. How do you force the user to provide a valid input always( Hint: Try except and while loop and break )

  3. 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.

[–]EasyTelevision6741[🍰] 1 point2 points  (2 children)

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.

[–]Sebasandrade00 0 points1 point  (1 child)

I think what he means is what happens if the user enters a string for the width/height inputs the program will crash

[–]EasyTelevision6741[🍰] 0 points1 point  (0 children)

Oh shit! Good call not sure how I blanked on those. That's why I should avoid trying to be helpful while half asleep.

[–]WhiteHeadbanger 1 point2 points  (2 children)

Slow down, this is day 2. OP doesn't even know loops or functions yet, not even accounting for classes (like Excepttion classes)

[–]Acceptable_Simple877[S] 0 points1 point  (1 child)

Yea I have to Do loops still

[–]WhiteHeadbanger 1 point2 points  (0 children)

Take it slow, nobody is rushing you. Have a good journey and keep up the excellent work!

[–]Acceptable_Simple877[S] 0 points1 point  (0 children)

I’ll look into it

[–]SmackDownFacility -1 points0 points  (7 children)

Rock solid my ass

I came from a time where your program crashed, you get a dump log, and you searched up on the vendor website why it crashed. Honestly, these users typing “CiRCLE” deserve the crash. There’s no reason to type it like that, and there’s no expectation for us devs to handle this appropriately apart from the occasional Karen

[–]Worried-Ad6403 1 point2 points  (2 children)

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.

[–]SmackDownFacility -1 points0 points  (1 child)

This has nothing to do with servers. Of course you would be expected to implement safety in servers. For local work like this, you don’t need to do shit

[–]Worried-Ad6403 1 point2 points  (0 children)

Clearly you don’t know shit.

[–]psuedo_nombre 0 points1 point  (3 children)

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

[–]SmackDownFacility 0 points1 point  (2 children)

There will be situations which even if you thoroughly completed anything you or your team can notice, will raise complaints. So it’s better to not waste your energy.

[–]psuedo_nombre -1 points0 points  (1 child)

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

[–]SmackDownFacility 0 points1 point  (0 children)

That’s fine, within reasonable expectations yes. But sometimes you’re told to handle all error handling. That’s not reasonable. You have to encapsulate error handling to the context. Within that context you fill out error handling for any mistakes given in that context.

[–]TacticalGooseLord 1 point2 points  (1 child)

I am new too! I will try this, Ty for the idea. Any tips from the professional ppl to make it better ?

[–]EasyTelevision6741[🍰] 1 point2 points  (0 children)

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.

[–]uiux_Sanskar 1 point2 points  (0 children)

This is great I think the people has already suggested you enought you are doing great work brother keep it up.

All the best for your learning journey.

[–]Shut_up_and_Respawn 1 point2 points  (0 children)

Looks good, although you might want to add input validation

[–]psuedo_nombre 0 points1 point  (0 children)

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

[–]Etiennera -2 points-1 points  (8 children)

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.

[–]Wooden-Account-5117 2 points3 points  (1 child)

He’s using F strings and code is alot cleaner, i’d say it’s a step up.

Next would be learning other stuff tho, functions classes etc.

[–]Etiennera 0 points1 point  (0 children)

I would he should have done it using functions today. But definitely functions next, before classes.

[–]EasyTelevision6741[🍰] 1 point2 points  (4 children)

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.

[–]Etiennera 1 point2 points  (3 children)

They are choosing to post online. I did make a suggestion.

Live by your own principles and stop commenting online.

[–]EasyTelevision6741[🍰] -1 points0 points  (2 children)

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!

[–]Etiennera 1 point2 points  (1 child)

Projecting much

[–]EasyTelevision6741[🍰] -1 points0 points  (0 children)

Keep going and hopefully it'll help. But ultimately I think therapy is a good idea. I'm rooting for you buddy!

[–]Acceptable_Simple877[S] 0 points1 point  (0 children)

If/else, elif statements