CBSE Class 11 Computer Science
Question 57 of 80
Conditional and Looping Constructs — Question 27
Back to all questionsI
N
D
I
A
Here's the detailed explanation:
1. String Assignment:
country = 'INDIA'This line assigns the string 'INDIA' to the variable country.
2. for i in country:: The for loop iterates over each character in the string country. The variable i will take on the value of each character in the string one at a time.
3. print(i): This prints the current character stored in the variable i for each iteration.
Let’s analyze the loop iteration by iteration:
- In the first iteration,
iis'I', soprint(i)outputs:I. - In the second iteration,
iis'N', soprint(i)outputs:N. - In the third iteration,
iis'D', soprint(i)outputs:D. - In the fourth iteration,
iis'I', soprint(i)outputs:I. - In the fifth iteration,
iis'A', soprint(i)outputs:A.
Putting it all together, the output will be each character of the string 'INDIA' printed on a new line:
I
N
D
I
A