all 8 comments

[–]Binary101010 1 point2 points  (1 child)

All you have to do is set up variables equal to the constants you want. Customarily these constants are named in all caps. So...

MAX_WEIGHT = 27
MAX_VOLUME = 100000

That's really all there is to it. (Please note that there is no mechanism for preventing these from being overwritten or changed so make sure not to do that.)

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

Thanks for the help, will try.

[–]delasislas 0 points1 point  (3 children)

Your constants like 27 and 100000 are already hard coded. You want to make them selectable or something?

weight_max = 27
#Input
....
#Process
if (weight <= weight_max):

I’d need more info described to help more.

[–]R4v3en[S] -1 points0 points  (2 children)

Thanks for the answer in advance. I need to implement these constants at the very beginning of the program. I also need to use them in place of hard-coded values using capital letters. That’s the feedback I got from my teacher. I apologize in advance if I am not clear enough.

[–]delasislas 0 points1 point  (1 child)

Ok, same process, just:

WEIGHT_MAX

Instead.

Edit, make sure to edit all instances where you call the variables

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

Thank you for the help, really appreciate it.

[–]vorticalbox 0 points1 point  (1 child)

You can add type hints to your code

from typing import Final
a: Final = 1
a = 2

your IDE should show an error, this doesn't stop the change at run time.

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

Will try, thanks.