04.python语法入门--基本数据类型

# python是一门解释型的、强类型的、动态语言


# 一:数字类型
# 1.1 整型int:记录人的年龄、等级、号码、个数
# age = 18
# print(type(age))

# 1.2 浮点数float:记录人的薪资、身高、体重
# salary = 3.7
# print(type(salary))

# x = 18
# y = 3.7
# print(x + y)
# print(x > y)

# 二:字符串:记录描述性质的状态,比如名字、一段话、性别
# x = "两个黄鹂鸣翠柳"
# y = '两个黄鹂鸣翠柳'
# m = """两个黄鹂鸣翠柳"""
# n = '''两个黄鹂鸣翠柳'''
#
# print(x)
# print(y)
# print(m)
# print(n)

# msg = "my name is 'egon'"
# print(msg,type(msg))

# gender = 1
# gender = 0

# age # 变量名
# "age" # 变量值的一种,str

# 了解:
# print("abc"+"xxx")
# print("abc"*3)
# print("*"*50)
# print('hello')
# print("*"*50)


# 三 列表:按照位置存放多个值,比如记录一个人的爱好
# hobbies = "打篮球 阅读 看电影"

#           0       1       2
# hobbies = ["打篮球", "阅读", "看电影"]
# print(hobbies[0])
# print(hobbies[1])
# print(hobbies[2])
# print(hobbies[3])

# print(hobbies[-1])
# print(hobbies[-2])


# #     0     1     2         3
# l1 = [1111,1.3333,"aaa",['bbb','ccc']]
# # print(type(l1))
#
# print(l1[3][0])


# 四:字典类型:在{}内,按照key:value的格式存放多个元素,其中value可以是任意类型,而key通常是str类型
# info = ["egon", 18, 1.8, 80, "male"]
# info = {
#     "name": "egon",
#     "age": 18,
#     "height": 1.8,
#     "weight": 80,
#     "gender": "male"
# }
# print(info["name"])
# print(info["xxxx"])


# info = ["egon",18,"male"]


# dic = {"k1":11111,"k2":1.3,"k3":"xxx",'k4':[111,222,333],"k5":{"a":1,"b":2}}

# print(dic['k4'][1])
# print(dic['k5']["a"])


# 五 布尔:记录真假
# print(type(True))
# print(type(False))
# x = True
# y = True

print(10 > 3)

 

posted @ 2021-05-30 19:56  简爱cx  阅读(426)  评论(0编辑  收藏  举报