凤7

导航

 

第一个python程序:print("hello,world")

输入:input()

注释:单行注释‘#’,多行注释’ '''  ''' 

关键字:['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

查看关键字代码:import keyword

        keyword.kwlist

算术运算符:

常用的数据类型转换:数据类型转换

if判断语句:if 要判断的条件:

        条件成立是要做的事

      elif 判断条件:

          条件满足做的事

      else:条件不成立时做的事  #else必须和if一起使用

例子:

score=int(input("输入成绩:"))
if score>90 and score<100:
    print("9")
elif score>80 and score<90:
    print("8")
elif score>70 and score<80:
    print("7")
elif score>60 and score<70:
    print("6")
else:
    print("5.9")

循环:while 条件:

    语句

  for 临时变量 in 列表或者字符串等可迭代变量

    循环满足条件时执行的代码

break:立刻结束当前循环

continue:用来结束本次循环,紧接着执行下一次的循环

 

posted on 2020-02-13 20:45  凤7  阅读(162)  评论(0编辑  收藏  举报