0

Printing a squared number

I was wondering how to print a squared number, such as x^2, in proper form. Currently I have print = ("x**2"). Although I understand this is x squared I was wondering if there is a way to make the output more user friendly with a correct looking notation?

1st Dec 2020, 1:49 AM
Will M
Will M - avatar
4 odpowiedzi
+ 10
If you want to print an square of a number Use print method Like this 👇 x= int(input()) print(x**2)
1st Dec 2020, 1:52 AM
Piyush
Piyush - avatar
+ 7
If you want to find value of 2x² then multiply square of x with 2
1st Dec 2020, 2:06 AM
Piyush
Piyush - avatar
0
Thank you but I'm currently creating a code for the quad formula. After prompting the user for the values of a, b, and c, I was hoping to print out whatever the equation they have is. For example if a is 2 I want to be able to print = (a + ("x squared")) with the output being 2x^2 Im not sure if it's even possible to print it correctly as x^2
1st Dec 2020, 2:01 AM
Will M
Will M - avatar
0
Thank you for the help Piyush! I was looking for how to print out "2x²" as "2x²" (not as x**2 or x^2) and realized I could just add the "²" as part of the string.
1st Dec 2020, 2:13 AM
Will M
Will M - avatar