Ana sayfa
/
Teknoloji
/
What will the following code output? for i in range(5): if i=3 break print(i) 0123 012 Error 01234

Soru

What will the following code output?
for i in range(5):
if i=3
break
print(i)
0123
012
Error
01234

What will the following code output? for i in range(5): if i=3 break print(i) 0123 012 Error 01234

Çözüm

4.5129 Voting
avatar
Ferhat
Elit · 8 yıl öğretmeni
Uzman doğrulaması

Cevap

The code will output "1", "2", and "3". The loop will iterate from 0 to 4, and when i equals 3, the if statement will execute the break command, which will exit the loop. Therefore, only the numbers 1, 2, and 3 will be printed.
Derecelendirmek için tıklayın: