用python乌龟库花一个甲基的结构式
时间: 2024-03-22 07:36:56 浏览: 23
好,以下是用Python的turtle库画一个甲基的结构式的代码:
```python
import turtle
# 设置画布大小
turtle.setup(500,500)
# 画上面的甲基
turtle.color("red")
turtle.pensize(5)
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.up()
turtle.goto(0,50)
turtle.down()
turtle.write("CH3", font=("Arial", 12, "normal"))
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
运行以上代码,就可以在窗口中看到一个用turtle库画的甲基结构式了。
相关问题
用python乌龟库花一个苯环的结构式
好的,以下是用Python的turtle库画一个苯环的结构式的代码:
```python
import turtle
# 设置画布大小
turtle.setup(500,500)
# 画上面的环
turtle.color("blue")
turtle.pensize(5)
turtle.circle(50)
# 画左边的甲基
turtle.up()
turtle.goto(-50,0)
turtle.down()
turtle.color("red")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.up()
turtle.goto(-75,25)
turtle.down()
turtle.write("CH", font=("Arial", 12, "normal"))
# 画右边的甲基
turtle.up()
turtle.goto(50,0)
turtle.down()
turtle.color("red")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.up()
turtle.goto(75,25)
turtle.down()
turtle.write("CH", font=("Arial", 12, "normal"))
# 画下面的甲基
turtle.up()
turtle.goto(0,-50)
turtle.down()
turtle.color("red")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.up()
turtle.goto(0,-75)
turtle.down()
turtle.write("CH", font=("Arial", 12, "normal"))
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
运行以上代码,就可以在窗口中看到一个用turtle库画的苯环结构式了。
用python乌龟库花一个甲苯的结构式
好的,以下是用Python的turtle库画一个甲苯的结构式的代码:
```python
import turtle
# 设置画布大小
turtle.setup(500,500)
# 画左边的芳环
turtle.color("blue")
turtle.pensize(5)
turtle.circle(50)
turtle.left(90)
turtle.up()
turtle.forward(50)
turtle.right(90)
turtle.down()
turtle.circle(50)
# 画右边的芳环
turtle.color("green")
turtle.up()
turtle.goto(100,0)
turtle.down()
turtle.circle(50)
turtle.left(90)
turtle.up()
turtle.forward(50)
turtle.right(90)
turtle.down()
turtle.circle(50)
# 画上面的甲基
turtle.up()
turtle.goto(25,50)
turtle.down()
turtle.color("red")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.up()
turtle.goto(0,75)
turtle.down()
turtle.write("CH3", font=("Arial", 12, "normal"))
# 画下面的甲基
turtle.up()
turtle.goto(75,-50)
turtle.down()
turtle.color("red")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.up()
turtle.goto(100,-75)
turtle.down()
turtle.write("CH3", font=("Arial", 12, "normal"))
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
运行以上代码,就可以在窗口中看到一个用turtle库画的甲苯结构式了。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![.zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)