Python Learning Path Basics--03python Basics + the evil operators

Source: Internet
Author: User
Tags arithmetic operators logical operators

1 Formatted output%

Use%s (which is used to represent the STR data type) and%d (to represent the int data type), and if the% number is used, it will be output by using two percent per cent.

2 Initial knowledge encoding

The computer transmits the data, the storage All is uses 01010101 way

1 byte = 8 bit (that is, 1 bytes = 8 bits)

1 KB = 1024x768 byte

1MB = 1024x768 KB

1 GB = 1024x768

1 TB = 1024x768 GB

ASCII code: First invented by the Americans, altogether 1 bytes, 8 bits, the first 7 bits, so the leftmost one is 0

Unicode: The first byte representing all English, numeric, and special characters, 2 bytes for Chinese (but apparently not enough), followed by a 4-byte representation, which takes up too much memory space.

Utf-8: The most popular, (and also utf-16 and utf-32) in 1 bytes of English, 2 bytes for European text, 3 bytes for Asian text

GBK: Chinese-made, can only be used in Chinese and ASCII code text

3 operator

Arithmetic operators

  

  

Comparison operators

  

  

Assignment operators

  

logical operators

  

Further research for logical operations:

In the absence of () the not priority is higher than the And,and priority or, that is, the priority relationship is () > Not > and > or, and the same priority is computed from left to right. (without a number of cases)

x or Y, X is true, the value is x,x false, the value is Y, X and Y,x are true, the value is y,x false, and the value is x. (from left to right)

Let's have a real battle.

  1, 8 or 3 and 2 and 0 or 9 and 7

8 or 3--> X is straight out of 8, don't look at the back.

  

2, 0 or 2 and 3 and 4 or 6 and 0 or 3

0 or 2--and X is false, take the back. 2 and 3-->x are true, take the back. 3 and 4--> X are true, take the back. 4 or 6-->x is true, take x, and the value is 4. Only the number of cases

  

3, 1 > 2 and 3 < 4 or 4 >5

If there are no numbers, first or again and. F

  

4, 1<2 and 3 or 4 and 3>2

X is true, take the back, then directly is a number, it is 3.

5, 1>2 and 3 or 4 and 3<2

X is false, take the front,,, X is false, take the back,,, true and false take, F

6, 1>2 and 3 or 4 and 3>2

X is false, take the front,,, X is false, take the back,,, true and true take, T

If the first is or the case, the front is true, then directly take the previous value, do not look at the back, if it is in the middle or will be compared to the last side.

If the and,x is true at first, take the back, and if it is a number, take it directly. If it's fake, keep comparing it.

  

  

Python Learning Path Basics--03python Basics + the evil operators

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.