首页 > 编程语言 > 详细

Python学习

时间:2020-02-13 21:37:47      阅读:51      评论:0      收藏:0      [点我收藏+]

第一个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:用来结束本次循环,紧接着执行下一次的循环

 

Python学习

原文:https://www.cnblogs.com/hly97/p/12305087.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!