Python Basic Learning Note one

Source: Internet
Author: User

First, quotation marks and comments:

1. In Python, single quotation marks ("") and double quotation marks ("") are not distinguished, and both single and double quotation marks can be used to identify a string.

      Print ("Hello")      rint (' Hello ')

2, single quotes and what u that quotation marks can be nested with each other, but not cross-use.

3, #表示单条注释; Multiple lines of comments are expressed in quotation marks.

Second, the circulation

1, if loop, python through the IF statement to achieve branch judgment, Syntax: If......else ...

A=0b=1if a>b:    print (' A relatively large ') Else:    print (' B larger ')

Note: Python uses indentation to determine the body of the statement;

The IF statement uses the = = operator to determine equality, and by the! = operator to indicate that you do not want to wait;

The IF statement can be judged by a Boolean type:

A=trueif A:    print (' A  is  true ') Else:    print (' A was not true ') output  A is true

If statement multiple conditional judgment:

If  score >=90:    print (' excellent ') Elif  score >=75:    print (' good ') elif  score >=60:    print (' Pass ') Else:    print (' fail ')

  

2. For loop

For I in  Range:    print (i)

Note: The range (Start,end[,step]) range () function loops from zero by default, start indicates the start position, end indicates the ending position, step identifies the step of each cycle

3. While loop

While count<10:     print (' hello,world! ')     Count=count+1else:     print (' Bye. ‘)

  

Break, exit the loop, break can only be used inside the loop

While count<10:     print (' hello,world! ')     count=count+1     if count==5:        break   

 

The use of continue, the role of continue is to exit this cycle

While count<10:     print (' hello,world! ')     count=count+1     if count==5:        continue     

  

Python Basic Learning Note one

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.