Python Learning notes-3 operators and expressions

Source: Internet
Author: User

① expression: A formula that combines different data (including functions, variables) with operators according to certain rules

② operator :

Arithmetic operators :

+ addition operator

-Subtraction operator

* Multiplication operator

/division operator, Integer and integer can only be divided into integers, if you want to get a fractional part, to add a decimal point after a number as 3/2 can only get 1, if you want to get 1.5, you need to do this: 3.0/2 can get 1.5

The integer division operator, regardless of the result of dividing two numbers, has no fractional part, and the result is to the whole number of parts

* * Sub-square operator, e.g. three of four-square 3**4

The remainder operator, the result of the residual

Assignment operators:

+ =, plus equals, such as a+=10 equivalent to a=a+10, that is, the first operation A+10, and then assigned to a

-=, minus equals

*=, multiply equals

/=, except equal to

=, general assignment method, direct assignment

%=, to seek the remainder equals

Relational operators

= =, exactly equal to

=, equals

, Greater than

<, less than

<=, less than or equal to

>= greater than or equal to

! = does not equal

logical operators

And, logically with, two or more conditions are established at the same time is only established

Or, logical OR, as long as there is a condition to be established immediately

Not, logical non, negate

###############################################

Raw_input () reads the user input, which is read by default as a string

int () casts a string to a number

Python Learning notes-3 operators and expressions

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.