Can someone help me in this? what's is wrong in this code? - Python
Аноним
1/27/2021, 9:26:43 PM
Ответов:
Can someone help me in this? what's is wrong in this code?

a=2 b=2 c=-1 d = b**2 - 4*a*c x1=-b + d**1/2/2*a x2=-b - d**1/2/2*a printd, x1, x2

Ответы (23)

Аноним
1/27/2021, 9:29:37 PM

Try import math and use math.pow() func

Аноним
1/27/2021, 9:30:44 PM

It executes and answers 12 0.3660254037844386 -1.3660254037844386, what is your issue with it?

Аноним
1/27/2021, 9:31:01 PM

It was the first thing I did, gave another answer.

Аноним
1/27/2021, 9:32:00 PM

every time i write this code (different software) give me a different answer.

Аноним
1/27/2021, 9:33:41 PM

If you want to solve a 2nd degree polynomial with your code, probably you want to use numpy for consistency and readability. Something like this should work: import numpy as np coeff = [a,b,c] np.roots(coeff)

Аноним
1/27/2021, 9:35:26 PM

no, I'm just training rsrs i decide to use something I can control.

Аноним
1/27/2021, 9:37:22 PM

it's correct here, i need to fix the other code. I realize that here, I was worry I made a mistake in the syntax

Аноним
1/27/2021, 9:37:35 PM

Another shot of solving your issue is using explicit conversion on your code. Something akin to this might solve it d = float(b**2 - (4*a*c)) x1=float((-b + d**(1/2))/(2*a)) x2=float((-b - d**(1/2))/(2*a)) print(d, x1, x2)

Аноним
1/27/2021, 9:38:06 PM

What is rsrs?

Аноним
1/27/2021, 9:38:33 PM

means a laugh

Аноним
1/27/2021, 9:39:21 PM

thanks i'll try this.

Аноним
1/27/2021, 9:41:48 PM

Is consistent my mistake must be in something else in the other software. I'm training the new software.

Аноним
1/27/2021, 9:41:57 PM

Now I know Brazilian argot lol. Hope you fix your issue

Аноним
1/27/2021, 9:42:28 PM

I can use this jajajaja 😀

Сергей
1/27/2021, 9:43:08 PM

Ok! This is a math rule: if d =0 then x=-b/2a and x is only

Аноним
1/27/2021, 9:43:20 PM

I got to study the software better

Аноним
1/27/2021, 9:43:43 PM

Are you running on same operating system and hardware?

Аноним
1/27/2021, 9:46:11 PM

I would recommend trying the numpy alternative and see if results are consistent. If not, are you using same Python implementation and version on both software?

Аноним
1/27/2021, 9:48:35 PM

I believe it uses a diferent implementation and the imput is strange. Is more complicate than I anticipated. Thanks for all the help

Аноним
1/27/2021, 9:48:52 PM

I suspect the two software somehow use different memory space for your variables during execution time. Add this to your code to see what happens: import sys print(sys.getsizeof(d)) print(sys.getsizeof(x1)) print(sys.getsizeof(x2))

ScriptHound
1/27/2021, 9:54:37 PM

Try calculating everything with float numbers.

Аноним
1/27/2021, 9:56:00 PM

ok, i'm trying the software is a little complicated but it claims to use python. so...

Аноним
1/27/2021, 9:56:37 PM

thank you i'lll try it

Похожие вопросы по теме Python

Аноним
5/15/2021, 2:14:11 PM
Ответов: 23
What to learn in Python after OOP?
Аноним
11/11/2020, 1:09:41 PM
Ответов: 23
Guys, could someone try to help me in my doubt regarding editing

csv files?? https://del.dog/arefeafuly i tried to declare the inputs as BINARY and STR, but even way i get the same error "TypeError: a bytes-like object is required, not 'str'"

Аноним
1/19/2021, 3:40:16 PM
Ответов: 23
is there any faster way to check if a number is a

power of 2?

Аноним
10/21/2020, 3:00:17 AM
Ответов: 23
can i use python for flutter android app backend?
Аноним
7/28/2021, 12:10:10 PM
Ответов: 22
Is there anyway to use multiple items in if statement?! Like, if

m1 , m2 >= 1 and m1 , m2 <= 6: #do stuff

Аноним
9/26/2020, 1:16:02 PM
Ответов: 22
Can someone help me with tips on mobile app development? Frameworks, guides,

links...

Аноним
6/7/2021, 2:20:26 PM
Ответов: 21
It's possible for example inside a function modify the variable of another

function?

Аноним
5/9/2021, 12:11:11 PM
Ответов: 21
Do anyone wants to learn python in just 3 days ??..

do let me know

Аноним
6/2/2021, 4:37:49 PM
Ответов: 21
how to allocate a function inside another without "return"?
BprMain
1/24/2021, 8:15:07 AM
Ответов: 23
How to enable my telegram robot to send a dice ?