| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1816 人关注过本帖
标题:萌新求教...请问我的python代码语法哪里出了问题?
取消只看楼主 加入收藏
timeofmei
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-3-4
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
萌新求教...请问我的python代码语法哪里出了问题?
import math
def loan_calc():
    x = input('What are you gonna calculate? ')
    if x == 'r' or x == 'R':
        t = input('How long is the period in years? ')
        pv = input('What is the present value? ')
        fv = input('What is the future value? ')
        print('{} euqals to {}'.format(x, pow(fv/pv, 1/t)-1)
    if x == 'p' or x == 'P':      (这一行总是提示语法出错,如果删除的话就提示下一个if行语法出错)
        r = input('What is the interest rate? ')
        pv = input('What is the present value? ')
        fv = input('What is the future value? ')
        print('{} euqals to {}'.format(x, log(1+r, fv/pv)))
    if x == 'pv' or x == 'PV':
        r = input('What is the interest rate? ')
        t = input('How long is the period in years? ')
        fv = input('What is the future value? ')
        print('{} equals to {}'.format(x, fv/pow(1+r, t)))
    if x == 'fv' or x == 'FV':
        r = input('What is the interest rate? ')
        t = input('How long is the period in years? ')
        pv = input('What is the present value? ')
        print('{} equals to {}'.format(x, pv*pow(1+r, t)))
loan_clac()
搜索更多相关主题的帖子: value if the 语法 input 
2020-03-04 18:06
timeofmei
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-3-4
收藏
得分:0 
标点符号都没有问题,都检查过了
2020-03-04 18:07
timeofmei
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-3-4
收藏
得分:0 
回复 3楼 Kittt
谢谢你,问题解决了!
2020-03-05 17:51
快速回复:萌新求教...请问我的python代码语法哪里出了问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027343 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved