2 Replies - 245 Views - Last Post: 25 August 2014 - 12:06 AM Rate Topic: ***-- 2 Votes

#1 JKpybeginner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-August 14

i want each table output to start from the first line of console

Posted 06 August 2014 - 06:45 AM

# I want each and every table to display parellel to each other
# like 1x1=1   2x1=2   3x1=3   4x1=4
#        1x2=2   2x2=4   3x2=6  4x2=8

def main():
    pass

if __name__ == '__main__':
    main()
import sys
write = sys.stdout.write
num = int(input("Display tables upto: "))
i=0
j=1

for i in range(0,num):
    for i in range(1,11):
        print j,"x",i,"=",j*i

    j+=1



#output
>>> 
1 x 1 = 1
1 x 2 = 2
1 x 3 = 3
1 x 4 = 4
1 x 5 = 5
1 x 6 = 6
1 x 7 = 7
1 x 8 = 8
1 x 9 = 9
1 x 10 = 10
	
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20
	
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30
	

>>> 



Is This A Good Question/Topic? 0
  • +

Replies To: i want each table output to start from the first line of console

#2 fatihmert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 04-March 12

Re: i want each table output to start from the first line of console

Posted 10 August 2014 - 02:32 AM

# I want each and every table to display parellel to each other
# like 1x1=1   2x1=2   3x1=3   4x1=4
#        1x2=2   2x2=4   3x2=6  4x2=8

def main():
    pass

if __name__ == '__main__':
        main()
import sys
write = sys.stdout.write
num = int(input("Display tables upto: "))
i=0
j=1

paralel = ""


for i in range(0,num):
        for i in range(1,11):
                paralel += "%s x %s = %s\t"%(j,i,j*i)
        print paralel
        j+=1


Was This Post Helpful? 1
  • +
  • -

#3 JKpybeginner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-August 14

Re: i want each table output to start from the first line of console

Posted 25 August 2014 - 12:06 AM

thanks buddy
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1