Python 99 multiplication table while looping print

Source: Internet
Author: User

Python 99 multiplication table is printed from four different directions: this is done with a while loop, which is a must for a double loop .

# lower left corner 99 multiplication table:

I=1

While I < 10:

J=1

While J <= I:

Print ("%d*%d=%2d"% (j,i,i*j), end= "") # control the format of the output

J+=1

I+=1

Print () # prints a line to wrap

# top left 99 multiplication table:

I=9

While i > 0:

J=1

While J <= I:

Print ("%d*%d=%2d"% (j, I, I * j), end= "")

J+=1

I-=1

Print ()

Print ("--------------------------------------------------------------------")

# Right bottom 99 multiplication table:

I=1

While I < 10:

K=9

While K >= I:

Print ("", End= "") # to squeeze the output format to the right, here we use a space to squeeze the contents of the output but note the alignment of the format

K-=1

J=1

While J <= I:

Print ("%d*%d=%2d"% (j, I, I * j), end= "")

J+=1

I+=1

Print ()

Print ("-----------------------------------------------------------------------")

# top right 99 multiplication table:

I=9

While i > 0:

K=1

While K <= 10-i:

Print ("", end= "")

K+=1

J=1

While J <= I:

Print ("%d*%d=%2d"% (j, I, I * j), end= "")

J+=1

I-=1

Print ()

Python 99 multiplication table while looping print

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.