Home python Multiplication table in python

Multiplication table in python

Author

Date

Category

Help make the multiplication table in python. View table:
When you enter 5

On typing 5

Trying to do a double loop:

1) For line

2) For column

This is what I’ve figured out so far … (Beginner)

s1 = int (input ())
for i in range (s1):
  print (i + 1, end = '\ t')
  for g in range (i):
    print ((g + 1) * i)
    break

Output

1 2 1
3 2
4 3
5 4

I would be very grateful for any help!


Answer 1, authority 100%

Try this:

for i in range (1, s1 + 1):
   print (* range (i, i * s1 + 1, i), sep = '\ t')

Output:

1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25

or “simple” option:

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

Output:

1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25

Answer 2, authority 50%

max_ = int (input ())
for row in range (1, max_ + 1):
  for column in range (1, max_ + 1):
    print (row * column, end = '\ t')
  print ()

You only want to print artwork and nothing else. I changed the name of the variables to make the code clearer.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions