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 display
Print S
2. #1-100 prime number num = 2cont = 0while num <: flag = 1 i = 2 while i < num: if num% i = = 0: flag= 0 Break i=i+1 If flag = = 1: cont =cont + 1 print num num = num + 1print ' prime number is%d '% (cont)
3. #m =1*2*3*4*...N m for a maximum nm of not greater than 20000 = 1n = 1while m <=20000: m = m * N n+=1n= n-1print n
4. Tick count within #1-30 for a in range (1,30): for B in range ( 1,30): For C in Range (1,30): If A * a + b * b = = C *c: Print A,b,c
5. #寻找平方后三位与自身一样的数字 (three digits only) n = 100while n <=: m = n * n if M% 1000==n: print n n=n+1
Python Simple applet (99 multiplication table)