Python Question. #appliedpython #developer #development #coder #coding #computer #internet #java #javascript #python #html #webdevelopment #website #programming #programmer #linux #windows #google #microsoft #learn #free #computerscience #jobs #laptop
1234. Once the value of i is 5, it will break out of if loop. Else statement is anyways executed if the primary statement(for in this case) is not executed. Btw, good question. Many think else cannot be used with for :-)
Thanks Prem Prakash for you reply. I will try posting questions like this in future.
>>> for i in [1,2,4,3,5]: ... if i==5: ... break ... print(i) ... else: ... print("Logical Python") ... 1 2 4 3
Correct. Mistakenly you shuffled order but your answer is correct.
B The output of this code appears four times as "Logical Python." This corresponds to elements 1, 2, 3, and 4 of the list. Logical Python Logical Python Logical Python Logical Python
Thanks Yukihiro. You are right. it will print 1 2 3 4.
Thank you for your attempt, though the correct answer is B.
The correct answer is B (1234) because we print the first 5 elements in the list [0-4]. So we print first fourth number
United States الاتجاهات
- 1. #WWENXT 9,239 posts
- 2. Cooper Flagg 4,184 posts
- 3. #LGRW 2,251 posts
- 4. Bruins 4,662 posts
- 5. Cam Johnson N/A
- 6. Maxey 2,563 posts
- 7. Embiid 2,884 posts
- 8. Larkin 1,758 posts
- 9. Markstrom N/A
- 10. Christmas Eve 149K posts
- 11. Rosetta Stone N/A
- 12. Southern Miss 1,661 posts
- 13. Fight Club 2,574 posts
- 14. #TheOvalOnBET N/A
- 15. Jordy Nelson N/A
- 16. Nets 6,381 posts
- 17. Insurrection Act 14.2K posts
- 18. Dunesday 1,898 posts
- 19. Trae Young 1,275 posts
- 20. Risacher N/A
Something went wrong.
Something went wrong.