只需运行用于“找钱”的简单程序即可。错误行7。 恰恰是
我尝试了str和int。
d= str(input('customer give'))
e= d-c
和
d= int(input('customer give'))
e= d-c
也
d= input('customer give')
e= d-c
和双引号
a= str(input ('give money'))
b= int(input ('quantity'))
c=a*b
print('the sum is ', c)
d= str(input('customer give'))
e= d-c
print ("The change is ", e , 'and customer give ', d)
回溯(最近通话最近):文件 “ /PycharmProjects/learn/learn.py”,第7行,在 e = d-c TypeError:-:“ str”和“ str”的不受支持的操作数类型
答案 0 :(得分:1)
e = d-c TypeError:-:'str'和'str'的不受支持的操作数类型
要执行上述操作,操作数应为整数或浮点型
尝试一下:
a= int(input ('give money '))
b= int(input ('quantity '))
c=a*b
print ('the sum is ', c)
d= int(input('customer give '))
e= d-c
print ("The change is ", e , 'and customer give ', d)
输出:
give money 10
quantity 3
the sum is 30
customer give 5
The change is -25 and customer give 5