赋值/用户交互/条件判断缩进

时间:2017-08-24 22:08:54   收藏:0   阅读:209

---恢复内容开始---

变量起名

   变量名只能是字母.数字.下划线的任意组合。

   变量名的第一个字符不能是数字。

   关键字不能声明为变量。

   变量名不能有空格.特殊字符。

 

 

用户交互

  name = input(“please input your name:”)   #3.0版本input输出为字符串格式。

  2.0版本                         3.0版本

   input             =           evel(input)

 raw_input         =               input

 

 

if....else条件判断与缩进

num = input (‘Enter a number:’)

if num > 0 :

    print ‘the number is positive‘

elif  num < 0:

    print ‘the number is negative‘

else:

    print  ‘the number is zero‘

缩进官方建议为四个空格.区分字符串级别。

 

---恢复内容结束---

原文:http://www.cnblogs.com/Donald-92/p/7425280.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!