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

  • 相关阅读:
    类与对象
    最大子段和
    贪心-Wooden Sticks
    MFC改变坐标系
    Java集合不能存放基本数据类型
    关于lower_bound( )和upper_bound( )的常见用法
    数组乘法(大整数相乘)
    米勒罗宾素数测试法
    深度搜索--poj1321 棋盘问题
    memcpy复制整型数组相关
  • 原文地址:https://www.cnblogs.com/ashh/p/8573802.html
Copyright © 2011-2022 走看看