Python basic syntax

Source: Internet
Author: User


Constants/Variables

Constant: Once assigned, the value cannot be re-assigned.

Literal constants: A single existing quantity that is not assigned to any variable or constant.

Variable: is a name, on the left side of the assignment symbol, that name can refer to the content to the right of the assignment symbol.

Example: i = 3

Except for spaces at the beginning of the line, other empty lines are meaningless.

Type System of variables

Python is the strongest type of language. (The different types can not be counted against each other, and the operation will be type checked)

Eg:4 + ' 4 ' returns the error.

Python is a dynamic language (meaning variables can be re-assigned to other types)

EG:I = 4 Type (i) return int

i = ' 4 ' type (i) returns STR

Basic types of Python

int \ float \ byte \ bool \ None

int integer (integer): Can be infinitely long and has no limit on length. A memory overflow occurs after the physical memory is fully occupied. Restricted to physical memory only.

Eg:4-1 1000

Float floating point (fractional): There is a length limit, and the precision is lost when there are a lot of decimal places.

eg:12.3 34.9 12.9

BOOL Type: True or False

None:none


Arithmetic operators


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/  Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>+-*///% * subtraction divisible Modulo exponentiation

Refers to the operation of our int and float.

Eg:1 + 1 =2

1 + 3.9 = 4.9

Not finished ...

Python basic syntax

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.