Python notes 001--conditions and loops

Source: Internet
Author: User

If Loop: two options

Example 1:

1 a=2if a<=:3    print ('the Number less than')4Else:5    Print ( ' Thank you! ')

Example 2:

While loop: Repeats a function multiple times

Example 1

1 greetings=12 while greetings<=3:    #这里记住了是 <= instead of <-, Do not confuse with R 3    print ('hello! '*greetings)4    greetings=greetings+1
2 . Pyhello! Hello!hello! Hello!hello!hello!

Example 2

For loop: Iterate through every element in the list

Example 1

 1  names=[ " a   ", "  b   ", "  c     for  name in   names:  3  Print ( hello!   +name) 
1 . Pyhello! Ahello! Bhello!c

Example 2

1 n=2 for in range (n):3   print (i)

Question 1:a=100,b=200, for a b between all odd and

Python notes 001--conditions and loops

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.