• Python输入输出练习


    1.hello world

    print('hello world')

    2.交互式

    name=input('name=:')
    print('我的名字是:{}'.format(name))

    3.两者之和

    print('两者之和为:%.0f'%float(float(input('输入第一个数字:'))+float(input('输入第二个数字:'))))

    4.三角形面积

    a=float(input('a='))
    b=float(input('b='))
    c=float(input('c='))
    p=float((float(a+b+c))/2)
    print('三角形abc的面积为:%.0f'%float((p*(p-a)*(p-b)*(p-c))**0.5))

    5圆的面积

    r=float(input('半径为:'))
    print('半径为{}的面积为:%.2f'.format(r) %float(3.1314 * r * r))

    6同切圆

    import turtle
    turtle.circle(5)
    turtle.circle(10)
    turtle.circle(15)
    turtle.circle(20)

    7.五角星

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

    8填充颜色的五角星

    import turtle
    turtle.bgcolor('red')
    turtle.color('yellow')
    turtle.fillcolor('yellow')
    
    turtle.begin_fill()
    
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    
    turtle.end_fill()

    9国旗

    import turtle
    turtle.color('yellow')
    turtle.bgcolor('red')
    turtle.fillcolor('yellow')
    
    
    
    turtle.begin_fill()
    
    turtle.up()
    turtle.goto(-200,100)
    turtle.down()
    
    turtle.forward(150)
    turtle.right(144)
    turtle.forward(150)
    turtle.right(144)
    turtle.forward(150)
    turtle.right(144)
    turtle.forward(150)
    turtle.right(144)
    turtle.forward(150)
    turtle.end_fill()
    
    
    turtle.begin_fill()
    
    turtle.up()
    turtle.goto(-80,160)
    turtle.down()
    
    
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.end_fill()
    
    
    turtle.begin_fill()
    
    turtle.up()
    turtle.goto(-22,68)
    turtle.down()
    
    
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.end_fill()
    
    turtle.begin_fill()
    
    turtle.up()
    turtle.goto(-30,110)
    turtle.down()
    
    
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.end_fill()
    
    
    turtle.begin_fill()
    
    turtle.up()
    turtle.goto(-45,-10)
    turtle.down()
    
    
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.end_fill()

  • 相关阅读:
    .NET实现之(WebService数据提供程序)
    站内搜索(主要技术点:Luncene.Net搜索引擎核心,Log4Net:日志,定时框架:quartz.Net,Jquery,Json,AJAX)
    非常棒的 ASP.NET Web Forms 和 ASP.NET MVC 免费培训视频!
    NET实现之(简易ORM)
    Razor4Orchard v1.2
    MVC和三层 【转】热闹
    .NET简谈平台大局观
    Trigger4Orchard
    步步为营 .NET 代码重构学习笔记 一、为何要代码重构
    步步为营 .NET 代码重构学习笔记 三、内联方法(Inline Method)
  • 原文地址:https://www.cnblogs.com/husiqi/p/7491880.html
Copyright © 2020-2023  润新知