Which of the following is not used as loop in Python?
Answers
Answered by
4
Answer:
python Java script is language
Answered by
1
Answer:
1. Which of the following is not used as a loop in Python?
A. for loop
B. while loop
C. do-while loop
D. None of the above
option c is correct.
Explanation:
why is there no "do while" loop in Python?
There are instances when you need the check to return on the give-up of the loop, however, be cautious while you write loops like that.
while condition1:
- Block of code this is in the loop
- The code that runs after the condition1 is false.
- Notice how smooth it's far to look condition1 is guarding the access to the block of code this is “inside” at the same time. So while reasoning approximately that Block of code, one component you could make sure of is that you’d by no means attain there if condition1 wasn’t proper. And you realize if condition1 is to start with fake, the Block of code won’t run at all. So, a vital component to invite yourself is that if the condition1 is to start with false, will the code that runs after the loop (this is my line three), be disappointed if my line 2 by no means ran at all?
- A vital component to the purpose approximately the loop is if I get into it, do I ever get out of it. You can search for apparent approaches out withinside the block of code (destroy statements, go back statements, yield statements, exceptions that are probably raised. And you could ask if there’s something in the block of code to subsequently make condition1 fake while you attain the give up of the block of code and iterate again as much as the check of condition1.
- Compare my simple “while condition1” to Alan’s “at the same time as True” notion for a way to pressure the looping check to return after the primary run of “your code”. But be aware that during reasoning approximately the code, “your code” (line 2) on its first generation has no assurance that the situation becomes proper or now no longer. The destroy stops that loop while execution reaches Alan’s line three if line three unearths the situation to be proper.
- So in the second and next iterations of “your code”, you could be positive that the situation is false while you enter “your code”, however you had no such assurance for the primary generation. In a normal actual lifestyles program, coming across the situation that controls the loop can also additionally take a few cautious studying of the code.
#SPJ3
Similar questions