Python99道经典练习题答案 本资源摘要信息涵盖了四个 Python programming 题目,涵盖了 Python 编程语言的基本概念和应用。 第一个程序 题目:有 1、2、3、4 个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 程序分析:可填在百位、十位、个位的数字都是 1、2、3、4。组成所有的排列后再去掉不满足条件的排列。 程序源代码:使用三重循环来生成所有可能的三位数,然后使用条件语句来过滤掉不满足条件的三位数。 相关知识点 * Python 的循环语句(for、while) * Python 的条件语句(if、elif、else) * Python 的数据类型(int) 第二个程序 题目:企业发放的奖金根据利润提成。利润(I)低于或等于 10 万元时,奖金可提 10%;利润高于 10 万元,低于 20 万元时,低于 10 万元的部分按 10%提成,高于 10 万元的部分,可提成 7.5%;20 万到 40 万之间时,高于 20 万元的部分,可提成 5%;40 万到 60 万之间时高于 40 万元的部分,可提成 3%;60 万到 100 万之间时,高于 60 万元的部分,可提成 1.5%,高于 100 万元时,超过 100 万元的部分按 1%提成,从键盘输入当月利润 I,求应发放奖金总数? 程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。 程序源代码:使用 if-elif 语句来判断利润的范围,然后计算相应的奖金总数。 相关知识点 * Python 的条件语句(if、elif、else) * Python 的数据类型(int、float) * Python 的运算符(+、-、*、/、%) 第三个程序 题目:一个整数,它加上 100 后是一个完全平方数,再加上 268 又是一个完全平方数,请问该数是多少? 程序分析:在 10 万以内判断,先将该数加上 100 后再开方,再将该数加上 268 后再开方,如果开方后结果满足如下条件,即是结果。 程序源代码:使用 math 模块的 sqrt 函数来计算平方根,然后判断是否满足条件。 相关知识点 * Python 的 math 模块 * Python 的数据类型(int、float) * Python 的函数(sqrt) 第四个程序 题目:输入某年某月某日,判断这一天是这一年的第几天? 程序分析:以 3 月 5 日为例,应该先把前两个月的加起来,然后再加上 5 天即本年的第几天,特殊情况,闰年且输入月份大于 3 时需考虑多加一天。 程序源代码:使用列表来存储每个月的天数,然后使用条件语句来判断闰年和月份。 相关知识点 * Python 的列表(list) * Python 的条件语句(if、elif、else) * Python 的数据类型(int)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/release/download_crawler_static/88579543/bg1.jpg)
![](https://csdnimg.cn/release/download_crawler_static/88579543/bg2.jpg)
![](https://csdnimg.cn/release/download_crawler_static/88579543/bg3.jpg)
![](https://csdnimg.cn/release/download_crawler_static/88579543/bg4.jpg)
![](https://csdnimg.cn/release/download_crawler_static/88579543/bg5.jpg)
剩余41页未读,继续阅读
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/5fa179f5c8ac4993a9cd4f2a8abdc4cd_weixin_43739045.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
- 粉丝: 231
- 资源: 119
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)