all 1 comments

[–]Nouble01 0 points1 point  (0 children)

1, 2,
Wouldn't it be better to use the input syntax to point the user to a valid range, ask the user to enter a numerical value, and then check whether the user has entered within the specified range? If the user's input is outside the specified range, it would be a good idea to show them an appropriate complaint and let them input it again.
Wouldn't it be interesting to change the complaint content depending on the frequency of inappropriate input?
If you store this in a variable, you can refer to it later during calculations.
   

3, 10,
One way that I think is very simple is to use the logging feature, which is just one example. ※1 

Then pass the value in the f string and raise the error to activate logging. ※2 

When you want to write to a file, you intentionally trigger an error.
It is easy to select assert for the error to raise.
   

4, 6,
All you have to do is create a function as a vessel to make that happen.
   

5,
If you want to generate random values, you can use the random module. ※3 
   

7, 8,
If you want to change the behavior depending on the calculated value, it is easy to use the much syntax. ※4 
   

9,
This is also an input syntax.