习题1:
三角形三条边长度分别为3,7,9,计算这个三角形的三角度数
import math
a = 3
b = 7
c = 9
cosC = (a**2 + b**2 - c**2) / c**2
C = math.acos(cosC)
print(C)
习题2、3略
习题4:
通过键盘输入数字作为圆的半径
计算圆的周长和面积,并分别打印显示出来,结果保留两位小数
import math
n = input('please input a number:')
n = float(n)
circle = 2 *math.pi * n
area = math.pi * n**2
print('the circle is:',round(circle,2))
print('the area is:',round(area,2))
习题5:
编写程序,实现如下功能
询问用户姓名和年龄
计算10年之后的年龄
打印出用户的姓名及其现在和10年后的年龄
name = input('your name:')
age = input('your age:')
after_ten = int(age)+10
print('-'*10)
print('your name is {0},\nyou are {1} years,now. \nAfter ten years, you are {2}'.format(name,age,after_ten))