Day-1python base loop for, while, judging if

Source: Internet
Author: User
1.if condition judgment

a=4if a==3:    print(‘正确,a的值为3‘)else:    print(‘错误!‘)>>:错误

2.for Cycle

for i in range(4):#range(3) range(start, stop[, step]) 如:range(4,7,2) 输出4,6    print(i)>>:0123

3.while Cycle

i=1while i<5:    print(i)    i += 1;

4.break jump out of the loop

i=1while i<5:    print(i)    i += 1;    if i==3:        break>>:12

5.continue continue the next cycle

while i<5:    i += 1;    if i==3:        continue    print(i)>>:245

Day-1python base loop for, while, judging if

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.