+ 2

When I tried to print (5²) the output was syntax error invalid character in identifier , why??

1st Sep 2021, 10:10 AM
Emma Chitembo
Emma Chitembo - avatar
8 Respostas
+ 9
Because the particular programming language in which you wrote that ,don't understand that syntax . Just because it makes sense to you doesn't means it should make sense to computer as well . If you want to find square of a number than most languages provide a math library (google about it for the language you are using) or you can just multiply numbers like 5*5.
1st Sep 2021, 10:13 AM
Abhay
Abhay - avatar
+ 5
Uhh, maybe print(5 ** 2)?
1st Sep 2021, 10:13 AM
Tim
Tim - avatar
+ 4
Emma Chitembo Nick Is right We need to raise the power of number for than we need to type like this print(5**2)
1st Sep 2021, 10:25 AM
<★Shaurya Chauhan★>
<★Shaurya Chauhan★> - avatar
+ 3
Machines can not understand stand the normal mathamatics like 11%2 we get 1 likewise u has to 5**2 And high level language there is specific syntax : float pow(x,y) Hope I discribed well...
2nd Sep 2021, 4:48 AM
Manvendra Yadav
Manvendra Yadav - avatar
+ 2
5**2 will be same as 5*5. Machine can't understand communication languages like we do
1st Sep 2021, 10:34 AM
purveshKolhe
purveshKolhe - avatar
+ 1
Manvendra Yadav Any answer is better than some people who love to add biased opinions and try to show off, yours is already considered good
2nd Sep 2021, 4:50 AM
Tim
Tim - avatar
+ 1
Can I ask a question? Are you here to mess around or you're being serious
3rd Sep 2021, 8:48 AM
Tim
Tim - avatar
0
Daryna Ripych Why are you doing a math operation on a string?
3rd Sep 2021, 8:04 AM
Tim
Tim - avatar