zoukankan      html  css  js  c++  java
  • 014 Python基本图形绘制小结

    一、Python基本语法元素

    • 缩进、注释、命名、变量、保留字
    • 数据类型、字符串、 整数、浮点数、列表
    • 赋值语句、分支语句、函数
    • input()、print()、eval()、 print()格式化

    1.1 温度转换

    # TempConvert.py
    
    TempStr = input("请输入带有符号的温度值: ")
    if TempStr[-1] in ['F', 'f']:
        C = (eval(TempStr[0:-1]) - 32) / 1.8
        print("转换后的温度是{:.2f}C".format(C))
    elif TempStr[-1] in ['C', 'c']:
        F = 1.8 * eval(TempStr[0:-1]) + 32
        print("转换后的温度是{:.2f}F".format(F))
    else:
        print("输入格式错误")
    

    二、Python基本图形绘制

    • 从计算机技术演进角度看待Python语言
    • 海龟绘图体系及import保留字用法
    • penup()、pendown()、pensize()、pencolor()
    • fd()、circle()、seth()
    • 循环语句:for和in、range()函数

    2.1 Python蟒蛇绘制

    import turtle
    
    turtle.setup(650, 350, 200, 200)
    turtle.penup()
    turtle.fd(-250)
    turtle.pendown()
    turtle.pensize(25)
    turtle.pencolor("purple")
    turtle.seth(-40)
    for i in range(4):
        turtle.circle(40, 80)
        turtle.circle(-40, 80)
    turtle.circle(40, 80 / 2)
    turtle.fd(40)
    turtle.circle(16, 180)
    turtle.fd(40 * 2 / 3)
    turtle.done()
    

    014-Python基本图形绘制小结-01.jpg?x-oss-process=style/watermark

  • 相关阅读:
    poj 1286
    poj 1815
    poj 3368
    十个利用矩阵乘法解决的经典题目
    poj 1026
    hdu 1394
    poj 3270
    poj 2154
    《重构 改善既有代码的设计》读书笔记2
    Android OpenGL ES: 渐变颜色的三角形
  • 原文地址:https://www.cnblogs.com/abdm-989/p/14129374.html
Copyright © 2011-2022 走看看