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

变量起名

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

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

   关键字不能声明为变量。

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

用户交互

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

  2.0版本                         3.0版本

   input             =           eval(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'

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

原文地址:https://www.cnblogs.com/Donald-92/p/7425280.html