(UPDATED)homework3_solution
- 格式:doc
- 大小:127.50 KB
- 文档页数:6
六年级英语科第三单元、Review1检测试卷评分:一、选出划线部分发音与众不同的一项,将其字母代号写在括号里。
(10分)1.( ) A. win B. miss C. feel D. busy2.( ) A. fast B. last C. guitar D. math3.( ) A. grass B. glass C. angry D. green4.( ) A. practiced B、played C、helped D、brushed5.( ) A. wrote B. cotton C. bottle D. hospital二、观察每组单词的意义,选出与众不同的一项,将其字母代号写在括号里。
(10分)1.() A. candy B. cookies C. juice D. chocolate2.() A. lion B. tiger C. animals D. rabbit3.() A. bike B. bus C. subway D. train4.() A. carrots B. grapes C. peaches D. mangoes5.() A. tasty B. spicy C. cheap D. yucky三、选择最恰当的一项完成下列各题。
(12分)( ) 1 . Jenny happy every day.A. lookB. looksC. lookedD. looking( ) 2 .I had a day. I won all the games.A. badB. luckC. luckyD. fine( ) 3 . I had fun my friends. We went to the fun park.A. andB. toC. withD. about( ) 4 . a big birthday cake!A. howB. whatC. WhatD. What a( ) 5 . ---Did you your keys ? --- Yes, they were under my bed .A. lookingB. findC. watchD. saw( ) 6.---What happened your brother ? --- He broke the windows.A. toB. withC. theD. for四、根据句意及首字母提示完成句子。
图书管理系统python代码一、鹿寨小学图书馆开馆了,准备开发一个图书管理系统。
用json模拟数据库的方式完成下列业务:1.用户登录;login() 判断用户名输入错误三次即强制退出,密码输入错误三次也强制退出。
2.显示图书列表;showAllBooks()3.图书上架;addBook() 增加图书信息4.图书下架;delBook() 删除增加图书信息5.借书;lendBook()判断借出状态是不是可借,如果是,就更改为已借出6.还书;returnBook()7.显示用户 showallusers() 显示用户名8.增加用户 adduser() 增加用户9.删除用户 deluser() 删除用户10.退出a.使用json数据保存用户数据(包含用户名,密码,姓名);b.使用json数据保存图书数据(包含编号,书名,作者,借出状态state);可借---已借出c.编写用户各个业务函数,在main函数中将所有函数串联起来。
二、需要注意的是:第一次运行程序时,标黄的初始化数据要运行,第二次运行后就不需要保留(原因:json初始数据需要程序写入,不能手动添加!如果第二次运行时仍然保留的话,数据库的信息都会被初始化!)该程序为面向过程的语言,缺点是当用户信息或图书信息变得很大时,程序的执行效率就会变得很慢,后续会利用面向对象的方法编写图书管理系统。
完整的Python程序如下:import jsonimport timeimport sys# 初始化数据# booksdata = '[{"编号": 1001, "书名": "<红楼梦>", "作者": "曹雪芹", "借出状态": "已借出"}, \ # {"编号": 1002, "书名": "<java教程>", "作者": "齐一天", "借出状态": "可借"}, \# {"编号": 1003, "书名": "<圣经>", "作者": "耶稣", "借出状态": "可借"}]'# usersdata = '[{"用户名": "admin", "密码": "123", "姓名": "张三"},{"用户名": "aaa", "密码": "123", "姓名": "李四"}]'# with open(r"user.txt", "w") as f:# f.write(usersdata)# with open(r"book.txt", "w") as f:# f.write(booksdata)# 读用户数据def readusersdata():with open(r"user.txt", "r") as f:jsondata = f.read()listdata = json.loads(jsondata)return listdata# 读图书数据def readbooksdata():with open(r"book.txt", "r") as f:jsondata = f.read()listdata = json.loads(jsondata)return listdata# 写用户数据def writeusersdata(listdata):jsondata = json.dumps(listdata)with open(r"user.txt", "w") as f:f.write(jsondata)print("---用户数据写入成功")# 写图书数据def writebooksdata(listdata):jsondata = json.dumps(listdata)with open(r"book.txt", "w") as f:f.write(jsondata)print("---图书数据写入成功")# 用户登录def login():with open(r"user.txt", "r") as f:listusersdata = f.read()usersdata = json.loads(listusersdata)user = input("请输入用户名:")msg = 0 # 判断用户名是否存在usererror = 0 # 判断用户名输入错误次数passworderror = 0 # 判断密码输入错误次数while 1 == 1:for x in usersdata:if x["用户名"] == user:usererror = 0password = input("请输入用户密码:")msg == 1while 1 == 1:if x["密码"] == password:passworderror = 0print("恭喜您,登入成功!")return "成功"else:passworderror += 1if passworderror == 2:print("密码已输入错误两次,第三次输入错误将锁定账号!")if passworderror == 3:print("对不起!第三次密码输入错误,账号已锁定!系统正在退出...")return "失败"password = input("密码错误!请重新输入:")if msg == 0:usererror += 1if usererror == 2:print("账号已输入错误两次,第三次输入错误将锁定账号!")if usererror == 3:print("对不起!第三次账号输入错误,账号已锁定!系统正在退出...")return "失败"user = input("无此用户名!请重新输入:")# 显示图书列表def showAllBooks():listdata = readbooksdata()print("==============图书管理系统================")print("编号", " ", "书名", " ", "作者", " ", "借出状态")for x in listdata:print(x["编号"], " ", x["书名"], " ", x["作者"], " ", x["借出状态"])# 图书上架def addBook():print("==============增加图书信息================")listdata = readbooksdata()list1 = []for book in listdata:list1.append(book["编号"])newNum = max(list1) + 1# number=int(input("请输入图书编号:"))# msg=0 #判断图书编号是否已存在# while 1==1:# for x in listdata:# if x["编号"]==number:# msg=1# if msg==1:# number=int(input("系统中已存在该编号!请输入新的图书编号:")) # else:# breakbook = input("请输入书名:")book = "<" + book + ">"author = input("请输入作者:")state = "可借"newBook = {"编号": newNum, "书名": book, "作者": author, "借出状态": state}listdata.append(newBook)writebooksdata(listdata)# 图书下架def delBook():listdata = readbooksdata()showAllBooks()number = int(input("请输入要删除的图书编号:"))for book in listdata:if book["编号"] == number:listdata.remove(book)print("-----图书", book["书名"], "已下架!")writebooksdata(listdata)# 借书def lendBook():listdata = readbooksdata()showAllBooks()number = int(input("请输入要借的图书编号:"))while 1 == 1:for book in listdata:print(book["编号"])if book["编号"]==number:if book["借出状态"] == "可借":print("---恭喜你借出图书:", book["书名"], "成功!")book["借出状态"] = "已借出"writebooksdata(listdata)returnelse:print("----",book["书名"], "已经借出!下次再来吧!")returnelse:number=int(input("----没有此书籍,请重新输入要借的图书编号:"))# 还书def returnBook():listdata = readbooksdata()showAllBooks()number = int(input("请输入要还的图书编号:"))msg = 0while 1 == 1:for book in listdata:if book["编号"] == number:if book["借出状态"] == "已借出":msg = 1print("---恭喜你还书:", book["书名"], "成功!")book["借出状态"] = "可借"writebooksdata(listdata)returnelse:print("该书不可还!")if msg == 0:number = input("----没有此书籍,请重新输入要还的图书编号:")#增加用户账户def adduser():userdata = readusersdata()account = input("请输入要增加的用户名:")password = input("请输入要增加的用户密码:")name = input("请输入要增加的用户姓名:")append1 = {"用户名": account, "密码": password, "姓名": name}userdata.append(append1)writeusersdata(userdata)print("添加用户成功!")#删除用户账号def deluser():userdata = readusersdata()account = input("请输入要删除的用户名:")msg=0while 1==1:for x in userdata:if x["用户名"]==account:msg=1userdata.remove(x)writeusersdata(userdata)print("删除用户成功!")returnif msg==0:account=input("不存在此用户名,请重新输入要删除的用户名:")# 显示用户列表def showallusers():listuser = readusersdata()print("用户名", " ", "密码", " ", "姓名")for x in listuser:print(x["用户名"], " ", x["密码"], " ", x["姓名"])# 主函数def main():print("==============图书管理系统================")msg = login()if msg == "成功":while 1 == 1:task = float(input("请输入要办理的业务:(1-显示图书列表,2-上架图书,3-下架图书,4-借书,5-还书,6-显示用户,7-增加用户,8-删除用户,9-退出)"))if task == 1:showAllBooks()elif task == 2:addBook()elif task == 3:delBook()elif task == 4:lendBook()elif task == 5:returnBook()elif task == 6:showallusers()elif task == 7:adduser()showallusers()elif task == 8:showallusers()deluser()elif task == 9:sys.exit(0)else:print("没有此业务!") else:msg = 3for i in range(0,msg):print(msg-i)time.sleep(1)sys.exit(0)# ---if __name__=='__main__':main()运行程序结果如下:。
【mysql3】我的⼤学teacher课程进⾏中课堂作业谁来救救我持续更新系列!1.做⼀下powerdesigner的画图2.所有的创建表格⽹上书店数据库uid + uname + email + tnum + score会员表user结构列名 + 数据类型 + 允许null + 约束 +备注uid char(4)uname varchar(20)email varchar(20)tnum varchar(15)score int书book信息bid intbname varchar(50)author char(8)price floatpublisher varchar(50)discount floatcid intb_order订购表数据uid intbid char(4)ordernum intorderdate datetimedelivery datedatetimecategory图书类别表cid intcname varchar(16)1MySQL配置、启动、登录操作操作要求:1.在windows服务对话框中,⼿动启动或者关闭mysql 服务。
#windows+R --> services.msc 回车#找到mysql 右键启动;2.使⽤net命令启动或者关闭mysql 服务。
3.配置系统变量path ,确保mysql安装路径下的bin⽂件夹包含在path变量中。
#在系统的⾼级环境变量中path配置。
#⽂件在C:\Program Files\MySQL\MySQL Server 5.7\bin4.分别⽤ navicat ⼯具和命令⾏⽅式登录mysql服务器。
在命令⾏如何退出?#use database stu;#mysql -h127.0.0.1 -uroot -proot#quit;#exit;5.在命令⾏修改登录密码,并重新登录。
⽅法1:⽤SET PASSWORD命令⾸先登录MySQL。
Exercise 2Question 2. Computer PurchaseLet us assume that you are purchasing a new computer for a specific usage. You need to choose a computer from various available configurations.Listed below are four different usage cases of a computer (a-d). For each usage case, identify components of the computer configuration that are most important to consider. Explain your answers.Components to be considered include (but are not limited to): ∙Monitor size/resolution∙Graphics card/video card∙Storage devices (for example, DVD-ROM)∙Memory (RAM, cache, and hard disk)∙Disk controller interfaces (ATA, EIDE)For example, if a computer were to be used for viewing movies, a DVD-ROM drive is needed since movies are available as CDs and now increasingly as DVDs. A l arge monitor (about 19”) that supports high resolutions and a video card will also be necessary to enjoy the movie.a. Simultaneously running a number of programsLarge capacity memory (at least 1G ) is needed to stores data and instructions needed to execute programs when a number of programs run. In order to resolve this question, we should select the appropriate processor.T he Intel® Core™ Duo processor with its two execution cores is optimized formulti-threaded applications and multitasking. You can simultaneously run multiple demanding applications, such as 3-D games or serious scientific research programs, while downloading files or runningvirus-scanning security programs in the background.b. Running a speed-critical applicationConsidering system running speed: AMD processor is typically with less cost, sometimes even faster than Intel's products.So the AMD Opteron™ processor is needed. The AMD Opteron processors with Direct Connect Architecture and HyperTransport™ Technology deliver leading-edge 32-bit performance today and enable you to transition to 64-bit computing at your own pace, without sacrificing your x86 technology investment.A mother board with high speed front side bus is neededc. Storing and retrieving huge volumes of dataA large storage hard disk is needed (at least 800G) to store huge volumes of data, at the same time, we should foresee the demand of it.A DVD-RW is needed when you want to store your huge volumes of data in DVD-ROM.A motherboard with EIDE interface can accommodate a total of four devices, maybe you will get up to2 hard disk or more.d. Purchasing a basic configuration, to be upgraded later as neededFor upgrading your system, you must set your system has ability of upgrade and extended. So one good motherboard is needed.The Intel® Desktop Board D975XBX is designed to deliver the best experience for advance d gamers and power-users. Based on the Intel® 975X Express Chipset and Intel® Pentium® processor Extreme Edition, this board has the best performance and the ability of upgraded. The Intel® Desktop BoardD975XBX supports Intel® Viiv™ technology, and comes with the software required to help meet Intel®Viiv™ technology brand verification requirements.Question 3. Laptop Computer SelectionYou are a new graduate student enrolling in a Masters in Information Technology program. The department requires you to have a computer with the following requirements:∙512 MB of RAM∙20 GB hard drive∙CD-ROM drive∙Wireless connection∙Ethernet network card∙Windows XP Professional versionYour school has wireless connection, and Ethernet jacks. However, some classes are three hours long, and your AC adapter may not be long enough to reach an outlet. You also would be carrying this computer around from class to class.The most you can spend is US$1200.Indicate the range of values you desire for each of the following criteria: a. Weightb. Screen sizec. Number of USB portsd. Number of Firewire portse. Need CD-RW?f. Need DVD-ROM?g. Need DVD-RW?h. Manufacturer preferences?i. Search the Internet for two suitable computers meeting the above requirements and your budget constraint. Submit screenshots of the Web pages detailing the computer configuration and price.j. Record your search results in a MS Excel spreadsheet. Fill column A with the following category labels:1. Manufacturer2. Processor3. Memory (maximum upgrade capacity)4. Screen size5. Weight6. Graphics card7. USB8. Firewire9. CD-ROM10. DVD-ROM11. Communications (e.g. wireless, Ethernet)12. Battery life13. Price14. Available RebateSave and submit your Excel file.k. Make your final purchase decision and justify your decision.Unit 1 and Unit 2 Review Materials2. Binarya.Define bit.b.Define byte.c.Fill in the following chart, listing the prefixes used forthe amount of bytes shown:d.Fill in the following chart, converting binary numbers todecimal and decimal numbers to binary:(Note:The numbers that appear in the table below will differon an exam from the numbers that appear on the exam's review sheet.)e.Although in sales literature 1000 bytes and 1024 bytes areboth commonly referred to as a kilobyte, in computing the only correct number of bytes in a kilobyte is1024. Explain why 1024 is correct. Many quantities in binary computers are restricted to powers of 2, and 210 is 1024, which is so close to 1000 that kilo is used informally.f.How can the difference in measuring bytes presented in parte impact a consumer when they are purchasing a hard disk drive?A hard disk drive is typically measured traditionally, in powers of 10. Thereforea gigabyte in a hard disk is 109, not the larger 230. Not knowing this, aconsumer might be surprised that the disk capacity was less than he thought was advertised.3. Component IdentificationChoose among the following components to label the image: MotherboardPower supplyBIOS ROM ChipCooling fanExpansion slotRAM chipExpansion cardDisk drivesChipsetIDE cableEthernet cablePCI busa)Label A is _ Power supply ____.b)Label B is __ Cooling fan ___.c)Label C is _ Expansion slot____.d)Label D is _ Expansion card____.e)Label E is _ Motherboard____.f)Label F is __ Disk drives ___.g)Label G is __ IDE cable ___.Describe the functionality of each of the followingcomponents (in 2 sentences or less):h)Microprocessor: Processes instructions stored in main memoryi)RAM: Stores data and instructions temporarily.j)Bus: Pathway through which data is transferred from one part of a computer to anotherk)Expansion card: Enables a computer to control peripheral devices such as the monitor and the microphonel)Disk drive: Stores data permanently (even after the computer is turned off).m)IDE cable: Transfers data from storage devices to the motherboard8. I/Oa.Define I/O device. An I/O device, or input/output device, provides the userwith ways of giving the processor data to process and ways of receivingprocessed datab.Consider that a computer requires I/O devices to be able tointeract with its environment. Explain why it is necessaryfor computers to have these devices. The basic definition of acomputer includes input and output. These devices are necessary for thecomputer to exist. Differing I/O devices allow alternate input and output, butminimally the computer needs at least one of eachc.Give four examples of I/O devices. [Choose from] Keyboard; monitor;tape backup drive; scanner; microphone; speakers; CD writer; …d.For each I/O device in your answer to part c, explain thedevice's function from the perspective of a user.i.A keyboard provides data to a computer, to direct its behavior or supplyinformation for processing (name, address telephone number).ii.A monitor displays to the user the status and results of work performed by the computer.iii.A tape backup drive receives a copy of information stored on hard disk drives, and can later supply information to be stored on that hard disk drivein case the disk drive crashes or a file is accidentally deleted.iv.A scanner translates a picture or document to a bitmap image that can be processed by a computer, or included in other work like a web page orWord documentv.A microphone translates speech or music into digital from that can be processed by the computer.12. Picture Qualitya.Explain resolution, with respect to a monitor.Number of pixels on the screenb.List two typical monitor resolutions.1024x768, as an example.640x480, as an example.c.Explain color depth, with respect to a monitor.Maximum number of colors on the screen at one time.d.List two typical monitor color depths.16 bit, as an example.24 bit, as an example.e.Consider that the higher the resolution and the higher thecolor depth, the more system resources are required todisplay output on the monitor.e the resolutions from part b and the color depthsfrom part d to calculate the amount of RAM required todisplay the image. 1024x768x24/8=2.25MB, as an example.ii.Explain the calculation you made in part e.i in a waythat confirms the statement made at the beginning ofpart e—that "the higher the resolution and the higherthe color depth, the more system resources are requiredto display output on the monitor." The calculations in partE.i demonstrate that by increasing either the resolution or the color depththat the amount of memory required will increase, demonstrating thatmore system resources (RAM) are required.13. Port IdentificationConsider the following devices:MousePrinterKeyboardModemSpeakerDigital cameraEthernet jackMonitorFor the following questions, indicate which device(s) should be plugged in which port(s) A-H shown in the diagram below.f.What device(s) can be plugged into port A? Keyboard or mousei.What is the name of this port? PS/2 portii.Is this a serial port or parallel port? Serialg.What device(s) can be plugged into port B? Digital camera, keyboard,mouse, printer, external storage, network adapter, etci.What is the name of this port? USB portii.Is this a serial port or parallel port? Serialh.What device(s) can be plugged into port C? Modem or mousei.What is the name of this port? DB-9 (serial) portii.Is this a serial port or parallel port? Seriali.What device(s) can be plugged into port D? Printeri.What is the name of this port? Parallel (printer) portii.Is this a serial port or parallel port? Parallelj.What device(s) can be plugged into port E? Speakerk.What device(s) can be plugged into port F? Monitorl.What device(s) can be plugged into port G? Phone linem.What device(s) can be plugged into port H? Ethernet network。
2023年12月青少年软件编程Python等级考试试卷六级真题(含答案)分数:100 题数:38一、单选题(共25题,共50分)1.题运行以下程序,输出的结果是?()class A():def __init__(self,x):self.x=x+1def b(self):return self.x*self.xt=A(3)print(t.b())试题编号:202306-zzh-26试题类型:单选题标准答案:D2.题运行以下程序,输出的结果是?()import sqlite3conn = sqlite3。
connect('t1。
db')cursor = conn.cursor()conn.execute("DELETE from user")cursor.execute('insert into user (id, name) values (\'1\', \'张三\')') cursor.execute('insert into user (id, name) values (\'2\', \'李四\')') cursor.execute('insert into user (id, name) values (\'3\', \'王二\')') cursor.execute('insert into user (id, name) values (\'4\', \'刘五\')') mit()cursor.execute('select id,name from user')values = cursor.fetchone()values = cursor.fetchone()print(values)cursor.close()conn.close()试题编号:202306-zzh-30试题类型:单选题标准答案:C3.题 以下SQLite 语句可以修改记录的是?( )试题编号:202306-zzh-31试题类型:单选题标准答案:B4.题 SQLite 函数中,以下语句的作用是?( )values = cursor.fetchmany(2)print(values)试题编号:202306-zzh-32试题类型:单选题标准答案:A5.题关于SQLite,说法错误的是?()试题编号:202306-zzh-33试题类型:单选题标准答案:D6.题有一个叫做Animal的类,请问下面哪个选项是正确的创建子类Cat的语法?()试题编号:20230614-ltj-023 试题类型:单选题标准答案:A7.题下面的代码定义了一个Circle类,用于表示圆形的信息。
2022年12月青少年软件编程Python等级考试试卷三级真题(含答案和解析)分数:100 题数:38一、单选题(共25题,共50分)1. 列表L1中全是整数,小明想将其中所有奇数都增加1,偶数不变,于是编写了如下图所示的A. x || 2B. x ^ 2C. x && 2D. x % 2标准答案:D试题解析:本题代码中,for x in L1 是在L1列表中循环,每次取出的值x交给if语句进行判断,如果除以2的余数不等于0,就是奇数,则x+1,若等于0则x值不变。
取余数的运算符是%,所以正确答案就是D。
2. 小明为了学习选择排序的算法,编写了下面的代码。
针对代码中红色文字所示的一、二、三处,下面说法正确的是?()a = [8,4,11,3,9]count = len(a)for i in range(count-1):mi = ifor j in range(i+1,count):if a[mi] > a[j]: #代码一mi = j #代码二if i!=mi:a[mi],a[i] = a[i],a[mi] #代码三print(a)A. 如果找到更大的元素,则记录它的索引号。
B. 如果找到更小的元素,则记录它的索引号。
C. 在一趟选择排序后,不管是否找到更小的元素,mi所在元素都得与i所在的元素发生交换。
D. 代码三所在的行必然要运行。
标准答案:B3. 小明编写了一段演示插入排序的代码,代码如下。
请问红色“缺失代码”处,应该填写哪段代码?()a = [8,4,11,3,9]count = len(a)for i in range(1, count):j = ib = a[i]while j>0 and b<a[j-1] :a[j] = a[j-1]缺失代码a[j] = bprint(a)A. j=j-1B. j=j+1C. j=i+1D. j=i-1标准答案:A试题解析:本题考查学生对插入排序算法的理解。
料四年级英语下册第三单元试卷姓名_____________听力局部(30分)一、听录音,选出你所听到的单词或短语。
(10分)()1. A. thirty B. twenty C. usually()2. A. homework B. home C.go home()3. A. when B. where C. who()4. A. after school B. afternoon C. in the afternoon ()5. A. have lunch B. have dinner C. have breakfest ()6. A. match B. lunch C. watch()7. A. go home B. go to bed C. go home()8. A. nine B. night C. nice()9. A. play football B. play basketball C. timetable()10. A. 5:50 B.5:55 C. 5:15二、听录音,依据所听到的依次,给下列图片标号。
(10分)( ) ( ) ( ) ( ) ( )( ) ( ) ( ) ( ) ( )三、听录音,选出正确的答句。
(5分)( ) 1. A. At seven thirty. B. I have seven. C. It’s seven.( ) 2. A. I have Chinese. B. It’s a big TV. C. She is Miss Li. ( ) 3. A. At six. B. Six. C. It’s six o’clock. ( ) 4. A. Yes, it is. B. Yes, she does. C. Yes, I do.( ) 5. A. No, thank you. B. No, it isn’t. C. Sorry, I don’t know.四、听录音,将对话补充完好。
Unit 3-4 综合测评卷一、从下列每组单词中选出画线部分读音不同的一项( ) 1. A. after B. skate C. take D. name( ) 2. A. tweet B. see C. tree D. coffee( ) 3. A. time B. idea C. river D. fly( ) 4. A. any B. many C. Maths D. lesson( ) 5. A. when B. where C. whose D. what二、根据所给中文提示填空1. Can you see the boat_________________(在河面上)?2. I usually______________(做我的家庭作业) before dinner.3. Those apples_______________(在树上) are nice and sweet.4. Don’t________________(看电视), Mike. It’s time for bed.5. -Let’s________________(踢足球) after school.-______________(好主意)!6. Mike usually______________(吃晚饭) at six thirty.7. They want to draw in the park______________(在星期日下午).三、用所给词的适当形式填空1. -When does Su Hai________(go) home?-At five o’clock.2. Sam________(have) a swimming lesson on Saturday.3. Mike can play basketball________(good). He has two basketball________(match) this afternoon.4. That________(be) a chicken and those________(be) ducks.5. Bobby, ________(try) again.6. -Let’s________(swim) in the river.-No. It’s dangerous.7. -Can you________(see) the ducks over there?-No, I can’t see________(they).四、单项选择( ) 1. -What can you________in the box?-I can________a ball.A. do, seeB. see, seeC. do, look ( ) 2. ________! This is the lake.A. LookB. Look atC. Watch ( ) 3. I have a________lesson________afternoon.A. skate, atB. skating, thisC. skating, in ( ) 4. It’s________, but I________try.A. easy, canB. difficult, can’tC. difficult, can ( ) 5. They have a swimming lesson on Sunday, but I________.A. aren’tB. can’tC. don’t( ) 6. -________those pear trees?-Yes, they________.A. Do, doB. Are, areC. Can, can ( ) 7. I usually watch TV________eight in the________.A. at, nightB. in, eveningC. at, evening ( ) 8. -________lessons do you have today?-We have English, Maths and PE.A. WhatB. How manyC. How much ( ) 9. -________lessons do you have________Friday morning?-We have two.A. What, onB. How many, onC. How many, in ( ) 10. Look at the green flower. Can you see________?A. themB. theyC. it五、从II栏中选出与I栏句子相对应的答句I II( ) 1. What day is it today? A. Seven.( ) 2. Is it difficult? B. Sure. It’s easy.( ) 3. How many subjects do we have? C. It’s Wednesday. ( ) 4. Can you draw these animals? D. It’s seven.( ) 5. When do you go to school? E. Yes, it is.( ) 6. What time is it now? F. At seven.六、按要求完成句子1. I can play table tennis.(改为一般疑问句)________ ________play table tennis?2. I can see some nice flowers.(改为否定句)I________ ________ ________nice flowers.3. I usually get up at six thirty.(对画线部分提问)________ ________ ________usually get up?4. I have lunch at twelve.(用he替换I改写句子)________ ________lunch at twelve.5. Mike can make a fruit cake.(对画线部分提问)________can Mike________?七、根据中文提示完成句子或对话1. -你在湖面上能看见什么?-我能看见一些小船。
CSCI303Homework3Problem1(9-1):Given a set A of n numbers,we wish tofind the k largest in sorted order using a comparison-based algorithm.Find the algorithm that implements each of the following methods with the best asymptotic worst-case running time,and analyze the running time of the algorithms in terms of n and k.a.Sort the numbers,and list the k largest.b.Build a max-priority queue from the numbers,and call Extract-Max k times.e an order-statistic algorithm tofind the i th largest number,partition around that num-ber,and sort the k largest numbers.Solution1:a.Merge-Sort(A,1,n)return A[n−k...k]This algorithm takes only as long as it takes to Merge-Sort a list of n numbers,so its running time isΘ(n lg n).b.Build-Max-Heap(A)for i←1to kB[i]←Heap-Extract-Max(A)return BThis algorithmfirst calls Build-Max-Heap on A,which has worst-case asymptotic com-plexity O(n).Then it calls Heap-Extract-Max k times,each of which has worst-case asymptotic complexity O(lg n).So the worst-case asymptotic complexity for this algorithm is O(n+k lg n).c.i←Select(A,k)A[n]↔A[i]Partition(A)Merge-Sort(A,n−k,n)return A[n−k...k]This algorithmfirst calls Select,which has worst-case asymptotic complexity O(n), then calls Partition,which also has worst-case asymptotic complexity O(n),then calls Merge-Sort to sort just the last k elements,which has worst-case asymptotic complexity O(k lg k).So the worst-case asymptotic complexity for this algorithm is O(n+k lg k).Problem2(9.3-5):Suppose that you have a“black-box”worst-case linear-time median subroutine.Give a simple, linear-time algorithm that solves the selection problem for an arbitrary order statistic.Solution2:Simple-Select(A,p,r,i)if p=rreturn A[p]A[r]↔A[Index-Of-Median(A,p,r)] Partition(A,p,r)k← r−p+12if i=kreturn A[k]else if i<kreturn Simple-Select(A,1,k−1,i)elsereturn Simple-Select(A,k+1,r,i−k)Problem3(9.3-8):Let X[1,...,n]and Y[1,...,n]be two arrays,each containing n numbers already in sorted order. Give an O(lg n)-time algorithm tofind the median of all2n elements in arrays X and Y. Solution3:Two-List-Median(X,p,q,Y,s,t)mx←Index-Of-Median(X,p,q)my←Index-Of-Median(Y,s,t)X[mx]↔X[q]Y[my]↔Y[t]Partition(X,p,q)Partition(Y,s,t)if X[mx]=Y[my]return X[mx]else if X[mx]>Y[my]return Two-List-Median(X,p,mx−1,Y,my+1,t)elsereturn Two-List-Median(X,mx+1,q,Y,s,my−1)Problem4(8.1-1):What is the smallest possible depth of a leaf in a decision tree for a comparison sort?Solution4:Given an array A that contains n elements,the smallest possible depth of a leaf in a decision tree to sort A using a comparison-type sort is n−1.To verify that A is in sorted order takes n−1 comparisons,and if fewer comparisons are used then at least one element was not compared to any of the others,so that element might not be in the correct position.Problem 5(Derived from 8.1-4):You are given a sequence of n elements to sort and a number k such that k divides n .The input sequence consists of n/k subsequences,each containing k elements.The elements in a given subsequence are all smaller than the elements in the succeeding subsequence and larger than the elements in the preceding subsequence.Thus,all that is needed to sort the whole sequence of length n is to sort the k elements in each of the n/k subsequences.Show an Ω(n lg k )lower bound on the number of comparisons needed to solve this varient of the sorting problem using a comparison-type sorting algorithm.(Hint:It is not rigorous to simply combine the lower bounds for the individual subsequences.)Solution 5:We will construct a decision tree for this varient of the sorting problem and show that it has height at least n lg k .Each leaf of the decision tree corresponds to a permutation of the original sequence.How many permutations are there?Each subsequence has k !permutations,and there are n/k subsequences,so there are (k !)n/k permutations of the whole sequence.Thus the decision tree has (k !)n/k leaves.A binary tree with (k !)n/k leaves has height at least lg (k !)n/k .lg (k !)n/k =n/k lg(k !)=Θ(n/k ·k lg k )=Θ(n lg k )Therefore the lower bound on the number of comparisons needed to solve this varient of the sorting problem using a comparison-type sorting algorithm is Ω(n lg k ).。
Have you ever watered a garden and watched the water disappear(消失) into the soil? This fun experiment shows how plants take water from the ground to grow. Ask an adult to help you.You Will Need:• Medium-sized glass• Water• Red food coloring• Spoon• 1 celery stalk with leaves (一根带叶的芹菜)You Will Do:1. Fill the glass halfway with water.2. Stir(搅拌) in enough food coloring to make the water dark red.3. Ask Mom or Dad to cut 1 inch off the bottom of the celery stalk. Place the stalk in the water and let it stand overnight.What Will Happen?The leaves will turn red, as well as the tiny tubes running up through the stalk. Break the stalk in half, and you will see red dots in each piece.Why?As a plant grows, its roots act like straws(麦秆状吸管), sucking water up into the stem or stalk. Tiny tubes(管)inside the stalk carry water farther up into the leaves. (By coloring the water red, this is easier to see.) The red dots show a cross-section of the tiny tubes through which the water traveled.(190)51. What is this article mostly about?A. how water protects plantsB. how water can change colorsC. how celery stalks grow in waterD.how plants get water from the ground52. Which of these things is needed for Step 1 of the experiment?A. Water.B. Spoon.C. Celery stalk.D. Food coloring.53. In which part of the article can you find how the water moves through plants?A. “You Will Nee d”B.“You Will Do”C. “What Will Happen”D. “Why”F or one week in April, millions of people chose not to watch TV for “TV Turnoff Week”.TV Turnoff Week started in 1995 and is more popular every year. Many people discover that you can have a good time with the TV off. If that sounds crazy to you, just have a look at some numbers:―An American teenager spends 900 hours every year at school; the same teenager spends 1,023 hours every year watching TV. That’s 2 hours 49 minutes every day. ―An average(平均)British person (not just teenagers) watches 3 hours 35 minutes every day.―In the US, most TV has adverts. American children see 20,000 adverts every year. By age 65, an American has seen two million ads!But some research from Britain says that may not be a problem. The London Business School watched people carefully during TV adverts and they discovered that people don’t watch a lot of the ads. The researchers discovered that the most common activity during the adverts was talking to other people in the room. Many other people started reading or doing housework or changed channels during adverts. They only really watched them about 25 per cent of the time. 51.During TV Turnoff Week, many people don’t __________.A.watch TVB. change channelsC. watch advertsD. do their school work52.From the passage we can learn that __________.A. American children see more adverts on TV than their parentsB. British people spend more than 3 hours a day in front of their TVC. Researchers noticed that most people changed channels during adsD. An American teenager spends more time at school than watching TV 53.The writer’s purpose is __________.A. to advise us to spend less time on TVB. to tell us how to avoid watching advertsC. to show us how many adverts American TV hasD. to ask us to turn off TV during TV Turnoff WeekPassage3Picky, PickyScientists have no idea exactly why birds choose certain objects to build their nests. Butscientists know that the main reason birds build nests is to keep their babies safe, warm andhealthy.Baby birds grow faster and are healthier when they are warm. They also learn to fly and leavethe nests sooner than birds without warm homes.What A Yarn (纱)Oriole’s Nest Yarn is big on an oriole’s shopping list during nest building. Scientists are still trying to workout why so many birds choose white yarn over other colors for nest building.Scientists think that the white objects remind birds of cotton fluff (绒毛) they find in thewild.Do It NaturallyEven though birds can help us recycle some of our junk by using it to build nests, they alsoneed to use lots of natural things. Long grass, dried sticks, spider’s silk and mud are some of thenatural ingredients that are good for nests, too.You can make a collection box of things to leave for birds so they can help themselves. Hang asmall plastic box with holes on a tree branch. Fill the box freely with nest building goodies. Hangthe box on a tree and watch birds climb on board to pick through the junk to find their treasures.Warning: Don’t let the birds turn into a tasty treat. Keep your bird station away from placeswhere cats hang out.For The Birds!Stop! Don’t throw all that garbage out! Give some to the birds. Look and see how your oldjunk can help beautify and warm a bird’s new home.51. The baby birds with warm homes are able to _____.A. choose right objectsB. leave the nests soonerC. build good nestsD. learn to fly higher52. What can people make for birds to build nests?A. Holes on the tree.B. Food out of the rubbish.C. A warning board.D. A collection box of things.53. What can we learn from the passage?A. Birds build nests to store things.B. Birds regard white objects as cotton.C. Birds and humans can help each other.D. Birds and cats fight against each other.五、完形填空(共12分,每小题1分)On April 5,1971, the government of China asked the government of the United States this question. "Would the U.S. table tennis team like to 36 a week competing in pingpong games in China?" The answer was yes! For 20 years, Americans had not been allowed to 37 the land of China.The 15 members of the U. S. pingpong team did not know much about the country they were to visit. They had little 38 about the land or the population of China. Even so they found it different from what they 39 ! They had thought the people of China would be 40 and unfriendly. Instead, there were friendly Chinese everywhere waving and smiling.Never before had a sport become such a powerful instrument of 41 and friendship between two nations! The United States and China had been completely out of 42 with each other for many years. The visit of the American pingpong team to China brought about new efforts at communication 43 the two countries. The Chinese have 44 been the world table tennis champions(冠军), and they won most of the games. But who won the pingpong competition was not as 45 as the new friends that were 46 . "Winning doesn't 47 ," one of the Chinese players said, "but friendship does!"36. A. take B. pass C. use D. spend37. A. enter B. understand C. talk about D. get on38. A. question B. problem C. worry D. information39. A. imagined B. wanted C. had expected D. had seen40. A. foolish B. cold C. warm D. proud41. A. people B. sports C. war D. peace42. A. war B. touch C. trouble D. question43. A. of B. to C. between D. for44. A. never B. long C. always D. not45. A. many B. clear C. important D. special46. A. made B. known C. found D. met47. A. last B. exist C. develop D. mind书面表达英语校刊上刊登了学生会(The Student’s Union) 发出的倡议书“Write to your teacher”。
更正:3.26题Homework 3:Questions from Data Networks:3.12 Let τ1 and τ2 be two exponentially distributed, independent random variables with means 1/λ1 and 1/λ2. Show that the random variable min{τ1, τ2} is exponentially distributed with mean 1/(λ1+λ2) and that P{τ1<τ2}=λ1/(λ1+λ2). Use these facts to show that the M/M/1 queue can be described by a continuous-time Markov chain with transition rates q n(n+1)=λ, q (n+1)n =μ, n=0,1,…. Solution:{}()()()()()x x x e e e x P x P x x P x P 2121212121,,min λλλλττττττ+---==>>=>>=≥因此{}21,min ττ服从指数分布,均值为211λλ+()()()()21121202210121212λλλλλλλττλλλλλ+=∞⎪⎪⎭⎫ ⎝⎛++-=-=<+---∞-⎰x x x x e e dxe e P3.13 Persons arrive at a taxi stand with room for W taxis according to a Poisson process with rate λ. A person boards a taxi upon arrival if one is available and otherwise waits in a line. Taxis arrive at the stand according to a Poisson process with rate μ. An arriving taxi that finds the stand full departs immediately; otherwise, it picks up a customer if at least one is waiting, or else joins the queue of waiting taxis.(a) Use an M/M/1 queue formulation to obtain the steady-state distribution of the person ’s queue. What is the steady-state probability distribution of the taxi queue size when W = 5 and λ and μ are equal to 1 and 2 per minute, respectively? (Answer: Let p i = Probability of i taxis waiting. Then p 0 = 1/32, p 1 = 1/32, p 2 = 1/16, p 3 = 1/8, p 4 = 1/4, p 5 = 1/2.)(b) In the leaky bucket flow control scheme to be discussed in Chapter 6, packets arrive at a network entry point and must wait in a queue to obtain a permit before entering the network. Assume that permits are generated by a Poisson process with given rate and can be stored up to a given maximum number; permits generated while the maximum number of permits is available are discarded. Assume also that packets arrive according to a Poisson process with given rate. Show how to obtain the occupancy distribution of the queue of packets waiting for permits. Hint: This is the same system as the one of part (a).(c) Consider the flow control system of part (b) with the difference that permits are not generated according to a Poisson process but are instead generated periodically at a given rate. (This is a more realistic assumption.) Formulate the problem of finding the occupancy distribution of the packet queue as an M/D/1 problem. Solution :(a )以(n,m)系统表示系统状态,n 为车的数目,m 为人的数目.可能的状态为(根据题目所描述的规则,不会存在车和人同时排队的情况): (W,0),(W-1,0),…(0,0),(0,1),…,(0,n),….状态转移率为:(i,0)->(i-1,0)为λ,(0,n)->(0,n +1)也是λ, (i-1,0)->(i,0)为μ, (0,n)->(0,n-1)也是μ.车的队列的分布(可根据马氏链解出P(W,0)=1-ρ .其他任意状态的概率可由P(W,0)来表示。
)P[0辆车]=∑n ≥0ρW+n (1- ρ)=ρW . P[i 辆车]= ρW-i (1- ρ), 1≤i ≤W同样可以算出人的队列的分布: P[无人]=∑0≤i ≤W P(i,0), P[i 个人]=P(i,0). 3.13(b)是的3.13(a)应用3.14(此题给出的题目有误,不算分。
正确的题目及答案如下):A communication node A receives Poisson packet traffic from two other nodes, 1 and 2, at rates λ1 and λ2, respectively, and transmits it, on a first-come first_serve basis, using a link with capacity C bits/sec. The two input streams are assumed independent and their packet lengths are identically and exponentially distributed with mean L bits. A packet from node 1 is always accepted by A. A packet from node 2 is accepted only if the number of packets in A (in queue or under transmission) is less than a given number K > 0; otherwise, it is assumed lost.(a) What is the range of values of λ1 and λ2 for which the expected number of packets in A will stay bounded as time increases?(b) For λ1 and λ2 in the range of part (a) find the steady-state probability of having n packets in A (∞<≤n 0). Find the average time needed by a packet from source 1 to clear A once it enters A, and the average number of packets in A from source 1. Repeat for packets from source 2. Solution:(a)因为当A 内的节点数≥K 时,来自2 的数据包即被丢弃,所以主要考虑来自节点1的数据包。
节点A 接受所有来自节点1的包,所以当λ1<μ=C/L 时系统是稳定的, 即节点A 内期望的packet 数<∞.(b)马氏链的状态转移率:q i,i+1=λ1+λ2, 0≦i<K, q i,i+1=λ1, i>K; q i,i-1=μ, i>0列出DBE,解出平稳分布,并计算系统内平稳客户数N.源1的packet 从到达系统到离开的平均时间T 1=1/μ+N(1/μ)= (1+N) (1/μ); 源1的packet 在系统内的平均数为: N 1=λ1T 1 下面考虑源2设N’为系统内客户数<K 时的平均客户数(条件期望值)源2的packet 从到达系统到离开的平均时间T 2= (1+N’) (1/μ);∑∑-=-=='1010/K n nK n n p np N实际进入节点A 的源2的到达率λ’2等于λ2(1-P[节点A 内packet 数≥K]) 所以源2的packet 在系统内的平均数N2=λ’2T 2.3.15 Consider a system that is identical to M/M/1 except that when the system empties out, service does not begin again until k customers are present in the system (k is given). Once service begins it proceeds normally until the system becomes empty again. Find the steady-state probabilities of the number in the system, the average number in the system, and the average delay per customer. [Answer: The average number in the system is N = ρ/(1-ρ)+(k-1)/2.] Solution:The Markov chain is由GBE ,可得:()()'-'-'''===122110k k p p p p p p λλλλλλ()'-''====⇒1210k p p p p且有()()()()()01110111201p p p p p p p p p p p p k k k k +=+=+=+==-'--'λλμλλμλμ()k i p p ii ≥=+λμ1即()()k i p p i i ≤≤+++=-1101ρρρ()()k i p p k k i i >+++=--+0111ρρρ由101=+∑∑∞=='i ik i i pp 得()k p ρ-=10系统平均顾客数:()()ρρ-+-=+=∑∑∞=='12101k ip ip N i i k i i平均时间:λN T =3.16 M/M/1-Like System with State-Dependent Arrival and Service Rate. Consider a system which is the same as M/M/1 except that the rate λn and service rate μn when there are n customers in the system depend on n. Show that()001p p n n ρρ =+Where1+=k k k μλρ and()10001-∞=⎥⎦⎤⎢⎣⎡+=∑k k p ρρSolution:The markov chain is根据此链写出细节平衡方程(DBE ),易证所给结论。