Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Python bool() Function | Boolean Type
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
Compito

Swipe to start coding

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

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 2
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

close

Awesome!

Completion rate improved to 3.85

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
Compito

Swipe to start coding

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

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 2
single

single

close

Awesome!

Completion rate improved to 3.85

bookPython bool() Function

Scorri per mostrare il menu

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
Compito

Swipe to start coding

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

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

some-alt