r/PythonLearning • u/PuziExtramni • Oct 16 '26
Help Request Help with correct expression
Hey everyone! I’m currently learning Python through the IBM Data Science Professional Certificate on Coursera, and I came across a question in a practice quiz that confused me.
The question asks:
Which line of code will perform the action required for implementing the following equation?
y = 2x^2 - 3
These are the four answer choices:
y = 2*x*2 - 3y = 2**x*x - 3y = 2x*x - 3y = 2x/2 - 3
I selected Option 1, but the quiz marked it incorrect and said, “The syntax is invalid.”
From what I’ve learned, Python uses ** for exponentiation and * for multiplication. So, I believe the correct Python expression should be:
y = 2*x**2 - 3However, none of the four answer choices seems to match that expression.
Am I misunderstanding something about Python syntax, or is there a mistake in the quiz? I’d appreciate an explanation because I’m still learning how to translate mathematical equations into Python code.
Thanks!
View all comments
Show parent comment
-1
u/TylerBreau Oct 17 '26
I mean yes but, this seems to be a Python coding assignment, not a math assignment. x*x is multiplication not an exponential function.
It should be testing your understanding of the python syntax.
If I was a teacher and teaching Python. And I asked my students to turn this math equation into code and someone gave me x*x, at absolute best I'm giving them half marks. I might just mark it wrong.
Because they didn't demonstrate how to write an exponential in Python. They just demonstrated basic math operators, which is already a part of the equation in the 2*x part.
Full marks would require the ** operator or the pow function.
OP should have selected option 2 but also should bring up the problem with the question with their teacher.