2016-09-13 14 views
-6

私はそれが非常に基本的だと私はそれを理解する必要がありますが、私はしていないと確信しています!x^2とはどういう意味ですか? Pythonで

は、私はこれを行うには与えられている:

> a=int(input("Enter the value for the co-efficient of x^2. ")) 
> b=int(input("Enter the value for the co-efficient of x. ")) 
> c=int(input("Enter the value for the constant term. ")) s=b**2-4*a*c 
> x1=(-b+(s**(1/2)))/2*a x2=(-b-(s**(1/2)))/2*a if a==0 and b==0: 
>  print("The equation has no roots.") elif a==0: 
>  print("The equation has only one root and it is", -c/b) elif s<0: 
>  print("The roots are not real!") else: 
>  print("The roots are", x1, "and", x2) 

は私が適切なソリューションと、すべての権利を取得しますが、私は^のためにそこにあるもの見当がつかない。私が使った唯一の理由は、練習前のレッスンで他の例で使われていたからです!

+0

「x^2」は、「xの2乗」、すなわち「x 2乗」を意味します。どうか、質問をする前にgoogleを使ってください。 –

+0

@TomLord x平方和を意味するものではなく、x ** 2はx平方和を意味します。 – Ezio

+0

はい、あります。 https://en.wikipedia.org/wiki/Square_(algebra) 'x^2'は、「x2乗」の非常に一般的な数学表記法です。しかし、いくつかの言語では、正方形を表現するための実際の構文は異なります。 –

答えて

3

Pythonではなく、何も意味しません。他

"Enter the value for the co-efficient of x^2. " 

あなたが書かれている可能性が何か:

"Enter the value for the co-efficient of x to the power 2. " 

input()を求めたときに示された出力が、何も変わっているだろう、それは文字列リテラルでちょうど別の文字です。

^は指数表記の一般的な表記法です。 Pythonでは、指数には**が使用されており、これが残りのコードで使用されています。

関連する問題