+ 4
What is the largest number this code prints? for i in range(10): if i > 5: print(i) break else: print("7")
I think the question is wrong because the program prints 7 within range 0 to 5.So 7 is the largest number?But the answer is 6.Why?
6 Respuestas
+ 9
True, ChillPill but the question asks what number is printed, not what integer. It should be 7 either way IMO
+ 7
Helena
I think what ChillPill was saying is that because the 6 being printed out from the loop is an integer, it could be classified as a number while the 7 would not (in the context of the problem) considering it's a string. Either way though, I feel the question was phrased a little weirdly and can definitely throw some people off
+ 5
Answer is 6
+ 1
Thank for your answers.
+ 1
the IF statement:
"if i>5"
only becomes true when i = 6
then it moves on to the " print(i)"
so it prints out a 6
then break ends the sequece
0
6