Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

Look at the below code:

def cube(number):

  return number^3

print cube(2)

I expect the output as 8, but instead, I'm getting 1 as output

Where did I go wrong? Anyone, please help me!

1 Answer

0 votes
by (26.4k points)

Here, You've used ^ operator, which is a xor operator.

To find the exponentiation you've to use ** symbol

2**3 =8

Join python training course fast, if you want to learn python in detail!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 20, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer

Browse Categories

...