1.解释器路径及编码:

#!/usr/bin/env python
#-*-coding:utf8 -*-
"""
一般这两行代码在最上面且没什么用,在python3中一般不用写

"""

 

 

2.变量名:(字母,数字,下划线)

    ps:数字不能开头

      变量名不能是关键字

      最好不要和python内置的东西重复

 

3.条件语句:

a.   if基本条件语句:

if 1 < 2:
    print("yes")
else:
    print("no")

 b.  if支持嵌套:

inp = int(input("请输入一个数:"))
if inp<10:
    if inp==5:
        print("yes")
    else:
        print("no")
else:
    print("ok")

"""
这里的inp本来是字符串,让它直接跟数字比较的话会出现指针类型不符的错误

        unorderable types: str() < int()
所以应该在这里定义一个int使其变成整形在将其和数字进行比较
"""

 c.  if支持多条件判断:

inp = int(input("please enter you grade:"))
if inp <= 100 and inp > 90:
    print("perfect")
elif inp <= 90 and inp > 80:
    print("good")
elif inp <= 80 and inp >= 60:
    print("及格")
else:
    print("不及格")


"""
这里成绩应该是个范围,否则你输入99,他都显示不及格
"""