- 2
What is the output of this code
X = 4 X _= 5 Print (x)
2 Antworten
+ 6
This will produce a NameError.
This is because the variable x is not defined.
Remember Python is case sensitive. The variable x and X are two different things.
Also Print is a NameError because of the case sensitivity. Print is not defined as a valid python function.
+ 5
Assuming you fix the capitalization problem and change the code to
x = 4
x -= 5
print(x)
the output will be the result of operation in the second line x -= 5, which is the same as saying x = x - 5, i.e. x = 4 - 5, i.e. -1.
Try it in the Code Playground and see for yourself 🙂