参考书籍:python程序设计

chapter 1

5.

print("This program illustrates a chaotic function")
x = eval(input("Enter a number between 0 and 1:"))
n = eval(input("How many times shoule I print?"))
for i in range(n):x = 3.9 * x * (1 - x)print(x)

chapter2

问题分析-程序规格说明-设计-实现-测试/调试-维护

4.

def convert():celsius = eval(input("What's the Celsius temperature?"))fahrenheit = 9/5 * celsius + 32print("The temperature is ", fahrenheit, "degrees Fahrenheit.")for i in range(5):convert()

5.

def main():celsius = 0for i in range(11):   fahrenheit = 9/5 * celsius + 32print("Celsius", celsius, "equals to Fahrenheit", fahrenheit, ".")celsius += 10
main()

7.

def main():print("This program calculates the future value.")year = eval(input("How may years do  you want?"))principal = eval(input("How much the principal each year?"))apr = eval(input("Enter the annual interest rate:"))value = principalfor i in range(year):value = (1 + apr) * valuevalue += principalprint("The value in", year, "years is: ", value)main()

12.

def main():print("This program calculates the expression's result.")for i in range(100):expr = eval(input("Enter an expression:"))print(expr)main()

chapter3

10.

import mathdef main():print("This program calculates the length of ladder.")angle = eval(input("Enter the angle:")) # degreeradians = angle * math.pi / 180 # radiansheight = 10length = height / math.sin(radians)print("The length of ladder is", length, ".")main()

11.

def main():print("This program calculates the sum of n natural numbers.")num = eval(input("Please enter the number:"))s = 0for i in range(num + 1):s += iprint("The sum is", s, ".")main()

15.

import math
def main():num = eval(input("Please input the number:"))s = 0for n in range(num):s = s + (-1)**(n) * 4/(2 * n + 1)error = math.pi - sprint("The sum is:", s, ".")print("The error is,", error, ".")main()

python习题练习(一)相关推荐

  1. 【Python习题】计算弓形的面积(保姆级图文+实现代码)

    目录 题目 实现思路 实现代码 总结 主要内容是校设课程的习题和课外学习的一些习题. 欢迎关注 『Python习题』 系列,持续更新中 欢迎关注 『Python习题』 系列,持续更新中 题目 题目 如 ...

  2. 百分制成绩转换五分制F【Python习题】(保姆级图文+实现代码)

    目录 题目 描述 输入格式 输出格式 输入输出示例 思路 代码 实现效果 总结 主要内容是校设课程的习题和课外学习的一些习题. 欢迎关注 『Python习题』 系列,持续更新中 欢迎关注 『Pytho ...

  3. 【Python习题】简易英汉字典(project-ssss)(题目的坑解析+实现代码)

    目录 题目 示例 1‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬ ...

  4. 浙大python习题超详细思路(第二章)

    人生苦短,我用python https://pintia.cn/problem-sets/1111652100718116864/problems/type/7 题源来自pta 没有读者验证码,只是验 ...

  5. Python 习题 老虎、棒棒、鸡、虫

    Python 习题 老虎.棒棒.鸡.虫 看了好多人写的同项目代码,好长,想着写个短的. import time,random def pd(n,t):if (n == 0 and t == 4) or ...

  6. Python.习题五 列表与元组(下)

    Python.<习题五> 列表与元组 11.假设列表lst_info=[["李玉","男",25],["金忠","男& ...

  7. python高级练习题:多米诺平铺 - 5×2N局【难度:4级】--景越Python编程实例训练营,不同难度Python习题,适合自学Python的新手进阶

    python高级练习题:多米诺平铺 - 5×2N局[难度:4级]: 请还检查了在[多米诺拼接系列]其他练习题(https://www.codewars.com/collections/5d19554d ...

  8. Python习题十三套汇总

    前言: Python习题系列结束,共计13套. 查找具体题目,按Ctrl+F搜关键字,定位到相关习题,再点击标题链接进入. 本章整合13套链接,如下: Python习题 习题一 接受多个整数输出最大值 ...

  9. python进阶练习题:馏分类【难度:2级】--景越Python编程实例训练营,不同难度Python习题,适合自学Python的新手进阶

    python进阶练习题:馏分类[难度:2级]: 为您提供了类"分数",这两个参数(分子,分母)的骨架. 例: fraction1 =分数(4,5) 分数fraction1 =新分数 ...

  10. python习题:函数

    python习题演练(三)(函数) 目录 python习题演练(三)(函数) 五.函数 五.函数 累加函数 描述:编写一个函数实现从 1 到 N 共 N 个数的累加 对指定r计算圆的面积(补全代码) ...

最新文章

  1. 用 Flask 来写个轻博客 (8) — (M)VC_Alembic 管理数据库结构的升级和降级
  2. android 关机 流程_Android系统关机的全流程解析
  3. Enterprise Library 企业库 V4.1
  4. Android 全屏抽屉fragment,NavigationView
  5. 如何在 Gitee 上使用 GPG
  6. android 正五边形图表,Android自定义View-蜘蛛网属性图(五边形图)
  7. GNS3中下载路由器
  8. kindeditor上传图片宽度自适应
  9. 图层php,ps图层怎么用
  10. 计算机怎样设置光盘启动项,怎么设置开机启动项-设置光盘启动教程
  11. Python 解析 spec 文件
  12. Chrome浏览器录屏扩展插件
  13. 科研人快速入门LaTex到日常使用,下载安装配置,语法使用说明等
  14. ChatGPT自动写了个AI办公office word插件,低配copilot,程序员看了焦虑。
  15. 西夏文可用电脑录入了【ZZ】
  16. php图片镜像翻转,利用css动画属性rotate来实现镜像翻转
  17. Android studio 中删除git 版本控制
  18. CNC编程的12个小技巧,学会终身受益!
  19. 【简单 快速,只需两步部署安装激活 Office】
  20. 磁盘提示无法访问参数错误,里面的文件怎么找回

热门文章

  1. 史上最全的nexus私服搭建全流程
  2. 全志T7 Display驱动简介
  3. linux笔记(6):东山哪吒D1H测试HDMI显示内置图片-命令行调试
  4. 大众点评api接口 开放平台
  5. matlab如何提取某一列的数据_MATLAB如何提取某一矩阵的某一列的部分数据?
  6. Android 自定义ViewGroup 实战篇 - 实现FlowLayout
  7. Exercise11-Matplotlib
  8. OC中声明变量的几种方式
  9. python库:Pandas学习笔记
  10. lq到底是什么意思_LQ是什么意思..?!谁知道..!?