+ 4
Need improvement on Multiplication table
Hello pls, I need help with coding A multiplication table using Python. I av done something but it needs improvement, what i need is two input, one that enters the last row you want and the other that enters the last column you want and output the multiplication table Here is my code: a = int(input('Enter the last row you want ')) c = 1 d = 1 print(list(range(c,a+1,d))) for i in (range(c,a,d)): i = i+1 c = c + 1 a = a + (12+1) d = d + 1 print(list(range(c,a,d))) https://code.sololearn.com/cRo6x8gSpHnX/#py
16 Antworten
+ 10
At SoloLearn you must use a new line for the second input. Your code works fine. Maybe you could make it a little bit pretty, but it works. Have a look at this one:
https://code.sololearn.com/cL41qXwD7Mzc/?ref=app
+ 4
Thank you..really helpful
+ 4
Corrected it, it works! thank uuu sir Paul Jacobs
+ 4
a = int(input('Enter the last row you want '))
b = int(input('Enter the last column you want '))
c = 1
d = 1
e = a+1
print(list(range(c,e,d)))
for i in (range(c,b,d)):
i = i+1
c = c + 1
e = a*i
d = d + 1
print(list(range(c,e+1,d)))
+ 3
done that.
+ 3
Yea in that order
+ 3
Do you want a code that works, more or less, or do you want instructions, so you do it yourself?
+ 3
Paul Jacobs, now i need instructions :)
+ 3
Thank you sir Paul Jacobs, I made this changes but it didn't give me the desire result:
a = int(input('Enter the last row you want '))
b = int(input('Enter the last column you want '))
c = 1
d = 1
e = a+1
print(list(range(c,e,d)))
for i in (range(c,b,d)):
i = i+1
c = c + 1
e = a+i
d = d + 1
print(list(range(c,e,d)))
+ 3
:)
+ 2
Do you want your in and output like this:
'''
input :
5 (rows)
3 (lines)
gives you:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
'''
+ 2
You need a second input variable b like a for the number of lines
And you need a new variable e to calculate the maximum in the range for each line.
The max range value in the for loop should be b (the number of lines), it is now a.
The max range value in the print statement should be e, it is now a.
You should calculate e using a and i in the loop (and replace a = a + (12 + 1)).
+ 2
It should be e = a * i in the for loop.
+ 2
Well done.
+ 1
rows = 5 # int(input())
lines = 3 # int(input())
for i in range(1,lines+1):
print(list(range(i,i*(rows+1),i)))