Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Python bool() Function | Boolean Type
Quizzes & Challenges
Quizzes
Challenges
/
Python Data Types

bookPython bool() Function

In Python there is bool() function that converts variables of any type into a variable of boolean type (True or False). Let's look at an example for better understanding.

Input:
zero = 0
print(bool(zero))

Output:
False
Input:
one = 1
print(bool(one))

Output:
True
Input:
number = 10
print(bool(number))

Output:
True

Any digit other than zero is True.

Input:
x = None
print(bool(x))

Output:
False
Завдання

Swipe to start coding

You have three numbers of different numeric types, you have to return a boolean object from each of one.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 2
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Сумаризуйте цей розділ

Пояснити код у file

Пояснити, чому file не вирішує завдання

close

bookPython bool() Function

Свайпніть щоб показати меню

In Python there is bool() function that converts variables of any type into a variable of boolean type (True or False). Let's look at an example for better understanding.

Input:
zero = 0
print(bool(zero))

Output:
False
Input:
one = 1
print(bool(one))

Output:
True
Input:
number = 10
print(bool(number))

Output:
True

Any digit other than zero is True.

Input:
x = None
print(bool(x))

Output:
False
Завдання

Swipe to start coding

You have three numbers of different numeric types, you have to return a boolean object from each of one.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 2
single

single

some-alt