python学习笔记—5—标识符和运算符

  1. 标识符

(1)定义

用户在编程时所使用的一系列名字,用于给变量、类、方法等命名

(2)标识符命名规则

<1>内容限定

标识符的命名中只能由数字、英文、中文、下划线组成,其他都不被允许使用

注意:1. 不推荐中文命名

  1. 数字不能用在命名开头

<2>大小写敏感

<3>不可使用关键字

  1. 变量的命名规范

(1)见名知意

(2)下划线命名法

(3)英文字母全小写

  1. 算数运算符
python 复制代码
score = 100
score = score + 1
print("score + 1 =", score)
score = score - 1
print("score - 1 =", score)
score = score * 2
print("score * 2 =", score)
score = score / 4
print("score / 4 =", score)
score = score % 3
print("score % 3 =", score)
score = score ** 3
print("score ** 3 =", score)
score = score // 3
print("score // 3 =", score)
  1. 赋值运算符
python 复制代码
score = 100
score += 1
print("score += 1", score)
score -= 1
print("score -= 1", score)
score *= 2
print("score *= 2", score)
score /= 4
print("score /= 4", score)
score %= 3
print("score %= 3", score)
score **= 3
print("score **= 3", score)
score //= 3
print("score //= 3", score)
相关推荐
呱呱复呱呱1 小时前
Django CBV 源码解读:一个请求是怎么找到你的 get() 方法的
python·django
曲幽6 小时前
刚部署的 LibreTranslate 频频翻车?我掏出了 20 年前的 StarDict 词典,用 FastAPI 搭了个本地词典翻译 API
python·fastapi·web·translate·goldendict·libretranslate·stardict·pystardict
荣码6 小时前
用Streamlit给AI应用套个界面,10行代码出Web页面
java·python
兵慌码乱16 小时前
基于Python+PyQt5+SQLite的药房管理系统实现:事务一致性与界面解耦全流程解析
python·sqlite·信号与槽·pyqt5·数据库设计·桌面应用开发·事务处理
金銀銅鐵17 小时前
[Python] 体验用欧几里得算法计算最大公约数的过程
python·数学
FreakStudio21 小时前
W55MH32L-EVB 上手测评:硬件 TCP/IP 加持的以太网单片机,MicroPython 零门槛开发
python·单片机·嵌入式·大学生·面向对象·并行计算·电子diy·电子计算机
用户0332126663671 天前
使用 Python 从零创建 Word 文档
python
Csvn1 天前
Python 两大经典坑点 —— 可变默认参数 & 闭包延迟绑定
后端·python
曲幽1 天前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
用户556918817531 天前
#从脚本到独立程序:Python + Playwright 批量抓取的完整踩坑记录
python·自动化运维