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

 

转载于:https://www.cnblogs.com/poonxiujet/p/7483927.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值