2020-12-06

计算收益

p = int(input(‘请输入你的本金:’))
r = int(input(‘请输入利率:’))
n = int(input(‘请输入存的年份:’))

amount = p+p*(1+r)**n
print(‘本金利率和是:{:.2f}’.format(amount))
1
2
3
4
5
6
计算球体的表面积和体积

import math
r = int(input(‘请输入球的半径:’))

area = 4math.pir2
volume = 4/3math.pir
3

print(‘球的表面积是:{:.2f},球的体积是:{:.2f}’.format(area,volume))
1
2
3
4
5
6
7
申明函数计算收益

ef getvalue(b,r,n):
v = b*(1+r)**n
return v #这里一定要返回值,不然amount就会不被定义

b = int(input(‘请输入本金:’))
r = int(input(‘请输入利率:’))
n = int(input(‘请输入年份:’))

amount = getvalue(b,r,n)
print(‘最终收益:{:.2f}’.format(amount))
1
2
3
4
5
6
7
8
9
10
计算函数x*x-10x+16=0的解

import math

a = float(input(‘请输入a:’))
b = float(input(‘请输入b:’))
c = float(input(‘请输入c:’))
d = b**2-4ac

if a != 0:
if d < 0:
print(‘无解’)
elif d == 0:
s = -b/(2a)
print(‘唯一根:x=’,s)
else:
s1 = (-b-math.sqrt(d))/(2
a)
s2 = (-b+math.sqrt(d))/(2*a)
print(‘两解,x1={:.2f},x2={:.2f}’.format(s1,s2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
计算您今年多少岁

import datetime
n = input(‘请输入你的姓名:’)
y = int(input(‘请输入你的出生年月:’))

w = datetime.date.today().year

print(‘您好!{}。您{}岁’.format(n,w-y))

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值