《pyhton语言程序设计》_第一章笔记

章1.62 python

(1).python区分大小写。函数

(2).python忽略在符号#以后的同行的内容对象

(3).python和matlab很类似(我的感受)blog

(4).章节1.91:ci

>>>import turtle #加载 turtle 模块,加载了之后就可使用turtle模块的全部函数it

注意:全部要用到turtle模块里面的函数,每次都要先加载turtle模块,即要在操做以前加上上面的这条函数。import

>>>turtle.showturtle() #会出现turtle的模块 ,箭头代表了当前的位置和方向。turtle的起始位置是窗口的中心,turtle是绘制图像的对象。基础

注意:在字符之间加上空格,对运行结果没有影响。程序

 

 

 

>>>turtle.write("welcome to python ")  #书写 welcome to python im

>>>turtle.forward(100)  #将箭头向前移动100像素,像箭头所指的方向绘制一条直线。

>>>turtle.color("red")  #把颜色改为红色

当点击了屡次运行,就会重复运行上面的程序,让程序重复运行,结果至关几回叠加。

 

 

 

 

 

 下面是一段有先后的连贯程序。

绘图(一)

>>>import turtle 

>>>turtle.goto(0,50) #将比从(0,0)移动到(0,50)

 

>>>turtle.penup() #拿起笔
>>>turtle.goto(50,-50) #设置笔的坐标是(50,-50)
>>>turtle.pendown() #放下笔   

 #在以上的程序的基础上运行,可是与原始仍是起始坐标的原点,把箭头移动到(50,-50)

>>>turtle.color("red") #把画笔颜色改为红色

>>>turtle.circle(50) #画出半径为50的圆

 

绘图(二)__绘制奥林匹克标志

 

import turtle #启动turtle模块
turtle.color("blue") #箭头(画笔)的颜色改为蓝色
turtle.penup() #拿起画笔
turtle.goto(-110,-25) #设置开始的位置坐标是(-110,-25)
turtle.pendown() #放下画笔,penup()抬起和pendown()放下笔,是控制笔移动时是否绘制成一条线
#假若不抬起画笔就移动箭头的话,就会在移动的路径出现一条直线链接,就如上面的程序(一)的案例。
turtle.circle(45) #以半径为45画圆

turtle.color("black")
turtle.penup()
turtle.goto(0,-25)
turtle.pendown()
turtle.circle(45)

turtle.color("red")
turtle.penup()
turtle.goto(110,-25)
turtle.pendown()
turtle.circle(45)

turtle.color("yellow")
turtle.penup()
turtle.goto(-55,-75)
turtle.pendown()
turtle.circle(45)

turtle.color("green")
turtle.penup()
turtle.goto(55,-75)
turtle.pendown()
turtle.circle(45)

 

 

 

 

 

 

 

turtle.penup()turtle.goto(50,-50)turtle.pendown()

相关文章
相关标签/搜索