简体   繁体   English

尝试输出两个值时,int对象不是可调用错误

[英]Int object is not callable error when trying to output two values

I am trying to create a program to give the length and width of a rectangle given the perimeter and diagonal. 我正在尝试创建一个程序来给出给定周长和对角线的矩形的长度和宽度。 I have two formulas, one for l and one for w. 我有两个公式,一个代表l,一个代表w。 The only difference is the initial minus/plus, for the quadratic formula. 唯一的区别是二次公式的初始减号/加号。

I have tried re-writing the formula to make sure there are no syntax errors but that does not work. 我尝试重新编写公式,以确保没有语法错误,但这不起作用。

from math import sqrt as s
def sum_area(p, d):
    l = (p/4) + (s((p/2)**2-(4((p/2)**2-d**2)/2))/2) 
    w = (p/4) - (s((p/2)**2-(4((p/2)**2-d**2)/2))/2) 
    return [l,w]
print(sum_area(28,10))

The program should output [6,8]. 程序应输出[6,8]。 I have tested this using pen and paper. 我已经用笔和纸测试过了。

You typed 4( which is wrong, you want 4*( I am guessing. 您输入了4(这是错误的,您想输入4 *(我猜是。

from math import sqrt as s
def sum_area(p, d):
    l = (p/4) + (s((p/2)**2-(4*((p/2)**2-d**2)/2))/2) 
    w = (p/4) - (s((p/2)**2-(4*((p/2)**2-d**2)/2))/2) 
    return [l,w]
print(sum_area(28,10))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM