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