+ 1
What does this mean?
What is the sum of the numbers printed by this code? try: print(1) print(1 + "1" == 2) print(2) except TypeError: print(3) else: print(4) Why is the answer 4 to this code?
10 Respuestas
+ 8
The answer IS 4... :)
"What is the SUM of the numbers printed by this code?"
try:
print(1) # <-- output
print(1 + "1" == 2) # raises TypeError exc
print(2)
except TypeError:
print(3) # <-- output
else:
print(4)
+ 5
correct answer is 4.
+ 4
Ha - you're right, I just looked at the code and somehow missed the question. Sorry, Tom!
+ 4
Relax :) jeje
+ 3
The answer is not 4. Please run your code, before you ask a question, so that you're asking the right question.
If an error occurs in try, the code will jump to except.
Only if no error occurs, else will eventually be executed.
Line 1 is okay, so 1 is printed.
Line 2 tries to add an int to a str, although they are different types. This raises a TypeError, so we jump into except and print 3.
Then it ends.
+ 2
The number 1 will be printed.
Since there is error in the next line, 3 will be printed.
2 won't print because the execution of code has stopped in the previous line.
So, it's 1+3=4
0
try:
print(1)
print(1 + "1" == 2)
print(2)
except TypeError:
print(3)
else:
print(4)
4
# output :- 1 3
0
Well, @HonFu
It seems that the correct answer is 4 because they may be a problem or glitch with your computer.
Don't give people the wrong answer.
0
***************************answer is 4 guys ***************
- 5
9 by guessss