Python Automated Scripting Learning (ii)

Source: Internet
Author: User

Process Control

Boolean value

temp = True Temp = False

Compare symbols

= = = < <= > >=

and or non-

And Or not

Comparison of mixed Booleans

(4<5) and (5<6)

Process Control elements

Conditional statement if Else

code block

Program execution

Process description

If Else

If Name= John:

Print ("My name is John");

Esle:

Print ("My name is not John");

Elif (ElseIf in other languages)

While loop

temp = 0

While temp <5

Print (' Hello world ')

temp = temp + 1;

Break statement: Jump out of

Continue statement: Jump out of this time to continue the next cycle

For loop and range functions:

For NUM in range (10)

Total = total + num;

Print total;

Range and interval of range

For NUM in range (0,10,2)

print (num);//0,2,4,6,8

For NUM in range (10,-2,-2)

print (num);//10,8,6,4,2,0

Importing packages

Import Random

For Num in range (3)

Print (Random.readint (1,10))/prints three times less than 10 random numbers

Import multiple packages at the same time:

Import Random,sys,amth,os

End Program

Sys.exit ();

Python Automated Scripting Learning (ii)

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.