• python 九九乘法表!小练习


     1 # 1*1 = 1
     2 # 1*2 = 2  2*2 = 4
     3 # 1*3 = 3  2*3 = 6  3*3 = 9
     4 
     5 i = 1
     6 j = 1
     7 for j in range(1,10):
     8     for i in range(1,j +1):
     9         print('%s*%s=%s   '%(i,j,i*j),end='')
    10         # print(j,'*',i,'=',i*j,end = '   ')
    11     print('')


    记录一下遇到的问题:

    1、 for i in j:#报错 TypeError: 'int' object is not iterable 类型错误 int 这个类型对象是不可迭代的,
    可迭代 range,这个问题细说

    2、print中打印的方法和c语言中的有所不同,记住格式是print('%s%s%s'%(a,b,c))

    3、end = '' 使这一行输出的时候不换行

    4、加一个print('')换行,让这一行输出的时候换行,然后在执行下一个j
      因为print自带换行,所以只要在里面加一段空格就好了,如果print(' ')就是换了两行


  • 相关阅读:
    codeforces round #433 div2
    bzoj1951
    bzoj3620
    bzoj2286
    bzoj1513
    bzoj4390
    codeforces round 430 div 2
    bzoj3339
    准备实现体积蒙皮
    看牛顿法的改进与验证局部收敛
  • 原文地址:https://www.cnblogs.com/timtike/p/5840939.html
Copyright © 2020-2023  润新知