• 014 Python 的数据类型(数字、字符串、列表、字典)


    #!/usr/bin/env python
    # -*- coding:utf-8 -*-
    # Datatime:2022/7/24 20:31
    # Filename:014 Python 的数据类型(数字、字符串、列表、字典).py
    # Toolby: PyCharm
    
    # 定义变量就会开辟内存空间
    
    # 变量:定义世间万事万物
    
    name = 'mage, jason'
    height = 180
    weight = 140
    hobby = ['piao','liang']
    
    # 变量就应该要有各种各样的数据类型
    
    # 数字
    
    ## 整型
    a = 11
    b = 12
    
    ## 浮点型
    height1 = 1.8
    
    # 数字有什么用:加减乘除
    
    print(a + b)
    print(a - b)
    print(a * b)
    print(a / b)
    
    # 字符串:一个单词一个单词,一句话一句话(一串字母)
    
    name1 = 'nick' # 把一串字符包在 '',""
    name2 = "xiaomage"
    name3 = "I'm tank"
    print(name3)
    
    shi = '''
    纸上得来终觉浅,绝知此事要躬行;
    我觉得这都是假的,我只想躺平
    '''
    print(shi)
    shi = """
    纸上得来终觉浅,绝知此事要躬行;
    我觉得这都是假的,我只想躺平
    """
    
    a = '*'
    print(a*100)
    
    abc = 'mage, jason'
    #      012345678
    print(abc[0])
    
    # 列表:一次性存放多个数据(元素)
    
    xiaomage_hobbies = ['piao','liang','jidiwangzi',150,1.60]
    print(xiaomage_hobbies[2])
    
    
    # 字典
    xiaomage = ['height',160,'weight',
                '150','hobby',['piao','liang','jidiwangzi']]
    print(xiaomage[0])
    print(xiaomage[1])
    print(xiaomage[2])
    print(xiaomage[3])
    
    # (key:value) 相当于一个元素
    xiaomage_features = {'height':160,'weight':150,
                         'hobby':['piao','liang','jidiwangzi']}
    print('*'*100)
    print(xiaomage_features['height'])
    print(xiaomage_features['hobby'])
    
    
    # 有兴趣的可以自己了解
    
    # 元组
    
    # 集合
    
  • 相关阅读:
    HDU 5135(再思考)
    HDU 5105
    HDU 5135
    Codeforces 985E
    Codeforces 985D
    Codeforces 975D
    Codeforces 975C
    Codeforces 976D
    HDU 1024 Max Sum Plus Plus (DP,水题)
    HDU 1003 Max Sum(DP,水题)
  • 原文地址:https://www.cnblogs.com/nickchen121/p/16522569.html
Copyright © 2020-2023  润新知