What is the value of x after this sequence of instructions is carried out?
x=0
for i in range(10):
x=x+1
in python programming language
Answers
Answered by
0
Answer :- 10
x=0
for i in range(10):
x=0+1 = 1
for i in range(10):
x=1+1 = 2
for i in range(10):
x=2+1 = 3
for i in range(10):
x=3+1 = 4
Continuing on...
for i in range(10):
x=8+1 = 9
for i in range(10):
x=9+1 = 10
Now it break out of this till when x = 10.
Answered by
0
First control structure and computer starts as first line.
It goes down from there and control structures change the order that statements are executed or decide if a certain statement will be run.
a = 0
while a < 5:
a += 1 # Same as a = a + 1
print (a)
Decision statements also influence and whether or certain statement will run and the source for a program that uses the while control structure:
Here is the output:
1
2
3
4
5
Similar questions