Python Learning Series (iii) Python Getting Started grammar rules 1

Source: Internet
Author: User

First, comments

‘‘‘

Multi-line comments

‘‘‘

#单行注释

"' #example1.1 Test program time: 4/17/2017

I1=input ("Please enter user name:")

I2=input ("Please enter password")

Print (I1)

Print (I2)

Print ("ainiyou")

‘‘‘

Second, the variable

1) (the rules are the same as the rules in C)

2) cannot make python internal keywords

III. Basic data types

1) Number

Age=24

2) string

Name= "Yuanguoliang"

Name= 'Yuanguoliang'

Name= "" "Yuanguoliang" ""

3) Boolean value (True,false)

Iv. Process Control and indentation

1) If the indentation under the if must remain consistent

If condition:

Content 1

Content 2

Else

Content 3

Content 4

Example1:

I1=input ("Please enter")

If i1==1:

Print ("haha")

Print (1111)

Else

Print ("Hehe Ride")

Print ("Yuanguo")

Example2:

Name=input ("Please name")

pssscode=input ("Please passcode")

If name== "Yuanguoliang" and pssscode= = "123456":

Print ("Yes")

Else

Print ("NO")

V. While loop and break, continue

1)

While condition:

Code

2) break jumps out of the loop, does not execute after the code

3) Continue is used to exit the current loop and continue the next cycle

‘‘‘

Python Learning Series (iii) Python Getting Started grammar rules 1

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.