You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could make this into a function so it is easier to add to it rather than copy-pasting, and clearer that the person giving the input value might be a different person.
I thought the same when giving the course on Tuesday, would have let me focus on the important parts of the lesson more.
I also find the wording of the test a bit weird. I would recommend:
> def test_number(val):
> if val == 0:
> print('Value ', val, 'is zero')
> elif val > -10 and val < 10:
> print('Value: ', val, 'is a single digit.')
> else:
> print('Value: ', val, 'is a multi-digit number.')
Honestly, the test itself is fairly unimportant, although I think making it clear that negative values are ok is a good idea because we had a student ask if this was the issue. Checking for negative, 0 or positive would also be fine, and probably simpler so we keep it focussed on what's important for the lesson:
Activity
Scottan commentedon Nov 14, 2025
I thought the same when giving the course on Tuesday, would have let me focus on the important parts of the lesson more.
I also find the wording of the test a bit weird. I would recommend:
Honestly, the test itself is fairly unimportant, although I think making it clear that negative values are ok is a good idea because we had a student ask if this was the issue. Checking for negative, 0 or positive would also be fine, and probably simpler so we keep it focussed on what's important for the lesson:
Scottan commentedon Nov 14, 2025
p.s. adding suggestion from @AnnieZQH to add a box in this section on use of try / except referring to:
https://docs.python.org/3.6/glossary.html#term-eafp