Computer Science, asked by rajashwani563, 6 months ago

Q:1. What does the following Python3 code do?
(using python 3.X version);
int(input('Enter a number?'))
i = 1
while i (= n;
i = i+1
print (i)
O 1. Print all integers from 1 to n
2. Print all integers from 1 to n-1
3. Print all integers from 2 to n
4. Print all integers from 2 to n+1​

Answers

Answered by s13064assaravana0174
1

Answer:

print all integrative from 1 to n print all integrating from 1 to 11 is the answer of this question

Answered by jubin22sl
0

Answer: 3. Prints all integers from 2 to n

Explanation:

While Loop: It repeats particular lines of code an undetermined number of times until and unless the specified condition is met.

Step 1: Consider the input n = 10.

Step 2:

  • i = 1 assigned in the code  
  • under the while loop the condition for termination of while loop is i should meet the n value that is 10
  • for first iteration i = i + 1 i. e. i = 1+1 and that becomes i = 2 which will get printed
  • this loop will be printing i's value unless i becomes equal to 10 or our n value

So the output is 2345678910 for n = 10

Similar questions