zoukankan      html  css  js  c++  java
  • python入门-2020.12.21

    1.行与缩进

    if True:
      print ("True")
    else:
       print ("False")

    2.注释

    #第一个注释

    3.数据类型

    数字:int (整数),float (浮点数),bool (布尔),complex (复数)

    字符串:string

    4.基础语法-接收键盘输入内容

    age =input("请输入年龄:")
    print("输入的年龄是" + age)
    print(type(age)) #默认输入的内容类型是str

    5.基础语法-导入模块用法

    import random
    huahua_age = random.randint(10, 20)
    print("华华的年龄是",huahua_age)

    6.if判断

    import random
    
    age =input("请输入年龄:")
    print("输入的年龄是" + age)
    
    huahua_age = random.randint(10, 20)
    print("华华的年龄是"+str(huahua_age))
    if int(age) > huahua_age:
        print("输入的年龄比华华的年龄大")
    elif int(age) == huahua_age:
        print("猜对了")
    else:
        print("输入的年龄比华华的年龄小")

    7.for循环

    for i in range(5):
        print(i)

    8.while循环

    count = 1
    while (count > 0):
        print(count)
        count = count + 1
        if count == 5:
            break



     

    加油
  • 相关阅读:
    代理模式
    组合模式
    策略模式
    状态模式
    js 未结束的字符串常量错误解决方法
    struts2+hibernate+poi导出Excel实例
    Java 实现导出excel表 POI
    ExtJS 4.2 中自定义事件
    dhtmlxGrid分页查询,条件查询实例
    '@P0' 附近有语法错误
  • 原文地址:https://www.cnblogs.com/huahuacheng/p/14170665.html
Copyright © 2011-2022 走看看