PY练习

from turtle import *

def position(x, y):
    up()
    goto(x, y)
    down()

def drawstar(size, x, y):
    position(x, y)
    color('yellow')
    begin_fill()
    fillcolor('yellow')
    for i in range(5):
        forward(size)
        if size == 150:
            right(144)
        else:
            left(144)
    end_fill()
bgcolor('red')

speed(5)
drawstar(150, -300, 160)

drawstar(50, -180, 250)
drawstar(50, -80, 200)
drawstar(50, -80, 90)
drawstar(50, -180, 10)

hideturtle()
done()

str1 ='Python!Python!Python'
print(str1)
print(str1[0])
print(str1[2:5])
print(str1[2:])
print(str1 * 2)

html1 = 'http://news.gzcc.cn/html/2018/xiaoyuanxinwen_0314/9024.html'
print(html1[-14:-5], '\n ----------------------')

html_end = '.html'
html2 = 'https://docs.python.org/dev/library/'
a = ['string', 'sys', 'turtle', 'os']
for g in a:
    html = html2 + str(g) + html_end
    print(html)
print('\n ----------------------')

new_html1 = 'http://news.gzcc.cn/html/2018/xiaoyuanxinwen/'
for i in range(0, 11):
    new = new_html1 + str(i) + html_end
    print(new)

 

a = ' There is  \n a python document \n ! is a good code!!!!'
print(a.strip(), '\n ---------------------')
print(a.lstrip(), '\n---------------------')
print(a.rsplit(), '\n---------------------')
print(a.count('!'), '\n---------------------')
print(a.count('is'), '\n---------------------')
print(a.split('\n'))

 

转载于:https://www.cnblogs.com/ben-9527/p/8605154.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值