day02homework7.17

NO.1
import math
r=float(input('Enter the length from the center to a vertex:'))
s=2*r*math.sin(math.pi/5)
area=5*s*s/(4*math.tan(math.pi/5))
print('The area of the pentagon is %.2f'%area)

NO.2
import math
x1,y1=map(float,input('Enter point 1(latitude and longitude) in degree:').split())
x2,y2=map(float,input('Enter point 2(latitude and longitude) in degree:').split())
x1=math.radians(x1)
y1=math.radians(y1)
x2=math.radians(x2)
y2=math.radians(y2)
d=6371.01*math.acos(math.sin(x1)*math.sin(x2)+math.cos(x1)*math.cos(x2)*math.cos(y1-y2))
print('The distance between the two points is %f km'%d)

NO.3
import math
s=float(input('Enter the side:'))
area=(5*s*s)/(4*math.tan(math.pi/5))
print('The area of the pentagon is %f'%area)

NO.4
import math
n=float(input('Enter the number of sides:'))
s=float(input('Enter the side:'))
area=(n*s*s)/(4*math.tan(math.pi/n))
print('The area of the polygon is %f'%area)

NO.5
code=int(input('Enter an ASCII code:'))
print('The character is ',chr(code))

NO.6
name=input('Enter employee`s name:')
time=float(input('Enter number of hours worked in a week:'))
pay=float(input('Enter hourly pay rate:'))
federal=float(input('Enter federal tax withholding rate:'))
state=float(input('Enter state tax withholding rate:'))
gross=time*pay
fw=gross*federal
sw=gross*state
td=fw+sw
np=gross-td
print('Employee Name:',name)
print('Hours Worked:',time)
print('Pay Rate:$',pay)
print('Gross Pay:',gross)
print('Deductions:')
print('   Federal Withholding(20.0%):',fw)
print('   State Withholding(9.0%):',sw)
print('   Total Deduction:',td)
print('Net Pay:',np)

NO.7
num=input('Enter an integer:')
num=num[::-1]
print(num)

NO.8
a=input('请输入一串字符:')
for i in a:
    print(chr(ord(i)-10),end=" ")

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值