Bed length artificial intelligence tutorial free expansion 130 – true and false

Friends, if you need to reprint, please indicate: [https://blog.csdn.net/jiangjunshow] (https://blog.csdn.net/jiangjunshow)

Disclaimer: During the teaching of artificial intelligence technology, many students will mention some Python related questions, so in order to let students master more expanded knowledge to better understand the AI ??technology, I will let the assistant responsible for sharing this Python series tutorial, hope Can help everyone! Since this Python tutorial is not written by me, it is better to teach humble as my AI technology, and learn to be boring; but its knowledge point is still a bit, and it is worth reading! Classmates who want to learn Ai technology can click to jump to my [Teaching Website] (https://www.captainbed.net/csdn). PS: I don’t understand this article, please see the previous article first, and gradually gradually learn every day, I will not feel difficult!

In Python, like most programming languages, integer 0 represents false, integer 1 representative. However, in addition, Python also treats any empty data structure as a false, regarding any non-air data structure as true. The concept of true and fake is inherent attributes of each object in Python: Each object is not true, as shown below:

? If the number is non-zero, it is true.

Other objects are true if it is not empty.

Python has a special object: None, it is always considered to be fake. This is a special data type in Python, which plays an empty placeholder, similar to the NULL pointer in the C language.

You can initialize a list with 0, but if you still don’t know the content of the list, use None more appropriate:

“ `

>>> l=[none] * 100

>>> L

[NONE, NONE, NONE, NONE, NONE, NONE, NONE, …]

“ `

Python’s Boolean BOOL is just a custom version of integers 1 and 0. Such a design is to make the true value more clear.

Python also provides a built-in function BOOL that can be used to test a Boolean value of an object:

“ `

>>> BOOL (1)

True

>>> BOOL (‘spam’)

True

>>> BOOL ({})