ow many times does the body of this loop run?
x = 1 while x<10: print("currently, x = " + str(x)) x += 1
Output:
Explanation:
Since, Initially value of x is 1 and while loop will iterate until x=9 because when x=10 while loop condition will not be satisfied and it will be terminated.
So, while loop will start with x=1 and in each iteration x will be incremented by 1. And while loop will be executed until x=9. Hence we can say body of loop will run 9 times.
Get Answers For Free
Most questions answered within 1 hours.