中国高校课件下载中心 》 教学资源 》 大学文库

上海交通大学:《程序设计思想与方法》课程教学资源(上机课)第五次上机_第五次上机

文档信息
资源类别:文库
文档格式:DOC
文档页数:2
文件大小:27KB
团购合买:点击进入团购
内容简介
上海交通大学:《程序设计思想与方法》课程教学资源(上机课)第五次上机_第五次上机
刷新页面文档预览

第五次上机题目 Problem 1 问题描述: 在l0.3.2中的projectile..py程序基础上,添加getDistance(self,time)函数,计算质点在time 时间内运行的路程。 程序文件命名:1py Problem 2 问题描述:第十章课后第l7题:首先定义Regression类,然后使用Regression类,完成第 8章的Programming Exercise 13的要求。 Redo the regression problem from Chapter8(Programming Exercise 13)using a Regression class. Your new class will keep track of the various quantities that are needed to compute a line of regression(the running sums of x,y,x2,and xy).The regression class should have the following methods: init Creates a new regression object to which points can be added. addPoint Adds a point to the regression object. predict Accepts a value of x as a parameter,and returns the value of the corresponding y on the line of best fit. Note:Your class might also use some internal helper methods to do such things as compute the slope of the regression line. 程序文件命名:2py Problem 3 问题描述:Chapter1 1 Exercises 19 Create and test a Set class to represent a classical set.Your sets should support the following methods: Set(elements)Create a set(elements is the initial list of items in the set). addElement (x)Adds x to the set. deleteElement(x)Removes x from the set,if present.If x is not in the set,the set is left unchanged

第五次上机题目 Problem 1 问题描述: 在 10.3.2 中的 projectile.py 程序基础上,添加 getDistance(self,time)函数,计算质点在 time 时间内运行的路程。 程序文件命名:1.py Problem 2 问题描述:第十章课后第 17 题:首先定义 Regression 类,然后使用 Regression 类,完成第 8 章的 Programming Exercise 13 的要求。 Redo the regression problem from Chapter 8 (Programming Exercise 13) using a Regression class. Your new class will keep track of the various quantities that are needed to compute a line of regression (the running sums of x, y, x 2 , and xy). The regression class should have the following methods: __init__ Creates a new regression object to which points can be added. addPoint Adds a point to the regression object. predict Accepts a value of x as a parameter, and returns the value of the corresponding y on the line of best fit. Note: Your class might also use some internal helper methods to do such things as compute the slope of the regression line. 程序文件命名:2.py Problem 3 问题描述:Chapter 11 Exercises 19 Create and test a Set class to represent a classical set. Your sets should support the following methods: Set (elements) Create a set (elements is the initial list of items in the set). addElement (x) Adds x to the set. deleteElement(x) Removes x from the set, if present. If x is not in the set, the set is left unchanged

member (x)Returns true if x is in the set and false otherwise. intersection(set2)Returns a new set containing just those elements that are common to this set and set2. union(set2)Returns a new set containing all of elements that are in this set,set2,or both display()Show all the elements in the set Use the following program to test your new class. def main(): 1st1=[1,2,3,4,5,6] 1st2=[5,6,7,8,9] s1=Set(Ist1) s2=Set(Ist2) s1.addElement(8) s2.deleteElement(10) s3=s1.intersection(s2) s4=s1.union(s2) s3.display() s4.display() 程序文件命名:3py

member (x) Returns true if x is in the set and false otherwise. intersection(set2) Returns a new set containing just those elements that are common to this set and set2. union (set2) Returns a new set containing all of elements that are in this set, set2, or both. display() Show all the elements in the set Use the following program to test your new class. def main(): lst1=[1,2,3,4,5,6] lst2=[5,6,7,8,9] s1=Set(lst1) s2=Set(lst2) s1.addElement(8) s2. deleteElement(10) s3=s1. intersection(s2) s4=s1.union(s2) s3.display() s4.display() 程序文件命名:3.py

已到末页,全文结束
刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档