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=" ")
day02homework7.17
最新推荐文章于 2024-07-19 01:20:22 发布