Print a variety of graphics in Python

Source: Internet
Author: User

#用python打印出直角三角形:

1 #!/usr/bin/env Python 2 # coding=utf-8 3 i = 0 4 while I < 5:5 j = 0 6 while J <= I:7 Prin T "*", 8 j+=1 9 print "" I+=1 output is as follows: * * * * * * * * * * * * * * * * *

#对上面的程进行深化, you can get two relative triangles:

#!/usr/bin/env python  2 # coding=utf-8  3 i = 0   4 while i < 5:  5     j = 0  6      while j <= i:  7          print  "*",  8         j+=1   9     print  ""  10     i+=1 11 i  = 5  12 while i > 0: 13     j =  0 14     while j <= i: 15          print  "*",  16         j+= 1                                                                                                                                          17     print  ""  18     i-=1

The output results are as follows:

*

* *

* * *

* * * *

* * * * *

* * * * *

* * * *

* * *

* *

*

#最后上个心形:

print ' \ n '. Join ([' python! ' [(X-y)%7]if ((x*0.05) **2+ (y*0.1) **2-1) **3-(x*0.05) **2* (y*0.1) **3<=0 Else ') for x in range ( -30,30)]) for Y in range ( 15,-15,-1)])

The output results are as follows:

                                                                                                                                               thon! pyth           ython! Pyt                           ! Python! Python! py   n! Python! Python! p                      n! Python! Python! Python! Python! Python! pyth                   n! Python! Python! Python! Python! Python! python                n! Python! Python! Python! Python! Python! Python! p               ! Python! Python! Python! Python! Python! Python! py               python! Python! Python! Python! Python! Python! pyt               ython! Python! Python! Python! Python! Python! Pyth               thon! Python! Python! Python! Python! Python! pytho               hon! Python! Python! Python! Python! Python! python                n! Python! Python! Python! Python! Python! python                   python! Python! Python! Python! Python! python                    ython! Python! Python! Python! Python! python!                      on! Python! Python! Python! Python! python                         ! Python! Python! Python! Python! python                           ython! Python! Python! Python! python                              on! Python! Python! Python! pytho                                  python! Python! Python! pyth                                       hon! Python! Python! pyt                                            python! Python! p                                                  on! python                                                         YTH                                                             h


Print a variety of graphics in Python

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.