当前位置:网站首页>第一章第十节:条件判断 if
第一章第十节:条件判断 if
2022-07-20 10:10:00 【中亿丰数字科技有限公司】
Python基础入门(全套保姆级教程)
第一章
第十节:条件判断 if
**
照着做,慢慢理解
**
if语句的语法规则:
1.
if 条件:
代码
如果条件成立就执行代码
如果不成立, 就不执行
money = 100
if money > 300:
print("铁锅炖")
print("回家")
- if 条件:
代码1
else:
代码2
如果条件成立, 执行代码1, 否则, 执行代码2
money = input("请输入你兜里的钱:")
money = int(money)
if money > 500:
print("足疗")
else:
print("回家")
- if语句可以互相嵌套
if 条件:
if…:
ss
else:
xx
else:
代码2
money = int(input("请输入你都里的钱:"))
if money > 1000:
if money > 5000:
print("充个会员卡")
else:
print('洗个脚就走')
else:
print("回家")
if 条件1: 代码1 elif 条件2: 代码2 elif 条件3: 代码3 .... else: xxxx
money = int(input("请输入你都里的钱:"))
if money > 5000:
print("充卡")
elif money > 1000:
print("洗个脚回家")
else:
print("回家")
总结:
1.
if 条件:
代码
如果条件成立就执行代码
如果不成立, 就不执行
2.
if 条件:
代码1
else:
代码2
如果条件成立, 执行代码1, 否则, 执行代码2
3.
if语句可以互相嵌套
if 条件:
if…:
ss
else:
xx
else:
代码2
4.
if 条件1:
代码1
elif 条件2:
代码2
elif 条件3:
代码3
…
else:
xxxx
边栏推荐
- 创建数据快照失败: lock file [/SiYuan/data/assets/image- 20220702163332-jijwccs.png failed: open /SiYuan/data/assets/image- 20220702163332-jijwccs.png: permission denied; unable to lock file
- Redis-key的层级格式
- 【系统设计】分布式键值数据库
- vs2019配置Qt5开发环境
- GBase 8s如何处理集合的?
- Some summary of QT | QWidget
- [u-boot] main line analysis of u-boot operation [02] - board_ init_ f
- 字节跳动确认将自研芯片:仅供内部使用;马斯克:我已将大脑上传云端;Go 语言产品负责人离职|极客头条
- Redis set type
- MySQL indexing principle
猜你喜欢
随机推荐
Redis-String类型
Excel-VBA 快速上手(九、VBA 中的跳转、退出、错误、With)
基于CLAR架构打造的宝马i3,并非是简单的“油改电”产品
Simulation analysis of bulk acoustic wave resonator based on two-dimensional phononic crystal
大数处理--使用案例
GBase 8s如何句查询关系数据库以从复杂类型中选择数据的样本语 法和结果
Research on elite hierarchical task unloading strategy based on reinforcement learning in edge cloud collaboration scenario
自定义持久层框架MyORMFramework(二)—框架设计
ogg 抽取数据延时大
Redis-介绍
[hdlbits skimming] Verilog language -- basics
创建数据快照失败: lock file [/SiYuan/data/assets/image- 20220702163332-jijwccs.png failed: open /SiYuan/data/assets/image- 20220702163332-jijwccs.png: permission denied; unable to lock file
Winform中实现窗体控件适配(自适应窗体)布局_通过C#代码方式
【u-boot】u-boot运行主线分析【03】—board_init_r
Excel-VBA 快速上手(八、单元格对象-常见的单元格操作)
在 Business Application Studio 里使用 SAP UI5 应用消费 OData 的 Create 和 Delete 操作
Redis data structure & General Command
6G: typical applications, key technologies and challenges
strcat() - 连接字符串
h5常用定位功能封装