Implementing 99 multiplication tables with Python

Source: Internet
Author: User

1. Implementation of a rectangle composed of "#"

Code

1eight = int (input ("Height:"))#User Input Height2width = int (input ("Width:"))#User Input width3 4Num_height = 15  whileNum_height <=height:6Num_width = 17      whileNum_width <=Width:8         Print("#", end="")9Num_width + = 1Ten     Print() oneNum_height + = 1
View Code

Output to

2. Implementation of a triangle composed of "*"

Code

1M1 =02num2 =03 4height = int (input ("height:"))5 6  whileNUM1 <height:7NUM1 + = 18      whileNum2 <num1:9Num2 + = 1Ten         Print("*", end="") one     Print() anum2 =0 - """ - line = 5 the While line > 0: - tmp = line - while tmp > 0: - print ("*", end= "") + tmp = tmp-1 - Print () + line- = 1"""
View Code

Output to

3. Implementation of the 99 multiplication table

Code for

1A = 0#A is multiplication sign left number2b = 0#b is multiplication sign right number3 4  whileB < 9:5B + = 16      whileA <B:7A + = 18         Print(str (a) +"*"+str (b) +"=", str (a * b), end="    ")9     Print()TenA = 0
View Code

Output to

Found permutations are misaligned, after correcting the code for

1A = 0#A is multiplication sign left number2b = 0#b is multiplication sign right number3 4  whileB < 9:5B + = 16      whileA <B:7A + = 18         if(a * B > 9):9             Print(str (a) +"*"+str (b) +"=", str (a * b), end="    ")Ten         Else: one             Print(str (a) +"*"+str (b) +"=", str (a * b),"", end="    ")#print (a, "*", b, "=", str (a * b), "", end= "") a     Print() -A = 0
View Code

Output to

The second method of modification is

1A = 0#A is multiplication sign left number2b = 0#b is multiplication sign right number3 4  whileb <num:5B + = 16      whileA <B:7A + = 18         Print(str (a) +"*"+str (b) +"=", str (a * b), end="\ t")9     Print()TenA = 0
View Code

"\ t" means adding a tab after the Output.

Implementing 99 multiplication tables with Python

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.