Pycharm不会将我的函数返回到控制台

时间:2018-11-17 12:24:33

标签: python intellij-idea pycharm

我的函数返回变量,但是在“返回”代码之后,在控制台上没有显示任何与Jupiter Notebook不同的东西。

dollar = 1.0
quarter = dollar / 4
dime = dollar / 10
nickel = dollar / 20
penny = dollar / 100


def quarter_returns(change):
    counter_quarter = 0
    while change >= quarter:
        change = change - quarter
        counter_quarter = counter_quarter + 1
    return "Your quarter change is {}, {}".format(counter_quarter,round(change,2))

quarter_returns(0.56)

1 个答案:

答案 0 :(得分:1)

因为它不是interactive mode。使用print查看结果:

print(quarter_returns(0.56))

输出:

Your quarter change is 2, 0.06