+2 votes
in Python by
Write a program to print out the 2-table using while loop.

1 Answer

0 votes
by

Below is the code to print out the 2-table:

We start off by initializing two variables ‘i’ and ‘n’. ‘i’ is initialized to 1 and ‘n’ is initialized to ‘2’.

Inside the while loop, since the ‘i’ value goes from 1 to 10, the loop iterates 10 times.

Initially n*i is equal to 2*1, and we print out the value.

Then, ‘i’ value is incremented and n*i becomes 2*2. We go ahead and print it out.

This process goes on until i value becomes 10.

Related questions

+1 vote
asked Feb 15, 2021 in Python by SakshiSharma
0 votes
asked Nov 24, 2023 in Azure by Robindeniel
...