python日记---day1

Life is  short,Test in  python

一、输入输出 

1.用print()在括号中加上字符串,就可以向屏幕上输出指定的文字。比如输出'hello, world'

   print('hello,world')

   print('Suki','TAJI','Yuki')

2.input()

   input("输入你的名字:")

二、变量

变量名称最好要英文,如:

  name='Suki',sex='man',age='18'

三、判断

四、循环

1.while循环

2.for循环:注意for循环是自己累加计数

五、格式化输出

 

print('%s,welcome'%username)
print('%s,welcome,时间是:%.3f'%f(username,time)) #运行效率高 %s string %d int %.2f float
print('{},welcome,时间是:{}'.format(username,time))#运行效率最高
print('{name},welcome,时间是:{data}'.format(name=username,data=time))

六、break 和continue

 1.break

break指跳出整个循环,i=5时,就跳出for循环,所以最终打印的输出为:0,1,2,3,4

2.continue

continue指跳出当前循环,i等于5时,就跳出当前循环,进行下次循环,所以最终打印的输出为:0,1,2,3,4,6,7,8,9

 

posted @ 2017-12-21 14:20  可可的私房菜  阅读(202)  评论(0编辑  收藏  举报