python语言基础-笔记
2021/6/14 1:22:24
本文主要是介绍python语言基础-笔记,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
计算机的流程控制:顺序结构、选择结构、循环结构
1.选择结构:1) 单分支结构 if 语句
1 #练习:取钱! 2 money=1000 3 s=int(input('请输入一个整数:')) 4 if s<=money: 5 money=money-s 6 print('您已取款成功,余额为',money)
2)双分支结构 if else 语句
#练习:录入一个整数,判断这个数是奇数还是偶数 a=int(input('请输入一个整数:')) if a%2==0: print(a,'为偶数') else: print(a,'为奇数')
3)多分支结构 if elif elif... else
#练习:输入一个整数,90-100为A,80-89为B以此类推,0-60为E,小于0或大于100非法 score=int(input('请输入您的成绩:')) print(score) if score>=90 and score<=100: print('您的等级为A。') elif score>=80 and score<=89: print('您的等级为B。') elif score>=70 and score<=79: print('您的等级为C。') elif score>=60 and score<=69: print('您的等级为D。') elif score>=0 and score<=59: print('您的等级为E。') else: print('您输入的成绩有误!')
这篇关于python语言基础-笔记的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-04Python外包有哪些常见的主要库-icode9专业技术文章分享
- 2024-10-02基于深度学习的钢铁缺陷检测系统(yolov8、注意力机制、PyQt5界面、Python)
- 2024-10-01怎么用python搭建一个系统-icode9专业技术文章分享
- 2024-09-30Python基础入门教程
- 2024-09-30获取参数学习:Python中的基础教程
- 2024-09-30Python编程基础详解
- 2024-09-29点击加载学习:Python编程基础教程
- 2024-09-29数据科学五大Python前端库:第二部分
- 2024-09-27使用python 将ETH账户的资产打散
- 2024-09-26Python编程基础