当前位置: 首页 > news >正文

python学习day05

if判断

name=input('请输入你的昵称:')
if name=='608':print('你好,608')
if name=='qwq':print('你好,qwq')print('qwq')

if...else...

name=input('你的名字是:')
if name=='608':print('答对了哦qwq')
else:print('不对哦qwq')
qwq_age=19
age=input('猜猜我的岁数吧qwq:')
age=int(age)   # 注意要转换数据类型
if age==qwq_age:print('!!!猜对了哦qwq')
else:print('猜错了哦qwq')

if ...elif..else

qwq_age=19
age=input('猜猜我的岁数吧qwq:')
age=int(age)   # 注意要转换数据类型
if age==qwq_age:print('!!!猜对了哦qwq')
elif age>qwq_age:print('你猜的年龄太大了哦qwq')
elif age<qwq_age:print('你猜的年龄太小了哦qwq')

if的嵌套

if():if():
qwq_age=19
age=input('猜猜我的岁数吧qwq:')
age=int(age)
if age!=qwq_age:if age>qwq_age:print('你猜的年龄太大了哦qwq')if age<qwq_age:print('你猜的年龄太小了哦qwq')
if age==qwq_age:print('!!!猜对了哦qwq')

while循环

qwq_age=19
while True:age=input('猜猜我的岁数吧qwq:')age=int(age)if age!=qwq_age:if age>qwq_age:print('你猜的年龄太大了哦qwq')if age<qwq_age:print('你猜的年龄太小了哦qwq')if age==qwq_age:print('!!!猜对了哦qwq')break
prize={0:'money',1:'health',2:'knowledge',3:'rio_love'}
qwq_age=19
while True:age=input('猜猜我的岁数吧qwq:')age=int(age)if age!=qwq_age:if age>qwq_age:print('你猜的年龄太大了哦qwq')if age<qwq_age:print('你猜的年龄太小了哦qwq')if age==qwq_age:print(f'!!!猜对了哦qwq\n请选择下列奖励中的一个:{prize}')while True:choice=input('请输入你的选择:')choice=int(choice)if choice in[0,1,2]:print(f'你不可以选择{prize[choice]}\n请重新选择')if choice==3:print(f'你选择了{prize[choice]},调月莉音赛高')breakbreak
count=1 
while count<101:if count==50:count+=1continueprint(count)count+=1

for循环

todo_list=['get up','study','eating','sleep']
ind=0
while ind<len(todo_list):print(todo_list[ind])ind+=1
for i in todo_list:print(i)

for+break

todo_list=['get up','study','eating','sleep']
ind=0
for i in todo_list:if i =='eating':breakprint(i)

for+continue

todo_list=['get up','study','eating','sleep']
ind=0
for i in todo_list:if i =='eating':continueprint(i)

for+else

todo_list=['get up','study','eating','sleep']
ind=0
for i in todo_list:if i =='eating':continueprint(i)
else:print('我没有被break掉哦qwq')
todo_list=['get up','study','eating','sleep']
ind=0
for i in todo_list:if i =='eating':breakprint(i)
else:print('我被break掉啦qwq')
i='loading'
import time
while True:print(i)i=i+'.'time.sleep(1)if i=='loading.......':break
import time
print('loading',end='')
for i in range(6):print('.',end='')time.sleep(1)
http://www.gsyq.cn/news/143625.html

相关文章:

  • Harmony之路:组件间对话——@Prop与@Link通信机制
  • C++高并发编程核心技能解析
  • 大数据领域数据科学的气象数据分析技术
  • 利用clip-retrieval自动化收集图像并用于模型引导
  • 线代强化NO20|矩阵的相似与相似对角化|综合运用 - 实践
  • 32 岁 IT 运维踩坑:甲方突然不续约,项目解散,我成了失业大军一员
  • 为什么偏偏是周二?一文了解微软“补丁星期二”的前世今生
  • 算法题 最大人工岛
  • 一文读懂:共聚焦显微镜的结构、扫描与应用
  • Harmony之路:UI构建之基石——ArkUI声明式组件与布局
  • 跨境热销游戏手柄爆款密码
  • 百度一站式全业务智能结算中台
  • 挖到高薪密码!网安人均 26.9K,3 大原因 + 薪资表,转行党速码!
  • ARM 汇编指令:BX
  • JVM 垃圾回收从入门到精通:生产环境性能暴涨的秘密武器
  • java计算机毕业设计伍一酒店管理系统 智慧旅宿一体化运营平台 无人值守酒店在线订住系统
  • 基于51单片机的秒表设计—0.01精度、有提示音
  • C语言学习——指针部分知识点归纳
  • 93 年 32 岁 IT 运维失业了!甲方不续约项目解散,你们有同款经历吗?
  • 直线模组:工业自动化的精度心脏
  • 2025年论文写作终极指南:8款免费AI神器,20分钟速成初稿,全学科覆盖!
  • AI元人文构想:从价值对齐到意义共生的范式革命与文明演进新路径(人机协作)
  • 【学习笔记】《道德经》第22章
  • python in visual studio 2022: for pip installing packages
  • AJAX本质与核心概念
  • 比话和其他降AI率工具有什么不同,为什么能把知网AI率降低到15%
  • 【分布鲁棒】基于Wasserstein距离的两阶段分布鲁棒简易模型附Matlab代码
  • 翻过入门的第一座小山
  • 基于知识图谱的RAG
  • YOLOv11 改进 - 注意力机制 | IIA信息整合注意力(Information Integration Attention ):精准保留空间位置信息,平衡精度与计算成本 | TGRS2025