What is the output of this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

What is the output of this code

X = 4 X _= 5 Print (x)

12th Nov 2020, 10:31 AM
Michael
Michael - avatar
2 Answers
+ 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.
12th Nov 2020, 10:35 AM
CouldntBeBothered.py
CouldntBeBothered.py - avatar
+ 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 🙂
12th Nov 2020, 11:35 AM
David Ashton
David Ashton - avatar