发布时间:2019-09-15 10:00:08编辑:auto阅读(3171)
#用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 print "*", 8 j+=1 9 print "" 10 i+=1 输出效果如下: * * * * * * * * * * * * * * *
#对上面的程进行深化,可以得到两个相对的三角形:
#!/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
输出结果如下:
*
* *
* * *
* * * *
* * * * *
* * * * *
* * * *
* * *
* *
*
#最后上个心形:
print'\n'.join([''.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)])
输出结果如下:
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
上一篇: python PAM30 PAMIE
下一篇: 【笔记3】python中的映射操作
47745
46240
37113
34628
29229
25887
24747
19863
19421
17910
5717°
6317°
5836°
5889°
6985°
5829°
5846°
6361°
6316°
7677°