当前位置:   article > 正文

python画图代码大全简单,python画图代码简单

python画图代码大全

本篇文章给大家谈谈python画图代码大全简单,以及python画图代码简单,希望对各位有所帮助,不要忘了收藏本站喔。

刚学python时画一些图

1.玫瑰花

  1. import turtle
  2. turtle.speed(5)
  3. # 设置初始位置
  4. turtle.penup()
  5. turtle.goto(0, 200)
  6. turtle.pendown()
  7. # 花蕊
  8. turtle.fillcolor("blue")
  9. turtle.begin_fill()
  10. turtle.circle(10, 180)
  11. turtle.circle(25, 110)
  12. turtle.left(50)
  13. turtle.circle(60, 45)
  14. turtle.circle(20, 170)
  15. turtle.right(24)
  16. turtle.fd(30)
  17. turtle.left(10)
  18. turtle.circle(30, 110)
  19. turtle.fd(20)
  20. turtle.left(40)
  21. turtle.circle(90, 70)
  22. turtle.circle(30, 150)
  23. turtle.right(30)
  24. turtle.fd(15)
  25. turtle.circle(80, 90)
  26. turtle.left(15)
  27. turtle.fd(45)
  28. turtle.right(165)
  29. turtle.fd(20)
  30. turtle.left(155)
  31. turtle.circle(150, 80)
  32. turtle.left(50)
  33. turtle.circle(150, 90)
  34. turtle.end_fill()
  35. # 花瓣1
  36. turtle.left(150)
  37. turtle.circle(-90, 70)
  38. turtle.left(20)
  39. turtle.circle(75, 105)
  40. turtle.setheading(60)
  41. turtle.circle(80, 98)
  42. turtle.circle(-90, 40)
  43. # 花瓣2
  44. turtle.left(180)
  45. turtle.circle(90, 40)
  46. turtle.circle(-80, 98)
  47. turtle.setheading(-83)
  48. # 叶子1
  49. turtle.fd(30)
  50. turtle.left(90)
  51. turtle.fd(25)
  52. turtle.left(45)
  53. turtle.fillcolor("green")
  54. turtle.begin_fill()
  55. turtle.circle(-80, 90)
  56. turtle.right(90)
  57. turtle.circle(-80, 90)
  58. turtle.end_fill()
  59. turtle.right(135)
  60. turtle.fd(60)
  61. turtle.left(180)
  62. turtle.fd(85)
  63. turtle.left(90)
  64. turtle.fd(80)
  65. # 叶子2
  66. turtle.right(90)
  67. turtle.right(45)
  68. turtle.fillcolor("green")
  69. turtle.begin_fill()
  70. turtle.circle(80, 90)
  71. turtle.left(90)
  72. turtle.circle(80, 90)
  73. turtle.end_fill()
  74. turtle.left(135)
  75. turtle.fd(60)
  76. turtle.left(180)
  77. turtle.fd(60)
  78. turtle.right(90)
  79. turtle.circle(200, 60)
  80. turtle.done()

2.圆:

  1. import turtle as t
  2. t.pencolor("blue")
  3. t.pensize(5)
  4. t.pendown()
  5. t.circle(100)
  6. t.done()

2.三角形

  1. import turtle as t
  2. t.pencolor("blue")
  3. t.pensize(5)
  4. t.fd(100)
  5. t.lt(120)
  6. t.fd(100)
  7. t.lt(120)
  8. t.fd(100)
  9. t.done()
  10. 3.虚圆
  11. ```python
  12. import turtle
  13. paiter=turtle.Turtle()
  14. paiter.speed(10)
  15. paiter.pencolor("red")
  16. for i in range(180):
  17. paiter.forward(100)
  18. paiter.right(30)
  19. paiter.forward(20)
  20. paiter.left(60)
  21. paiter.forward(50)
  22. paiter.right(30)
  23. paiter.penup()
  24. paiter.setposition(0,0)
  25. paiter.pendown()
  26. paiter.right(2)
  27. turtle.done()

文章知识点与官方知识档案匹配,可进一步学习相关知识
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/276590
推荐阅读
相关标签
  

闽ICP备14008679号