zoukankan      html  css  js  c++  java
  • Python练习

    Hello World!

    print('hello world!')

    简单交互(交互式,文件式)教材P19

    name = input("输入姓名:")
    print("{}同学,学好Python,前途无量!".format(name))

    用户输入两个数字,计算并输出两个数字之和:

    a = float(input('输入第一个数字:'))
    b = float(input('输入第二个数字:'))
    s = a+b
    print(s)

    用户输入三角形三边长度,并计算三角形的面积:(海伦公式)

    x = float(input('输入第一条边:'))
    y = float(input('输入第二条边:'))
    z = float(input('输入第三条边:'))
    p = float((x+y+z)*0.5)
    s = float((p*(p-x)*(p-y)*(p-z))**0.5)
    print('面积是;{0}'.format(s))

    输入半径,计算圆的面积。

    r = 25
    area = 3.1415 * r * r
    print(area)
    print("{:.2f}".format(area))

    画一组同切圆

    import turtle
    turtle.pensize(2)
    turtle.circle(10)
    turtle.circle(40)
    turtle.circle(80)
    turtle.circle(160)

    画一个五角星

    import turtle
    turtle.forward(200)
    turtle.right(144)
    turtle.forward(200)
    turtle.right(144)
    turtle.forward(200)
    turtle.right(144)
    turtle.forward(200)
    turtle.right(144)
    turtle.forward(200)

    画一个全黄色的五角星

    import turtle
    turtle.color('yellow')
    turtle.fillcolor('yellow')
    turtle.begin_fill()
    turtle.forward(200)
    turtle.right(144)
    turtle.forward(200)
    turtle.right(144)
    turtle.forward(200)
    turtle.right(144)
    turtle.forward(200)
    turtle.right(144)
    turtle.forward(200)
    turtle.end_fill()

  • 相关阅读:
    C primer plus 5 读书笔记2
    c primer plus 5 读书笔记1
    控制反转(IOC)模式
    软件设计原则
    springmvc跨域
    由阿里巴巴笔试题看java加载顺序
    spring各个包之间的依赖关系
    spring mvc 国际化
    git 笔记
    eclipse中maven项目部署到tomcat
  • 原文地址:https://www.cnblogs.com/knight-hui/p/7483923.html
Copyright © 2011-2022 走看看