Python If-else And while

Source: Internet
Author: User

If-elif syntax if Condition:[tab key] Commandelif condition:[tab key] Commandelif condition:[tab key] Commandelse:[tab key] Commandwhile syntax while Condition:[tab key] commandif nested if Condition:[tab key] Command[tab key] if Condition:[tab key] [tab] command[ TAB] Else:[tab key] [tab] commandelse:[tab key] Command
#-*-coding:utf-8-*-#double-loop print Rectangle#The length of the rectangle is 7 and the width is 5.I=0j=0 whileI < 5: J=0 whileJ < 7:                if(i = = 0)or(i = = 4):                        #this end= "" does not wrap operation is python3.x version support, python2.x will be error                        Print("*", end="')                Else:                        if(j = = 0)or(J = = 6):                                Print("*", end ="")                        Else:                                Print(" ", end="') J+ = 1Print("") I+ = 1

Python If-else And while

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.