day 03
目录
一、变量1、什么是变量变量是会变化的量 2、为什么要有变量计算机需要一种概念来描述事物 3、定义变量如何在python中定义变量? 直接赋值 = name='nick' age=10 print(age) 4、变量的组成1.变量名变量名用来引用变量值,不需要定义变量 2.赋值符号赋值给变量 3.变量值存放数据,用来表达数据的状态 5、变量名的规范
[‘and‘,‘as‘,‘assert‘,‘break‘,‘class‘,‘continue‘,‘def‘,‘del‘,‘elif‘,‘else‘,‘except‘,‘exec‘,‘finally‘,‘for‘,‘from‘,‘global‘,‘if‘,‘import‘,‘in‘,‘is‘,‘lambda‘,‘not‘,‘or‘,‘pass‘,‘print‘,‘raise‘,‘return‘,‘try‘,‘while‘,‘with‘,‘yield‘] 6、变量名的两种风格
age_of_nick 二、pycharm的使用与快捷键1.设置file --》 settings --》 editor --》general --》 change font size 。。。。 file --》 settings --》 editor --》font --》 修改默认字体大小 file --》 settings --》 editor --》color Scheme --》 python --》monokai (主题的配置) file --》 settings --》 editor --》 general --》 code completion --》case sensitive completion --》 None 不区分大小写 2快捷键ctrl + v 粘贴 ctrl + c 复制 ctrl + a 全选 ctrl + x 剪切 ctrl + y 删除整行 ctrl + backspace 删除一个单词 shift + enter 换行 ctrl + f 搜索 --》 match case 匹配大小写;words 匹配单词(以空格区分单词) ctrl + d 向下复制 ctrl + shift + r 全局搜索 shift + F10 运行上一次运行的文件 ctrl + shift + f10 运行当前文件 home键与end键对应行首行尾 ctrl+home 整个代码的起始 三、python-turtle利用turtle(海龟)库可以绘制各种你想要的的图形,是turtle绘图体系的Python实现 1.蟒蛇绘制代码详解import turtle #调用turtle库 for i in range(4): turtle.fd(40) #画笔前进-250(即后退250) 2.基础指令import turtle #调用库 turtle.speed(4) 运行速度 turtle.setup(800,600) 默认画布大小 turtle.done() 空间布局 隐式turtle.goto(100,100) # 到达某一个点 turtle.goto(-100,-100) # 到达某一个点 旋转turtle.seth(40) # 绝对 turtle.left(30) # 相对当前的角度而言旋转 turtle.seth(0) turtle.right(90) 颜色体系turtle.pencolor(‘red‘) # 画笔的颜色# turtle.colormode(255) 255 RGB模式 turtle.pencolor(255,255) # 画笔的颜色 turtle.colormode(1) turtle.pencolor(1,1) 101模式 画笔大小turtle.pensize(10) # 控制画笔大小 控制画笔前进turtle.forward(100) turtle.fd(100) turtle.bk(200) turtle.circle(20,180) 填充颜色turtle.fillcolor(‘yellow‘) turtle.begin_fill() turtle.circle(20) turtle.end_fill() 控制画笔turtle.penup() # 抬笔 trutle.pu() turtle.pendown() # 落笔turtle.done() 3.画鹅代码: import turtle t=turtle turtle.speed(10) t. setup(800,600) #画头 turtle.penup() turtle.goto(0,100) turtle.pendown() turtle.pensize(20) turtle.fillcolor('black') turtle.begin_fill() turtle.circle(80,360) turtle.end_fill() #画肚子 turtle.up() turtle.goto(-70,130) # turtle.pencolor("red") #找画笔 turtle.seth(-125) turtle.pendown() turtle.pensize(10) turtle.circle(300,60) turtle.up() turtle.goto(70,130) # turtle.pencolor("red") turtle.down() turtle.circle(-320,60) # turtle.pencolor("red") turtle.seth(-180) turtle.circle(-450,18) #画脚 turtle.up() turtle.pencolor("yellow") turtle.seth(-100) turtle.pendown() turtle.fillcolor("yellow") turtle.begin_fill() turtle.fd(50) turtle.seth(30) turtle.fd(63) turtle.end_fill() turtle.seth(0) turtle.up() turtle.fd(50) turtle.seth(-70) turtle.pendown() turtle.fillcolor("yellow") turtle.begin_fill() turtle.fd(50) turtle.seth(60) turtle.fd(50) turtle.end_fill() turtle.up() #画手 turtle.goto(125,30) turtle.down() turtle.pencolor("black") turtle.seth(-65) turtle.pensize(50) turtle.fd(100) turtle.up() turtle.goto(-135,30) turtle.down() turtle.seth(-120) turtle.fd(100) turtle.up() #围巾 turtle.goto(-70,120) turtle.seth(-60) turtle.down() turtle.pencolor("red") turtle.pensize(20) turtle.circle(80,125) #画眼 turtle.up() turtle.goto(-20,190) turtle.down() turtle.pencolor("white") turtle.pensize(3) turtle.fillcolor('white') turtle.begin_fill() turtle.circle(20,360) turtle.end_fill() turtle.up() turtle.goto(60,190) turtle.down() turtle.fillcolor('white') turtle.begin_fill() turtle.circle(20,360) turtle.end_fill() #画眼珠子 turtle.pencolor("black") turtle.up() turtle.goto(40,200) turtle.down() turtle.pensize(3) turtle.circle(1,360) turtle.up() turtle.goto(-40,200) turtle.down() turtle.circle(1,360) #画嘴 turtle.up() turtle.goto(-35,160) turtle.down() turtle.pencolor("yellow") turtle.seth(0) turtle.fillcolor('yellow') turtle.begin_fill() turtle.fd(80) turtle.seth(-145) turtle.fd(50) turtle.seth(145) turtle.fd(50) turtle.end_fill() turtle.up() turtle.goto(200,200) turtle.done() (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |