Demo01
celsius = int(input("请输入一个摄氏温度:"))
fahrenheit = (9 / 5) * celsius +32
print("转化后的华氏温度为%s"%(fahrenheit))
radius = int(input("请输入圆柱的半径:"))
length = int(input("请输入圆柱的高:"))
area = radius * radius * 3.14
volume = area * length
print("area is %s"%(area))
print("volume is %s"%(volume))
Demo03
number = int(input("请输入一个0-1000的整数:"))
number1 = number % 10
number2 = (number // 10) % 10
number3 = number // 100
sum = number1 + number2 + number3
print("他各位数字之和为%s"%(sum))
Demo04
minutes = int(input("请输入分钟数:"))
days = minutes / 60 / 24
years = days / 365
print("%s分钟所对应的天数为%s天,年数为%s年"%(minutes,days,years))
Demo05
wen1 =int(input("请输入一个初始温度:"))
wen2 =int(input("请输入一个最后温度:"))
water =int(input( "请输入水量:"))
Q = water*(wen2-wen1)*4184
print("Q=%s"%(Q))
Demo06
Ta = int(input("请输入一个介于-58~41的温度:"))
v = int(input("请输入一个大于等于每小时2里的风速:"))
Twc = 35.74 + 0.6215 * Ta - 35.74 * v ** 0.16 + 0.4275 * Ta * v ** 0.16
print("风寒温度为:%s"%(Twc))
Demo07
v = int(input("请输入飞机的起飞速度:"))
a = int(input("请输入飞机的加速度:"))
length = v ** 2 / 2 * a
print("最短跑道长度为:%s"%(length))
Demo08
number = int(input("请输入一个四位整数:"))
number1 = number % 10
number2 = (number // 10) % 10
number3 = (number // 100) % 10
number4 = number // 1000
print("%s"%(number1))
print("%s"%(number2))
print("%s"%(number3))
print("%s"%(number4))
Demo09
方法一:
number = int(input("请输入一个四位整数:"))
number1 = number % 10
number2 = number // 10 % 10
number3 = number //100 % 10
number4 = number // 1000
number5 = number4 + number3 * 10 + number2 * 100 + number1 * 1000
print("颠倒各位数字后的数为:%s"%(number5))
方法二:
number = int(input("请输入一个四位整数:"))
print(number[::-1])
Demo10
(x1,y1,x2,y2,x3,y3) = eval(input("请输入三角形的三个顶点"))
side1 = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
side2 = ((x3 - x2) ** 2 + (y3 - y2) ** 2) ** 0.5
side3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
s = (side1 + side2 + side3) / 2
area = (s * (s - side1) * (s-side2) * (s-side3)) ** 0.5
print("该三角形的面积为:%s"%(area))
Demo11
s = float(input("请输入正六边形的边长:"))
area = (3 * 3 ** 0.5 / 2) * s ** 2
print("正六边形的面积为:%s"%(area))
Demo12
value = int(input("请输入首月存款:"))
month_Profit = 1.00417
value6 = value * 6.00417 * (month_Profit ** 5)
print("六月后的存款为:%s"%(value6))
Demo13
capital = int(input("请输入投资额:"))
ear = float(input("请输入年利率:"))
years = int(input("请输入年数:"))
value = capital * (1 + ear / 12 ) ** (years * 12)
print("未来投资额为:%s"%(value))
Demo14
import math
a = int(input("请输入a的值:"))
b = int(input("请输入b的值:"))
c = int(input("请输入c的值:"))
A = math.acos((a * a - b * b - c * c) / (-2 * b * c))
B = math.acos((b * b - a * a - c * c) / (-2 * a * c))
C = math.acos((c * c - b * b - a * a) / (-2 * a * b))
print("A = %s rad" %(A) )
print("B = %s rad" %(B) )
print("C = %s rad" %(C) )
Demo15
import math
n = int(input("请输入正多边形的边数:"))
s = float(input("请输入正多边形的边长:"))
area = (n * s ** 2) / (math.tan( 3.14 / n) * 4)
print("正多边形的面积为:%s"%(area))
Demo16
name = (input("请输入雇员姓名:"))
time = int(input("请输入一周的工作时间:"))
pay = float(input("请输入每小时的报酬:"))
pay_Urate = float(input("请输入联邦预扣税率:"))
pay_Srate = float(input("请输入州预扣税率:"))
print("雇员姓名:%s"%(name))
print("一周的工作时间:%s"%(time))
print("每小时的报酬:%s"%(pay))
print("联邦预扣税率:%s"%(pay_Urate))
print("州预扣税率:%s"%(pay_Srate))
Demo17
dollar = float(input("请输入含两位小数的美元总金额:"))
cent = 100 * dollar
dollar_Number = cent // 100
left_One = cent % 100
quarter_Number = left_One // 25
left_Two = left_One % 25
dime_dollar = left_Two // 10
left_Three = left_Two % 10
nickel_dollar = left_Three // 5
left_Four = left_Three % 5
cent_dollar = left_Four
print("美元有:%s张"%(dollar_Number))
print("两角五分有%s张"%(quarter_Number))
print("一角有%s张"%(dime_dollar))
print("五分有%s张"%(nickel_dollar))
print("一分有%s张"%(cent_dollar))