Python Novice Learning Basics operators--assignment and logic operations

Source: Internet
Author: User

Assignment is also an operator

We have learned in previous chapters that variables in Python are not required to be declared, as long as the variable's identity conforms to the law, it can be directly defined and assigned, and Python allows us to assign values to multiple variables at the same time (including assigning different types of values to multiple variables), for example:

A = b = c = #三个变量赋同样的值d, E, F =-2, 5.5, ' Hello ' #三个变量赋不同类型的值

There are several assignment operations in Python: 650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/86/76/wKioL1e_ Ocrt0poqaabngfscigy030.png-wh_500x0-wm_3-wmp_4-s_780042295.png "title=" 3.png "alt=" Wkiol1e_ Ocrt0poqaabngfscigy030.png-wh_50 "/>

Take a look at the instance code and run the results, and do the following:

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/86/76/wKioL1e_oDfw73_qAACDMcxCwms199.png-wh_500x0-wm_3 -wmp_4-s_1797257958.png "title=" 4.png "alt=" Wkiol1e_odfw73_qaacdmcxcwms199.png-wh_50 "/>

Logical operations

Logic operations are often used in programs, and life is also logic.

For example, the teacher wants you to listen to the lecture tomorrow 3 o'clock in the afternoon or the lecture tomorrow night 7 o'clock, that is, you can listen to the lecture tomorrow 3 o'clock in the afternoon, you can also listen to the lecture tomorrow evening in 7 o'clock, both as long as it satisfies one, this is the logic operation in the program or in Python with or to express.

If the teacher said to you, tomorrow 3 o'clock in the afternoon lecture and tomorrow Evening 7 o'clock lecture you will come, that is to say you all 2 time point to listen to lectures, all must satisfy, this is the logic operation in the program and Python, with and to express.

The logical operators in Python are as follows:

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/86/76/wKiom1e_oEWSDKA-AABVorDAyrk798.png-wh_500x0-wm_3 -wmp_4-s_223325309.png "title=" 5.png "alt=" Wkiom1e_oewsdka-aabvordayrk798.png-wh_50 "/>

Also, let's take a look at the code and run the results to see how the logical operation works: more learning content, just in the code bud Net Http://www.mayacoder.com/lesson/index

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/86/76/wKioL1e_oE3gnuIUAAAzUYxVHaI809.png-wh_500x0-wm_3 -wmp_4-s_768185439.png "title=" 6.png "width=" "height=" 769 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:300px; height:769px; "alt=" Wkiol1e_oe3gnuiuaaazuyxvhai809.png-wh_50 "/>


Python Novice Learning Basics operators--assignment and logic operations

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.