zoukankan      html  css  js  c++  java
  • Python(基础)

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

  • 相关阅读:
    LeetCode 4 :Majority Element
    LeetCode 3 :Min Stack
    Oracle操作4
    plsql安装教程
    java Date与String互相转化
    Oracle操作3
    Oracle操作2
    Oracle操作
    Oracle11g修改密码
    Visual Studio2013完全卸载
  • 原文地址:https://www.cnblogs.com/hly97/p/12305087.html
Copyright © 2011-2022 走看看