Demo01
celsius = int(input("请输入摄氏温度:"))
fahrenheit = (9 / 5) * celsius + 32
print("%s摄氏温度是%s华氏温度" %(celsius,fahrenheit))
结果
Demo02
radius=float(input("请输入半径:"))
length=int(input("请输入高度:"))
pi=3.1415
area=radius*radius*pi
vokume =area * length
print("面积:%s" %(area))
print("体积:%s" %(vokume))
Demo03
num = int(input("输入一个0到1000的数:"))
num1 = num % 10
num2 = num //10 % 10
num3 = num // 10 //10 % 10
sum = num1 + num2 + num3
print("输入数的各个数的和:%s" %(sum))
Demo04
minute = int(input("输入分钟数:"))
year = minute / 60 / 24 // 365
day = minute / 60 / 24 - year*365
print("年数:%s" %(year))
print("天数:%s" %(day))
Demo05
m = float(input("请输入水量以千克计算:"))
FirstTem = float(input("请输入开始温度:"))
LastTem = float(input("请输入结束温度:"))
Q = m*(LastTem-FirstTem) * 4184
print("需要能量:%s" %(Q))
Demo06
tem = float(input("请输入一个温度介于-58度和41度间:"))
v = float(input("请输入风速大于等于2公里每时:"))
t = 35.74 + 0.6215 * tem - 35.75 * v**0.16 + 0.4275 * tem * v**0.16
print("风寒温度:%s" %(t))
Demo07
v = float(input("请输入速度以米/秒为单位:"))
a = float(input("请输入速度以米/秒的平方为单位:"))
length = v * v / 2 / a
print("最短跑道:%s" %(length))
Demo08
num = int(input("请输入一个四位数:"))
num1 = num % 10
num2 = num // 10 % 10
num3 = num // 100 % 10
num4 = num // 1000
print(num1)
print(num2)
print(num3)
print(num4)
Demo09
x1 = float(input("请输入x1:"))
y1= float(input("请输入y1:"))
x2 = float(input("请输入x2:"))
y2= float(input("请输入y2:"))
x3 = float(input("请输入x3:"))
y3= float(input("请输入y3:"))
side1 =((x1-x2)**2+(y1-y2)**2)**0.5
side2 =((x1-x3)**2+(y1-y3)**2)**0.5
side3 =((x3-x2)**2+(y3-y2)**2)**0.5
s = (side1 + side2 + side3)/2
area = (s*(s - side1)*(s - side2)*(s -side3))**0.5
print("三角形面积:%s"%(area))
Demo10
s = float(input("请输入正六边形边长:"))
area = 0.5*3*3**0.5*s*s
print("正六边形面积:%s" %(area))
Demo12
money = float(input("请输入金额:"))
FarstMouth = money * (1 + 0.00417)
TwoMouth = (money + FarstMouth )* (1 + 0.00417)
ThreeMouth = (money + TwoMouth )* (1 + 0.00417)
FourMouth = (money + ThreeMouth )* (1 + 0.00417)
FiveMouth = (money + FourMouth )* (1 + 0.00417)
SixMouth = (money + FiveMouth) * (1 + 0.00417)
print(SixMouth)
Demo13
amount = float(input("请输入投资额:"))
rate = float(input("请输入年利率:"))
year = float(input("请输入年数:"))
FutureAmount = amount * (1 + 0.01 * rate) ** year
print("未来投资额:%s" %(FutureAmount))
Demo14
import math
a = int(input("三角形边a:"))
b = int(input("三角形边:b"))
c = int(input("三角形边c:"))
if a + b > c and a + c > b and b + c > a :
A = math.acos((a*a-b*b-c*c)/(-2*b*c))
B = math.acos((b*b-c*c-a*a)/(-2*a*c))
C = math.acos((c*c-a*a-b*b)/(-2*b*a))
A = round(math.degrees(A))
B = round(math.degrees(B))
C = round(math.degrees(C))
print("A=%d,B=%d,C=%d" %(A,B,C))
else :
print("三边不能构成三角形")
Demo15
import math
pi = 3.1415926
n = int(input("请输入边数:"))
s = float(input("请输入边长:"))
area =( n*s*s)/(4*math.tan(pi/n))
print("area=%s" %area)
Demo16
sum = int(input("请输入一个四位数:"))
sum1 = sum % 10
sum2 = sum // 10 % 10
sum3 = sum // 100 % 10
sum4 = sum // 1000
print(sum1 * 1000 + sum2 * 100 + sum3 * 10 + sum4)
Demo17
sum = float(input("请输入一个带小数点的数:"))
sum1 = sum * 100
sum2 = sum1 // 100
sum3 = sum1 % 100
sum4 = sum3 //25
sum5 = sum3 % 25
sum6 = sum5 //10
sum7 = sum5 % 10
sum8 = sum7 // 5
sum9 = sum7 % 5
print("美元:%s" %(sum2))
print("二角五分硬币:%s" %(sum4))
print("一角硬币:%s" %(sum6))
print("五分硬币:%s" %(sum8))
print("一分硬币:%s" %(sum9))
Demo18
name = input("输入员工姓名:")
time = int(input("输入一周工作时间:"))
pay = float(input("输入每小时报酬:"))
tax1 = float(input("输入联邦预扣税率:"))
tax2 = float(input("输入州预扣税率:"))
print("\n")
print("员工姓名:%s" %(name))
print("一周工作时间:%s" %(time))
print("每小时报酬:%s" %(pay))
print("一周扣前总报酬:%s" %(pay * time))
print("联邦预扣:%s" %(tax1 * pay * time))
print("州预扣:%s" %(tax2 * pay * time))
print("总共扣:%s" %(tax1 * pay * time + tax2 * pay * time))
print("一周扣后总报酬:%s" %((pay * time)-(tax1 * pay * time + tax2 * pay * time)))