How to apply a Python Boolean expression

Source: Internet
Author: User

Python boolean expressions are widely used. First, we need to familiarize ourselves with the Python programming language. Next, let's take a look at how to use the Python Boolean expression.

 
 
  1. # Coding: UTF-8 # The Boolean expression has only two values: True and False.
  2. X = 12.4
  3. Y = 12.3
  4. Print x = y # symbol '=' is used to determine whether two numbers are equal. The result of this statement is False.
  5. X = 12.3
  6. Print x = y # The result of this statement is True.
  7. Print x! = Y # symbol '! = 'Is used to determine whether two numbers are not equal. The result of this statement is False.
  8. A = 12
  9. B = 14
  10. Print a> = B # symbol '> =' is used to determine whether a is greater than or equal to B. The result of this statement is False.
  11. Print a <= B # symbol '<=' is used to determine whether a is less than or equal to B. The result of this statement is True.
  12. Print a> B # symbol '>' is used to determine whether a is greater than B. The result of this statement is False.
  13. Print a <B # symbol '<' is used to determine whether a is less than B. The result of this statement is True.
  14. A = 'aaa'
  15. B = 'bbb'
  16. Print a> B # You can also determine the size of the two strings. The reslut of this statement is False.
  17. Print a <B # The result of this statement is True.
  18. # Note the difference between the operator "=" and operator "=". "=" is to assign the value on the right to the variable on the left.
  19. # "=" Is used to determine whether the value on the left is equal to the value on the right.

The above is a detailed introduction to the Python Boolean expression in the Python language. I hope you will get some benefits.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.