Python ----- & gt; process control, python ----- Process

Source: Internet
Author: User

Python -----> process control, python ----- Process

1:
If 1 <2: ("the condition is True, and the result is True ")
Print ('true ')
Else:
Print ('forse ')

2:
I = 0 (assign 0 to I)
While I <5: ("True if I is less than 5 ")
Print (I)
I + = 1; ("I add 1 each time. If I do not write, it will jump into an endless loop ")

3: for I in range (1, 10 ):
For j in range (1, I + j ):
Print ('{}* {}={}\ t'. format (j, I, j * I), end = '')
Print () ("line feed ")
If condition judgment statement:

1: if is followed by a condition (Note: This is different from java, and the condition does not need to be added ())

If the condition is True, a (True) is returned and the following statement is executed.

If the condition is not true, execute the statements in else. (Note: Code indentation)

Loop statement:

2: while

 

The judgment condition can be any expression, and any non-zero or non-null value is True. The judgment condition Forse

3:

Output a 9-9 multiplication table using a for Loop

1--3 (top instance)

4: variable exchange

A = 8

B = 1

A, B = B, a ("output result: B = 8, a = 1 ")

5: Random Number

Import random ("import random ")
Print (random. randint () ("random number range 0-9 ")

      

 

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.