Week 1 Unit 4: Self-test

05. December 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?

week1 unit4 f2

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?

week1 unit4 f3

Python is the very best programming language
Error
PYTHON IS THE VERY BEST PROGRAMMING LANGUAGE
PYTHON IS THE BEST PROGRAMMING LANGUAGE

< Previous unit | Next unit > | Course Overview