Computer Science, asked by sunitakumarijsr4, 3 days ago

write a program in python to display power table of 2 by using while loop​

Answers

Answered by Anonymous
8

Required program :-

n = 1

while n<11:

‎ ‎ ‎print(f"2^{n} = {2* *n}")

‎ ‎ ‎n = n+1

Explanation :-

Define a variable with initial value of 1 and run a while loop till this value is smaller than 11 because we have to print the power table of 2 upto 10 terms. Now use a print statement to print the power table, * * is an operator for power in python. Message inside print statement is written inside f strings to print both variables and text. Add an extra statement to increment the value of n by 1 every time the loop runs.

More :-

For printing multiplication table use the following còdes:

n = 1

while n<11:

‎ ‎ ‎print(f"{2} x {n} = {2*n}")

‎ ‎ ‎n = n+1

Attachments:
Similar questions