Answer to Question #345750 in Python for Abcdeffffff

Question #345750

Develop a Python script that will display the exponentiation of the numbers in every line of a text file where the first number is the base and the second number is the exponent.


TEXT FILE


8 3


4 5


6 2


OUTPUT


512


1024


36

1
Expert's answer
2022-05-30T15:15:57-0400
list1 = []
list2 = []
with open("test.txt", "r") as f:
    for line in f.readlines():
        list1.append(int(line[0]))
        list2.append(int(line[2]))
exponent = [a ** b for a, b in zip(list1, list2)]
for i in exponent:
    print(i)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS