Python study NOTE 2: Boolean expression

Source: Internet
Author: User
 1 # coding: UTF-8
2 # boolean expressions have only two values: True and False.
3 x = 12.4
4 y = 12.3
5 print x = y # symbol '=' is used to determine whether two numbers are equal. The result of this statement is False.
6 x = 12.3
7 print x = y # The result of this statement is True.
8 print x! = Y # symbol '! = 'Is used to determine whether two numbers are not equal. The result of this statement is False.
9 a = 12
10 B = 14
11 print a> = B # symbol '> =' is used to determine whether a is greater than or equal to B. The result of this statement is False.
12 print a <= B # symbol '<=' is used to determine whether a is less than or equal to B. The result of this statement is True.
13 print a> B # symbol '>' is used to determine whether a is greater than B. The result of this statement is False.
14 print a <B # symbol '<' is used to determine whether a is smaller than B. The result of this statement is True.
15 a = 'aaa'
16 B = 'bbb'
17 print a> B # You can also determine the size of the two strings. The reslut of this statement is False.
18 print a <B # result = True for this statement
19 # note the difference between the operator "=" and operator "=". "=" is to assign the value on the right to the variable on the left.
20 # And "=" is used to determine whether the value on the left is equal to the value on the right.
21

 

 

 

{Online shopping for rebates, new shopping choices}

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.