I'm typing the code:

import cmath
import math
print r"pow(2,3) returns 2^3 pow(2,3,1) returns 2^3 modulo 1" pow(2,3) pow(2,3,1)

and I'm getting this error:

File "sample2.py", line 26
print r"pow(2,3) returns 2^3 pow(2,3,1) returns 2^3 modulo 1" pow(2,3) pow(2,3,1)
^
SyntaxError: invalid syntax


Why is this invalid syntax?

You are missing the comma between values.

I'm typing the code:

Python Syntax (Toggle Plain Text)
import cmath
import math
print r"pow(2,3) returns 2^3 pow(2,3,1) returns 2^3 modulo 1" pow(2,3) , pow(2,3,1)

and I'm getting this error:

File "sample2.py", line 26
print r"pow(2,3) returns 2^3 pow(2,3,1) returns 2^3 modulo 1" pow(2,3) , pow(2,3,1)
^
SyntaxError: invalid syntax


I put the comma between the values pow(2,3) , pow(2,3,1). and it said the same thing

For python 2 and 3,i think you use pyhon 3 because you get error on print.

#Python 2.7
>>> print r"pow(2,3) returns 2^3 pow(2,3,1) returns 2^3 modulo 1", pow(2,3), pow(2,3,1)
pow(2,3) returns 2^3 pow(2,3,1) returns 2^3 modulo 1 8 0
#Python 3
>>> print(r"pow(2,3) returns 2^3 pow(2,3,1) returns 2^3 modulo 1", pow(2,3), pow(2,3,1))
pow(2,3) returns 2^3 pow(2,3,1) returns 2^3 modulo 1 8 0
>>> help(pow)
Help on built-in function pow in module builtins:

pow(...)
    pow(x, y[, z]) -> number
    
    With two arguments, equivalent to x**y.  With three arguments,
    equivalent to (x**y) % z, but may be more efficient (e.g. for longs).

>>>

pow is a function in the "math" program

import math
print r"pow(2,3) returns 2^3-->", math.pow(2,3)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.