Python 第一周常见运算符作业

一、作业详情

1.第一题

代码如下:

ce=int(input("Enter a defree in Celsius"))
fa=(9/5)*ce+32
print("%s Celsius is %s Fahrenheit"%(ce,fa))

 2.第二题

代码如下:

length=float(input("高"))
radius=int(input("半径"))
area=radius*radius*3.14
volume=area*length
print("The area is %s"%(area))
print("The volume is %s"%(volume))

 3.第三题

代码如下:

num=int(input("Enter a number between 0 and 1000"))
if num>99:
	a=num%10
	b=num//10%10
	c=num//10//10%10
	sum=a+b+c
	print("The sum of the digits %s"%(sum))
elif num<99:
	a=num%10
	b=num//10%10
	sum=a+b
	print("The sum of the digits %s"%(sum))
	

 4.第四题

代码如下:

num=int(input("Enter a number of minutes: "))
k=num/(60*24*365)-num//(60*24*365)
if k>0:
	day=int(k*365)
year=num//(60*24*365)
print("%s minutes is approximately %s years and %s days"%(num,year,day))

5.第五题

代码如下:

M=float(input("Enter the amount water in kilograms:"))
intem=float(input("Enter the initial temperature:"))
fitem=float(input("Enter the initial temperature:"))
q=M*(fitem-intem)*4184
print("The energy needed is "+str(q))

 6.第六题

代码如下:

ta=float(input("Enter the temperature in Fahrenheit between -58 and 41:"))
v=int(input("Enter the wind speed in miles per hour:"))
tw=35.74+0.6215*ta-35.75*v**0.16+0.4275*ta*v**0.16

print("The wind chill index is "+str(tw))

 7.第七题

代码如下:

speed=float(input("Enter :"))
acceleration=float(input("acceleration:"))
length=speed**2/(2*acceleration)
print("The minimum runway length for this airplane is"+str(length))

  8.第八题

代码如下:

a=int(input("输入四位数字"))
b=a%10
print(b)
c=a//10%10
print(c)
d=a//100%10
print(d)
e=a//1000%10
print(e)

 9.第九题

代码如下:

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=((x2-x3)**2+(y2-y3)**2)**0.5
s=(side1+side2+side3)/2
area=(s*(s-side1)*(s-side2)*(s-side3))**0.5
print("The area of the triangleid "+str(area))

10.第十题

代码如下:

s=float(input("Enter the side :"))
area=s**2*3*3**0.5/2
print("The area of the hexagon is "+str(area))

12.第十二题

代码如下:

a=float(input("Enter the monthly saving amount :")) 
#第一个月
f1=a*(1+0.00417)
#第二个月
f2=(f1+a)*(1+0.00417)
f3=(f2+a)*(1+0.00417)
f4=(f3+a)*(1+0.00417)
f5=(f4+a)*(1+0.00417)
f6=(f5+a)*(1+0.00417)
print("after the sixth month,the account vaule is "+str(f6))

 13.第十三题

代码如下:

jin=float(input("Enter invvestment amount:"))
nian=float(input("Enter anaual interest rate:"))
year=float(input("Enter number of year:"))
w=jin*(1+nian/1200)**(year*12)
print("Accumulated value is "+str(w))

 14.第十四题

代码如下:

import math
a = float(input("a:"))
b = float(input("b:"))
c = float(input("c:"))
A = math.acos((a * a - b * b - c * c)/(-2 * b * c))
B = math.acos((b * b - a * a - c * c)/(-2 * b * c))
C = math.acos((c * c - b * b - a * a)/(-2 * a * b))
A = round(math.degrees(A))
B = round(math.degrees(B))
C = round(math.degrees(C))
print(A,B,C)

 15.第十五题

代码如下:

import math
n=float(input("输入边个数"))
s=float(input("边长长度"))
area=(n*s*s)/(4*math.tan(3.14/n))
print(area)

 16.第十六题

代码如下:

a=float(input("Enter an integer:"))
a4=int(a%10)

a3=int(a//10%10)

a2=int(a//100%10)

a1=int(a//1000%10)

print(a4,a3,a2,a1)

 17.第十七题

代码如下:

a=float(input("输入数字"))
a=a*100
#美元个数
a1=a//100
#剩余分数
a2=a%100
#两角五分的个数
a3=a2//25
#剩余分数2
a4=a2%25
#一角
a5=a4//10
#剩余分数3
a6=a4%10
#五分
a7=a6//5
#一美分
a8=a6%5
print("美元%s 两角五%s 一角%s 五分%s 一美分%s"%(a1,a3,a5,a7,a8))

  18.第十八题

代码如下:

name=input("Enter employee's name:")
worktime=float(input("Enter number of hours worked in a week:"))
pay_rate=float(input("Enter hourly pay rate:"))
lianbang=float(input("Enter federal pax withholding rate:"))
zhou=float(input("Enter state pax withholding rate:"))

cross_pay=pay_rate*worktime
Federal=cross_pay*lianbang
state=cross_pay*zhou
total=Federal+state
net_pay=cross_pay-total
print("""
	Employee Name:$%s 
	Hours Worked:$%s
	Pay Rate:$%s
	Cross Pay :$%s
	Deductions:
	Federal Withholding (20.0) %s
	State  Withholding (9.0) :$%s	
	Total Deduction :$%s
	Net Pay:$%s
	"""%(name,worktime,pay_rate,cross_pay,Federal,state,total,net_pay))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值