Converting: bool()
This short practical chapter will get us acquainted with the bool()
function. You may recall that numbers can be converted to the boolean data type too: 1
means True
, and 0
means False
.
Note
We can put whatever we want into the
bool()
function, and everything except0
in different types (0
,0.0
), andNone
will lead toTrue
.
Swipe to start coding
Your goal is to understand how Python treats different values when converted to bool.
- Convert the number -90 to a boolean and store the result in
is_negative_nonzero_truthy
. - Convert the non-empty string
"La vie est belle"
to a boolean and store the result inis_nonempty_string_truthy
. - Convert the special value None to a boolean and store the result in
is_none_falsy
.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 3.03Awesome!
Completion rate improved to 3.03
Converting: bool()
This short practical chapter will get us acquainted with the bool()
function. You may recall that numbers can be converted to the boolean data type too: 1
means True
, and 0
means False
.
Note
We can put whatever we want into the
bool()
function, and everything except0
in different types (0
,0.0
), andNone
will lead toTrue
.
Swipe to start coding
Your goal is to understand how Python treats different values when converted to bool.
- Convert the number -90 to a boolean and store the result in
is_negative_nonzero_truthy
. - Convert the non-empty string
"La vie est belle"
to a boolean and store the result inis_nonempty_string_truthy
. - Convert the special value None to a boolean and store the result in
is_none_falsy
.
Рішення
Дякуємо за ваш відгук!
single
Awesome!
Completion rate improved to 3.03
Converting: bool()
Свайпніть щоб показати меню
This short practical chapter will get us acquainted with the bool()
function. You may recall that numbers can be converted to the boolean data type too: 1
means True
, and 0
means False
.
Note
We can put whatever we want into the
bool()
function, and everything except0
in different types (0
,0.0
), andNone
will lead toTrue
.
Swipe to start coding
Your goal is to understand how Python treats different values when converted to bool.
- Convert the number -90 to a boolean and store the result in
is_negative_nonzero_truthy
. - Convert the non-empty string
"La vie est belle"
to a boolean and store the result inis_nonempty_string_truthy
. - Convert the special value None to a boolean and store the result in
is_none_falsy
.
Рішення
Дякуємо за ваш відгук!