Python Basics Review-1-1 file types, variables, operators, expressions

Source: Internet
Author: User

File type: the
.py python源文件 由python解释器执行.pyc python源码编译后生成的文件(字节代码)编译方法:    源码文件中使用py_compile模块      import py_compile      py_complie.compile(‘***.py‘)      .pyo python源码优化编译后后文件    python -O -m compile ***.py  (无需要源码中使用 compile模块)    -O 表示优化    -m 表示模块    
Python variables

A variable is an area of computer memory that can store values within a specified range, and the value can be changed

The python under variable is a reference to a data

Variable

The python under variable is a reference to a data

Variable assignment is an area that points to a variable
Change the value of a variable to point to another area

Variable assignment does not need to declare a variable type, it automatically determines the type based on the value

Built-in functions
id()  内置函数 查看内存地址type() 内置函数  查看类型从键盘读取输入input("提示符")  字符串需用‘‘,适用于数字raw_input(“提示符”) 将所有输入做为字符串 建议使用
Assignment operators:
=   x = 2 将2赋于x+=  x += 2   <=>  x = x + 2-=  x -= 2   <=>  x = x - 2*=  x *= 2   <=>  x = x * 2/=  x /= 2   <=>  x = x / 2%=  x %= 2   <=>  x = x % 2  ```### 算术运算符:
    • Connecting two number addition operations concatenate two strings, stitching strings
    • Subtraction
    • Multiplication
      /Division A number is a floating point and the result shows the number of decimal parts 4.0/3
      Divisible
      % take-up
      * * exponentiation
### 关系运算符:(返回值为布尔值 true fales)

Greater than
Less than
= greater than or equal to
<= less than or equal to
= = constant equals
! = does not equal

### 逻辑运算符

Add logic with True and False
or logical OR False or True
Not Logic not True

### 格式化字符串

%s
Print "%s +%s =%s"% (3, 4, 3+4)
Output:3 + 4 = 7
```

Python Basics Review-1-1 file types, variables, operators, expressions

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.