Week 1 Unit 4: Self-test
Last updated:
(05. April 2024)
Question 1
Which of the following casting operations result in the Boolean value True?
Note: There are 2 correct answers to this question.
bool(int("0"))
❌bool(0)
❌bool(2-2)
❌bool(1)
✅bool("False")
✅Question 2
Why are the following statements not robust, and could cause the program to crash if the wrong input is given?

Note: There are 2 correct answers to this question.
The program is unable to handle negative numbers.
❌It would be better if the program would check for the birthdate.
❌The answer "eighteen" would lead to problems.
✅If the user enters not only digits, the program will run into an error.
✅The age of the user is not double checked, so there is no mechanism against cheating.
❌Question 3
What is the value of the variable text after the execution of the following statements?
