python头歌实践教学平台-python第三章作业(初级)

不想考试的ID 2024-06-17 14:05:02 阅读 87

第1关判断是否直角三角形

a=eval(input())b=eval(input())c=eval(input())shortest=min(a,b,c)longest=max(a,b,c)middle=sum([a,b,c])-shortest-longestif shortest<=0 or shortest+middle<=longest: print('NO')elif shortest**2+middle**2==longest**2: print('YES')else: print('NO')

第2关今年多少天?

year=int(input())if year%400==0 or year%4==0 and year%100!=0: print('366')else: print('365')

第3关判断三角形并计算面积

a=float(input())b=float(input())c=float(input())if a+b>c and a+c>b and b+c>a: s=(a+b+c)/2 area=(s*(s-a)*(s-b)*(s-c))**0.50 print('YES') print(f'{area:.2f}')else: print('NO')

第4关身高测算

father_h=int(input())mother_h=int(input())child=input()if child=="男": child_h=(father_h+mother_h)*1.08/2 print(int(child_h))elif child=="女": child_h=((father_h*0.923)+mother_h)/2 print(int(child_h))else: print(f'无对应公式')

第5关个税计算器

n=eval(input())x=0if n<0: print("err



声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。