Python with Learn-write (while loop and for loop)

Source: Internet
Author: User

1Yueer = 182Count =03  whileCount < 3:4yueerage = Int (input ('How big is yue son:'))5     ifYueerage = =Yueer:6         Print('congratulations on your guess. ')7          Break8     elifYueerage >Yueer:9         Print('you guessed it too much. ')Ten     elifYueerage <Yueer: One         Print('a little bigger.') ACount + = 1 -     ifCount ==3: -Count_jixu = input ('continue y, do not continue N:') the         ifCount_jixu = ='Y': -Count =0 -         elifCount_jixu = ='N': -Count = 3 + Else: -     Print("Fuck off")

Approximate usage of while loop, English poor--...
There is also a for loop, with the following specific usage:

 for  in range (3):    print(a)

Print a can be printed out in a.

Range (10) to print out the 1,2,3,4......10.

What if I want to print an even number?

The For loop also has a trick that can be set from when the loop starts, when it ends, how many times the loop is done, specifically as follows:

 for  in range (0,10,2):    print(a)

0
2
4
6
8

Rang (0,10,2):

The first two bits represent a range of 0 to 10 loops, followed by a loop interval.

Python with Learn-write (while loop and for loop)

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.