码迷,mamicode.com
首页 > 编程语言 > 详细

Python基础

时间:2018-03-15 15:15:19      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:log   bubuko   height   输出   .com   输入输出   开发   from   hid   

Pycharm开发环境设置与熟悉。

练习基本输入输出:

print(‘你好,{}.‘.format(name))

uprint(sys.argv)

 

库的使用方法:

import ...

from ... import ...

 

条件语句:

    if (abs(pos()))<1:

        break

 

循环语句:

for i in range(5):

while True:

 

函数定义:

def mygoto(x,y):

def drawjx(r):

 

综合练习:画一面五星红旗,将代码与运行截图发布博客交作业。

import turtle

turtle.setup(600,400)
turtle.color("yellow")
turtle.bgcolor("red")
turtle.fillcolor("yellow")

def mygoto(x,y):
    turtle.up()
    turtle.goto(x,y)
    turtle.down()

def drawsatr(r):
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(r)
        turtle.right(144)
    turtle.end_fill()

mygoto(-250,75)
drawsatr(90)

mygoto(-110,150)
drawsatr(40)

mygoto(-70,100)
drawsatr(40)

mygoto(-70,50)
drawsatr(40)

mygoto(-110,0)
drawsatr(40)

turtle.hideturtle()
turtle.done()

运行结果截图:

 

技术分享图片

Python基础

标签:log   bubuko   height   输出   .com   输入输出   开发   from   hid   

原文地址:https://www.cnblogs.com/stcy520/p/8573400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!