+ 3

When I am doing exercises for practice and they mention a constraint, should I assume it will be true or check for it?

If in the letter of an exercise they say for example "constraint:1<=x<100 where x is input " should I validate if this is true in the code or just asume it is true and the input they'll give me is between that range in this case? I am not sure so if you could help me I would be really grateful 😊

15th Oct 2018, 3:21 AM
C.E.
C.E. - avatar
3 odpowiedzi
+ 1
For example in the first exercise I have to make a ceil and floor functions, it says the input is a "real" number, output print ceil and floor of the number, and constraint 1<=x<=100.
15th Oct 2018, 12:50 PM
C.E.
C.E. - avatar
+ 1
it doesn't specify if I should make something to prevent invalid inputs
15th Oct 2018, 12:51 PM
C.E.
C.E. - avatar
+ 1
Would need more context to opine. I would say that if a user should not do something and the program let's them do it...it's a bug.
21st Jun 2019, 1:35 AM
Paul K Sadler
Paul K Sadler - avatar