Computer Science
Predict the output of the following code fragments:
for x in [1,2,3,4,5]:
print (x)
Python
Python Control Flow
27 Likes
Answer
1
2
3
4
5
Working
x will be assigned each of the values from the list one by one and that will get printed.
Answered By
10 Likes
Related Questions
Predict the output of the following code fragments:
keepgoing = True x=100 while keepgoing : print (x) x = x - 10 if x < 50 : keepgoing = FalsePredict the output of the following code fragments:
x = 45 while x < 50 : print (x)Predict the output of the following code fragments:
for x in range(5): print (x)Predict the output of the following code fragments:
for p in range(1,10): print (p)