For I in range (1, 10 ):If I! = 1:Print ('') # This is actually to print a \ n line feed.For k in range (1, 10 ):If I Ans = STR (I * K)If Len (ANS) = 1: # Write a judgment for the good-looking format. If the result is a single digit, it will be null. If it is not a single digit, it will not be empty.Print ('{}* {}='. Format (I, K) + ''+ STR (I * k), end = '')Else:Print ('{}* {}='. Format (I, K) + STR (I * k), end = '')Print a 9-9 multiplication
First, this is Python.For I in range (1): print ("". Join (["%d*%d=%d"% (j, I, I*j) for J in range (1, i+1)]))DetailedFor I in range (1): #当i = = 1 O'Clock: print ("". Join (["%d*%d=%d"% (j, I, I*j) for J in range (1, i+1)])) a ["%d*%d=%d" % (J, I, I*j)] is said to be the first J [J for J in Range] B for J in range (1, i + 1)--When I==1, is J gets 1, if it is 2,j for the C so a 1*1=1 “ ”。 Join 2*1 =2Using the Python list derivation to make a 99-
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced. Snail-jsp Learn multiplication table page output
Program code:#include stdio . h >void Main (){ int i,j; for (i Span style= "Font-family:fixedsys;color: #ff0000;" >= 1;i 9;i ++ ) { for (J = 1;j Span style= "Font-family:fixedsys;color: #010101;" >9;j ++ ) printf ( "%d*%d=%2d", i,j,i* j);printf ( "\ n"); } return 0;}This topic is mainly to want to use two for loop nesting, to pay attention to the relationship betweenprintf ( "%d*%d=%2d", i,j,i* j); This statement can make the running result right-al
#-*-Coding:utf-8-*-Implementing code One,x,y=9,9lst=[(X,y,str (y) + ' x ' +str (x) + ' = ' +str (x*y)) for X in range (1,y+1) for Y in range (1,x+1)]For item in LST:Print Item[2],if (Item[0]==item[1]):print ' \ n 'Implementation code Two,For I in Range (1,10):For j in Range (1,i+1):Print str (i*j) + ' = ' +str (i) + "*" +str (j) + ",print 'Print default line wrapping does not want to wrap at the end of a comma, output if there is a variable to output can be preceded by a STR () into a string con
1.#99乘法表#第一种for i in range (1,10): s= "for J in Range (1,i+1): s+=str (j) + ' * ' +str (i) + ' = ' +str (j*i) + ' \ t ' print S#第二种For I in Range (1,10):S= "For j in Range (1,i+1):S+=str (j) + ' * ' +str (i) + ' = ' + ' {0:2d} '. Format (j*i) + ' \ t ' #{0:2d} Explanation: Indicates that 0 represents j*i,:2d represents two width of 10 binary number displayPrint S 2. #1-100 prime number num = 2cont = 0while num 3. #m =1*2*3*4*...N m for a maximum nm of not greater than 20000 =
' For I in Range ' (1,10):For j in Range (1,10):Print I, ' * ', j, ' = ', i*j, ',‘‘‘‘‘‘For a in range (1,10):For b in Range (1,10):#print A, ' * ', b, ' = ', a*b, ',print '%d*%d=%d '% (a,b,a*b),print ' \ n 'For M in range (1,10):For n in range (1,m+1):print '%d*%d=%d '% (n,m,m*n),print ' \ n '‘‘‘For h in range (9,1,-1):For L in range (1,H):print ',Print "%d*%d=%d"% (l,h,l*h),print ' \ n 'Python Basics (7) Print multiplication
One, the use of knowledge points:1. Use of variables.2. Use of circular statements, here is a double while loop. Of course, it's also possible to use other loops to do it. I think the use of a double while loop is easier to understand for people who have just come into contact with programming.3. Use the line break "\ n" and the tab "\ T" to make the output more beautifulSecond, the code:1 Print("\ n"+"From top to bottom")2 3A1 = 14 5 whileA1 :6A2 = 17 whileA2 A1:8 Print(STR (A2) +
echo-n non-newline output$echo-N "123" $echo "456" final output 123456 instead of 123456 echo-e handling special characters if the following character appears in the string, it is handled in particular, not as a general text output: \a a warning; \b Delete the previous\c End with a newline symbol; \f the cursor remains in its original position; \ n Wraps and the cursor moves to the beginning of the line; \ r The cursor moves to the beginning of the line but does not wrap; \ t inserts the same ta
#!/bin/bashfor I in {1..9}dofor j in ' seq 1 $i ' dom= ' echo "$i" "*" "$j" |bc ' Echo-n "$j" x "$i" = "$m" "" Doneecho "" DoneExecution Result:[Email protected] shell]#./99.sh1 x 1 = 11 x 2 = 2 2 x 2 = 41 x 3 = 3 2 x 3 = 6 3 x 3 = 91 x 4 = 4 2 x 4 = 8 3 x 4 = 4 x 4 = 161 x 5 = 5 2 x 5 = 3 x 5 = 4 x 5 = 5 x 5 = 251 x 6 = 6 2 x 6 = 3 x 6 = 4 x 6 = 5 x 6 = 6 x 6 = 361 x 7 = 7 2 x 7 = 3 x 7 = 4 x 7 = 5 x 7 = 6 x 7 = 7 x 7 = 491 x 8 = 8 2 x 8 = 3 x 8 = 4 x 8 = 5 x 8 = 6 x 8 = 7 x 8 = 8 x 8 =1 x 9 =
row = 1while row
for row in range(1, 10): for col in range(1, row+1): print("{} * {} = {}".format(col, row, row*col), end="\t\t") print("")
row = 1while row
for row in range(1, 10): for col in range(1, row+1): print("%d * %d = %d"% (col, row, row*col), end="\t\t") print("")99 multiplication Table How Python is expressed
The example in this article describes the Python output 9*9 multiplication table method. Share to everyone for your reference. The implementation methods are as follows:
?
1 2 3 4 5 6
#!/usr/bin/env Python # 9 * 9 for I in range (1): Print to J in range (1, i+1): print "%d*%d=%d"% (i, J, I*j),
To add a simpler approach:
The code is as follows:
Print (' n '. Join (["%d*%d=%2s"%
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.