Getting Started with Python functions

Source: Internet
Author: User

X=print (' a ') #返回a

Print (a) #返回None

Here are three kinds of scores of programmers

a=[1,2,3,4] #想让输出结果显示次数和数字一样 (compared by five total)

The results shown are:

1

22

333

4444

The first method: (three points) the second method: (four points) the third method: (Five points)

For x in a:                                                 for  x in a:                                                           for x in  A:

    If x==1:                                                     if x==1:                                                              Print (SHR (x) *x)

Print (x) print (' 1 ')

Elif x==2:if x==2: When demand becomes more (a=[1,2,3,4 , 5,6,7,8]), the first must be changed to achieve basic functions, obviously more troublesome

       Print (str (x) *)                                        print (' $ ')                                                                                               The second kind also needs to be added, simple and convenient one point

    else:                                                           if x==3:                                                                                                   The third type does not need to change, the most concise and convenient

       If x==3:                                                      print (' 333 ')                                                                                              

Print (str (x)) if x=4:

Else:print (' 4444 ')

Print (str (x))

Getting Started with Python functions

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.