Python loop and pythonfor Loop

Source: Internet
Author: User

Python loop and pythonfor Loop

Password ciphertext passwd. py

 

Import getpass

_ Username = 'sunny'

Password = '000000'

Username = input ("username :")

Password = getpass. getpass ("password :")

 

If _ username = username and _ password = password:

Print ("Welcome to {name} login...". format (name = username ))

Else:

Print ("Invalid username or password ")

 

Guess. py

 

Age = 56

Count = 0

While count <4:

 

Guess_age = int (input ("guess age :"))

If guess_age = age:

Print ("Congratulations! ")

Break

Elif guess_age> age:

Print ("ops ...")

Else:

Print ("devops ...")

Count + = 1

If count = 3:

Continue_flag = input ("do you want to keep ...")

If continue_flag! = 'N'

Count = 0

Else:

Print ("......")

 

While. py

 

Count = 0

While True:

Print ("count:", count)

Count + = 1

 

Exce1.py

For I in range (10 ):

/* Range (0, 10, 2)

0 ~ 10, step 2

*/

Print ("loop:", I)

For j in range (10 ):

Print (j)

If j> 5:

Break

 

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.