Class - 12 CBSE Computer Science Important Output Questions 2025
Write the output of the following:
for i in '123':
print("CPU", i)
Python
Python Control Flow
3 Likes
Answer
CPU 1
CPU 2
CPU 3
Working
The for
loop iterates over each character in the string '123' using the in
operator, and during each iteration, the variable i
takes on the value of each character in the string. The print("CPU", i)
statement then prints the string "CPU" followed by the value of i
during each iteration of the loop.
Answered By
1 Like