What is the output of the following Python code: lis = "12345" num = "0" while num in lis: print(num, end=" a) 1 2 3 4 5 b) 0 0 0 0 0 ... c) No output d) 12345
Answers
Answer:
Question
What is the output of the following Python code: lis = "12345" num = "0" while num in lis: print(num, end="
Answer : option c no output
Missing code:
"what is the output of the code snip" is missing in the above question.
more explanation about the question
The above code is in python language which prints nothing and terminates as a normal termination.
It is because the syntax defined above is a for loop syntax, not a while loop syntax which can be written as "for num in lis". It takes a num object and prints the all number or character from the list and there is no need to initialize the num variable.
But when it is written with the while loop then it prints nothing because it takes the num value and searches from the list if match found print otherwise not.
But when the value of num variable will be changed by any of the matching list values, then this loop behaves like the infinite loop.
It is because the num is recognized by the variable not an object and the while condition will give true always. It is because there is no operation that pulls the condition to be false.
Explanation:
hope it helped you friend if it helps you mark it as brainliest
Answer:
Explanation:
The output of the following Python code will be no output, because the while loop will not execute at all. The value of num is "0", which is not in the list lis, so the loop condition will evaluate to False and the loop will not execute. Therefore, the correct answer is c. No output.