@python练习小程序
#!/usr/bin/env python
#!-*-coding:utf-8 -*-
#!@Time :2019/11/5 9:39
#!@Author : October
#!@File : .py
'''绘制一个等边三角形'''
import turtle
def drawSnake(rad,neckrad): #定义一个drawSnake函数
turtle.fd(rad)
turtle.circle(neckrad+1, 120)
turtle.fd(rad)
turtle.circle(neckrad + 1, 120)
turtle.fd(rad)
turtle.circle(neckrad + 1, 120)
def main():
turtle.setup(800, 800, 0, 0)
pythonsize = 30
turtle.pensize(pythonsize)
turtle.pencolor("blue")
turtle.seth(0)
drawSnake(180, pythonsize/2)
main()
#!/usr/bin/env python
#!-*-coding:utf-8 -*-
#!@Time :2019/11/5 9:18
#!@Author : October
#!@File : .py
'''绘制一条彩色的蛇'''
import turtle
def drawWave(rad, angle, len): #定义一个drawSnake函数
for i in range(len):
turtle.circle(rad,angle)
turtle.circle(-rad,angle)
def drawStra(rad, angle):
turtle.circle(rad,angle/2)
turtle.fd(rad)
def draw(rad, neckrad):
turtle.circle(neckrad+1,180)
turtle.fd(rad*2/3)
def main():
turtle.setup(1300,800,0,0)
pythonsize = 30
turtle.pensize(pythonsize)
turtle.pencolor("blue")
turtle.seth(-40)
drawWave(40, 80, 1)
turtle.pencolor("green")
drawWave(40, 80, 1)
turtle.pencolor("purple")
drawWave(40, 80, 1)
turtle.pencolor("gold")
drawWave(40, 80, 1)
turtle.pencolor("violet")
drawWave(40, 80, 1)
turtle.pencolor("green")
drawStra(40, 80)
draw(40, pythonsize / 2)
main()
#!/usr/bin/env python
#!-*-coding:utf-8 -*-
#!@Time :2019/11/5 8:53
#!@Author : October
#!@File : .py
str1 = 'print("你好!")'
eval(str1)
str2 = "1 + 3"
a = eval(str2)
print(a)
b = "[[1,2],[3,4],[5,6]]"
print(type(b))
c = eval(b)
print(type(c))
print(c)
d = "{1:'a',2:'b'}"
print(type(d))
e = eval(d)
print(type(e))
print(e)
f = "([1,2],[3,4],[5,6],(7,8),(9,0))"
print(type(f))
g = eval(f)
print(type(g))
print(g)