zoukankan      html  css  js  c++  java
  • Python输入输出练习,运算练习,turtle初步练习

    1、Hello World!
    print
    ("Hello World!")
    2、简单交互(交互式,文件式)教材P19
    >>> name = input("please input your name:") >>> please input your name:Poon >>> print(name) >>> Poon
    3、用户输入两个数字,计算并输出两个数字之和:
    s1 = float(input("please input the first num:")) s2 = float(input("please input the second num:")) sum = s1 + s2 print("the result is:%s" % sum) print("the result is %.2f" %((float(input("the first num is"))) + (float(input("the secibd num is")))))
    4、用户输入三角形三边长度,并计算三角形的面积:(海伦公式)
    a = float(input("Please input the a side:")) b = float(input("Please input the b side:")) c = float(input("Please input the c side:")) p = (a + b + c)/2 s = (p *(p-a) *(p-b)*(p-c))**0.5 print("the square is:%.2f" % s)
    5、输入半径,计算圆的面积。
    from
    math import pi r = float(input("Please input the r:")) s = pi * (r**2) print("the area is %.2f" % s)
    6、画一组同切圆
    import
    turtle as t t.speed(1) t.circle(10) t.circle(20) t.circle(30)
    7、画一个五角星
    import
    turtle as t t.speed(1) for i in range(5): t.forward(100)
    t.right(144)
    8、画一个全黄色的五角星
    import
    turtle as t t.fillcolor("red") t.begin_fill() while True: t.forward(200) t.right(144) if abs(pos())<1: break t.end_fill()
  • 相关阅读:
    第八届极客大挑战 Web-php绕过
    第八届极客大挑战 Web-故道白云&Clound的错误
    IMDB-TOP_250-爬虫
    任意角度图片旋转
    图片处理代码
    C#获取获取北京时间多种方法
    STL vector用法介绍
    C++ 用libcurl库进行http通讯网络编程
    CString 使用方法
    A星算法(游戏寻路算法)的C++实现(转)
  • 原文地址:https://www.cnblogs.com/poonxiujet/p/7483927.html
Copyright © 2011-2022 走看看