为什么我不断收到:'int' 对象在 Python 中不可调用? [英] Why do I keep getting: 'int' object is not callable in Python?

查看:39
本文介绍了为什么我不断收到:'int' 对象在 Python 中不可调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

x = 4y = 5a = 3(x + y)打印(一)

我一直在努力解决这个问题.我什至试过这个.

x = input(输入 x 的值:")

<块引用>

输入 x:4 的值

y = input(请输入 y 的值:")

<块引用>

输入 y:5 的值

a = 3 x + y

我做错了什么?

解决方案

要进行乘法,需要使用 * 运算符:

a = 3 * (x + y)

3(x + y) 看起来和感觉就像是函数 3函数调用,这就是为什么你得到错误.

FWIW,代数表达式,其中您只是将两个相邻的符号相邻,并不能在大多数编程语言中直接翻译,除非它们是专门为数学设计的.

x = 4
y = 5
a = 3(x + y)
print(a)

I keep trying to solve that. I've even tried this.

x = input("Enter value for x:")

Enter value for x:4

y = input("Enter value for y:")

Enter value for y:5

a = 3 x + y

What am I doing wrong?

解决方案

To multiply, you need to use the * operator:

a = 3 * (x + y)

3(x + y) looks and feels like a function call for the function 3, which is why you're getting the error.

FWIW, algebraic expressions where you simply abut two symbols next to each other does not translate directly in most programming languages, unless they were specifically designed for mathematics.

这篇关于为什么我不断收到:'int' 对象在 Python 中不可调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆