第九章(第一部分)(Four_Slides_per_Page)

合集下载

此教程由魔御使整理

此教程由魔御使整理

此教程由魔御使整理。

参照通宵虫的BB基础教程,BBIDE 的使用教程。

BBIDE使用教程BBIDEv2.0使用帮助(1)介绍:曾几何时,有许许多多像我一样的人想要学习BBASIC,然而不少人因为它没有集成的开发环境而忘而却步,这也不怪,像我们这些学生又有几个会用DOS的,我学BBASIC时就特别学习了一下DOS系统的使用.然而,到现在为止,BBASIC终于有了集成的开发环境(BBIDEv3.0),它让BBASIC编程变的更容易(包括嵌入BB汇编),即使你不会使用DOS.声明本程序编译器版权归步步高公司所有,请勿用于商业用途.程序制作步游工作室:方寸BBIDE使BBASIC编程变得更容易的新特点一键编译执行只需按下F5键即可编译执行你所写的BB程序一键调用ResMake用过BBASIC写过图形程序的朋友可能都知道ResMake被用到的频率之高一键调用MapEdit(地图编辑器)可以直接编译内嵌汇编.生成BB程序只要填写好选项即可生成输出BB程序BBIDE的整合性整合了整个BB2.0开发包(因此如果你以前下的有BB2.0开发包就可以把它删了)加入了天狼星,cr的BB汇编教程加入了BBKDOWN,步游工作室,BBK游盟,EEBBK论坛等我所知道的BBK相关网站的链接(帮助菜单下),在帮助菜单下,个人建意把你写的BB程序发到BBKDOWN,这是目前惟一几个发BB程序的好地方之一,理由:方便下载.问一些关于BB的问题可以到EEBBK论坛或BBK游盟.3.0版本新功能1.对BBTool进行了修改,进行文件内容小写化时不在更改半角双引号间的内容2.支持直接编译链接运行Obj(Vasm汇编文件)3.代码错误自动跳转到错误行4.Tab字符自动缩进5.独立的Sim文件夹6.加入浏览栏7.对语言进行了修改,加入了中文说明,并进行了分类,加色8.MDI多文档界面,可以同时编辑多个文件9.识别命令行,识别的文件有(*.bas;*.obj;*.bbp(BBASIC工程文件);*.txt)(2)写第一个用BBIDEv3.0创建的BB程序首先双击启动BBIDE.exe启动后画面如下单击工具栏上的新建工程代码编辑框代码编辑框如下文件菜单项子项保存——保存代码另存为——另存为代码关闭——关闭该代码编辑框编辑菜单项子项与Windows记事本基本相同项就不介绍了转换插入运行菜单子项如下编译运行——编译并运行BBasic程序快捷键F5编译——编译BBasic程序快捷键F6运行——运行编译后的BBasic程序快捷键F8生成——弹出生成对话框快捷栏快捷栏如下设置对话框设置对话框如下对代码编辑器进行设置需要注意的是字体设置中只用字号和字体和字体颜色是有效的其它选择无效设置后必须重新打开代码编辑器才生效生成对话框新建工程对话框可以自己添加工程模板仿照BBIDE文件夹下Projects文件夹内的内容即可自行创建模板新建文件对话框新建文件对话框如下需要注意的是,新建的文件被放在了文件夹列表中的当前打开的文件夹中并会出现在文件列表框IDE没有直接打开文件双击文件列表框中的文件名即可打开代码编辑器进行编辑语言栏语言栏界面如下双击语言栏中的终节点,就会将该节点的文本放入当前的BBASIC代码编辑框中(V asm代码编辑框无效)浏览栏浏览栏如下在文件过滤器上单击右键会弹出“刷新浏览区”菜单可以更新文件列表的内容当你对文件进行添加或复制操作之后,可以刷新显示新的文件列表文件夹列表右键菜单文件列表右键菜单以上的就是BBIDE3.0的使用教程了。

python第9章类课后习题答案

python第9章类课后习题答案

Solutions - Chapter 99-1: RestaurantMake a class called Restaurant. The __init__() methodfor Restaurant should store two attributes: a restaurant_name and a cuisine_type. Make a method called describe_restaurant() that prints these two pieces of information, and a methodcalled open_restaurant() that prints a message indicating that the restaurant is open.Make an instance called restaurant from your class. Print the two attributes individually, and then call both methods.Output:9-2: Three RestaurantsStart with your class from Exercise 9-1. Create three different instances from the class, and call describe_restaurant() for each instance.Output:9-3: UsersMake a class called User. Create two attributescalled first_name and last_name, and then create several other attributes that are typically stored in a user profile. Make a method called describe_user()that prints a summary of the user’s information. Make another method called greet_user() that prints a personalized greeting to the user.Create several instances representing different users, and call both methods for each user.Output:9-4: Number ServedStart with your program from Exercise 9-1 (page 166). Add an attribute called number_served with a default value of 0. Create an instance called restaurant from this class. Print the number ofcustomers the restaurant has served, and then change this value and print it again.Add a method called set_number_served() that lets you set thenumber of customers that have been served. Call this method with a new number and print the value again.Add a method called increment_number_served() that lets youincrement the number of customer s who’ve been served. Call this method with any number you like that could represent how many customers were served in, say, a day of business.Output:9-5: Login AttemptsAdd an attribute called login_attempts to your User class from Exercise 9-3 (page 166). Write amehtodcalled increment_login_attempts() that increments the value of login_attempts by 1. Write another methodcalled reset_login_attempts() that resets the valueof login_attempts to 0.Make an instance of the User class andcall increment_login_attempts() several times. Print the valueof login_attempts to make sure it was incremented properly, and then call reset_login_attempts(). Print login_attempts again to make sure it was reset to 0.Output:9-6: Ice Cream StandAn ice cream stand is a specific kind of restaurant. Write a class called IceCreamStand that inherits from the Restaurant class youwrote in Exercise 9-1 (page 166) or Exercise 9-4 (page 171). Eitehr version of the class will work; just pick the one you like better. Add an attribute called flavors that stores a list of ice cream flavors. Write a method that displays theese flavors. Create an instanceof IceCreamStand, and call this method.Output:9-7: AdminAn administrator is a special kind of user. Write a classcalled Admin that inherits from the User class you wrote in Exercise 9-3 (page 166) or Exercise 9-5 (page 171). Add an attribute, privileges, that stores a list of strings like "can add post", "can delete post", "can ban user", and so on. WRite a method called show_privileges() that lists the administrator’s set of privileges. Create an instance of Admin, and call your method.Output:9-8: PrivilegesWrite a separate Privileges class. The class should have one attribute, privileges, that stores a list of strings as described in Exercise 9-7. Move the show_privileges() method to this class. Make a Privileges instance as an attribute in the Admin class. Create a new instance of Admin and use your method to show its privileges.Output:9-9: Battery UpgradeUse the final version of electric_car.py from this section. Add a method to the Battery class called upgrade_battery(). This methodshould check the battery size and set the capacity to 85 if it isn’t already. Make an electric car with a default battery size,call get_range() once, and then call get_range() a second time after upgrading the battery. You should see an increase in the car’s rang e.Output:9-10: Imported RestaurantUsing your latest Restaurant class, store it in a module. Make a separate file that imports Restaurant. Make a Restaurant instance, and call one of Restaurant’s methods to show thatthe import statement is working properly.restaurant.py:my_restaurant.py:Output:9-11: Imported AdminStart with your work from Exercise 9-8 (page 178). Store theclasses User, Privileges and Admin in one module. Create a separate file, make an Admin instance, and call show_priveleges() to show that everything is working correctly.user.py:my_user.py:Output:9-12: Multiple ModulesStore the User class in one module, and storethe Privileges and Admin classes in a separate module. In a separate file, create an Admin instance and call show_privileges() to show that everything is still working correctly.user.py:admin.py:my_admin.pyOutput:9-13: OrderedDict RewriteStart with Exercise 6-4 (page 108), where you used a standard dictionary to represent a glossary. Rewrite the program usingthe OrderedDict class and make sure the order of the output matches the order in which key-value pairs were added to the dictionary.Note: In Python 3.6, dictionaries store keys in order. However, this is not guaranteed to work in all versions of Python, so you should still use an OrderedDict when you need key-value pairs to be stored in a particular order.Output:9-14: DiceThe module random contains functions that generate random numbers in a variety of ways. The function randint() returns an integer in therange you provide. the following code returns a number between 1 and 6:Make a class Die with one attribute called sides, which has a defaultvalue of 6. Write a method called roll_die() that prints a randomnumber between 1 and the number of sides the die has. Make a6-sided die and roll it 10 times.Make a 10-sided die and a 20-sided die. Roll each die 10 times.Output:。

chapter_9

chapter_9

返回
9.5 缓冲流 1.BufferedReader类 BufferedReader的构造方法是: BufferedReader(Reader in) BufferedReader流能够读取文本行,方 法是readLine()。
通过向BufferedReader传递一个Reader对 象(如FileReader的实例),来创建一个 BufferedReader对象,如:
read方法还有其它一些形式。这些形式能使 程序把多个字节读到一个字节数组中: int read(byte b[ ]); int read(byte b[ ], int off, int len); 其中,off参数指定read方法把数据存放在字节数 组b中的什么地方样,len参数指定该方法将读取 的最大字节数。上面所示的这两个法都返 回实际读取的字节个数,如果它们到达输入流的 末尾,则返回-1。
第九章 输入、输出流
n n n n n n n
&本章导读 1. 文件 2. 文件字节流 3. 文件字符流 4. 从键盘读取数据 5.缓冲流 6.数组流
n n n n n n n
7.字符串流 8.数据流 9.管道流 10.对象流 11.序列化与对象克隆 12. 随机读写流 13. 文件锁
I/O流中的输入流的指向称做源,程序 从指向源的输入流中读取源中的数据; 输出流的指向称做目的地,程序通过向 输出流中写入数据把信息传递到目的地。
在下面的Example9_5.java中,我们 将文件“Student.txt”中的内容按行 读出,并写入到另一个文件中,且 给每一行加上行号。
返回
9.6 数组流
字节输入流:ByteArrayInputStream 和字节输出 流:ByteArrayOutputStream分别使用字节数组作为流 的源和目标。使用下列ByteArrayInputStream流的两 个构造方法构造字节数组输入流对象: ByteArrayInputStream(byte[] buf) ByteArrayInputStream(byte[] buf,int offset,int length) 第一个构造方法构造的数组字节流的源是参数buf指定 的数组的全部字节单元,第二个构造方法构造的数组 字节流的源是参数buf指定的数组从offset处取的 length个字节单元。

五年级英语第九册_Module_1_There_wasn't_a_pond

五年级英语第九册_Module_1_There_wasn't_a_pond

• • •
• • •

四、名词可数不可数“六注意” 1、可数名词是可以用来计数的名词。可数名词有单数和复数形式。如:desk-desks, apple-apples等。不可数 名词是不可以直接用来计数的名词。不可数名词没有复数形式,只有单数形式。如:some bread, a little milk等。 2、单数可数名词表示泛指时,前面要用不定冠词a(an),表示特指时,前面要用定冠词the; 而不可数名词前不 能用a(an)修饰,表示特指时,前面一定要用定冠词the。如: He is a factory worker. 他是一名工人。 No one can see air. 没有人能看见空气。 3、可数名词和不可数名词前都可以用some, any, a lot of, lots of 等来修饰,表示"一些,许多"。如: There are some oranges on the desk. 桌子上有一些桔子。 There is a lot of water in the bottle. 瓶里有许多水。 4、可数名词前可用具体的数词来表示具体的数量。如:two apples, four books等。不可数名词前通常用"单位 词+of"来表示数量。如: a piece of paper, three pieces of paper等。 5、可数名词作主语时,谓语动词的单复数与主语的单复数保持一致。如: This picture is very beautiful. 这幅画很美。 不可数名词作主语时,谓语动词要用单数形式,但是不可数名词前有复数"单位词"时,谓语动词要用复数形式。 如: There are two cups of tea on the table. 桌上有两杯茶。 6、对可数名词前的修饰语提问用how many; 对不可数名词前的修饰语提问用how much。 如: How many apples are there in the box?盒子里有多少个苹果? How much tea is there in the cup?杯里有多少茶水? 注意:对不可数名词前的"单位词"的修饰语提问时,疑问词用how many。 如: How many pieces of bread are there on the plate?盘子里有多少片面包?

小学下册I卷英语第二单元全练全测(有答案)

小学下册I卷英语第二单元全练全测(有答案)

小学下册英语第二单元全练全测(有答案)英语试题一、综合题(本题有100小题,每小题1分,共100分.每小题不选、错误,均不给分)1.The _____ (校园) is large and green.2.The bus arrives at ______ (ten) o'clock.3.The ______ (蟋蟀) is often heard at night.4.I enjoy visiting the ________ (历史博物馆).5.What is the capital of Iceland?A. OsloB. ReykjavikC. HelsinkiD. Copenhagen答案:B6.Oceans are deeper than ________.7.I enjoy playing with my ________ (拼图游戏) on weekends.8.The _____ (teacher/student) is helpful.9.I can create art with my ________ (玩具).10.The capital of Oman is ________ (阿曼的首都是________).11.The __________ can reveal the history of the Earth's geological formations.12. A reaction that releases energy is called an ______ reaction.13.The children are _____ in the sandbox. (playing)14.The _______ can be a source of food and shelter.15.Kites fly high due to _______ and lift.16.What do you call the act of making something look nice?A. DecoratingB. DesigningC. BeautifyingD. Arranging答案: A17.The playground has many ______ (slides).18.We are going to the ______. (zoo)19.Plants need __________ (阳光) to grow well.20.He is very ___. (smart)21.My sister is _____ (高).22.He is a firefighter, ______ (他是一名消防员), saving lives every day.23. A ____ can often be found resting in the shade.24.The ________ (地图) shows us where to go.25.The tiger roars loudly in the _________ (丛林).26. A bee collects ______ from flowers.27.I enjoy making ________ (贺卡) for special occasions.28.My favorite activity is ______ (打乒乓球).29.The _____ (fireworks) are colorful.30. A rabbit has sharp ______ (牙齿) for chewing.31. A combustion reaction produces ______ and water.32.They are _____ (sitting) on the grass.33.The unit of measure for chemical concentration is ______ per liter.34. A strong base has a pH value that is ________ than35.I like to collect ________ from different places.36.Which fruit is known for having seeds on the outside?A. BananaB. StrawberryC. KiwiD. Blueberry答案: B37.My sister loves to play ____ (soccer) after school.38.My aunt has a beautiful ________ (玫瑰花园) that attracts many ________ (蜜蜂).39.What is the capital of Guinea?A. ConakryB. NzérékoréC. KankanD. Kindia答案: A40.The narwhal has a long ________________ (牙).41.We have ___ (fun) at the party.42. A __________ is a mixture that can be separated by filtration.43.I dream of going to ________ (太空) one day.44.The _____ (土壤质量) affects plant growth significantly.45.The ancient Greeks established the concept of _______ democracy.46.I want to _____ (go/stay) at home.47.She is _____ (riding) a bike.48.My sister loves to learn about ____.49.__________ are used in the paper industry.50.I love to draw pictures of _____ in my sketchbook.51. Wall is one of the most famous ________ (地标). The Grea52.The _____ (路) leads to the park.53.When I go to the movies, I like to bring my favorite ________ (玩偶) along.54. A _______ (金鱼) can be orange, yellow, or white.55.The ancient Greeks believed in the power of ________.56.My ________ (玩具名称) is a soft pillow.57. A molecule that is formed from the combination of two or more elements is called a ______.58.The owl is silent when it _______ (飞行).59.How many legs does an insect have?A. SixB. EightC. FourD. Two答案: A60.My _____ (爸爸) builds model airplanes in his free time. 我爸爸在空闲时间搭建模型飞机。

Chapter09_new

Chapter09_new

19
链式实现
链式实现
以结点的概念为基础。 结点(Node) 一个结点由两部分数据构成:
– 存入列表的项目 (item) – 指向列表中的下一个结点的指针 (next)
20
链式实现
图 9.4 一个链式列表的 Figure 9.4 Anatomy of a linked list 结构图
21
链式实现
36
快速排序
基本思想:通过一趟排序将待排记录分割成 独立的两部分,其中一部分记录的关键字均 比另一部分的小,则可对这两部分记录继续 进行排序,以达到整个序列有序。
37
快速排序
图 9.12 用快速排序算法对一个列 表排序 38
It is easier to sort a smaller number of items: Sort A…F, G…L, M…R, and S…Z and A…Z is sorted
图 9.5 无序链式列表
22
链式实现
图 9.6 有序链式列表
23
链式实现
操作的实现?
Add item Remove item Get next item more items
24
链式实现
图 9.7 把info为 67的结点存入current之后
25
链式实现
图 9.8 删除结点next(current)
1.从具体问题抽象出一个适当的数学模型。(分析问题) 2.设计一个解此数学模型的算法。
3.编写出程序。
3
数据结构
问题:非数值计算问题无法用数学方程加以 描述。
图书馆书目检索系统自动化问题?(线性的) 计算机和人对弈问题?(树) 多叉路口交通灯管理问题?(图)

小学五年级上册第1次英语第1单元期测验题(答案和解释)

小学五年级上册第1次英语第1单元期测验题(答案和解释)

小学五年级上册英语第1单元期测验题(答案和解释)英语试题一、综合题(本题有50小题,每小题2分,共100分.每小题不选、错误,均不给分)1.Which one is used to eat soup?A. KnifeB. ForkC. SpoonD. Plate2.I __________ (wake) up early every day because I __________ (like) to get to school on time. This morning, I __________ (wake) up at 6:30, but I __________ (feel) very tired because I __________ (stay) up late last night.3.I __________ (like) to play soccer. Every weekend, I __________ (go) to the park with my friends. We __________ (play) for two hours, and then we __________ (have) a snack. After playing, we __________ (feel) very tired but happy.4.What do you do in the morning?A. SleepB. Eat dinnerC. Go to schoolD. Watch TV5.Which of these is used to drink water?A. KnifeB. ForkC. CupD. Plate6.Emily is getting ready for school. She puts her books in her __________ and wears her __________ to stay warm. Emily walks to school with her friend __________, and they talk about their favorite subjects. At school, they sit at their __________ and start the day with a math lesson.7.I like to __________ in the summer. The weather is always __________, and I can go __________ with my friends. We usually go to the __________ and swim in the__________. After swimming, we eat __________ and drink __________. In the evening, we often watch the __________ and have a __________. I enjoy summer because it is a __________ season.8.Which of these is a shape?A. FishB. SquareC. DogD. Ball9.Which of these is a type of food?A. AppleB. DogC. TableD. Chair10.Which one is used for sleeping?A. BedB. ChairC. PlateD. Spoon11.The children ______ (play) in the garden right now. They ______ (run) around and ______ (laugh) happily. Yesterday, they ______ (build) a treehouse in the backyard. I______ (think) it ______ (be) a great idea!12.What is the opposite of "hard"?A. SoftB. LightC. FastD. Tall13.Which of these is a color?A. AppleB. BlueC. CarD. Dog14.What do we wear to keep our hands warm in winter?A. SocksB. HatC. GlovesD. Shoes15.Jack is learning about the seasons. He knows that in __________ (1), the weather is cold, and it sometimes __________ (2). Jack loves to play outside in the __________ (3), where he can enjoy the warm sun. In __________ (4), the leaves on the trees turn orange and fall to the ground. Jack’s favorite season is __________ (5) because he loves to build snowmen and go ice skating.16.Which of these is a family member?A. MotherB. DogC. ChairD. Spoon17.I ______ (learn) a new song today. It ______ (be) very easy to sing. My teacher______ (teach) it to us, and we ______ (practice) it during class.18.I __________ (1) a new pet last week. It __________ (2) a small rabbit, and I__________ (3) her Rosie. I __________ (4) to take care of her every day.19.Which one is used for eating soup?A. SpoonB. KnifeC. PlateD. Fork20.I _______ (be) at the zoo last weekend. I _______ (see) many animals, including lions, elephants, and monkeys. The monkeys _______ (be) my favorite. They _______ (play) in the trees and _______ (make) funny noises. My sister _______ (take) many photos, and I _______ (buy) a souvenir. In the afternoon, we _______ (watch) a show where the zookeepers _______ (train) the dolphins. It _______ (be) a fun day at the zoo.21.Which one is used to brush teeth?A. ToothbrushB. KnifeC. SpoonD. Plate22.Which of these is a cold drink?A. Hot teaB. Cold waterC. SoupD. Hot chocolate23.Tom is at the zoo with his family. They are looking at the __________, which is playing with its baby. Tom also sees a __________, which is swinging from tree to tree. After visiting the animals, they stop at the zoo café for some __________. Tom’s little brother loves the __________, and they all share some while talking about their favorite animals.24.My best friend ______ (be) Amy. She ______ (have) a lot of hobbies. She ______ (like) painting and drawing pictures. She also ______ (enjoy) reading books about animals. Last weekend, we ______ (go) to the library together. I ______ (borrow) a book about dinosaurs, and Amy ______ (borrow) a book about wild animals. After the library, we ______ (go) to the park to play.25.I __________ (usually/play) basketball after school, but today I __________ (decide) to stay at home and __________ (read) a book. I __________ (read) about animals and it __________ (be) very interesting.26.Which one is a pet animal?A. DogB. LionC. ElephantD. Shark27.I always get up at 7:00 AM in the morning. Yesterday, I ______ (wake) up at 8:00 AM because I ______ (stay) up too late last night. I ______ (feel) very tired, so I ______ (skip) my breakfast. After that, I ______ (run) to school and ______ (arrive) just in time for the first lesson.28.Yesterday, I __________ (go) to the park with my friends. We __________ (play) football for an hour, and then we __________ (have) lunch at a nearby café. After lunch, we __________ (decide) to take a walk around the lake. I __________ (feel) very happy because the weather __________ (be) sunny and warm. Later, we __________ (see) some ducks swimming in the water. It __________ (be) a fun day.29.Which one is a holiday?A. SummerB. ChristmasC. OctoberD. Morning30.Which one is not a vegetable?A. TomatoB. LettuceC. CarrotD. Banana31.Which one is the opposite of "cold"?A. SmallB. HotC. HeavyD. Light32.How do you say "你好" in English?A. GoodbyeB. HelloC. PleaseD. Thank you33.What do we use to carry things?A. BagB. SpoonC. PlateD. Fork34.Tom and his friends are at the park. They are playing __________. Tom kicks the ball toward the __________, but it goes too far. His friend Mark runs to catch it. They are having a lot of __________ playing together. After a while, they all sit on the__________ to rest and drink some __________. It’s a sunny afternoon, and they a re enjoying their time outside.35.David is at the playground with his friends. He is playing on the __________ and swinging back and forth. After a while, he slides down the __________ and lands on the soft ground. His friend is playing on the __________ and spinning around. They are all having fun on the playground!36.I always ______ (take) a shower before going to bed. After I ______ (finish) my shower, I ______ (put) on my pajamas and ______ (brush) my teeth. Then, I ______ (read) a book or ______ (listen) to music before falling asleep. I ______ (feel) relaxed after my shower.37.Whats the opposite of "big"?A. SmallB. TallC. ShortD. Heavy38.What is the opposite of "hot"?A. WarmB. ColdC. CoolD. Wet39.Which of these is a mode of transportation?A. BusB. PlateC. SpoonD. Chair40.What is the color of a banana?A. GreenB. YellowC. RedD. Purple41.I __________ (have) a pet cat. Her name __________ (be) Mia. She __________ (like) to sleep on the couch, and she __________ (play) with her toys when she__________ (wake) up.42.Which one is used to write?A. ForkB. KnifeC. PenD. Plate43.What is the opposite of "new"?A. OldB. TallC. BigD. Short44.Anna ______ (study) for her English test right now. She ______ (use) her notebook to write down new words. Yesterday, she ______ (practice) speaking English with her classmates. She ______ (feel) confident because she ______ (study) hard.45.Which one is used to drink water?A. SpoonB. CupC. KnifeD. Fork46.What should you do if you see a car coming while you are crossing the street?A. Keep walking without looking.B. Stop and wait until the car has passed.C. Run across quickly.D. Jump onto the car.47.What do you use to eat a sandwich?A. SpoonB. KnifeC. ForkD. Hands48.Which one is a color?A. BlueB. TableC. ChairD. Book49.In the afternoon, we are going to the __ to play soccer. I will bring my __ and my friend is going to bring a __. We will play a game and try to score a __. After the game, we will go to the __ to rest and drink some water.50.I __________ (1) a letter to my cousin last weekend. I __________ (2) about my school life and the things I __________ (3) to do on the weekend. I __________ (4) to meet him soon.(答案及解释)。

第九章 社会影响

第九章 社会影响

Conformity

Why do people conform?


信息的影响Informational Influence

规范性的影响Normative Influence

渴望正确The Desire to Be Right
渴望被接受和喜欢The Desire to Be Liked
Conformity

但是,通过减少认知不协调,行为的改变会导致观 念的改变However, through dissonance reduction, a behavioral change can lead to a change in beliefs.

Underage students have been found to be less often abstinent and more often drinking to excess than students over the legal drinking age.

服从Obedience to Authority

从众Conformity

Changing one’s beliefs or behavior to be consistent with group standards

―Why doth one man’s yawning make another yawn?‖
Conformity
Personality effects loom larger when we note people’s differing reactions to the same situation, as when one person reacts with terror and another with delight to a roller coaster ride.

小学三年级下册U卷英语第四单元期中试卷(答案和解释)

小学三年级下册U卷英语第四单元期中试卷(答案和解释)

小学三年级下册英语第四单元期中试卷(答案和解释)英语试题一、综合题(本题有50小题,每小题2分,共100分.每小题不选、错误,均不给分)1.My family ______ (have) a big garden behind our house. We ______ (plant) flowers and vegetables there. Last weekend, we ______ (pick) some tomatoes from the garden, and they ______ (taste) really fresh. We ______ (water) the plants every day to help them grow.2.What do you use to clean the floor?A. BroomB. PlateC. KnifeD. Book3.This morning, I helped my mom clean the ______. First, I dusted the ______ and then I mopped the ______. My younger brother helped by putting away the ______. After we finished cleaning, we sat down and had some ______ for lunch.4.We __________ (1) a new playground in our neighborhood last month. It__________ (2) swings, slides, and a climbing frame. I __________ (3) to play on the swings, but my brother __________ (4) to climb the frame. After playing, we__________ (5) to the ice cream truck and __________ (6) some ice cream.5.What do we use to drink water?A. SpoonB. CupC. KnifeD. Plate6.Which of these is a color?A. GreenB. BananaC. TableD. Apple7.I _______ (read) a book when the phone _______ (ring). I _______ (answer) the phone and it _______ (be) my friend Jack. He _______ (ask) me if I _______ (want) to go to the park with him. I _______ (say) yes, and we _______ (go) together.8.What do you call the thing you use to write on paper?A. EraserB. PenC. BookD. Chair9.My sister ______ (like) to read books. She ______ (have) a lot of books at home. Yesterday, she ______ (buy) a new book from the bookstore. She ______ (read) it all afternoon. I ______ (ask) her what the book ______ (be) about, and she ______ (tell) me it ______ (be) a mystery story.10.Which of these is used to write on paper?A. KnifeB. ForkC. PenD. Plate11.My brother __________ (be) very good at drawing. He __________ (draw) pictures of animals and plants every day. Last night, he __________ (draw) a beautiful picture ofa bird, and I __________ (help) him color it.12.Which one is a famous landmark in Paris?A. Eiffel TowerB. Statue of LibertyC. PyramidsD. Colosseum13.What do you use to write on paper?A. BrushB. PenC. PhoneD. Knife14.What do you use to write?A. ForkB. SpoonC. PencilD. Plate15.We __________ (be) very tired after the long hike, but when we __________ (arrive) at the top of the mountain, the view __________ (be) amazing. We __________ (take) many pictures and __________ (stay) there for a while to enjoy the scenery.16.Ben is learning how to swim at the __________. His instructor shows him how to kick his __________ and move his __________. After practicing for a few weeks, Ben feels more confident and is ready to swim __________ in the pool.17.This morning, we ______ (have) a science lesson at school. Our teacher ______ (teach) us about the solar system. We ______ (learn) that the Earth ______ (orbit) the Sun and that there ______ (be) eight planets in our solar system. It ______ (be) a very interesting class.18.What is the plural form of "child"?A. childrensB. childesC. childrenD. childs19.I ______ (not like) math before, but now I ______ (enjoy) it. My teacher ______ (teach) us how to solve problems step by step. Last week, we ______ (learn) how to divide large numbers. I ______ (practice) every day, and now I ______ (be) much better at it.20.Tommy is in the kitchen. He is making __________ (1) with his mom. First, they mix the __________ (2) and __________ (3). Then they roll out the dough and cut it into __________ (4). After baking, they decorate the __________ (5) with colorful sprinkles.21.What do you call a baby cat?A. PuppyB. KittenC. CubD. Foal22.What do you do with a book?A. jumpB. readC. runD. swim23.Which of these is a food?A. AppleB. ChairC. BookD. Car24.Which of these is a shape?A. TriangleB. ChairC. CarD. Book25.My aunt __________ (live) in a big city, but she __________ (want) to move to the countryside. She __________ (like) the quiet atmosphere, and she __________ (prefer) fresh air and open space.26.Lily is at the zoo with her family. She sees many different animals, such as__________, __________, and __________. Her favorite animal is the __________ because it has long necks and eats leaves from tall trees. After visiting the animals, Lily and her family go to the __________ to buy some souvenirs. Lily buys a __________ asa reminder of the trip.st summer, we ______ (go) on a family trip to the beach. We ______ (stay) in a small hotel near the sea. Every morning, we ______ (swim) in the ocean, and in the afternoon, we ______ (build) sandcastles. It ______ (be) an unforgettable vacation. 28.Lucy is going to the beach with her family. They will bring a big __________ to sit on. Lucy loves to build __________ with her brother. They will also swim in the__________ and look for small __________. After the fun day at the beach, they will have a __________.29.Which one is a vegetable?A. AppleB. CarrotC. StrawberryD. Banana30.Which of these is a time of day?A. MorningB. SpoonC. PlateD. Chair31.Which of these is a body part?A. SpoonB. HandC. TableD. Chair32.I __________ (like) animals a lot. Last weekend, I __________ (go) to the zoo with my family. We __________ (see) many animals there, including elephants, lions, and monkeys. My sister __________ (take) pictures of the animals while I __________ (feed) the goats. It __________ (be) a fun day, and we __________ (have) a great time.33.We ______ (go) to the new shopping mall yesterday. It ______ (be) very big and modern. We ______ (buy) some clothes, and then we ______ (eat) lunch at a restaurant.34.Sarah is reading a book about animals. She learns that the __________ lives in the ocean and is very smart. She also reads about __________, which live in the forest and like to swing from trees. The book talks about the __________ animals need to survive, like food, water, and shelter. Sarah’s favorite animal is the __________ because it is cute and loves to eat bamboo.35.I ______ (play) basketball every Saturday. Last Saturday, I ______ (play) with my friends at the park. We ______ (have) a great time because the weather ______ (be) perfect for sports.36.Which one is a transportation vehicle?A. BusB. KnifeC. SpoonD. Plate37.Which of these is a mode of transportation?A. TableB. CarC. TreeD. House38.Which of the following animals live in water?A. ElephantB. DogC. FishD. Lion39.Which of these animals has four legs?A. BirdB. FishC. CatD. Butterfly40.Every morning, I __________ (wake) up at 7:00 a.m. and __________ (have) breakfast with my family. After breakfast, I __________ (go) to school. Yesterday, I__________ (arrive) late because I __________ (forget) to set my alarm.41.What does the word "cat" mean?A. A type of birdB. A kind of animalC. A kind of foodD. A kind of tree42.What is the opposite of hot?A. ColdB. WarmC. WetD. Dry43.Which one is the correct greeting?A. GoodbyeB. HelloC. Thank youD. Please44.Which of these is a part of your body?A. HandB. ChairC. TableD. Spoon45.Which one is a type of tree?A. RoseB. TulipC. OakD. Lily46.Which of these is a kind of tree?A. PineB. CarrotC. TomatoD. Banana47.My name is Lucy, and I __________ (be) a student. I __________ (study) in a small school. Every day, I __________ (get) up at 6:30 a.m. and __________ (have) breakfast at 7:00 a.m. After that, I __________ (go) to school by bus. I __________ (like) to study English and Math because they __________ (be) interesting. In the afternoon, I __________ (play) with my friends at school.48.I usually _______ (wake) up at 6:30 a.m., but today I _______ (sleep) until 7:00 because I _______ (stay) up late last night. I _______ (rush) to get ready for school, but I still _______ (arrive) on time.49.Which one is a fruit?A. PearB. CarrotC. PotatoD. Lettuce50.What color is the sun?A. BlackB. YellowC. GreenD. Blue(答案及解释)。

Java课件

Java课件

: String
A string object for "Welcome to Java"
s1
: String
Interned string object for "Welcome to Java"
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807
10
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807
animation
Trace Code
String s1 = "Welcome to Java"; String s2 = new String("Welcome to Java"); String s3 = "Welcome to Java";
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807
5
Strings Are Immutable
A String object is immutable; its contents cannot be changed. Does the following code change the contents of the string? String s = "Java"; s = "HTML";

java2D英文版9到11章读书笔记(英文版翻译)

java2D英文版9到11章读书笔记(英文版翻译)

第九章--图片1、java.awt.Image类的相关知识:a、java.awt.Image类是Java的图像的中心。

它代表了一个矩形的彩色像素。

图象的数据是不能直接访问。

在本质上,一个图片就是一个框图像数据。

b、如果图像可以使用,下面几种方法可以检索的图像的宽度和高度public abstract int getWidth(ImageObserver observer)此方法返回的图像的宽度,以像素为单位。

如果宽度是不可以使用的(因为尚未加载的图像数据),则返回-1。

所提供的ImageObserver 将成为可用的图像数据。

同时可以将ImageObserver参数设置为null。

public abstract int getHeight(ImageObserver observer)此方法返回的图像的高度,以像素为单位。

它的行为和getWidth ()相似。

2、java.awt.image.BufferedImage类的相关知识:a、java.awt.image.BufferedImage 类,允许直接访问的图像的数据。

BufferedImage中的一个非常好的事情是,它的图像数据总是立即访问。

这意味着你从来没有乱,当你周围的ImageObservers使用BufferedImage的。

如图像,缓冲图片的宽度和高度的方法,返回的图像。

但他们总是返回有效值。

b、java.awt.image.BufferedImage类提供的方法:public int getWidth()public int getHeight()这些方法返回此BufferedImage的宽度和高度。

public BufferedImage getSubimage(int x, int y, int w, int h)此方法返回一个由x,y ,w,和h 所定义的图像。

3、图像的加载:a、Applet中图像加载的两种方式:Applet可以使用两种方法在java.applet.Applet类的URL加载图像。

小学三年级上册第3次英语第6单元期末试卷(答案和解释)

小学三年级上册第3次英语第6单元期末试卷(答案和解释)

小学三年级上册英语第6单元期末试卷(答案和解释)英语试题一、综合题(本题有50小题,每小题2分,共100分.每小题不选、错误,均不给分)1.I ______ (have) a big family. I ______ (live) with my parents and my two younger brothers. We ______ (like) to go on trips together. Last year, we ______ (visit) the mountains. We ______ (take) many photos and ______ (enjoy) the beautiful scenery.2.I ______ (never) ______ (eat) sushi before, but my friend ______ (invite) me to try it. We ______ (go) to a Japanese restaurant last weekend. I ______ (enjoy) the sushi. The fish ______ (be) fresh, and the rice ______ (taste) delicious.st weekend, I went to the __________ with my family. It was a __________ day, and we had a lot of fun. My brother and I played __________ while my parents relaxed under a big __________. We brought a __________ with us that had sandwiches, apples, and drinks inside. After lunch, we went to the __________, where we saw some ducks swimming in the water. My sister loved watching them, and we took lots of __________. It was a __________ day, and I can’t wait to go again.4.Which one is a part of your body?A. FootB. ChairC. TableD. Book5.David loves to read books. His favorite books are about __________ and__________. He has a big collection at home. David’s dad takes him to the __________ every Saturday to borrow new books. This week, David borrowed a book about__________ and learned a lot of interesting facts. After reading, David likes to draw pictures of the __________ he has read about in his books.6.Which of these is a planet?A. SunB. MoonC. MarsD. Cloud7.Which of these is the opposite of "hot"?A. WarmB. ColdC. FastD. Slow8.Which of the following is a color?A. AppleB. CarC. RedD. Table9.What do we wear on our feet?A. ShoesB. ShirtC. HatD. Jacket10.Tom loves animals, and his favorite animal is the __________. Every summer, he goes to the zoo with his family to see the __________. He also enjoys watching the__________ swim in the pond. Tom always carries his __________ so he can take pictures of the animals. After visiting the zoo, he likes to buy a __________ as a souvenir.11.Mark and his friends are playing soccer. Mark passes the __________ to his friend, Tim. Tim tries to kick the __________ into the goal, but the goalkeeper catches it. After the game, they all feel __________ because they had fun.12.Which of these is a shape?A. catB. squareC. chairD. book13.Which of the following is a shape?A. appleB. chairC. circleD. table14.What do we use to write?A. KnifeB. PenC. SpoonD. Plate15.Which of these is a day of the week?A. AprilB. MondayC. WinterD. Night16.Which of these is a day of the week?A. MondayB. CarC. ChairD. Plate17.It ______ (be) a sunny day yesterday. I ______ (go) to the park with my family. My little brother ______ (play) with his toy car, and I ______ (fly) a kite. The wind ______ (be) very strong, so the kite ______ (go) very high in the sky. We ______ (stay) at the park for two hours, and then we ______ (go) home to have lunch.18.Which of these is used to play music?A. GuitarB. PlateC. ChairD. Car19.Which of these is a kind of animal?A. ElephantB. CarrotC. PotatoD. Spoon20.Which one is a type of transportation?A. BicycleB. SpoonC. TableD. Shoe21.We ______ (go) to the new shopping mall yesterday. It ______ (be) very big and modern. We ______ (buy) some clothes, and then we ______ (eat) lunch at a restaurant.22.Which one is used to eat soup?A. KnifeB. SpoonC. PlateD. Fork23.I __________ (study) English every afternoon. My teacher __________ (give) us new words to learn. Sometimes, we __________ (play) games in class, and we__________ (learn) more easily when we __________ (have) fun.24.At school, we __________ (study) many subjects. We __________ (learn) math, science, and English. My favorite subject __________ (be) math because I __________ (enjoy) solving problems. My friend Sarah __________ (like) English.25.Which one is a body part?A. EyeB. ShoeC. TableD. Car26.Every morning, Lily __________ (wake) up at 7:00 AM. She __________ (brush) her teeth, __________ (eat) breakfast, and __________ (get) dressed. Then, she__________ (take) the bus to school. In the afternoon, Lily __________ (come) home at 4:00 PM. After school, she __________ (do) her homework before going to the park with her friends. They __________ (play) basketball and __________ (have) a great time.27.You are at the zoo with your family. You see lions, tigers, and bears in large cages. You also see many monkeys playing in the trees. Where are you?A. In a parkB. In a zooC. At the beachD. In a museum28.Which of these is a tool for cleaning?A. BroomB. PlateC. SpoonD. Knife29.Which fruit is yellow?A. AppleB. BananaC. OrangeD. Cherry30.My father __________ (work) in an office. He __________ (start) work at 9:00 in the morning, and he __________ (finish) at 6:00 in the evening. After work, he__________ (come) home and we __________ (have) dinner together.31.What do you use to drink?A. SpoonB. KnifeC. PlateD. Cup32.What do you use to erase pencil marks?A. ScissorsB. EraserC. PaperD. Sharpener33.Which of these is a part of a tree?A. LeafB. TableC. CarD. Chair34.What do you use to eat rice?A. SpoonB. ForkC. KnifeD. Plate35.What do you use to write?A. PenB. PlateC. ForkD. Chair36.What do we use to drink?A. SpoonB. GlassC. PlateD. Knife37.Which of these is used to write on a board?A. MarkerB. SpoonC. ForkD. Plate38.Which of these is a shape?A. CircleB. BookC. TableD. Chair39.Which one is an animal?A. TableB. DogC. SpoonD. Cup40.Which of these animals has four legs?A. FishB. DogC. BirdD. Butterfly41.I __________ (1) to a new restaurant with my family last Saturday. The food__________ (2) very good. We __________ (3) a big pizza and __________ (4) some pasta. My little sister __________ (5) spaghetti, and I __________ (6) to try the lasagna. After the meal, we __________ (7) some ice cream.42.Which one is a shape?A. AppleB. CircleC. TableD. Tree43.What do we use to brush our teeth?A. ToothbrushB. SpoonC. PlateD. Knife44.Which of these is a type of transport?A. BookB. TrainC. TableD. Chair45.Emily and her friends are at the park. They are playing __________ (1) in the playground. Emily climbs the __________ (2) and slides down the __________ (3). Her friend, Lily, is swinging on the __________ (4). After playing, they sit under a__________ (5) tree and have some __________ (6).46.My mother is a teacher. She works at a school near our house. Every day, she teaches English to young students. She loves her job and helps her students learn new things. After school, we sometimes go to the library together.47.Which animal is known for its loud roar?A. DogB. ElephantC. LionD. Tiger48.Which one is a part of the body?A. BananaB. HeadC. CarD. Apple49.Which of these is used to eat spaghetti?A. KnifeB. ForkC. SpoonD. Plate50.What do we call the baby of a dog?A. KittenB. CalfC. PuppyD. Lamb(答案及解释)。

第9章 (13)教师用书配套课件

第9章 (13)教师用书配套课件

HTML5+CSS3网页设计基础教程
第9章 Workers多线程处理
第8页
9.1.4 WebWorkers的使用场合

在实际项目开发中,Web Workers API适用于如下一些 场合:
► 预先抓取并缓存一些数据以供后期使用。 ► 代码高粱处理或其他一些页面上的文字格式化处理。 ► 拼写检查。 ► 分析视频或音频数据。 ► 后台的输入输出操作。 ► 大数据量分析和计算操作。 ► canvas元素中的图像数据的运算和生成处理。 ► 本地数据库中数据的存取和计算问题。
第9章 Workers多线程处理
第12页
9.2.2 与线程进行数据的交互

Байду номын сангаас
后台线程不能直接访问页面或者窗口对象,但是 并不代表后台线程不能与页面之间进行数据交互。 可以通过postMessage方法将处理结果返回给页 面或窗口对象:
HTML5+CSS3网页设计基础教程
第9章 Workers多线程处理

HTML5+CSS3网页设计基础教程
第9章 Workers多线程处理
第3页
主要内容
9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 认识Web Workers 使用Web Workers 线程嵌套 线程中可用的变量、函数与类 SharedWorker 线程工作原理 综合实战 本章小结
第9章 Workers多线程处理
HTML5+CSS3网页设计基础教程
第2页
本章的学习目标
掌握Web Workers的基本知识。 掌握在前台页面与后台线程进行数据交互 时所使用到的方法和事件。 掌握在主线程之间嵌套子线程的方法。 了解在后台线程中可以使用JavaScript脚 本中的对象、方法和事件。 掌握SharedWorker的基本概念。

小学上册第1次英语第六单元全练全测

小学上册第1次英语第六单元全练全测

小学上册英语第六单元全练全测英语试题一、综合题(本题有100小题,每小题1分,共100分.每小题不选、错误,均不给分)1.The main gas produced during respiration is __________.2.What do we call the primary color that mixes with blue to create violet?A. RedB. YellowC. GreenD. OrangeA3.The bunny hops through the _____ tall grass.4.Coal is a type of ______ rock that is formed from ancient plants.5.What do you call the person who flies an airplane?A. PilotB. EngineerC. DriverD. SailorA6.Mars is often called the ______ planet.7.Which planet is known for its storms, including the Great Red Spot?A. EarthB. NeptuneC. JupiterD. Mars8.The ________ was a famous leader who united the Mongol tribes.9.How many legs does a butterfly have?A. FourB. FiveC. SixD. Eight10.He is learning to ___. (swim)11.What do you call a story about someone's life?A. NovelB. BiographyC. PoetryD. FictionB12.The __________ (历史传说) often blend fact and fiction.13.Which shape has three sides?A. SquareB. CircleC. TriangleD. RectangleC14.I like to help organize _______ (活动) at school. It’s a great way to meet new_______ (朋友).15. A mole is a unit that measures the amount of ______.16.The man has a funny ________.17. A __________ is a mammal that can fly.18.What is the main ingredient in salad dressing?A. OilB. VinegarC. WaterD. Milk19.The unit for measuring temperature in science is ______.20.What do you call a baby horse?A. CalfB. FoalC. KidD. LambB21.I have a strong bond with my ____.22. A crab walks sideways using its ______ (腿).23.What is the largest mammal in the ocean?A. SharkB. DolphinC. WhaleD. Octopus24.The _______ of light can create patterns when refracted.25.The process of converting liquid to solid is known as _______.26.The element with the symbol O is __________.27.The dolphin is very ______ (聪明) and friendly.28.What is the name of the longest bone in the human body?A. FemurB. TibiaC. FibulaD. HumorousA29.She has a _____ (dog/cat) in her bag.30.The _______ (蜥蜴) is often seen in warm climates.31.The cake tastes ________ (甜).32.What is the term for a bright streak of light that occurs when a meteoroid enters the Earth's atmosphere?A. MeteorB. Shooting StarC. FireballD. Comet33. A _____ (植物) can tell us about the environment it grows in.34._____ (orchids) are often found in tropical climates.35.I love to go ______ (滑沙) in the desert.36.The _______ (Glorious Revolution) occurred in England in 1688.37.I found a _____ (penny/dime) on the ground.38.The chemical symbol for barium is ______.39. A chemical reaction that produces a gas is called a ______ reaction.40.The _______ (The Great Society) aimed to reduce poverty and promote social welfare.41.The playground has many ______ (slides).42.What is the smallest unit of life?A. OrganB. TissueC. CellD. OrganismC43.The __________ (地质) of the area is fascinating.44.What do we call the time when the sun sets?A. SunriseB. SunsetC. DuskD. TwilightB45.Which of these is a type of pasta?A. RiceB. NoodlesC. BreadD. Cake46.What do we call the small pieces of paper we use to write notes?A. NotebookB. Sticky NotesC. Index CardsD. Post-it Notes47.What do we call a place where animals are kept and displayed?A. ZooB. AquariumC. ParkD. FarmA Zoo48.On weekends, I usually __________. Sometimes, I visit my grandparents who live in __________. They have a beautiful garden where I love to __________. My grandma often teaches me how to __________, and I find it very interesting.49.The monkey is very ______ (聪明) and likes to swing.50. A compound that can change color in different pH levels is called an ______.51.The ________ (气候变化) impacts agriculture.52. A _______ can be used to investigate the properties of light.53.What is the name of the hot drink made from beans?A. TeaB. CoffeeC. JuiceD. Milk54.__________ are known for their colorful plumage and ability to mimic sounds.55.What is the main purpose of a compass?A. To measure distanceB. To find directionC. To show timeD. To calculate speed56.The chemical formula for lithium hydroxide is __________.57.The __________ is often full of life in spring. (大自然)58.What is the main function of the heart?A. To filter bloodB. To pump bloodC. To digest foodD. To produce energyB59.What do you call the person who teaches in school?A. DoctorB. TeacherC. EngineerD. Chef60.Saturn's rings are believed to be remnants of a destroyed ______.61.I love to explore ________ (山脉) during vacations.62.The _____ (cat/dog) is playful.63.What do you call the person who teaches at school?A. DoctorB. EngineerC. TeacherD. FarmerC64.The parrot loves to sit on my _________ (肩膀).65.Creating a wildlife-friendly garden can support local ______ populations. (创建一个适合野生动物的花园可以支持当地的野生动物种群。

python核心编程第二版第9章习题答案

python核心编程第二版第9章习题答案

9–1. 文件过滤. 显示一个文件的所有行, 忽略以井号( # )开头的行. 这个字符被用做Python , Perl, Tcl, 等大多脚本文件的注释符号.附加题: 处理不是第一个字符开头的注释. 答案:f = open('test1.txt','r')for eachline in f:if eachline[0] == '#':continueelif '#' in eachline:loc = eachline.find('#')print eachline[:loc]else:print eachline,9–2. 文件访问. 提示输入数字N 和文件F, 然后显示文件F 的前N 行.答案:N = int(raw_input('Enter a number: '))f = raw_input('Enter filename :')f1 = open(f,'r')allline = f1.readlines()f1.close()for i in range(N):print allline[i],9–3. 文件信息. 提示输入一个文件名, 然后显示这个文本文件的总行数.答案:f = raw_input('Enter filename :')f1 = open(f,'r')sum = 0for i in f1:sum += 1print sumf = raw_input('Enter filename :')f1 = open(f,'r')sum = 0for i in f1:sum += 1print sum方法二:f = raw_input('Enter filename :')f1 = open(f,'r')allline = f1.readlines()f1.close()print len(allline)9–4. 文件访问. 写一个逐页显示文本文件的程序. 提示输入一个文件名, 每次显示文本文件的25 行, 暂停并向用户提示"按任意键继续.", 按键后继续执行.答案:f = raw_input('Enter filename :')f1 = open(f,'r')allline = f1.readlines()f1.close()sum = 0for i in allline:print i,sum += 1if sum == 25:a = raw_input("press any key to continue:")sum = 0方法二import osF=raw_input('pls input a file name:')n=0f=open(F,'r')for i in f:print i,n+=1if n==25:n=0os.system('pause')f.close()9-5 考试成绩,改进你的考试成绩问题(练习5-3和6-4),要求能从多个文件中读入考试成绩。

Slides removed from old version of chapter 99章幻灯片从

Slides removed from old version of chapter 99章幻灯片从
Slides removed from old version of chapter 9
Finalizers in Subclasses
When classes in your hierarchy declare their own finalize methods … A subclass finalize should invoke the superclass finalize as its last action
Constructors in Subclasses
When you instantiate a subclass object
– Subclass constructor invokes superclass constructor
Implicitly Explicitly with super ( ) reference
Example Test Program
// Fig. 9.17: ConstructorTest.java // Display order in which superclass and subclass constructor public class ConstructorTest { public static void main (String args []) { CommissionEmployee4 employee1 = new CommissionEmploye "Bob", "Lewis", "333-33-3333", 5000, .04); System.out.println (); BasePlusCommissionEmployee5 employee2 = new BasePlusCommissionEmployee5 ( "Lisa", "Jones", "555-55-5555", 2000, .06, 80 System.out.println (); BasePlusCommissionEmployee5 employee3 = new BasePlusCommissionEmployee5 ( "Mark", "Sands", "888-88-8888", 8000, .15, 20

python编程快速上手让繁琐工作自动化第二版第九章实践项目

python编程快速上手让繁琐工作自动化第二版第九章实践项目

python编程快速上手让繁琐工作自动化第二版第九章实践项目(实用版)目录一、Python 编程快速上手——让繁琐工作自动化第二版第九章实践项目概述二、实现文件读写功能的示例三、字符串操作实战技巧四、列表和元组操作实战技巧五、字典和结构化数据操作实战技巧六、函数和模块操作实战技巧七、实战项目:编写一个简单的文本编辑器八、总结正文一、Python 编程快速上手——让繁琐工作自动化第二版第九章实践项目概述本章主要介绍了如何利用 Python 编程实现文件读写功能,字符串操作实战技巧,以及列表、元组、字典和结构化数据操作实战技巧等内容。

通过这些示例,可以帮助读者更好地理解 Python 编程的基本概念和语法,并学会运用 Python 编写实际的应用程序。

二、实现文件读写功能的示例文件读写是 Python 编程中常见的操作之一。

Python 提供了丰富的文件读写函数,可以方便地实现文件的读取和写入。

下面是一个简单的文件读写示例:```python# 打开文件with open("example.txt", "r") as file:content = file.read()print(content)# 写入文件with open("example.txt", "w") as file:file.write("Hello, world!")```三、字符串操作实战技巧字符串是 Python 编程中经常使用的数据类型。

Python 提供了许多字符串操作函数,如字符串拼接、字符串截取、字符串替换等。

下面是一些常用的字符串操作技巧:```python# 字符串拼接str1 = "Hello"str2 = "world"result = str1 + " " + str2print(result)# 字符串截取str1 = "Hello, world!"result = str1[:5]print(result)# 字符串替换str1 = "Hello, world!"result = str1.replace("world", "Python")print(result)```四、列表和元组操作实战技巧列表和元组是 Python 编程中常用的数据类型。

chapter9

chapter9

查找23
位置

3 定 树 1 4 2
6 9 7 5 8
10 11
结论
成功的查找过程正好等 于走了一条从根结点到 被查找结点的路径,经 历的比较次数恰好是被 查找结点在二叉树中所 处的层次数 !
成功
平均查找长度
n h
第j层结点数的最大值
对于具有n个记录的排序连续顺序文件,若 查找概率相等,则有
1 ASL=∑ pici = n ∑ j×2j–1 = n+1 log2(n+1) –1 n j=1 i=1
件 索引 文件 散列 文件 序文 顺
四.文件的基本操作
查找
在文件中确定某个特定记录存在与否的过程。 结论: 查找成功,给出被查到记录的位置;
查找失败,给出相应的信息。 (1) 查找文件的第i个记录; (2) 查找当前位置的下一个记录; (3) 按关键字值查找记录。
插入 删除 修改 排序
以查找操作为基础
第九章
文件及查找
本章主要内容
9.1 9.2 9.3 9.4 9.5 文件的基本概念 顺序文件 索引文件 B-树和B+树 散列(Hash)文件
9.1 文件的基本概念 9.1 文件的基本概念
例1
花名册
学号 姓 名 性别 年龄 其 他
99001 99002 99003 … … … 99050
张 李 王 … … … 刘
字段、数据项
属性 :描述一个客体某一方面特征的数据信息。 属性 记录 :由若干属性值构成的属性的集合。 记录 文件 :具有相同性质的记录的集合。 文件 关键字 :区分不同记录的属性或属性组。 关键字
二.文件的逻辑结构
记录呈现在用户眼前的排列的先后次序关系。
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

= =
−2x1(k) + u(k) −3x2 (k) + u(k)
slide 18
由Z传递函数求状态方程
[例9.3] 设Z传递函数为
G(z)
=
Y (z) U (z)
=
(z
1 + 1)2 ( z
+
2)
试用
并行法求状态方程和输出方程。
【解】:将G(z)表示成极点形式
G(z) = Y (z) = 1 + 1 − 1 U ( z ) z + 2 ( z + 1)2 z + 1
⎪⎩ zx3 ( z) = − x3 ( z) + U ( z)
对应的状态方程为
由于
⎡ x1(k +1) ⎤ ⎡−2 0 0 ⎤ ⎡ x1(k)⎤ ⎡1⎤
⎢ ⎢
x2
(k
+ 1) ⎥⎥
=
⎢ ⎢
0
−1
1
⎥ ⎥
⎢ ⎢
x2
(k
)⎥⎥
+
⎢⎢0⎥⎥
u(k
)
⎢⎣ x3(k +1)⎥⎦ ⎢⎣ 0 0 −1⎥⎦ ⎢⎣ x3(k)⎥⎦ ⎢⎣1⎥⎦
9.2 离散系统状态空间设计
9.2.1 极点配置 9.2.2 状态观测器
slide 7
线性离散系统状态方程
¾ 差分方程或脉冲传递函数--离散时间系统输入/输出特 性的描述;
¾ 如何根据系统的差分方程和Z传递函数描述得到它的基 于输入-状态-输出的状态空间描述?
slide 6
由高阶差分方程求离散状态方程
9.2 离散系统状态空间设计
9.2.1 极点配置 9.2.2 状态观测器
slide 3
第九章 计算机控制系统现代设计方法
-基于状态空间的分析与设计-
slide 2
计算机控制系统经典设计方法 回顾
模拟化设计方法 离散化设计方法
slide 4
经典控制和现代控制的区别何在
研究对象 数学模型 数学基础
⎧ x(k + 1) = A(k ) x(k ) + B (k )u (k )
⎨ ⎩
y(k
)
=
C
(k
)
x(k
)
+
D
(k
)u (k
)
slide 14
由Z传递函数求状态方程
设离散系统的Z传递函数的一般形式为
G(z)
=
Y (z) U (z)
=
b0 z m + b1 z m −1 + L + bm −1 z + bm z n + a1 z n −1 + L + an−1 z + an
U (z) 2
+
(z
1 + 1)2
U (z)

1 U(z) z +1
选取的状态变量为
⎧ ⎪
x1
(
z
)

=
z
1 U (z) +2
⎪ ⎨
x2
(
z
)

=
1 z + 1 x3 ( z)
⎪ ⎪⎩
x3
(
z
)
=
1 U (z) z +1
slide 21
由Z传递函数求状态方程
2.串行程序法
串行程序法也叫迭代程序法,当G(z)的零极点都已知时,
x1(k +1) x2 (k +1)
⎪ ⎪
M
⎪⎩xn (k) = y(k + n −1) = xn−1(k +1)
则可得到离散状态方程和输出方程分别为
⎧x1(k +1) = x2 (k)
⎪ ⎪⎪
x2

(k
+ 1) M
=
x3
(k)
⎪ ⎪
xn−1
(k
+ 1)
=
xn
(k)
⎪⎩xn (k +1) = −an x1(k) −L − a1xn (k) + bu(k)
z+2
z+3
则对应的方块图如图9.1所示。
slide 17
由Z传递函数求状态方程
对应的状态方程为
⎡ ⎢ ⎣
x1 ( k x2 (k
+ 1) ⎤ + 1)⎥⎦
=
⎡−2 ⎢⎣ 0
0⎤ −3⎥⎦
⎡ ⎢ ⎣
x1 x2
(k (k
) )
⎤ ⎥ ⎦
+
⎡1⎤ ⎢⎣1⎥⎦
u
(k
)
系数矩阵A的对角线上的两个元素即为G(z)的两个极点。
式中x(k)是n维状态向量,A、B、C 分别为n×n、n×1、 1×n系数矩阵。表示为
⎡0
⎡ x1(k) ⎤
x(k
)
=
⎢ ⎢
x2
(k
)⎥⎥
⎢M⎥
⎢ ⎣
xn
(k
)⎥⎦
,
⎢ ⎢
0
A=⎢ M
⎢ ⎢
0
⎢⎣−an
1 0 M 0 −an−1
L 0⎤
L
0
⎥ ⎥
L M⎥
L
1
⎥ ⎥
L −a1 ⎥⎦
⎡0⎤
B
=
⎢ ⎢
M
⎥ ⎥
当m=0时,差分方程的形式为:
y (k + n) + a1 y (k + n − 1) + L + an y (k ) = bu (k )
slide 8
由高阶差分方程求离散状态方程
若选取状态变量为
⎧x1(k) = y(k)
⎪ ⎪⎪ ⎨
x2 x3
(k (k
) )
= =
y(k y(k
+1) = + 2) =

⎧ x(k +ຫໍສະໝຸດ 1) = Ax(k ) + Bu (k )
⎨ ⎩
y(k
)
=
Cx(k
)
y(k) = x1(k)
slide 9
由高阶差分方程求离散状态方程
【解】:由已知条件知a1=5,a2=3,a3=6,b=2,得到状 态方程和输出方程分别为
⎡ x1(k +1) ⎤ ⎡ 0 1 0 ⎤ ⎡ x1(k) ⎤ ⎡0⎤
=
Y (z) U (z)
=
z2 z2
+ 2z +1 + 5z + 6
试用并行法
【解】:将G(z)表示成极点形式
G(z) = Y (z) = z2 + 2z +1 = 1+ 1 − 4
U (z) z2 + 5z + 6
z+2 z+3
于是,得到 Y ( z ) = U ( z ) + 1 U ( z ) − 4 U ( z )
⎢0⎥
, C = [1
0
L
0]
⎢⎣b⎥⎦
[例9.1] 设线性定常差分方程为
y(k + 3) + 5 y(k + 2) + 3 y(k + 1) + 6 y(k ) = 2u (k )
试写出状态方程和输出方程。
slide 10
由高阶差分方程求离散状态方程
【情况2】 差分方程包含输入函数的高阶差分项
当m=n(也适用于m<n)时,差分方程的形式为
式中n≥m,ai,bj为常系数。
1.并行程序法
也称为部分分式法,当Z传递函数G(z)的极点已知 时,将G(z)表示成部分分式和的形式,用这种方法比较 简便。下面分单极点和重极点两种情况,分别举例说明 这种方法求状态方程和输出方程。
slide 16
由Z传递函数求状态方程
[例9.2] 设Z传递函数为 G ( z) 求状态方程和输出方程。
由于
Y (z)
= U (z) +
z
1 +
U (z) − 2
z
4 U (z) +3
=
x1 ( z ) −
4x2 (z) + U (z)
则有 y (k ) = x1 (k ) − 4 x2 (k ) + u (k )
于是得到输出方程为
y(k) = [1
-
4]
⎡ ⎢ ⎣
x1 x2
(k ) ⎤ (k ) ⎥⎦
9.2 离散系统状态空间设计
9.2.1 极点配置 9.2.2 状态观测器
slide 15
由高阶差分方程求离散状态方程
以上针对线性定常差分方程介绍了状态方程的列写方法, 由于状态变量的选择不是惟一的,因此状态方程也不是惟 一的;
对于线性时变差分方程也可以用上述类似的方法写出状态方 程,且可以得到形式上与时不变状态方程相同的时变状态方 程 , 只 是 由 于 时 变 差 分 方 程 的 系 数 ai,bj(i=1,2,…,n; j=0,1,…,m)都是k的函数,即ai(k),bj(k),因此,系数矩阵 A,B,C,D 也 都 是 k 的 函 数 , 即 A(k),B(k),C(k),D(k)。 于是,对于线性时变差分方程所对应的状态方程和输出方程 的一般形式为:
于是,得到
Y (z) =
1 U (z) + z+2
(
z
1 + 1)2
U
(
z
)

1 U (z) z +1
则对应的方块图如图9.2所示。
slide 20
相关文档
最新文档