Answer to Question #345749 in Python for Abcdeffffff

Question #345749

Develop a Python program that will display the multiplication table represented by the two non negative integers in a text file. The first integer will be the rows and the second integer will be the columns of the multiplication table.


TEXT FILE


3 5


4 2


OUTPUT


3x5


1 2 3 4 5


2 4 6 8 10


3 6 9 12 15


4x2


1 2 3 4


2 4 6 8


3 6 9 12


4 8 12 16

1
Expert's answer
2022-05-30T08:15:58-0400
path = "text.txt"
lines = [x.split() for x in open(path, 'r').readlines()]
for x in lines:
  height, width = int(x[0]), int(x[1])


  print("(", height, "," , width, ")")
  for i in range(1,height+1):
    for j in range(1,width+1):
      print(i*j, end='\t')
    print()

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