货币税和小费浮动并发症

Money Tax and Tip Float Complication

我正在制作一个程序来查找税金金额并将其与小费相结合。

我正在研究小费金额和介绍。

代码:

print "Welcome \nEnter The Amount Of Money For the Transaction"

amount = raw_input

print "Taxed Amount Below\n"
taxed = (amount * float((1.065)))

print taxed

这就是我得到的:

>>> runfile('/home/meyer/.spyder2/temp.py', wdir='/home/meyer/.spyder2')
Welcome 
Enter The Amount Of Money For the Transaction
Taxed Amount Below

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
    execfile(filename, namespace)
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
    builtins.execfile(filename, *where)
  File "/home/meyer/.spyder2/temp.py", line 8, in <module>
    taxed = (amount * float((1.065)))
TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'float'
>>> 

我知道我不能乘以这个浮点数,但我找不到任何其他方法。甚至 MMPath

我正在使用 python 2.7

提前致谢!

您的代码无效,因为您在 raw_input 之后需要参数,请尝试以下操作:

print "Welcome \nEnter The Amount Of Money For the Transaction"

amount = float(raw_input())

print "Taxed Amount Below\n"
taxed = (amount * float((1.065)))

print taxed

您正试图将一个内置函数乘以一个浮点数。您必须改为调用该函数来获取数字:

amount = float(raw_input())