write a program in python to display power table of 2 by using while loop
Answers
Answered by
1
Answer:
I am trying to make a program that will print out a table of powers. The user is asked to provide the base, and then the maximum exponent. Then the program will print out a table of powers based on this information. For example, if the user typed in 2 for the base, and 4 for the max exponent, the program would first start at 2^1, then 2^2, then 2^3, and finally 2^4. I do not understand why what I wrote isn't working. I debugged, and saw that my base value is actually incrementing itself by 1 and I have no idea why.
def main():
base=eval(input("Enter the base number: "))
max=eval(input("Enter the maximum exponent "))
counter = 1
while counter<=max:
base = base^counter
counter = counter+1
Similar questions
Math,
9 days ago
Math,
19 days ago
English,
19 days ago
English,
8 months ago
India Languages,
8 months ago