Power Math in Python

0 votes

What is the difference between "**" operator and "^"?

when I try to print 8^3 it gives an output of 11. But for my required answer, when I print 8**3 it gives the correct answer of 512. why?

 Why is it that 8^3 does not equal 512 as it is the correct answer? 


Nov 12, 2018 in Python by Sayantini
• 140 points
779 views

1 answer to this question.

0 votes
When you use "^" operator, it is a bitwise operator, which does "bitwise exclusive or".
 

The power operator is "**", like 8**3 which equals to 512.
answered Nov 12, 2018 by ana1504.k
• 7,910 points

Related Questions In Python

0 votes
1 answer

How can I use indices in math using python

Operator ^ is a bitwise operator, which does "bitwise exclusive or". More: http://wiki.python.org/moin/BitwiseOperators The ...READ MORE

answered Dec 11, 2018 in Python by aryya
• 7,460 points
2,315 views
0 votes
1 answer

How can I use the power function in python 2.7?

print(pow(3,4)) #this will return the exponentiation of 3 ...READ MORE

answered May 21, 2019 in Python by Mohammad
• 3,230 points
1,443 views
0 votes
1 answer

syntaxerror: "unexpected character after line continuation character in python" math

There is a slight confusion as both ...READ MORE

answered Feb 16, 2022 in Python by Nandini
• 5,480 points
851 views
0 votes
1 answer

syntaxerror: "unexpected character after line continuation character in python" math

The division operator is /, not \ READ MORE

answered Feb 16, 2022 in Python by CoolCoder
• 4,420 points
582 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,467 views
0 votes
1 answer
0 votes
1 answer

% operator in Python

When you use '(%g,%g)', it is the ...READ MORE

answered Nov 12, 2018 in Python by ana1504.k
• 7,910 points
992 views
+1 vote
1 answer

ssh first with mysqldb in python

Setup an ssh tunnel before you use ...READ MORE

answered May 23, 2019 in Python by ana1504.k
• 7,910 points
2,803 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP