登录后查看本帖详细内容!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
2.1: C=eval(input('输入摄氏温度:')) fahrenhrit=(9/5)*C+32 print(str(C)+'Celsius is'+str(fahrenhrit)+'Farhrenheit') 2.2: import math radius,height=eval(input('输入圆柱体半径和高:')) area=math.pi*radius**2 volume=area*height print('The area is '+str(area)) print('The volume is'+str(volume)) 2.3: feet=eval(input('输入英尺数:')) meters=0.305*feet print(str(feet)+'feet is'+str(meters)+'meters') 2.4: pounds=eval(input('输入磅数:')) kilograms=0.454*pounds print(str(pounds)+'pounds is'+str(kilograms)+'kilograms') 2.5: subtotal,gratuity_rate=eval(input('输入小计和酬金率:')) gratuity=subtotal*(gratuity_rate/100) total=subtotal+gratuity print('The gratuity is'+str(gratuity)+'and the total is'+str(total)) 2.6: number=eval(input('输入一个0~1000之间的整数:')) if 0<number<1000: sum=(number % 10)+(number//10) % 10+(number//100) print('The sum of digits is'+str(sum)) else: print('输入错误') 2.7: minutes=eval(input('输入分钟数:')) days=(minutes//60) // 24 years=days//365 days=days%365 print(years,days) 2.8: water_amount,initial_temperature,final_temperature=eval(input('输入水量,初始温度和最终温度:')) energy=water_amount*(final_temperature-initial_temperature)*4184 print('The energy needed is'+str(energy)) 2.9: temp,wind_speed=eval(input('输入华氏温度和风速:')) if -58<temp<41 and wind_speed>2: wind_chill=35.74+0.6215*temp-35.75*wind_speed**0.16+0.4275*temp*wind_speed**0.16 print(wind_chill) else: print('输入错误') 2.10: speed,acceleration=eval(input('输入速度和加速度:')) length=speed**2/(2*acceleration) print('The minimum runway length for thisairplane is '+str(length)+'meters') 2.11: final_value,years_rate,years=eval(input('输入最终金额,年利率和年数:')) initial_vaule=final_value/(1+years_rate/12/100)**(years*12) print('The initial deposit value is'+str(initial_vaule)) 2.12: print('a b a**b''\n' '1 2 1''\n' '2 3 8''\n' '3 4 81''\n' '4 5 1024''\n' '5 6 15625') 2.13: number=eval(input('输入一个四位整数:')) print(number%10,number//10%10,number//100%10,number//1000) 2.14: x1,y1,x2,y2,x3,y3=eval(input('输入三角形三个顶点的坐标:')) side1=pow((x1-x2)**2+(y1-y2)**2,0.5) side2=pow((x2-x3)**2+(y2-y3)**2,0.5) side3=pow((x1-x3)**2+(y1-y3)**2,0.5) s=(side1+side2+side3)/2 area=pow(s*(s-side1)*(s-side2)*(s-side3),0.5) print('The area of the triangle is'+str(area)) 2.15: side=eval(input('输入正六边形边长:')) area=3*3**0.5/2*side**2 print('The area of the hexagon is '+str(area)) 2.16: v0,v1,t=eval(input('输入初始速度,最终速度和时间:')) a=(v1-v0)/t print('The average acceleration is'+str(a)) 2.17: weight,hight=eval(input('输入以磅为单位的体重和以英尺为单位的身高:')) bmi=weight*0.45359237/(hight*0.0254)**2 print('BMI is'+str(bmi)) 2.18: import time time_zone=eval(input('输入时区:')) all_seconds=int(time.time()) seconds=all_seconds % 60 minitues=all_seconds//60 hours=minitues // 60 minitues=hours % 60 hours=hours % 24 hours+=time_zone print('The current time is'+str(hours)+':'+str(minitues)+':'+str(seconds)) 2.19: investment_amount,interest_rate,years=eval(input('输入金额,年利率,年数:')) accumulated_value=investment_amount*(1+interest_rate/12/100)**(years*12) print('accumulated value is '+str(accumulated_value)) 2.20: balance,interest_rate=eval(input('输入差额和年利率:')) interest=balance*(interest_rate/1200) print('The interest is'+str(interest)) 2.21: month_save=eval(input('每个月存款数:')) month1_value=month_save*(1+0.00417) month2_value=(month_save+month1_value)*(1+0.00417) month3_value=(month_save+month2_value)*(1+0.00417) month4_value=(month_save+month3_value)*(1+0.00417) month5_value=(month_save+month4_value)*(1+0.00417) month6_value=(month_save+month5_value)*(1+0.00417) print('After the sixth month,the account valueis'+str(month6_value)) 2.22: years=eval(input('输入年数')) all_seconds=years*365*24*60*60 people=3120324986+all_seconds//7-all_seconds//13+all_seconds//45 print('The population in 5 years is'+str(people)) 2.23: from turtle import* radise=eval(input('输入半径:')) penup() goto(radise,0) pendown() circle(radise) right(180) circle(radise) penup() goto(-radise,0) pendown() circle(radise) right(180) circle(radise) done() 2.24: from turtle import* penup() goto(100,0) pendown() circle(100,steps=6) right(180) circle(100,steps=6) penup() goto(-100,0) pendown() circle(100,steps=6) right(180) circle(100,steps=6) done() 2.25: from turtle import* x1,y1,length,width=eval(input('输入矩形中心、长和宽')) penup() goto(x1,y1) goto(x1+length/2,y1) pendown() left(90) forward(width/2) left(90) forward(length) left(90) forward(width) left(90) forward(length) left(90) forward(width/2) done() 2.26: from turtle import* import math x1,y1,radise=eval(input('输入圆心和半径:')) penup() goto(x1,y1-radise) pendown() circle(radise) penup() goto(x1,y1) pendown() write(math.pi*radise**2) done()
|