Variable types and operators in python

Six data types: 

# _*_ coding : utf-8_*_
# @Time : 2023/4/12 14:21
# @Author: suoheng
# @File : 变量的定义
# @Project : pythonPractice

# 数据类型
# Number 数值
#     int
#     float
# boolean 布尔
# string  字符串
# list    列表
# tuple   元组
# dict    字典

# 变量类型的基本使用
#  Number 数值
#   int
money = 1000
#   float
money1 = 1.2333
#   boolean
sex = False
#   string
str0 = '过了周三就是年~'
# 单引号和双引号的嵌套,也是可以的
str1 = '"过了周三就是年"'
str2 = "'过了周三就是年'"


# list  列表
name_list = ['小姐姐','小哥哥']
# tuple 元组
age_tuple = (12,121,23)
# dict  字典
# 应用场景:scrapy 框架使用
person = {'name':'suosuo','age':18}

View data types:

# 查看数据类型 type(变量)即可
print(type(person)) # <class 'dict'>

 

Identifier:

        In computer programming languages, identifiers are the names used by users when programming. They are used to name variables, constants, functions, statement blocks, etc., so as to establish the relationship between names and usage.

Variable naming convention:

  • Identifiers consist of letters, underscores, and numbers, and numbers cannot begin with
  • Strictly case sensitive
  •  keywords cannot be used
  • Generally use the big hump or small hump nomenclature 

keywords:

There are mainly the following, which cannot be used to define identifiers

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

 Type conversion:

operator:

Compound assignment operator:

 Logical Operators:

Equivalent to and and or or not in js 

Guess you like

Origin blog.csdn.net/qq_41579104/article/details/130108602