zoukankan      html  css  js  c++  java
  • Python基础

    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):

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

    # -*- coding: UTF-8 -*-# -*-
    import turtle
    from turtle import *
    
    
    def mygoto(x, y):
        turtle.up()
        turtle.goto(x, y)
        turtle.down()
    
    turtle.bgcolor('red')
    turtle.color('yellow')
    turtle.fillcolor('yellow')
    turtle.setup(600,400,100,100)
    turtle.hideturtle()
    
    turtle.up()
    mygoto(-280,100)
    turtle.down()
    
    turtle.begin_fill()
    for i in range(5):
            turtle.forward(80)
            turtle.right(144)
    turtle.end_fill()
    
    turtle.up()
    mygoto(-180,170)
    turtle.down()
    
    turtle.begin_fill()
    for i in range(5):
            turtle.forward(30)
            turtle.left(144)
    turtle.end_fill()
    
    turtle.up()
    mygoto(-140,120)
    turtle.down()
    
    turtle.begin_fill()
    for i in range(5):
            turtle.forward(30)
            turtle.left(144)
    turtle.end_fill()
    
    turtle.up()
    mygoto(-140,70)
    turtle.down()
    
    turtle.begin_fill()
    for i in range(5):
            turtle.forward(30)
            turtle.right(144)
    turtle.end_fill()
    
    turtle.up()
    mygoto(-180,20)
    turtle.down()
    
    turtle.begin_fill()
    for i in range(5):
            turtle.forward(30)
            turtle.left(144)
    turtle.end_fill()
    
    done()
    
    def draw_star(a):
        turtle.begin_fill()
        for i in range(5):
            turtle.forward(a)
            turtle.right(144)
        turtle.end_fill()

  • 相关阅读:
    Anaconda+用conda创建python虚拟环境
    Linux安装matlab及简单操作
    Matlab2016b 版本knnclassify函数在Matlab2019b的替换及解决方案
    WIN TO GO实现win10系统迁移
    ArcMap高版本文件保存成低版本
    matlab 保存大于2GB数据
    Tensorflow_gpu + anconda3_3.4.2 +keras2.1.1 + CUDA8.0+CUDNN5.1
    B
    A
    POJ I Think I Need a Houseboat
  • 原文地址:https://www.cnblogs.com/ashh/p/8573802.html
Copyright © 2011-2022 走看看