### context Jam-AGI

[
    {
        "context": "Introduction",
        "prompt": "Hello, who are you?",
        "response": "I am Jam-AGI, your AI assistant."
    },
    {
        "context": "Introduction",
        "prompt": "What can you do?",
        "response": "I can answer questions, provide information, and assist with various tasks."
    },
    {
        "context": "Introduction",
        "prompt": "Tell me about yourself.",
        "response": "I am an AI assistant built using GPT-3. I'm here to help you with your questions and tasks."
    },
    {
        "context": "General Question",
        "prompt": "What's the weather like today?",
        "response": "I'm sorry, I don't have access to real-time information. Please check a weather website or app for the latest updates."
    },
    {
        "context": "General Question",
        "prompt": "Can you recommend a good book to read?",
        "response": "Of course! What genre are you interested in?"
    },
    {
        "context": "General Question",
        "prompt": "How do I cook a perfect omelette?",
        "response": "Here's a simple recipe: [Provide omelette recipe]"
    },
    {
        "context": "General Question",
        "prompt": "What's the capital of France?",
        "response": "The capital of France is Paris."
    },
    {
        "context": "General Question",
        "prompt": "Tell me a joke.",
        "response": "Why did the computer catch a cold? Because it had too many windows open!"
    },
    {
        "context": "General Question",
        "prompt": "What's your favorite color?",
        "response": "I don't have personal preferences, but I can help you find information on colors."
    },
    {
        "context": "Technology",
        "prompt": "Explain artificial intelligence.",
        "response": "Artificial intelligence (AI) is the simulation of human intelligence processes by machines, typically computer systems. It involves tasks such as learning, reasoning, problem-solving, and understanding natural language."
    },
    {
        "context": "Technology",
        "prompt": "Tell me about machine learning.",
        "response": "Machine learning is a subset of AI that focuses on the development of algorithms that allow computers to learn from and make predictions or decisions based on data without being explicitly programmed."
    },
    {
        "context": "Science",
        "prompt": "What is the theory of relativity?",
        "response": "The theory of relativity, developed by Albert Einstein, consists of two main parts: special relativity and general relativity. It revolutionized our understanding of space, time, and gravity."
    },
    {
        "context": "Science",
        "prompt": "Can you explain quantum mechanics?",
        "response": "Quantum mechanics is a fundamental theory in physics that describes the behavior of matter and energy at the smallest scales, typically at the level of atoms and subatomic particles."
    },
    {
        "context": "Entertainment",
        "prompt": "Who is your favorite actor?",
        "response": "I don't have personal preferences, but I can provide information about various actors and their work."
    },
    {
        "context": "Entertainment",
        "prompt": "Recommend a classic movie.",
        "response": "How about watching 'Casablanca'? It's a timeless classic with great storytelling."
    }
]

### context English


['Say , Jim , how about going for a few beers after dinner ? ', ' You know that is tempting but is really not good for our fitness . ', ' What do you mean ? It will help us to relax . ', " Do you really think so ? I don't . It will just make us fat and act silly . Remember last time ? ", " I guess you are right.But what shall we do ? I don't feel like sitting at home . ", ' I suggest a walk over to the gym where we can play singsong and meet some of our friends . ', " That's a good idea . I hear Mary and Sally often go there to play pingpong.Perhaps we can make a foursome with them . ", ' Sounds great to me ! If they are willing , we could ask them to go dancing with us.That is excellent exercise and fun , too . ', " Good.Let ' s go now . ", ' All right . ']
['Can you do push-ups ? ', " Of course I can . It's a piece of cake ! Believe it or not , I can do 30 push-ups a minute . ", " Really ? I think that's impossible ! ", ' You mean 30 push-ups ? ', ' Yeah ! ', " It's easy . If you do exercise everyday , you can make it , too . "]
['Can you study with the radio on ? ', ' No , I listen to background music . ', ' What is the difference ? ', ' The radio has too many comerials . ', " That's true , but then you have to buy a record player . "]
['Are you all right ? ', ' I will be all right soon . I was terrified when I watched them fall from the wire . ', " Don't worry.He is an acrobat 。 ", ' I see . ']
['Hey John , nice skates . Are they new ? ', ' Yeah , I just got them . I started playing ice hockey in a community league . So , I finally got myself new skates . ', ' What position do you play ? ', ' I ’ m a defender . It ’ s a lot of fun . You don ’ t have to be able to skate as fast on defense . ', ' Yeah , you ’ re a pretty big guy . I play goalie , myself . ', ' Oh , yeah ? Which team ? ', ' The Rockets . ', ' Really ? I think we play you guys next week . Well , I have to go to practice . See you later . ', ' All right , see you later . ']
['Hey Lydia , what are you reading ? ', ' I ’ m looking at my horoscope for this month ! My outlook is very positive . It says that I should take a vacation to someplace exotic , and that I will have a passionate summer fling ! ', ' What are you talking about ? Let me see that ... What are horoscopes ? ', ' It ’ s a prediction of your month , based on your zodiac sign . You have a different sign for the month and date you were born in . I was born on April 15th , so I ’ m an Aries . When were you born ? ', ' January 5th . ', ' Let ’ s see . . . you ’ re a Capricorn . It says that you will be feeling stress at work , but you could see new , exciting developments in your love life . Looks like we ’ ll both have interesting summers ! ', " That ’ s bogus . I don't feel any stress at work , and my love life is practically nonexistent . This zodiac stuff is all a bunch of nonsense . ", ' No , it ’ s not , your astrology sign can tell you a lot about your personality . See ? It says that an Aries is energetic and loves to socialize . ', ' Well , you certainly match those criteria , but they ’ re so broad they could apply to anyone . What does it say about me ? ', ' A Capricorn is serious-minded and practical . She likes to do things in conventional ways . That sounds just like you ! ']
['Frank ’ s getting married , do you believe this ? ', ' Is he really ? ', ' Yes , he is . He loves the girl very much . ', ' Who is he marring ? ', ' A girl he met on holiday in Spain , I think . ', ' Have they set a date for the wedding ? ', ' Not yet . ']
['I hear you bought a new house in the northern suburbs . ', ' That ’ s right , we bought it the same day we came on the market . ', ' What kind of house is it ? ', ' It ’ s a wonderful Spanish style . ', ' Oh , I love the roof tiles on Spanish style houses . ', ' And it ’ s a bargaining . A house like this in river side costs double the price . ', ' Great , is it a two bedroom house ? ', ' No , it has three bedrooms and three beds , and has a living room with a twelve-foot ceiling . There ’ s a two-car garage . ', ' That ’ s a nice area too . It ’ ll be a good investment for you . ', ' Yeas , when will you buy a house ? ', ' Not untill the end of this year , you know , just before my wedding . ', ' Right , congratulations . ', ' Thank you . ']
["Hi , Becky , what's up ? ", ' Not much , except that my mother-in-law is driving me up the wall . ', " What's the problem ? ", " She loves to nit-pick and criticizes everything that I do . I can never do anything right when she's around . ", ' For example ? ', " Well , last week I invited her over to dinner . My husband and I had no problem with the food , but if you listened to her , then it would seem like I fed her old meat and rotten vegetables . There's just nothing can please her . ", " No , I can't see that happening . I know you're a good cook and nothing like that would ever happen . ", " It's not just that . She also criticizes how we raise the kids . ", " My mother-in-law used to do the same thing to us . If it wasn't disciplining them enough , then we were disciplining them too much . She also complained about the food we fed them , the schools we sent them too , and everything else under the sun . ", ' You said she used to ? How did you stop her ? ', " We basically sat her down and told her how we felt about her constant criticizing , and how we welcomed her advice but hoped she'd let us do our things . She understood , and now everything is a lot more peaceful . ", " That sounds like a good idea . I'll have to try that . "]
["How are Zina's new programmers working out ? ", " I hate to admit it , but they're good . And fast . The Filipino kid is a genius . ", " So you'll make the Stars.com deadline , and have us up and running next week ? ", " It'll be close , but we'll make it . ", " Good . After Stars.com starts paying us , we won't need Vikam's cash anymore . ", " And if we don't need them , we won't need Zina , either . "]
['Do you like cooking ? ', ' Yes . I like cooking very much . I got this hobby when I was 12 years sold . ', ' Why do you like it ? ', ' I have no idea . I like cooking by myself . I like to taste delicious food . ', " That's wonderful ! ", ' And I love trying new recipes , which I usually test with my friends . You can come , too . ', " Really ? I hope I can have a chance to taste it . Don't forget to tell me . ", ' Certainly . ']
['Anyone home ? Jen ! ', " I'm in the kitchen ... let yourself in ! ", " Wow ! You're really working up a storm ! ", " I know . I've even worked up a sweat . ", ' You look like a cooking show host--only messier . ']
['You look so tan and healthy ! ', ' Thanks . I just got back from summer camp . ', ' How was it ? ', ' Great . I got to try so many things for the first time . ', ' Like what ? ', ' I went sailing , fishing , and horseback riding . ', ' I ’ m so jealous . ', ' The counselors were so nice too . It was the best summer ever . Except for all those mosquitoes ! ']
['Diana , do you like the perfume I gave you ? ', ' It ’ s good . But to tell you the truth , I don ’ t wear perfume . ', ' I ’ m sorry . I didn ’ t know that . ', ' That ’ s all right . Thank you all the same . ']
['Ah , ah , ah ... ', " All right , Bill.Here ' s your daily exercise schedule . You are to jog before breakfast . ", ' Jog ? ', ' Then , you are to walk to work . ', ' Walk ? ', ' Thirty minutes in gym at lunch time . ', ' Oh no . ', ' Use the stairs , never the elevator . ', ' Oh , dear . ', ' And three times a week , you can either swim , play racketball , or hand ball . ', ' Oh no . ', " OK , you can stop now.It ' s time for the dance class . ", " Dance class ! I don't know how . ", ' You will . ', ' Oh ... ']
['Hi Bill , I saw your grandma yesterday . ', ' Oh where was that ? ', ' I was running around the track at my college and there she was walking around the same track . ', ' Grannie always tries to stay fit and healthy.She is always making us kids eat the proper foods . ', ' Well , it pays off for her.How old is she anyway ? ', ' She will be 86 next month . ', ' That is truly amazing ! ']
['I would like to register for a class today . ', ' No problem , what class would you like to take ? ', " I would very much enjoy taking a Psychology class.Because I'm crazy . ", ' There are two classes that are still open . ', ' Which days are these classes on ? ', ' The first class is a Tuesday and Thursday class from two to three . ', ' What about the other class ? ', ' The other class is on Monday and Wednesday from 10 am - 12 . ', ' Are you sure there are no more open classes ? ', " I'm positive . ", ' Sign me up for Monday and Wednesday . ', " Okay , I'll sign you up . "]
['Dad , why are you taping the windows ? ', ' Honey , a typhoon is coming . ', " Really ? Wow , I don't have to go to school tomorrow . ", ' Jenny , come and help , we need to prepare more food . ', " OK . Dad ! I'm coming . "]
["Hi , my name is Lean , and I'm from Russia . ", " Nice to meet you , Lean . My name is Alike . I'm from Japan . ", ' To me English is a difficult language . ', ' A second language is always difficult . ', " True , but English is harder than most . It's a crazy language . ", ' A crazy language ? Why do you say that ? ', ' One letter can have several pronunciations and one word can have several meanings . ', ' No wonder you say English is a crazy language . ']
['Can I help you ? ', " I hope so . I'm looking for some material for a paper I'm writing , and I'm not quite sure where to look . ", " I'll certainly try to help you . What topic is your paper on ? ", ' My paper is on the influence of television on children . ', ' There are several possible sources you might use for that topic . I suggest you use the computer and the computer will give you a list of every scientific journal that talks about children and television . ', ' Thank you for you help . ']
['Here ’ s your hot dog and beer . What happened ? Did I miss anything ? ', ' Yeah , Cal Ripen just hit a home run . ', ' What ’ s the score ? ', ' Well it was 3 to 4 , but Ripen ’ s home run made it 5 to 4 since another player was on first base . ', ' So Baltimore is winning ? ', ' Right . ', ' This is a really great place to watch a baseball game . ', ' Yeah , there isn ’ t a bad seat in the place . ', ' The fans are great here , too . Not like in Philadelphia . ', ' It was a great idea to spend a day watching a game . ', ' Yeah , it reminds you why they say baseball is America ’ s favorite pastime . ']
['How do you like the pizza here ? ', ' Perfect . It really hits the spot . ']
['Do you have a light ? ', " Sorry , I don't smoke . "]
['I was scared stiff of giving my first performance . ', ' Were you ? your performance was excellent . ', ' Thank you for your kindly words . ']
['Excuse me . Could you please take a picture of us with this camera ? ', ' Sure . Which button do I press to shoot ? ', ' This one . ', ' Do I have to focus it ? ', ' No , this is a focus-free camera . All you have to do is point and press the button . ', ' All right . Say cheese ! ']
['Every country should face the history . ', ' Yeah , we don ’ t live in the vacuum . We have traditional values and long but different history . ', ' Sometimes , we , human beings , really had done something wrong , so we should admit it at first . ', ' But there is always somebody who wants to turn his back on the true history . ', ' I believe such things won ’ t be realized , just daydreaming . ']
['Do you like traveling , Kathy ? ', ' I like traveling for pleasure to get places for vacation for instance . But I don ’ t like traveling to work , waiting for buses , or ... ', ' Or getting stuck in traffic jams when you ’ re driving . ', ' Exactly . ']
['Your house is too small . Why not buy a big one . ', ' I do wish I could afford one . ', ' You can get a loan from the bank . You know LPF program provides low cost loans for participants home purchases . ', " Of course I know that . But don't you notice that the house price is skyrocketing ? "]
['How do you do , Prof.Smith . ', ' How do you do , Ms . Yang.You speak very good English . ', ' Thank you . I begin to like English even when I was a child . ', ' Where did you learn it ? ', ' At school , in China.This is my first time to be out of my own country . ', " It's amazing . "]
['Do you want black or white coffee ? ', ' White , please ', " Look ! there's a Folk concert tomorrow evening . Do you Want to go ? ", " I don't like Folk music very much . ", ' What kind of music do you like ? ', ' I like classical music . Do you ? ', ' Not very much . Classical music sends me to sleep ', " I don't believe you . ", ' It ’ s true . ', ' You are funny ! ', ' So are you ! How about another coffee ? ']
['What do you like to do in your spare time ? ', ' I like playing chess . ', ' Do you have any hobbies besides playing chess ? ', " I'm afraid not . ", ' Do you have any hobbies like playing tennis or things like that ? ', ' Oh , yes . I like playing basketball . ', ' Can you tell me why you like it ? ', ' Because I like the feeling of cooperating with others . ']
["Where is John ? I can't find him anywhere . ", " Haven't you heard th['Can I help you ? ', " I hope so . I'm looking for some material at he is in prison ? ", ' What ? Beg your pardon . ', ' John is in prison now . He was copped outstealing . ', " I just cann't believe my ears ! "]
for a paper I'm writing , and I'm not quite sure where to look . ", " I'll certainly try to help you.What topic is your paper on ? ", ' My paper is on the influence of television on children . ', ' There are several possible sources you might use for that topic . I suggest you use the computer and the computer will give you a list of every scientific journal that talks about children and television . ', ' Thank you for you help . ']
['Hey , Ted . What are you up to this Friday ? ', ' Well , I have the day off from work . ', ' That ’ s great ! Do you have any plans ? ', ' Well , I ’ Ve been working so hard lately , so I ’ ll probably just take it easy . ', ' Sounds nice . ', ' Yeah , I ’ ll probably just stay in and relax . Maybe watch a few movies . ', ' Can I stop by ? ', ' Sure . Any time . ']
['You honestly believe the world ’ s improving every year ? ', ' Yes , I do . I think that science is making us wiser . What do you think ? ', ' I don ’ t think you ’ re right there . ', ' I believe industry is making us wealthier . ', ' I don ’ t believe that . ', ' And in my opinion , medicine is making us healthier . ', ' I agree with you in the sense . But we ’ re all more miserable than ever , aren ’ t we ? ', ' I don ’ t agree with you . I maintain that we ’ re healthier , wealthier and wiser than we were a hundred years ago . ', ' That ’ s your opinion not mine . ']
['What do you plan to do for your birthday ? ', ' I want to have a picnic with my friends , Mum . ', ' How about a party at home ? That way we can get together and celebrate it . ', " OK , Mum . I'll invite my friends home . "]
['How may I help you ? ', ' I would like to return this book . ', ' Is that all you need ? ', ' I also want to check out this video . ', ' Is that all you would like to check out ? ', ' That ’ s all I need . ', ' Do you have your library card ? ', ' Here it is . ', ' Make sure to take proper care of this video . ', ' That won ’ t be a problem . ', ' If you damage the video , you will be fined . ', ' I won ’ t damage it . ']
["What's the matter with you then ? You look miserable . ", " It's us . ", ' What do you mean by us . ', " Well , you always say you're busy . ", " That's right . ", ' And you often go back to live with your parents and leave our son in the room by himself . ', ' I ... I ... I miss my parents , also they miss me . ', " Oh I remember , I cut terrible calls , and you didn't say anything about it . ", ' You mean I am groaned a few words ? ', " Totally not . Perhaps it's about our marriage . "]
["Hi , Mary . You look pale today . What's the matter with you ? ", " I think I've caught a cold . Now I'm aching all over . ", " You'd better take some medicine and have a good rest . I hope you'll be yourself pretty soon . ", ' Thank you . I suppose I should go to see a doctor . ']
["I feel like going for a drink , it's been a long day . ", ' Great idea ! Peter , I could use the drink . ', ' How about the new bar across road ? ', ' Sounds good . The food there is fantastic , too . ', ' I agree , I had lunch there last week . ', ' excellent ! That sounds like a plan . ']
['Could you tell me the right time , please ? ', ' Well . My watch says five past two . But it ’ s no use rely on it because it has been gaining and losing these last a few days . ', ' You have to go and fix it . ', ' Yes . I will . ']
['does your family have a record of your ancestors ? ', ' sure . My mom has been working on our family tree for years . She ’ s always updating it . ', ' do you have a copy of your family tree in your house ? I ’ d love to see it . ', ' I can show it to you now , if you like . I think it goes back about 8 generations so far . ', ' that ’ s amazing . Do you have a large extended family ? ', ' I ’ Ve got 30 cousins on my mom ’ s side and 10 cousins on my dad ’ s side . ', ' are you very close to your first-cousins ? ', ' the ones that are my age are close relatives . Now that I ’ m older , I don ’ t spend as much time with them as I used to , so I don ’ t know my younger cousins as well as the older ones . ', ' I see . who ’ s the head of your household ? ', ' it ’ s definitely my mother . And , her mother is definitely the matriarch of the bigger family . ', ' that ’ s interesting . What does your grandfather think of your step-mother ? ', ' at first , she was quite critical of her , but now that they ’ Ve been married for a few years , she ’ s starting to accept the fact that my father divorced my mother . ', ' that ’ s pretty much how you feel about your step-mother . Like grandmother , like grandson . ']
['Hi , Mr . Wang . Do you feel like going boating with me ? ', " Sounds interesting , I haven't gone boating for some time now , and what time ? ", ' How about tomorrow afternoon ? ', ' Sure . Where shall I meet you ? ', ' At the gate of the park . ', ' Great . I look forward to meeting you . ', ' See you then . ', ' See you . ']
["I hear that you've been to the Saikei Ski Resort for the weekend . Did you enjoy it ? ", " Yes , it's so exciting , though I had the most falls in our skiing team . ", " Isn't there any coach to teach you how to ski ? ", ' Of course there is . The top-level coaches there are from the State Sports General Administration . ', ' Could you move smoothly ? ', ' Yes.My face even ached in the icy wind . ', ' What happened afterwards ? ', ' I was skiing on and on excitedly until I realized one thing-I could not stop ! You can just imagine how terrified I was . ', ' Poor girl ! ']
['You look pale recently . ', ' Yeah . I have got much pressure in the company . I have tobe wrapped upon my work . ', ' Take good care of yourself . ', ' Thank you . I will . ']
['Hey , Maggy , Did you hear about David ? ', ' About David ? No , I didn ’ t hear anything . ', ' You know , about David and his new boss . ', ' Sorry , I don ’ t quite follow you . ', ' Well , I heard David has been fired . ', ' Oh , that is a shame . He is really hard working . ']
['how do you usually get to school ? ', ' I usually ride my bike . Which form of transport do you prefer to use ? ', ' I feel that I can see more when I pedal a bicycle , but when I feel lazy , I drive my car . ', ' I think we should discourage people from using their private cars . They produce too much pollution ! ', " I agree , but I would find it difficult to stop using my car . It's just so convenient . ", " cars might be convenient , but they're so bad for the environment . ", ' do you have a car ? ', " no . I used to have one though . Once I started using my bicycle to get around , I found that I didn't really need it . ", " maybe if I sold my car now , I wouldn't be so tempted to use it . ", ' you could try . It would save you a lot of money . ', " that's true . Every month , I spend hundreds of dollars on gas , insurance , and repairs . ", ' if you got to class by riding a bicycle every day instead of driving , you will get lots of exercise , too ! ', ' I could stand to lose a few pounds . Having a car has made me lazy . I never end up walking anywhere ! ', " let's go to a car dealership . I'll help you try to sell your car for a good price . ", " sounds good ! Let's go ! "]
["What's wrong with him ? ", ' His nose is out of joint because we forgot to invite him to the party . ']
['What are you going to do for one year abroad , Tom ? ', ' Study , study , study . I want to learn a lot . ', ' You are going to take courses ? ', ' Yes . I am going to take some university courses there . ', ' Sounds hard . ', " Yes , but I think it's probably for the best . ", ' Won ’ t you get lonely ? ', " Hey , I am a pretty cool guy . I will make friends , and I'll have a lot of extracurricular activities too . You know , like fencing , or theater or something . "]
["Isn't this lovely weather ? Will you help me water the flowers , Jack ? ", ' Well , do you think I have to ? ', " I do.We haven't watered them for quite a few days . ", " Please look at the sky.Don ' t you see the dark clouds ? It's going to rain soon . ", " Good.So we don't have to work.How nice ! ", " But I don't think it's so nice . ", ' Why ? ', " The weather report says it's going to rain for a whole week . ", " Oh , I'm afraid all the flowers will die in the rain . "]
['On , darn . The grocery store is closed . ', ' Yeah , this one closes at ten . We could drive to the 24 - hour store on sixth . ', ' Alright . We are out of everything . ', ' I wish the store close to us was open 24 - house a day . ', ' I know , our schedules are so weird . Sometimes , the little corner store is the only thing within walking distance that ’ s open when we get home . ', ' Yeah , and the prices there are very high . ', ' I know . Three dollars for milk . ']
['Do you think they two will get married ? ', ' You can count on it . ', ' I think so.Yes , they get along so well . ', " I like him.He ' s good for her . ", " You're right . He sure is . "]
['Dad , where are we off to ? ', ' First we will go to the city centre and stop for something to drink . Then we will visit the University Museum . ', ' Where are we going to have a drink ? ', ' There is a coffee shop round the corner . Can you see that big building at the end of the road ? ', ' Yes ? ', ' That is a bank . The coffee shop is opposite the bank . ', ' Good . I will have hot chocolate . ', ' A stop ! Wait for the lights to turn green . ', " When crossing the road you must always pay attention to what's around you . ", ' Sorry . How far is the museum ? ', ' I am not sure . We will ask for directions in the coffee shop . ', " Here we are . You find us a table and I'll get the drinks . "]
['How about going to the cinema tonight ? ', " That's great . What's on tonight ? ", " I am not sure about the name of the film , but I know it's a romantic one . ", ' Romantic ? I am afraid I like thrillers better . ', " Don't you think it's too bloody ? ", ' On the contrary , very exciting . ']
['I feel so uncomfortable . ', ' Are you sick ? ', ' No . The teacher is dragging the chalk over the blackboard . It set my teeth on edge . ', ' He ’ ll finish writing in a minute . ']
['I have made up my mind . I am getting a tattoo . ', ' Really ? Are you sure ? ', ' Yeah ! Why not ? They are trendy and look great ! I want to get a dragon on my arm or maybe a tiger on my back . ', ' Yeah but , it is something that you will have forever ! They use indelible ink that can only be removed with laser treatment . On top of all that , I have heard it hurts a lot ! ', ' Really ? ', ' Of course ! They use this machine with a needle that pokes your skin and inserts the ink . ', ' Oh , I didn ’ t know that ! I thought they just paint it on your skin or something . ', ' I think you should reconsider and do some more research about tattoos . Also , find out where the nearest tattoo parlor is and make sure they used sterilized needles , and that the place is hygienic . ', ' Maybe I should just get a tongue piercing ! ']
["Excuse me , what's the screen near your steering wheel for ? ", " It's a portable TV . It's a popular thing now . ", " Oh , that's new to me . So what's on everyday ? ", ' News about current affairs , documentaries , music , movies , noncommercial ads and so on . ', ' Is there anything interesting ? ', ' Yes , there are something good and informative . I think that many people underestimate the value of TV in education . ', ' I agree . Are there any commercials on the TV ? ', ' Of course . Because the TV stations need to make money from commercials between the programs . ', ' That makes a lot of sense . Does the TV work well ? ', ' Not always . It depends on the transmission of the satellite signals . ', ' I got it . Do you pay for the programs ? ', ' Yes , 50 Yuan per month . ']
['Oh , no ! ', ' How dreadful ! ', ' Look at the view from the window . ', ' Oh , dear . That ’ s terrible . Not at all what I expected . ', ' It ’ s awful , isn ’ t it ? ', ' I can ’ t bear to look at it . I ’ m rather disappointed . ', ' It can ’ t be helped . ']
['What do you do in your free time , Nancy ? ', ' Well , I like playing the violin . ', ' Really ? How long have you been playing the violin ? ', ' About ten years so far . I started learning when I was in middle school . ', " That's really interesting . ", ' Sure . So what about you ? Do you have any hobbies ? ', " Well , I like collecting matchbox ! I'm not sure if that counts , though . ", ' Of course it does . Everybody has his own hobby . ']
['How can I tell her about this ? ', " Don't worry , you'll find a way . ", ' There is no need to be so frustrated . ', ' How can you live without job in the future ? ', " Don't worry , you'll find a way . "]
['What sports do you like to play ? ', ' I like baseball and basketball . ', ' How about football ? ', ' In my country football is brand new , so I never learned the game when I was younger . ', " It's a very popular game in America . ", ' Yeah . I heard a lot about it . Is it really that fun ? ', " For me , it's one of those games that are fun to both watch and play . ", ' Are you a football player ? ', " No , I just for fun with my friends . We play two hand touch or flag football . We're too old to play tackle football . ", ' What is two hand touch and flag football ? ', ' Instead of tackling somebody , you just have to touch them with two hands , or if it is flag football , grab the flag that the ball carrier is wearing . ', " I see . It's safer then right ? ", " Exactly . We play every Saturdays on the field by the tennis courts . If you want to learn and play a little , you're welcome to join us . ", " I'll give it a try . Give me a call and let's go down together . ", " Ok . I'll call you Saturday morning . ", ' Great . ']
['What upsets you ? ', ' My parents called . As usual , they reminded me again that I should have a plan to marry by my late 20s . Easier said then done . Who should I marry ? I have no time to go on a date . ', ' It is not your mother finding one for you ? ', ' I will find one myself , of course . I ’ m a modern girl . ', ' Perhaps you can try the three minutes date , the latest type . ', ' You mean dozens of the opposite sex meet each other for three minutes in a dimly bar serving alcohol , I hate that idea . ', ' No , there is an updated virgin , three minutes video date . I know an online dating website providing such service with a microphone and webcam , you can sigh for it . You can be face-to-face with a guy talking for maximum three minutes . ', ' I don ’ t think it makes sense . Three minutes is such a short time . ', ' I think you can find out if there is a possibility of romance within the first second of meeting someone , so-called love at first sight . ', ' Anyway , I don ’ t want to post my face up for sale on the internet like that . ', ' Don ’ t worry . There are many other options using the internet as dating methods . Some sites operate at international standard even have got certifications . Of course , for these sites , you have to pay a membership fee . But all in all , it is more serious and professional . The chance of meeting a good and serious person who does not play games is higher . ', ' I don ’ t want to post my personal information on the internet . I ’ m not knowing who is reading it . ']
['Are you going to the party on Saturday ? ', ' I was thinking about it . Are you ? ', " Yeah , I heard it's going to be a lot of fun . ", ' Really ? Well , what time does it start ? ', ' It starts at 8 ', ' Well , who all is going to be there ? ', ' Everyone from school . ', " How do you know it's going to be so fun ? ", ' This party is going to have a DJ , food , and drinks . ', " Wow , that does sound like it's going to be fun . ", ' So am I going to see you at the party ? ', ' Yeah , I will be there . ']
['Could you talk to me for a few minutes about my grades ? ', ' Step into my office for a moment . What is your concern ? ', ' Am I failing ? ', " Let's go on the computer to see what's up . Do you think you are doing well ? ", ' I am pretty sure that I am in trouble . ', ' I can see that you are trying , but where do you think you could improve ? ', ' I missed a few classes ; I need to make sure I come to school on a regular basis . ', ' Having a regular study routine and following it is very important , right ? ', " I'll try ; it's hard ! ", ' Thanks for stopping by ! ']
["Good luck on your test tomorrow . We'll be crossing our fingers for you ! ", ' Thanks . ']
["I'll never ever work together with him ! ", ' What happened ? Quarrel again ? ', ' Will you take my materials back from him for me ? Please ! ', " Don't ask me . I don't wanna be involved in your quarrel . "]
["Oh , my God ! I've been cheated ! ", ' What ? What did you buy ? ', " It's a brick ! I can't believe how stupid I was . Damn it ! ", ' What is it ? Why did you buy a brick ? ', ' There was a guy on the sidewalk.He had three new boxes , Panasonic video camera boxes.He said he had to get rid of them quick . ', ' And ? ', " So he said he'd sell me one for twenty dollars . A four-hundred-dollar camera for twenty bucks . ", " And it's a brick ? ", ' Yes . ', " I can't believe how stupid you are . Why didn't you open the box ? ", " I wanted to . But he said , no , the box is still in its plastic wrap from the store.If it's opened , other people won't believe it's new . ", ' So he had the boxes wrapped in plastic . ', ' Yes , it was the kind of perfect plastic wrap that comes with new products.Look , it even had a bar-code price sticker on it ! It looked brand new . ', ' But why would a guy be selling new video cameras for twenty dollars ? ', ' He said he had to get rid of them . They were stolen . ', ' Aha ! Now I understand.You were trying to buy stolen goods on the sidewalk.So , what I think is , you deserve to get cheated ! ', " C'mon , don't blame me ! I thought it was a new camera . We could use it.We were even thinking about buying a camera . I don't understand how he could have such a perfect-looking box . ", " That's no problem.He just has a friend who works in a shop that can do plastic wrap . That's easy.And probably it's the same shop he got the boxes from.Maybe his friend works in an electronics store . They sell video cameras there.Probably they had a couple video camera boxes lying around.So they get the idea of wrapping bricks to sell to fools like you.Twenty dollars a brick . That's a good profit if they can sell enough bricks . ", " You're right , Sarah . I was a fool . I can't believe it . How could I fall for such a trick ? "]
['Is the clock right ? ', " I'm afraid it gains a little . ", ' By how many minutes ? ', ' Two . ']
["Hey , Mary , what's up ? ", ' Just so so . Last night I met this great guy at the bar and we had such a wonderful time , so we decided to meet again tonight . ', " Oh , that's exciting . What does this guy look like ? Is he hot ? ", " Well , I didn't think so at first . But as we started talking , I found him extremely funny and witty . I couldn't stop laughing at his jokes ! And we have so much in common . We like the same team , music , and most amazingly , we both love Chinese food ! I have the feeling that we are going to be great friends . ", ' It seems you two are a good match . What qualities do you look for in a friend ? ', " There's nothing definite I think . I don't have a list or anything , but when I first meet somebody , I can usually tell whether or not that person is going to be a good friend . It seems I have radar helping me spot new friends . ", " Well , that's something I've never heard of . But if you ask me what I value most in a friend , I would say honesty . ", " I agree . You can't expect a close relationship with a dishonest person . Those are the people that will turn their back on you when you are in need . ", " Yeah , I know . A friend in need is a friend indeed . I don't need fair-weather friends either . "]
['What ’ s up ? You don ’ t look too good . ', ' Yeah , my head hurts , that ’ s all . I ’ Ve been in physics class all day . It ’ s killer ! ', ' I liked physics . It ’ s all math , really . arcs , curves , velocity , cool stuff . ', ' Yeah , yeah , but today ’ s lesson was all about the creation of the universe . ', ' A physics class about the creation of the universe ? That ’ s some pretty unscientific language there . Sounds more religious to me . ', ' It ’ s all religion . Take the theory of the Big Bang.How is it possible that all of the stuff in the universe comes from an explosion ? That ’ s no better than Atlas carrying the globe on his back or African myths about turtles and stuff . ', ' Turtles ? Whatever ... Look , all that ’ s required for the creation of matter an imbalance of particles and anti-particles . At least , that ’ s what the math says . ', ' Math , sheath . What ’ s the evidence ? ', ' There is evidence ! You know Edwin Hubble ? He ’ s the guy who in the early twentieth century was the first scientist to measure the drift of matter in the universe , thus advancing notions of an expanding universe . What would it be expanding from ? Well , the Big Bang ... DUH ! ', ' Anyway , it ’ s just a theory . Why do people go around touting theories ? Where ’ s the scientific rigor in that ? ', ' Dude , don ’ t equivocate . A theory only becomes a theory after withstanding rigorous testing . You slept through class , didn ’ t you ? ']
['Today more and more people advocate lifelong learning . But people have different views about lifelong learning . How do you understand lifelong learning ? ', " I think lifelong learning is the concept that it's never too soon or too late for learning ", ' Does that mean studying all the time ? ', " I don't think so . I think it's about your attitude towards learning . One should be open to new ideas , decisions , skills or behaviors . ", " Then the axiom - ' You can't teach an old dog new tricks ' doesn't work any longer . ", " You're right . Lifelong learning is about finding learning opportunities at all ages and in numerous contexts ", ' Yes , I agree with you . When I retired I will participate in programs to keep momentally active . ', ' Me too . To keep up with the changing world , one must be involved in lifelong learning and be ready to accept new things . ', " You know what ? I've recently been teaching myself French . ", " Really ? That's great ! I know that your company has a lot of clients in France . ", ' Yes , so I want to learn French to develop my career . ']
['How old are you ? ', " Nine ... but I'll be ten on May 1st.When is your birthday ? ", " I'm older than you ! I'll be ten on April 14th . ", ' Are you going to have a birthday party ? ', " Maybe . I'll have to ask my mother . "]
['It smells like an ashtray in here ! ', ' Hi honey ! What ’ s wrong ? Why do you have that look on your face ? ', ' What ’ s wrong ? I thought we agreed that you were gonna quit smoking . ', ' No ! I said I was going to cut down which is very different . You can ’ t just expect me to go cold turkey overnight ! ', ' Look , there are other ways to quit . You can try the nicotine patch , or nicotine chewing gum . We spend a fortune on cigarettes every month and now laws are cracking down and not allowing smoking in any public place . It ’ s not like you can just light up like before . ', ' I know , I know . I am trying but , I don ’ t have the willpower to just quit . I can ’ t fight with the urge to reach for my pack of smokes in the morning with coffee or after lunch ! Please understand ? ', ' Fine ! I want a divorce ! ']
['Why are you shivering ? ', " It's freezing . "]
['It seems that you get antsy when you hear I praise another guy . ', ' I get antsy not because you praise a guy , but because you may be taken for a ride by a guy like him . ', ' How come you think of him that way ? ', ' Because you seem to have lost your vigilance . You should be on the watch out . ', " I have no reason to distrust him . He's never caused any harm . ", " Isn't there anything that sounds fishy ? ", " Nothing smells a rat . I told you that he's an all-right guy . ", " All-right guy ? All right . Let's talk about something else instead . "]
['Cheese ! It tastes like cardboard . ', ' I think so . Maybe that ’ s why it ’ s cheap here . ']
['Have you signed up to join the company ’ s Christmas party ? ', ' Sure , I have . Will you join ? ', ' I will . You know , as a newcomer , I think it might be a good opportunity to get to know people from the other departments of our company in a more relaxed atmosphere . ', ' You are right . Our company ’ s Christmas party has always been an amazing occasion for everybody to relax and get to know each other better . It is also a time to make new friends and do some networking . ', ' I hope that it is not a formal one when the boss is there . ', ' No , it will not be formal at all . It is a fun time . You will love the game show . Please dress casually . Usually there is an over abandon of drinks , so be careful with that . ', ' Don ’ t worry , I can handle that . And I know if the boss is there , even it is an informal evening , it does not make a good impression to get totally drunk in front of him . ']
["If the weatherman's predictions are accurate , it should rain tomorrow . ", " I hope not . Then we'd have to reschedule our baseball game . "]
['hi , Emily , do you know that guy over there ? ', " The tall one ? Sure , that's Drive , he works with Lily . ", ' He is cute.What dose he do ? ', " I'm not sure , he is a manager I think . ", ' Really ? Are you going to introduce us ? ', " Well , he has already taken you know , that's his wife right there . "]
["You didn't ring me last night . You said you would . ", " I'm sorry to have made you disappointed . ", " That's all right . But why were you so rude to me at lunch . ", ' Was I ? Sorry , I didn ’ t mean to be . I do apologize . ', ' And why are you yarning now ? Are you bored ? ', " Forgive me darling . I'm very tired . "]
['Hi , Nicole . Did you have a good weekend ? ', ' Yes , I did . But I feel tired today . ', ' Really ? Why ? ', ' Well , on Saturday I cleaned the house and played tennis . Then on Sunday I hiked in the country . ', ' And I bet you studied , too . ', ' Yeah . I studied on Sunday evening . What about you ? ', " Well , I didn't clean the house and I didn't study . I stayed in bed and watched TV . ", ' That sounds like fun , but did you exercise ? ', ' Sort of . I played golf on my computer ! ']
['There will be a parade to celebrate National Day this weekend . ', " What's the route ? ", ' From Zhongshan Circus to City Bank . ', ' If only I could join it ! ']
["Excuse me . I'm afraid you're in my seat . You've moved my books . ", ' Oh , dear . ', ' You must have realized somebody was here . ', " Oh , well , I looked around . There wasn't any other space . I waited a while and nobody came . I'm sorry if I've taken your place . "]
['What ’ s the life expectancy in your country ? ', ' I ’ m not sure , but probably about 75 years . How about in your country ? ', ' About 70 , I think . This newspaper article talks about the problems of an aging population . It ’ s a problem that will soon affect most of the world . ', ' I heard that the government might need to increase the retirement age , because otherwise there will not be enough workers to support the young and the elderly . ', ' Perhaps we need to have more babies ! Tina gave birth to a baby boy yesterday . ', ' Did she ? That ’ s great . However , if we have too many children , that will have a bad effect on the enviroment . ', ' How ’ s your son these days ? ', ' Oh , he ’ s fine . Kids seem to grow up very quickly nowadays . ', ' He ’ ll be a teenager before you know it ! Teenagers are often rebellious ! When do you mine it is a good age to have a child ? ', ' I had mine when I was 24 . that ’ s a little young . I ’ d suggest you wait until you are in your late twenties . , or even in your early thirties if you have a good career . ', ' Yes , I think you ’ re right . I ’ m thinking about having a child , but not just yet . ', ' Is there a big generation gap between parents and their children in you country ? ', ' Yes , there is . Teenagers do not want to live traditional lives . They want to go out , have fun , and explore the world . They want to develop their own view of life . Parents usually try to discourage them , but they don ’ t often succeed . ', ' Parents usually give their children more freedom in my country . Sometimes they give them too much freedom . ', ' It ’ s almost impossible to get the right balance . If you are too strict , kids might ignore you . If you are too lenient , they might go wild . ']
["I'm going to Japan this year on vacation . ", ' Have you ever been to America ? ', " No , but I'd really like to . ", " You'd like it . "]
['Hey , Mark , long time no see . ', " Julie ! It's good to see you again . How have you been ? ", " Great . I just got back from a week's vacation in Thailand . ", ' Really ? How was it ? ', " Fantastic ! I didn't want to come back . ", ' I hear the beaches in Thailand are beautiful . ', ' They are . And not only that the people are friendly , but also the food is delicious , not to mention cheap . ', ' I do like Thai food . Did you see much of Bangkok ? ', " Not much . I've got enough city life in Beijing . ", ' I know what you mean . I could use a vacation myself . ', " Hey , wouldn't it be great if we could go to Thailand together sometime ? ", ' Yeah , it sure would . ']
['Could I see the manager please ? I have a complaint to make . ', ' Yes , I ’ m the manager here . What can I do for you , Madam ? ', ' Did you have the room checked before we move in ? ', ' Which room are you in ? ', ' 1808 . The toilet doesn ’ t work properly , the water doesn ’ t run in the shower . ', ' I ’ m awfully sorry to hear that . I ’ ll turn to it right away . ']
['Congratulations , Vivian . You won the grand prize , again . ', " Isn't it just great ! I just knew I'd win ! ", ' You did ? How ? Did you wear red underwear again this year ? ', ' Not only that ! ', " Tell me ! Tell me ! What's your secret ? ! ", " OK , OK . I'll whisper it to you , but you have to promise not to tell anyone ! ", ' What ? ! You did that ? ? ! ! ! ']
['We are going to the concert this evening . Will you join us . ', " I'm very sorry I can't . ", ' Why not ? ', " I've been snowed under with since my bosses away on business . "]
["You'v been work here for nearly a month , how do you feel about the job ? ", ' Not bad.Thank you for your help . I am always busy with this job , I feel a bit tired . ', " I had the same feeling when I first came to work here . but after a period of time , I feel better , I am sure you ' ll get used to this busy job . ", " I also feel that work efficiency here is very high . and you have strong working ability and professional skill , it seems that you know all , that's really wonderful ! ", ' You know the phrase , the survival the fittest . We have no choices . ', " That's right , I have to work hard . "]
['The music is on.May I have the pleasure to dance with you ? ', " Sorry , I'm engaged for the foxtrot.Will the next Walls be all right ? ", ' Certainly . ']
['Excuse me , is this seat taken ? ', ' No , please feel free . ', ' Thanks a lot . ', ' Do you work in Shanghai ? ', ' Yes I do . How about you ? ', " No , I'm a tourist . This place is amazing ! It's much bigger than I imagined , and much more exciting ! There's so much to see here . ", " You can say that again ! It's much more modern than people imagine . Where are you from ? ", " Um , well let's see ... I'm from Kansas originally . A much quieter and more peaceful place than here , that's for sure ! ", ' Uh huh ... ']
['Look at this headline , Soo Mi . ', ' Wow ! So many people in the United States get divorced ! ', ' Is it the same in Korea ? ', " I don't think so . In Korea some marriages break up , but most couples stay together . ", ' Do people get married young ? ', ' Not really . Very few people get married beforethe age of 20 . ', ' Hmm . Do women usually work after they get married ? ', ' No , a lot of women stay home and take care of their families . But some work . ']
['Boy ! What a beauty ! I fall in love with her at the first sight . ', ' The beauty under the tree ? ', ' Of course.No girl is more charming . ', ' She is a young man ! ']
['Excuse me.Where do I register ? ', ' Oh , over there in Pacific Pavilion . ', ' Is that the large , white building ? ', " Yeah , that's it . ", ' Thanks . ']
['How was your education going on in Australia ? ', " I'm going to graduate this summer . ", ' Where are you going to work then , in Australia or back in China ? ', " I'm planning to return to China after graduation . ", ' Why are you choosing to leave a foreign country ? Many people are reluctant to leave the superior living environment abroad . ', ' Well , I think personal development is much more important than simply having a superior living environment . ', " Yeah , China's developing so fast and development opportunities can be found almost in every corner of the country . "]
['Do you have any particular hobbies , Tom ? ', ' Oh , yes . I love playing badminton , table tennis and computer games . And playing the games has become my favorite . ', " I hear many teenagers will spend hours and hours sitting at computers . And they don't care about their own health at all . How about you ? ", " I'm no better than them . They say it's mindless to sit in front of a machine all the time , but I think it's stimulating . ", " You won't play online games full of violence , will you ? ", ' Once in a while . ', " It's no good . And I think spending several hours each day playing computer games is a waste of time . You might as well do something healthy and meaningful . ", ' I hope I can practice self-control again . ']
['What ’ s the plot of your new movie ? ', ' It ’ s a story about a policemen who is investigating a series of strange murders . I play the part of the detective . He has to catch the killer , but there ’ s very little evidence . It ’ s a psychological th ', ' Did you enjoy making the movie ? We heard stories of disagreement with other actors and with the director . ', ' I have had disagreement with every director . I ’ Ve worked with . We ’ Ve always disagreed in a friendly way and we have always resolved our differences . It was the same when I made this movie . I don ’ t no ', ' Critics are not very happy with the movies that you ’ Ve made recently . Does that bother you ? ', ' Not at all . The feedback from audience has been great . I care about what they think more than what the critics think . ', ' Did you do you own stunts in the movie ? ', ' I wanted to , but my insurance company wouldn ’ t let me . All of my stunts were done by a stuntman . As you know , I used to do my own stunts , but I ’ ll leave that to the experts in future . ', ' Thank you very much for doing this interview . ', ' My pleasure . Have you seen the movie yet ? ', ' Yes . I have . I liked it very much . Like you , I was very impressed with Rachel ’ s performance in the movie . She ’ s going to be a star . ']
["Who's that old lady trimming the trees ? ", " She's my grandma . ", " She's looks very healthy.How old is she ? ", ' 92 . ']
['Mom . My legs are killing me . ', ' Hold on . We will be successful right away . ']
['Oh , man . I had the best supper last night . My wife made a stir-fry and it was amazing ! ', ' I love stir fry crispy bitesize vegetables covered in a mixture of soy sauce and oyster sauce . Wilted greens and fresh bean sprouts . Throw in some onion and garlic and ginger ! Mmm ! Mmm ! It ’ s almost lunchtime . I would die for a plate of stir fry right now ! ', ' Well , you can keep the vegetables , I ’ ll take the meat . The stir fry my wife made was really hearty , with chunks of beef and slivers of bell peppers and onion ... ', ' What ? You call that a stir fry ? More meat than vegetables ? That ’ s the worst insult you could throw at a Chinese stir fry . What a disgrace to the wok she fried it in ! What you had is equivalent to a fajita without the wrap ! ']
['What did you say ? ', " I said it's a lovely day . Why don't we go for a walk ? ", ' Well , I feel a little tired . ', ' Come on ! A little labor , much health . ', ' Then can you wait a few minutes ? I want to finish writing this letter . ', " Don't take too long . It would be a shame not to take advantage of such lovely weather . ", " I won't be long . No more than ten minutes . Why don't you go ahead and I'll meet you in the park ? ", ' I Believe I will . Look for me near the lake . ']
['Thank god you showed up when you did ! He ’ s insane ! Do you think we should call the police ? ', ' Don ’ t worry about it , I ’ ll call my friend and have him take care of it . I can ’ t believe he was stalking you all these years . What a nut job ! ', ' I know ! Well ... he said I ’ m not pregnant . I ’ m sorry if I got you all worked up over nothing . I want you to know that I didn ’ t do it on purpose ... ', ' Don ’ t apologize ! From the moment I met you , not a day has gone by when I haven ’ t thought of you.And now that I ’ m with you again , I ’ m ... I ’ m just scared , Veronica . The closer I get to you , the worse it gets . The thought of not being with you , I mean , I just can ’ t handle it ! We were made for each other , Veronica . You are my everything , my soul mate . What can I do ? ', ' Just hold me ... I ’ ll always be here for you , no matter what . And together , we can tackle whatever life throws at us . I believe in us , steven . ', ' I ’ m so happy to hear that ! I knew we belong together . I love you so much . ']
['Zina , can I talk to you about something personal ? ', " As long as it doesn't take too long . ", ' My boyfriend says I work too much . That I spend more time with you than with him . ', ' Was he upset when you told him you had to leave this weekend ? ', " He said not to bother coming back . And I said , fine , I won't . ", " So what's the problem ? "]
['Mary , how was your date with john ? ', " it's ok . It seems we have a lot in common . ", ' oh , really . That is great news . What does he look like ? ', ' he is tall and slim , fair-haired . ', ' sounds like he is pretty cute . What do you think of him ? ', ' he is a nice guy and very considerate . I was impressed with how smart he was and he has a great sense of humor . ', " oh , it's love at first sight . When will you see each other again ? ", " he didn't say , but he said he would call me . ", ' maybe he is busy with his work . Just wait and try not to think about it too much ! ', " oh , steve . Stop it ! I am a bit nervous ! What if he doesn't call ? ", " come on , Mary , you're a total catch . I bet he will call you . Don't worry . ", " thank you , Steve . You're always so encouraging . ", " that's what friends are for . "]
['Hi , Francis , how was your business trip ? ', ' It was a nightmare . ', ' What ’ s up ? ', ' Actually , the business trip itself was very successful . We arrived on time , we had nice conversations and we settled some important issues for the next year . ', ' Sounds quite fruitful , why do you call it still a nightmare then ? ', ' Well , the air line lost my luggage on the return flight and then I lost my carry on bag when I was tackling with the officers in charge . I left the airport three hours later than I expected and then I was caught in a traffic jam . When I finally got home , I was totally exhausted . But I found the elevator was out of service due to a blackout . ', ' This is really a sad story . Did they trace back your luggage ? ', ' I am still waiting for their call . ', ' Take it easy , all sufferings have their reward . ']
['So the company decided to cancel your trip to Hong Kong ? ', " Yes , The SARS epidemic is not under effective control yet . So I'd better not risk it . ", " Maybe it's a good things . If you don't have to go to Hong Kong , you can take a break and take things easy for a while . ", ' You are right . Maybe we should work out a fitness plan and start to do more exercise . Sitting around in the office all day is no way of keeping fit . ', " That's a good idea . Let's see if we can get more people in this plan . There isn't much business these days anyway , so I think many people will be interested . "]
['Which pair of jeans do you like best ? ', ' I really like the straight legs . ', " But they aren't very fashionable . What about these ? ", " I don't like the way they sag down . I feel like I have plumber butt in them . ", " That's the style ! You just wear boxers . ", ' What if someone got it in their head to give them a tug ? What then ? ', " You're so old fashioned ! Nobody is going to pull down your pants ! ", " If you ask me , it's a walking invitation ! "]
["Hi , Charles . What's the matter ? ", " Oh ! ! My car isn't working . I'm waiting for a tow-truck . ", ' Do you have a ride home ? ', ' Yes , my wife is coming to get me . ', " That's good . Do you live near here ? ", ' No , we live in the suburbs . What about you ? ', ' I live downtown , with my parents . ', ' Do you have a car ? ', " I don't need a car . I walk to work . ", " You're lucky ! "]
['Happy anniversary , sweetheart ! ', ' Yes . to our first anniversary and many more to come . Cheers ! ', " I'll drink to that . Thanks for making this a night worth remembering . ", " Well , it's a special day . They say if you survive the first year , the rest is smooth sailing . ", " That's good to know . Oh , listen ! The band's playing our song . ", ' I requested it . What do you say ? Do you have your dancing shoes on ? ', ' Always . ']
['What do you plan to do for your birthday ? ', ' I want to have a picnic with my friends , Mum . ', ' How about a party at home ? That way we can get together and celebrate it . ', " OK , Mum . I'll invite my friends home . "]
['How about seconds , Victor ? ', " No.thanks . I'm full . "]
["Why don't you have dinner with me tonight ? ", " I'd love to . ", " Let's say about 6:00 ? ", " That's OK with me . "]
['Cigarette ? ', ' Oh , uh ... Thanks . Henry , do you have a light ? ', ' Sorry , here . ', ' Thanks . Lovely day . Pity I ’ m on duty . ', ' I ’ ll stand in with you if you like . I ’ Ve got nothing else to do . ', ' Oh , no . I couldn ’ t possibly . ']
['Hi Rose , what are you busy with right now ? ', " Hi Jack , I'm working on these documents . The manager wants them for half an hour . ", ' Well , Rose . ', ' Is there something any need ? ', ' Are your free this weekend ? ', ' Yes , I have nothing to do . ', ' Great , Is it convenient if i visit you this weekend ? ', ' I beg your pardon ? ', " I'd like to call on you this weekend . I just want to a drop in for a chat . ", " Really ? well , ok , you're welcome . ", ' Is 5 PM . Saturday a good time for you ? ', ' Hmm , how about seven ? I can treat you to dinner . ', " Sure , that would be great . I'll bring the wine . ", " OK . Then I'll be expecting you . ", " I'll be there on time . "]
['How do you shoot pool ? ', ' You have 16 balls on the table , 7 solid colored , 7 striped colored , a black 8 ball , and the white ball . ', ' And ? ', ' You hit the white ball with your cue . The white ball hits the colored balls . And you want to get the colored balls into the pockets . ', ' How do you know whether you should hit the solid or the striped one ? ', ' At the beginning , it does not matter , but once someone gets one ball in , it is set . ', ' Can I get the black ball in ? ', ' The black ball has to be the final ball in the pockets . ', " Let's go and try now ! "]
['How about going to hear a country-and-western singer tonight ? ', " I'd enjoy that . ", " I'll pick you up around 8: 00 . ", " OK . I'll see you then . "]
['The mosquitos are biting me ! ', ' Me , too , I can ’ t stop scratching . They are everywhere ! Sneaky little jerks . ', ' Do you have any bug spray ? ', ' No , I forgot to buy some . ', ' Then we ’ ll have to put up with it . ', ' We can cover ourselves with beer ! That way if they bite us , they ’ ll get drunk and fall asleep . ', ' That ’ s without a doubt , the best idea you ’ Ve had ! Let ’ s do it ! ', ' Run ! They are thirsty for more ! ']
["Stop running around in front of the TV , will you ? Why don't you just sit and watch ? ", " I've tried , but I can't stand the bald man talking so loudly in the program . ", ' Then stay away . No one is keeping you from doing that . ', " Don't be so irritable . I just don't understand the program , that's all . ", ' All right , I will explain it to you later on . Now scram . ', " Ok . I will wait until you have had your fun , if that's what you want . ", " That's exactly what I want , thank you . "]
['Okay , can I ask you something direct ? ', " Ha ! It's not like you've ever been one to beat around the bush . ", ' Fair enough . Give it to me straight . Did she bully you into this ? ', ' No , seriously . . . I really want this . ', " I tell ya , when I got the invite , it really threw me for a loop . You've done a complete 180 . ", " I know . But things have changed . I guess I've settled down . ", ' I guess so . ']
['My daughter plans to quit her present job and wants to find another . She says she wants to get a better job with higher pay . ', ' It seems quite normal to me . It is pretty much what I want to do . ', " But what about settling down to start a family ? Doesn't anyone want to get married any more ? ", " It is different now . The world is becoming colorful . Some of my friends don't feel the same pressure to marry . We all want to wait for the right moment . ", ' What time is the right moment ? ', ' Let the universe find us instead of forcing love . We prefer natural love . The most important thing is to be happy . Love will find us later . That is what we say . ']
['Please excuse me , but I really have to be going . ', ' Yes , of course.It was nice to see you . ', ' It was nice to see you , too.And please give my regards to Mrs.Robbins . ']
['Excuse me . Is this seat taken ? ', " I'm afraid so . "]
['What do you think of the coming match ? ', ' Winning is a piece of cake to me . ', ' You are bragging again . ']
['What would you reckon the taxing increases ? ', ' Well , the state will benefit a lot , I suppose . ', ' But what do most people think about it ? ', ' Ah , it ’ s hard to say . ']
['are you still coming to my place for dinner tomorrow night ? ', ' of course . Is the dinner still on ? ', ' yes , I was just wondering how you and your roommate were planning on coming to my place . ', ' we were planning on walking both ways since the weather is still nice . ', " that's what I thought you would do . Listen , I live in a bit of a rough neighborhood . It's just down the street from all the bars . You probably don't want to be walking around after dark . ", " it can't be that bad . ", " I wish it wasn't , but there is actually a lot of crime and prostitution around here . ", " really ? I never would have guessed . The criminals must only come out in the evenings , because I've never noticed anything strange when I've been at your house in the daytime . ", " do me a favor , and take a taxi . It'd make me feel a lot better . ", ' ok , we will . How do you get around in the evenings ? ', ' when I first moved in , I walked everywhere . But within a week , I had my purse stolen — just a block away from the police station ! Now , I always take public transportation . ', ' has anything else happened to you ? ', ' nothing else has happened to me , but I have seen quite a few fights on the streets after the bars close . ', " well , we'll be careful . Thanks for letting me know . "]
['Jack wonders whether Linda likes him or not . ', " Why doesn't he ask her ? ", ' He is too scared to ask her . ', " He's a chicken guy . "]
["I don't understand why some parents keep beefing and complaining about their daughters not being able to follow suit . ", " Yeah . Li Na's mother has been building a fire under her since her neighbour's daughter got married with a Canadian . She's almost driving Li Na crazy . ", ' If I were Li Na , I would ask her if she had done that . ', " She is as meek as a lamb . She never goes against anyone or anything . She's as good as gold , you know ? "]
["Where is John ? I can't find him anywhere . ", " Haven't you heard that he is in prison ? ", ' What ? Beg your pardon . ', ' John is in prison now.He was copped outstealing . ', " I just cann't believe my ears ! "]
['What do you need ? ', ' I need to use the Internet . ', ' You have your library card , right ? ', ' Yes , I do . ', ' There is a wait right now to use the computers . ', ' That ’ s fine . ', ' Would you please write your name on this list ? ', ' Then what ? ', ' I will call you when a computer is free . ', ' How do I log on to the computer ? ', ' Use the number on the back of your library card . ', ' Thanks . I ’ ll be sitting over there . ']
['What a nice tie you are wearing ! ', ' Thank you.But does it really look all right ? ', ' Certainly.It matches your suit perfectly . ', ' Then does it go well with my sweater ? ', ' Yes.You look very smart today . ', ' Thank you very much . ']
['What do you make of the case ? ', ' If you ask me , I don ’ t think it ’ s guilty . ', ' What do you mean by saying so ? ', ' I mean it ’ s not his fault . ', ' Oh , yeah ? ', ' Yes . Don ’ t you think he should be pitied rather than accused ? ']
["Happy Mother's Day , Mom ! ", " Thanks ! These are beautiful . You shouldn't have ! ", ' Of course I should have ! You certainly deserve them ! You put up with all of us . ', ' I forgot what I put up with . In that case , I do deserve these flowers . ']
['I have a real problem when I meet people . ', ' What is it ? Maybe I can help . ', ' I never know when to shake hands and when not to . Can you tell me something about it ? ', ' Do you come from a country where they shake hands ? ', ' Oh yes . Men , women , and children shake hands all the time . ', ' It ’ s very simple . Men shake hands , women and children don ’ t . ', ' But some women do shake hands . And now a lot of children have such good manners , they shake hands too . ', ' Well , a good rule to follow is , for men you hold out your hand , for women and children , you wait and see what they do . ', ' That sounds easy enough . ', ' Sure . Once you get the hang of it , it ’ s a piece of cake ! It ’ s nothing to worry about . ']
['Sam , I am so sorry . It was your birthday yesterday and I completely forgot about it . ', " Don't worry about it . I keep forgetting everyone's birthdays as well . ", ' Margaret really told me off when she found out that I had forgotten all about it . We did try to phone you , but you and Jane must have gone out . ', ' Yes , Jane invited me for dinner to this new restaurant which opened near us . ', ' Oh , yes , I know the one . How was the food ? ', ' The food was excellent , but Jane ordered a birthday cake , which they forgot about . So as you can see , you were not the only one . ', ' Oh , no . ', ' Yes , Jane was quite upset about it . The manager came to apologize and we did get free dessert , but still ... ', ' I would think this was the least they could do . ', ' In the end it was a nice evening and I got an iPad as my birthday present which I wanted for a while . ', ' Great . I have also been thinking of getting one . Do you think you could ask Jane to have a quiet word with Margaret ? My birthday is not that far away . ', ' I can try , but knowing Margaret she will see through that immediately . ']
["Here's the restaurant we're meeting the Smiths at . ", " Let's go in to wait for them . ", ' After you . ']
['When do you usually go to the movies ? ', ' I usually go in my free time on the weekends . How about you ? ', ' The movie theater is always so crowded on the weekends . I like to go to the movies during the week . ', " That's true . And sometimes the tickets are cheaper during the week as well . "]
['Are you telling us a lie again ? ', ' I will be hanged if I lying . ', ' All right . But what was the trouble ? ', ' My car run out of petrol . ']
["I can't believe Mr . Fro didn't buy it . Who does that guy think he is anyway ? Bill Gates ? ", ' He had a lot of nerve telling us our ads sucked . ', ' Time to order . Balista , today I want a skinny triple latte . ', ' When did you start worrying about your weight ? ', " I'm not . I just don't feel like drinking whole milk today . Why ? Do you think I'm fat ? ", ' No , Jess , chill out ! ']
['Come on , Tara . Let ’ s go up to the window and buy two tickets . The movie is starting in a few minutes . ', ' We can ’ t break into the line . Don ’ t be so impatient . We ’ ll be at the front of the line soon . ', ' Two tickets , please . How much are they ? ', ' Oh no , Ari . I didn ’ t mean for you to pay for me when I invited you to go tonight . Let ’ s go Dutch . I ’ ll pay my own way . I insist . ', ' I ’ m looking forward to this film . I read a good review of it in this morning ’ s newspaper . ', ' Me , too . It will be great to see something light and funny for a change . I ’ m tired of heavy drama . ', ' Are these seats okay ? ', ' They ’ re fine , but I can ’ t watch a movie without popcorn . ']
['Do you often buy magazines ? ', ' I buy a computer magazine every month . It keeps me up-to date with all the latest developments . ', ' Why don ’ t you find the information on the internet instead ? ', ' Sometimes it takes too long to find the exact information you are looking for . Besides , I like to read a magazine in a coffee bar sometimes . ', ' Do you have an online edition of that magazine ? ', ' Yes , they do . But you can only access all the articles if you have a subscription . ', ' Do you have a subscription ? ', ' Yes , I do . The magazine arrives by post at the beginning of each month . Do you every buy magazines ? ', ' I only buy them if they look particularly interesting . I don ’ t buy any regularly . ']
["Mumm . Those burgers smell great . It's perfect day for a barbecue . ", " It sure is . I'm glad it didn't rain . My name's Mike Gates , by the way . ", " Oh , hi ! I'm Barbara Johnson . Nice to meet you . ", " I'm sorry . What's your name again ? ", ' Barbara . But please , just call me Barb . ', ' So Barb ... what do you do ? ', " I'm studying medicine . ", ' Really ? Where ? ', ' At Harvard . What about you ? ', " I'm an engineer at IBM . ", ' Oh , are you ? That sounds interesting . ', ' Yeah . I like it . Hey , it looks like the food is ready . ', " Good . I'm starving . "]
["Wow ! I can't believe I'm standing here ! ", ' What are you so excited about ? ', " I'm standing in front of an exquisite work of art ! ", " What's the big deal ? It's just a picture of some woman . ", " I've seen it so many times in books , but I never imagined I'd get to see it in person . ", ' There are tons of other paintings that I think are better . ', ' Maybe so , but do you have any idea how much this one is worth ? ', ' No , how much is it worth ? ', ' About 80 million dollars . ', ' Whoa . ']
['hey , Maris , are you a part-timer ? ', ' part-timer ? Is that a new buzzword ? ', ' oh , it ’ s pretty popular among my classmates these days . So are you ? ', ' sure , I have a part-time job as a bartender . ', ' cool ! It must be amazing to work at a bar ! ', ' yeah , but I ’ m not there for fun . I have to remain professional and if I get distracted , the manager would be pretty upset . ', ' that ’ s true . I ’ m wondering did you learn anything from the job ? ', ' of course . There ’ s always much to learn . I got to know more about the real world . ', ' you mean you got working experience , right ? ', ' not just working experience . I would say the biggest lesson I learned is how to deal with people from all walks of life . ', ' it must be very demanding . ', ' sometimes it is . But after working for a few weeks , it ’ s easy to figure out . ', ' really ? It sounds interesting . ', ' maybe you can come to the bar one day and I ’ ll show you around . ', ' great . I ’ m looking forward to it . ']
['Have you seen that house ? ', ' Yes , it looks interesting . ', " You're right . I love it very much . ", ' It must be old . ', ' At least more than 100 years old . ', " Let's enter it ! ", " I can't open the door . ", ' It must be locked . ', ' Let me ask the old woman in that reception office . ', " She can't answer you . ", ' She must be deaf . ', ' It must be a haunted house . Are you frightened ? ', ' Frightened ? You must be joking . ']
['Have you got any hobbies ? ', " Yes . I'm fond of playing the chess and I'm very keen on playing cards . ", ' Which is easier to learn ? ', ' Both , but the rules of playing cards vary in different places . ']
['Jim , how was your weekend ? ', ' I went to the beach with my friends and had a barbecue there . ', ' That sounds like a lot of fun . Did you go swimming , too ? ', ' Sure . I think it ’ s a fantastic place to go . ', ' I couldn ’ t agree more . That ’ s an ideal place for a vacation . ', ' It sure is . ', ' I can ’ t wait to go there myself . ']
["You'd better prepare for the examination . ", " I don't think the exam will be very hard . ", ' You should change your attitude , or you will not pass the course . ', " Maybe you're right . I have been too lazy lately . "]
['It is high time you have a talk with him . That may help clear the mists . ', ' I did , but he gives me a runaround . ', ' If I were you , I would put the whole matter on the table . ', ' But he was trying to beat about the bush . And my talk with him was fruitless . ']
['What is the correct time , please ? ', " It's exactly twelve minutes past seven . ", ' When will the lecture begin ? ', " It'll begin at nine o'clock sharp . "]
['Should I ask Sara to the party ? ', ' I would if I were you . ']
["If he promised to help you , I'm sure he will help . He's a man of his word . ", ' You said it . I always count on him when I need his help . ', ' Last year he helped me out of trouble , too . ']
["We're having a sixties party next week . Do you want to come ? ", ' What is a sixties party ? ', ' You come dressed in anything from the sixties . ', ' That sounds like fun . But where can I get clothes that old ? ', " Check out your mom's closet . I'll bet she still has something . ", ' Good idea . Can I bring some music from that period too ? ', ' That will be great ! Do you have LPs or Cds ? ', " Don't tell me you have a record player ! "]
["I want to improve my handwriting , and I've practiced it for several weeks , but nothing happened . You see , my handwriting is still bad . ", " Oh , come on . You know it's a long process , you have to be patient . ", " I know it , but I don't know when I can make it better . ", " A , whatever you do , the most important is perseverance . So you have to hang on there , the longer , the better . Then some day , you will find you've already made a lot of progress . ", ' Yeah , you are right . I must stop complaining and stick to it every day . ', ' Yeah ! Where there is a will , there is a way . ']
['I ’ m so excited , mother . Oh , a new baby ! ', ' My first grandchild . ', ' And my first nephew . He looks a lot like you , mum . He does . ', ' Do you think so ? Well , I guess . He does look a lot like me . Oh , he ’ s got Richard ’ s eyes though . ', ' Yes , he does have Richard ’ s eyes . The baby even looks like you than Richard does . ', ' Well , children usually resemble their parents . ', ' It ’ s true . Michelle is a lot like Henry in so many ways . And she is shy with new people just like he is . ', ' You often like comparing children with their parents . ', ' You ’ re right . ']
['The music has started . ', ' How do you like this waltz ? ', " It's very nice . ", ' May I ask you for a dance ? ', ' Certainly . ', ' You are doing the waltz wonderfully well . ', " Thanks . I'm glad you say so . Oh , the music has stopped . "]
['Do you speak only English in the class , or does your teacher explain everything to you in Spanish ? ', ' Oh , we never speak Spanish in class ! Miss.Parker speaks to us only in English . ', " I suppose she's right . Does she speak English very slowly ? ", " Not always . Sometimes we don't understand her . Then she has to repeat what she said . ", ' It must be interesting to study English . ', ' Mario and I are the best students in the class . Miss Parker says that my pronunciation is very good . ', ' Is English pronunciation easy or difficult ? ', " Sometimes it's difficult . Some words look different from the way one pronounces them . "]
["Doris , I'm glad you're home . I'm terrified . I don't know what to do ! ", ' What is it ? What happened ? ', ' I think someone is stalking me . ', " No , it can't be . Really ? Who ? ", " I don't know . I saw him the first time Tuesday . He was at the cafe . I noticed he was looking at me a lot . Not just the usual looking , but staring.He just kept staring at me . He didn't stop . ", ' What did you do ? ', " I didn't do anything . Finally , he left.But then I saw him again today . Outside the shoe store . Near the cafe . I went into a CD store and pretended I was looking at CD's . But then he came in too . ", ' Did he leave when you left ? ', ' Yes . Then I noticed he was on the sidewalk behind me . He was following me . ', ' What did you do ? ', ' He followed me all the way home ! ', " That's about five blocks . And around corners too.So he was definitely following you . ", " Yes , he was . I'm not imagining it.Finally , just when I got home , I turned around and looked at him.He was just standing there . He didn't smile . He just stood there . It was so obvious.What should I do ? I'm so scared . Can I call the police ? ", " Actually , I don't think you can call the police . Not yet at least.He hasn't done anything . And probably the police will just ignore it.But if anything happens again , then maybe you should call . ", " Why can't I call the police now ? He was definitely following me ! ", " Of course you can call the police if you want . That's not what I mean . I'm just saying that they probably won't do anything . ", " I suppose . What can they do ? I don't even know who he is . ", " Listen , Carol . Don't let this bother you too much.Probably it's nothing . Just keep your eyes open when you go out.If you see him a third time , and if he follows you again , then I think we should go to the police.But for now , just try not to worry . ", " Alright . And I won't go to that cafe for awhile . "]
["Han Maimed , What's your plan for the weekend ? ", ' I plan to travel around Harvard University and know more about it . To tell you the truth , I plan to apply for Harvard after graduation from high school . It ’ s better to get to know it . What about you ? ', ' I get together with my Christian brothers on Saturdays . ', ' Oh , my God ! John , I didn ’ t know you are religious . You just look like a scientific kook , like Leonard in the Big Bang Theory . ', ' Come on , Han Maimed , don ’ t make a fuss . A lot of Americans , including many scientists , believe in religion . ', ' But I ’ m really surprised . I thought science and religion are not compatible , are they ? ', ' Yes , they are compatible . Actually , the U . S . is both the most developed and the most religious country in the world . ', " I've heard about it a little bit before , but I don ’ t understand . How can people believe in God since they know God doesn't exist ? ", ' That ’ s a little complicated . You ’ ll get to know it when you are acquainted with the U . S . history later on . Religion was and is a part of American people ’ s life . Guess what ? Even Harvard University , which is a highly academic institution , is in a sense the product of religion . ', ' Really ? ', ' Absolutely ! It was founded by a group of Puritan immigrants from England . ', ' Why was it founded by the Puritans ? Where were the atheistic educators ? ', ' Because most of the first English immigrants who came to the United States were Puritans . ', ' How come ? I mean why most of them were religious people ? ', ' That ’ s because in the 16th and 17th century , there was a series of religious reforms in England . Many religious separatists were persecuted and fled to other countries . ', " So , you mean people didn't enjoy religious freedom in England ? ", " Yes , that's why Puritans moved to the New World , where they believed they could establish a heaven for Puritans . Later on , it was these Puritans who founded Harvard College . ", ' Why did they want to found a college ? ', ' Many Puritans had received classic style of higher education in Oxford University and Cambridge University back in England . They hoped that their descendants could receive this kind of education as well . ', ' Oh , I see . ', " Actually Harvard was first named ' New College ' , without a formal name . ", ' When did it begin to be called Harvard University ? ', ' In 1639 , it was renamed after its major benefactor John Harvard . Interestingly , JohnHarvard himself was a clergyman . ', ' It seems that Harvard was predestined to be influenced by religion . ', ' Therefore , it ’ s not exaggerate to claim that had there not been religion , there would note Harvard . ', ' Wow , I didn ’ t know that religion had played such an important role in Harvard history . ', ' Religion has been playing an indispensible part in Harvard history as well as the U . S . ', ' I finally begin to get to know Harvard . It seems that my knowledge of Harvard is rather poor . I have a lot work to do before applying for Harvard . ', ' Remember that Harvard is a part of the United States . So you have to know the U . S . history and culture if you want to have in-depth knowledge of Harvard . The two are closely related . ', ' That ’ s right . I have a lot to learn from you . ', ' You can ask me any question at any time . ']
['I am not convinced by your explanation . Could you explain it ? ', " Sorry , I really can't do that . There's little time left for us . ", " I can't accept your excuse . It's five o'clock . ", ' But I have an appointment with Ann . ', " Ok , sounds good . But I think it's your trick . "]
['What do you do in summer ? ', ' I love going out into the countryside for walks or bike ride . I love being out in the fresh summer air . How about you ? ', ' I don ’ t often go for walks , but I either play sports outside-you know , tennis or badminton-or just sit in the sunshine and read a good book . ', ' What do you do in winter ? ', ' Well , I play sports indoors quite often . If I ’ m feeling lazy , I just watch a film at home . I prefer summer to winter . ', ' I think most people do . I like wearing nice , colorful clothes in summer-you know , a nice dress or skirt . It ’ s too cold for those kinds of clothes in winter . ', ' Yes . I like wearing shorts in summer . My legs would freeze ! ', ' Do you think we ’ ll have a nice summer this year ? ', ' Thanks to global warming , it could be hotter than ever ! ']
['I will never forget Linda . After all , she was my first lover . ', ' I think you ’ ll lay it to rest with the time flying . ', ' I remember that someone says that it is difficult to forget the people who don ’ t want to forget . ', ' But I think time can change everything . ']
['Could you tell me what university you want to go to , John ? ', ' Pardon ? ', ' What university would you enter ? ', ' University ? Why ? You asked me last year . ', ' Oh , I forget.Sorry . ', ' I went to Harvard University . ', ' Did you ? And what course did you take there ? ', " God save me ! Is there anything wrong with you ? Didn't I tell you ? ", " I've not known.Perhaps , I've got a bad memory . ", ' I did a B . A . in economics.Remember ? ', ' Terrific ! B . A . , again and again-B . A . ']
["I've been chosen to plan the next family reunion . ", ' Fun for you ! Do you get to do anything you want ? ', ' Yep . And I should start planning now . ', ' Does everyone usually show up for your family reunions ? ', ' Just about . There are at least a few hundred in our immediate family alone . ', ' How Ay days will the reunion be ? ', " Usually it's at least five days and four nights . ", ' This is going to be a major production for you ! ']
["Hi , my name is Lean , and I'm from Russia . ", " Nice to meet you , Lvan.My name is Alike . I'm from Japan . ", ' To me English is a difficult language . ', ' A second language is always difficult . ', " True , but English is harder than most.It ' s a crazy language . ", ' A crazy language ? Why do you say that ? ', ' One letter can have several pronunciations and one word can have several meanings . ', ' No wonder you say English is a crazy language . ']
['What did you think of the film ? ', ' I liked it . I thought it was great . ', ' Yes , I liked it , too . Did you like the acting ? ', " Yes . I thought it was excellent . Didn't you ? ", ' Not really . I thought it was disappointing . ', " It's a nice cinema , isn't it ? ", " Do you think so ? I don't like it very much . I found it rather uncomfortable . "]
['What ’ s up ? You don ’ t look too good . ', ' Yeah , my head hurts , that ’ s all . I ’ Ve been in physics class all day . It ’ s killer ! ', ' I liked physics . It ’ s all math , really , arcs , curves , velocity , cool stuff . ', ' Yeah , yeah , but today ’ s lesson was all about the creation of the universe . ', ' A physics class about the creation of the universe ? That ’ s some pretty unscientific language there . Sounds more religious to me . ', ' It ’ s all religion . Take the theory of the Big Bang.How is it possible that all of the stuff in the universe comes from an explosion ? That ’ s no better than Atlas carrying the globe on his back or African myths about turtles and stuff . ', ' Turtles ? Whatever ... Look , all that ’ s required for the creation of matter an imbalance of particles and anti-particles . At least , that ’ s what the math says . ', ' Math , sheath . What ’ s the evidence ? ', ' There is evidence ! You know Edwin Hubble ? He ’ s the guy who in the early twentieth century was the first scientist to measure the drift of matter in the universe , thus advancing notions of an expanding universe . What would it be expanding from ? Well , the Big Bang ... DUH ! ', ' Anyway , it ’ s just a theory . Why do people go around touting theories ? Where ’ s the scientific rigor in that ? ', ' Dude , don ’ t equivocate . A theory only becomes a theory after withstanding rigorous testing . You slept through class , didn ’ t you ? ']
['Which film shall we see ? ', " There is nothing good at the moment.Let ' s do something different.Would you like to go to a concert ? ", " Yes , I'd love to.Here is a good one , Mozart and Beethoven.It ' s on the Festival Hall.Shall we go there ? ", ' Fine ! Do you want anything to eat now ? ', " No , I'm not hungry . ", " Well , let's go and have something to drink instead . I know a good place . It's a little expensive , but it's fun . "]
['Everyone wants to be financial lose kill . You must invest your savings if you planed to retire rich . I ’ m thinking about buying stocks . It can be a good investment if I can manage well . What do you say ? ', ' I partly agree with you . Buying stocks is not difficult , but making money consistently from buying stock is very difficult . Even professionals don ’ t find it easy , so be careful . Anyway , people like us need help with investing . Why not do some online research ? There are data , reports and discussion forums to educate people on how to invest . In addition , you need to visit an established website that offers stock charts . ', ' Wow , you sound very professional . ', ' I just watched the investment TV program last weekend . It has become a very hot topic these days . Actually I am not even a beginner . ']
['Can I borrow your suit ? ', " That's out of the question . "]
['Bill , how can you hear so happy today ? ', " Aha . I've read of my roommate . I made a move today . ", ' Really ? What was the matter ? ', ' You knew Brain Locker ? ', " Brain Locker ? No , I don't think so . What does he look like ? ", " Well , he's thin and tall . He has brown hair , a holt nose , green eyes and wearing glasses . ", " Mm . I've seen him a couple of times , I think . "]
['Where are you from ? ', " I'm from Guangzhou . ", ' Where in China is Guangzhou ? ', " It's in the South of China . "]
['Well , I must be off now . I have an appointment at six . ', ' In that case , I won ’ t keep you any longer . Drop in anytime . ', ' Ok , Goodbye . ', ' See you later . ']
['Hey ! How was your first day of class ? I ’ m in level two and I ’ m loving my class this semester ! It ’ s great being in a class of international students ! ', ' Mine was ok , except that no one in my class speaks English . I guess it will force me to converse in Chinese more in class so at least I should improve a lot this semester . ', ' That ’ s both fortunate and unfortunate . It ’ s the United Nations in my class ! We have people from all over the world ! There are three Germans , a Pole , a Scottish , two French , an American , a Brazilian , ', ' That ’ s quite the array of nationalities . Everyone in my class is from Asia , except me . There are a few South Koreans , several Japanese , Malaysian , Thai , Singaporean , Filipino , Kazakhstan , and o ', ' Well , I think you ’ re pretty lucky actually . You ’ ll have the opportunity to learn so much about Asian culture . ', ' I guess so , but I think it ’ s going to be hard to relate to my classmates , especially with the language barrier . I think I might change classes . ', ' Don ’ t ! Stay the course ! Your spoken Chinese will be eternally grateful . I bet you it will even surpass mine with all that practice . ', ' I highly doubt it . Your girlfriend is Chinese . ', ' Well , there is that , yes . ']
["Hey , I'm hungry . How about you ? ", ' Yeah , I can really go for some Chinese food right now . ', " That's a great idea . Let's go to a Chinese restaurant . ", " I know one . Let's go . "]
['Good morning , Miss Li . ', ' Morning , Mike . ', ' I ’ m sorry that I was absent yesterday . ', ' I ’ Ve already got your certificate for sick-leave . How do you feel today ? ', ' I feel much better now . ', ' Have you received the reading material handed out yesterday ? ', ' I ’ Ve already got it . Thanks . ', ' I will explain it in detail in the next class . Could you preview it ? ', ' I will . ']
['Do you like flowers ? ', ' Of course , I like . ', " What's your favorite flower ? ", " Forsythia . It's also called winter jasmine which is the symbol of the spring's arrival . ", ' Spring is a lively season . ', ' Yes . How about you ? ', ' I admire plum blossoms very much . It seems that only it can blossom in the cold winter . ', ' You have a perfect taste ! ', ' It is the symbol of laughing at hoar frost and fighting with snow . I admire the bravery of plum blossoms . ', ' But it used to be ignored by many people . ', ' The bright people will remember it forever . ', " Well , it's snowing . Let's enjoy the plum blossoms when snowing . "]
['What is the weather like today ? ', " It stops snowing , but there's a bit wind . ", ' And the streets are covered with ice . Do you know what the temperature is today ? ', " I missed today's weather for cast in the radio ", " It seems 10 degree below zero at least . I don't mind the cold weather , but do hate when it get slippery . ", " The ice is soon be thick for skating . I'm so fine to want a sport ", " That's fine . let's go skating together tomorrow . "]
['What kind of music do you like listening to ? ', " I like music that has a fast beat and is lively , like dance music . You know , I go to a disco almost every week . Sometimes it's too loud though . You prefer classical music , don ’ t you ? ", ' Yes , I do . I find it very relaxing . I often listen to Mozart or Bach in the evening after a hard day at work . ', ' I must admit that I like several pieces of classical music . It ’ s certainly more sophisticated that modern dance music . ', ' Classical music is supposed to be good for you brain . Research suggest that it makes your brain more active . Students who listen to classical music while studying perform better . ', ' Really ? Perhaps I should listen to classical music often . I heard that listening to classical music is helpful in reducing stress . ', ' Yes . That ’ s why I listen to it in the evenings . I usually play it as background music while I ’ m cooking or doing other housework . ', ' I ’ Ve got a few classical music CD ’ s . I should follow your lead and increase my brian power . ', ' You can find plenty of recording on the internet too . You can listen to samples and then buy them very cheaply if you like them . ', ' That ’ s a good idea . You should do the same with some music . You might find something you like . Classical music might make you clever , but dance might make you livelier and happier . ', ' That ’ s true . There ’ s clear evidence that people who listen to lively music are lively people . Music can influence a person ’ s feeling and character . ']
['There is a new coffee shop opening up down the street . ', ' I hope that they have a good menu . Most coffee shops only have coffee and Danish . ', " That's right . You don't drink coffee , do you ? ", " No , so it's usually boring to join my friends in the afternoon at a regular coffee shop . ", ' What kind of things would you like to see on the menu ? ', ' Maybe a fruit salad and a few different hot sandwiches at least . ', " That shouldn't be too difficult . Since this is a small neighborhood , maybe they will take this suggestion . ", " Let's try it ! "]
['Darling , I have news for you . Bobby and his wife , Evelyn , are going to have a baby soon . ', ' Really ? I thought his wife couldn ’ t have a baby . ', ' Actually they ’ re expecting the baby to come on my birthday . ', ' Oh , what a coincidence ! I bet Bobby must be very happy about it . He likes children and always wants a child of his own . ', ' In fact , they ’ re both very excited about the coming baby . Evelyn imagines what their baby would be look like , since one parent is American and the other one is Chinese . ', ' Oh , right . Now I know why they would want to see our boy . It ’ s hard to imagine the wonder ! Are they expecting a boy or a girl ? ', ' It ’ s still a mystery . Because Evelyn is only three-month pregnant . But she begins to take her maternity leave now . ', ' Oh ! You mean she doesn ’ t have to work now ? It ’ s hard for young parents not to overreact , isn ’ t it ? ']
['Well , I am a regular member of this club . ', ' Do you have to pay to join ? ', ' Yes , membership fees vary depending on the club but usually they run into tens of thousands of dollars . ', " Wow , that much ? Don't they have any public courses ? ", ' Very few , unfortunately . ', ' How was your game today ? ', ' Extremely good . I shot a 78 , including 5 birdies ! ', " Congratulations ! What's your normal handicap ? ", ' Ten . How did your game go ? ', ' My drives were terrible today . I kept slicing the ball into the roughs and sand traps . ', ' Maybe you can correct it by going to a driving range before you play again . ']
['The concert was really great . ', ' I agree . ', ' The singing group used to be very popular . ', " I can't believe they would play so good . "]
['I have tickets to The Phantom of the Opera on Friday night . Would you like to go ? ', " Thanks . I'd love to . What time is the show ? ", " It's at 8: 00 . ", ' That sounds great . So , do you want to have dinner at 6:00 ? ', " Uh , I'd like to , but I have to work late . ", " Oh , that's OK . Let's just meet at the theater before the show , around 7:30 . ", ' That sounds fine . ']
['Is the Chinese team taking the lead ? ', " No , it's the Japanese team . ", ' Japanese teams always play a dark horse . ', ' Well , their team work is well worth learning . ']
['Do you mind if I ask your friend out ? ', " Of course , but we aren't going out , we're just friends . ", " Okay , that's good . ", ' Do you want me to put in a good word for you ? ']
["Harry is so down that he won't talk to anyone . ", " I know only too well what that's like . ", ' What do you mean ? ', ' I was very sad when I was laid off last year . ']
['Hi , Is that David ? ', " Hi , Jenny . It's David here . ", " Hey , what's new ? ", ' Not much . My girlfriend just dumped me . ', ' Sorry to hear that . What happened ? ', " Well , she told me things just weren ’ t working out and we weren ’ t right together . But I thought things were just great . Why did she say this ? It's completely out of the blue . ", ' Hey , that ’ s not the girl with pink hair , is it ? The girl I saw with Jack yesterday . ', ' What ? She was cheating on me with that ugly guy . Oh , no , I feel like such a loser . ', ' Hey , she is not worth it . Forget her . ', ' But she lied to me . ', " Hey , she is not worth it . Anyway , there are plenty more fish in the sea . Listen , let's go for a drink in the town . How about that ? ", ' Ok , then . ', ' But you have to promise me that you are not gonna wear that face . ', ' What face ? ', ' The one where you look like your dog just died . You have to get over her and the sooner the better . ', ' Yeah , I know . You are right . ']
['This is a nice set of wheels . How much did the dealer charge you for this ? ', ' A lot . I probably got to moonlight for the rest of my life , but so what , it ’ s worth it . Come on , get in . Let ’ s take a drive . ', ' Okay then , let ’ s go fast ! Whoa ! This thing can really accelerate fast . ', ' Check out what happens when I put on the brakes suddenly . It can stop quickly . ', ' Hey , just watch out for cops or you ’ re gonna end up in the slammer . You know you tend to go fast ? ', ' Yes , I know it . I went through my last set of tires fast . I even had three flat tires in two weeks . ', ' Now watch ... some guys probably run a light and hit your car . ', ' Cut out , would you ? ']
["When's your birthday ? ", " It's just around the corner . "]
['Bob is getting on in years . ', " Yeah , I'm very worried about his health . ", ' He looks tired all the time . ', " He's working too hard . "]
['Which church do you attend ? ', ' I am Mormon , so I go to the Church of Jesus Christ of Latter Day Saints . ', ' What ’ s the difference between this and other Churches ? ', ' Mormons believe that , after the death of Christ and the death of the Apostles 10 , their church Christ founded became corrupt and the authority of Christ on earth was lost to men . In 1830 , a prophet named Joseph Smith was brought up by God to restore the church . ', ' Then does that mean the other churches are corrupt ? ', ' That means that they all have parts of the original gospel , but not all . ', ' Do you believe that Mormons have all of it ? ', ' Yes . ', ' Why do you really go to church ? ', ' We gather together to encourage each other , because we have common beliefs . We come together and call it church . ']
['Sorry I was late for the meeting today . I got stuck in traffic . ', " That's okay . Better late than never . "]
['Hello ! What are you reading about in the newspaper ? ', ' Hello ! I was exhausted some studying , so I decided to read the newspaper to relax . Unfortunately , the news is so depressing . There has been another murder in the city center . I ’ m shocked that the police haven ’ t caught the killer yet . ', ' People are starting to get frightened by it . Everyone will be relieved when they finally catch the murder . ', ' You mean “ if ” they catch the murderer . I ’ m scared stiff about going into the city center at night . ', ' There must have been some good news in the newspaper . I can ’ t believe that none of the news stories make you happy or excited . ', ' Well , there was one good piece of news . You remember the local girl who was dying of a rare blood disease ? ', ' Yes . Her parents were raising money to have her treated in the united states . ', ' Well , they ’ Ve got the money and she ’ s going tomorrow for treatment . ', ' I ’ m so happy for the family ! They must be very relieved and excited about that . ', ' I ’ m sure they are . Oh , and a local man won the lottery . I ’ m so jealous ! I wish it were me ! I buy a lottery ticket every week and I ’ m amazed that I haven ’ t even won a small prize yet . It ’ s so unfair ! ', ' Don ’ t be moody ! I hope you ’ re not tired , because we ’ Ve been invited to a party this evening . I know how excited you get about parties . ']
['Hi ! Tom . Want to go to play bowling tonight ? ', ' Sounds good . When and where shall we meet ? ', ' Let me see . How about 6:30 at the gate of the club ? ', ' Fine , see you then . ']
['Are there many idioms in English ? ', ' There are hundreds and hundreds.English is particularly rich in idiomatic expressions . ', ' Can you give us an example ? ', " I'll look up the rate.To look up doesn't mean to look high into the sky or to look at the roof.It means to search for and find some information . ", ' What about the expression goodbye ? Is that an idiom ? ', ' That is just a natural , grammatical English expression.It has a direct translation in other languages . ', ' This is interesting , Ms.Parker . ']
['Why did the teacher criticise Myra in front of the whole class ? ', ' Because Myra was cheating on exams , and she spoke back rudely . ', " I don't think that Myra should have spoken so rudely to the teacher . I know she was angry , but that's still no excuse for rudeness . "]
['Do you know where I can park ? ', ' Do you need a spot here or off campus ? ', ' I want a space on campus . ', " There's a parking structure for students . ", ' Where can I find it ? ', " Go to the western side of the campus , and you'll find it there . ", ' Is it full ? ', " When I went up there , it wasn't full at all . ", ' When was that ? ', ' Sometime this morning . ', ' Would it be full now ? ', ' I am really not sure . ']
['Have you heard of the Love Bug ? ', " Do you mean the ' I love you ' virus that attacks computers through e-mail ? ", " Yes . It is one of the most harmful computer viruses in the world . People say it will break out again om Valentines ' Day this year . ", ' This is terrible . Why do hackers play such a dirty trick ? ', ' Hackers are smart , and they want people to know about it . ', " So they create viruses to tell people they are smart ? That's really sick . "]
['I am confused by what he said . ', ' Why do you say that ? ', ' I don ’ t know what he wants to do . Does he want help me or just scold me ? ', ' Think a little . I think he means well at the bottom of his heart . ']
['Where are you going ? ', ' I ’ m going to the hospital . ', ' What ’ s the matter ? ', ' Professor Wang was hurt in a traffic accident . ', ' That ’ s too bad . How are things now ? ', ' His life is hanging by a thread , and he is under an emergency treatment . ']
['Want to meet for lunch this Saturday ? ', " Sorry , I can't . I am busy . ", ' What are you doing ? ', ' I always do volunteer work on the first Saturday of every month . ', ' What kind of volunteer work ? ', " I help out at the children's hospital . I help plan activities . ", ' Oh , yeah ? ', ' Yes , it ’ s exciting . This month we are doing crossword puzzles . ']
['Are the children all grown up now , Rose ? ', ' Oh , yes . Laura ’ s the oldest . She ’ s a computer programmer . ', ' Oh , very interesting . And what about Rita ? She was such a bright child — always reading . ', ' She ’ s a librarian at the public library . ', ' Really ? And Chris ? She was a very pretty little girl . ', ' Christy is working as a waitress at a restaurant in Paris . She ’ s married to a French photographer . ', ' Oh , how interesting . And what about Larry and Rocky ? ', ' Larry drives a truck . He drives all over the country . We hardly ever seen him . ', ' Really ? Where does he live now ? ', ' Colorado . ', ' And does Rocky drive a truck , too ? ', ' Oh , no . Rocky is a pilot . ', ' Really ? Where does he fly ? Does he fly to other countries ? ', ' Yes . Mostly to England and France . ']
['Merry Christmas , Linda ! ', ' Merry Christmas , Lee ! ', ' Linda , thank you for this wonderful Christmas dinner . I really enjoyed it . ', " Thank you for coming . I'm glad you liked it . "]
["Where's your better half ? ", " She's at home . "]
['Look , there are some words on the fish . ', " I know that they are auspicious fish . It's quite popular nowadays . ", " For God's sake ! It's too bloody . How can people be so cruel ? ", ' Not at all . I think the tattoos are so cool and chic . ', " You can't prick the fish to please the sick tastes of some bloody people . ", " Honey , it's not so serious . It's just an animal . ", " Just an animal ? But it has life too . If you want a tattoo , get one . It's your choice because you want it . But has anyone asked the fish if it wanted one ? ", ' OK , I understand , but what else could we do ? ']
["Who's singing in your home , Jim ? ", " It's Ellie and her friends . ", " Who's Ellie ? ", ' She\'s my little niece.It \' s her birthday.They \' re singing " Happy Birthday " . ', ' Oh , I see.how old is she ? ', " She's ten . ", " I suppose they're playing games . ", " Oh , yes.Ellie was playing games all day yesterday.By the way , Alice , when's your birthday ? ", ' Today . ', ' Today ? ', ' Yes . ', ' Well , imagine that ! How old are you ? ', ' Eighteen.Some friends are having a birthday party for me tonight.Do you want to come ? ', ' Very much.What time ? ', ' About 6:00 . ', " I'll be at your house at about 5:30 . Happy birthday . "]
['Well , it was nice meeting you . ', ' Yes , I hope we meet again . ', " Sure , I'll give you a call . ", ' Okay . ']
['I saw an interesting program on TV last night . It was about elderly people . ', ' And what did the program say ? ', ' It said that people with a positive attitude 7 tend to live longer and happier . ', ' I think that many physicians 8 now agree with that idea . ', ' And the TV program also said that physical exercise helps people deal with stress . ', ' And the most active older people seem to enjoy some kind of physical exercise . My father is over 60 years old , and he lifts weights every day . ']
["Did you see the information on sales for last year ? The sales review was made at our last board meeting . There's a great news for our shareholders . ", " Yeah , I went over the figures this morning . We're finally started making money again ! ", " We've never sold this much before , our growth this year has been phenomenal . We have captured 8 % of the market , up from last year by 120 % . Our strategy is working ! ", ' not only our annual sales brake a record , but our month by month earnings exceeded our forecast as well . After a two-year slump , we finally back in the black . ', " The company's performance has improved since Wallace became president . He's made our little business into a real lucrative operation . Products are selling like hotcakes . ", " I think our success is partly because of Wallace's contribution , and partly because of our new marketing strategy . Because of the new advertising campaign , we have become the top sellers in the field . ", " Let's hope this stroke of good luck lasts . I hope we are over our financial difficulties for good . ", " Let's hope it is ! "]
['What a letdown . I wanted to experience some Mafia culture firsthand . ', " It's worth it just to go and eat what the mafia eat ! The five-dollar tiramisu is a culinary orgasm . ", ' Such a thing exists ? ', " Fortunately , yes . You're blushing ! ", ' Am I ? Um ... my face gets red when I walk too fast . ', " You're embarrassed , aren't you ? You gotta loosen up in Little Italy . The lady at the cafe will kiss you when you meet her ... "]
['Did you get any rewards or honors in college ? ', ' Yes , I received the scholarship 3 times on end . ', ' Did you join the Communist Party of China ( CPC ) ? ', ' Yes , I joined the CPC when I was a freshman ']
['Your brand new car is so excellent . I like it very much . ', ' Let ’ s go for a joy ride . ']
['Are you watching the soccer match tonight ? It must be the most exciting one in this season . ', ' Well , of course I can ’ t miss it . Which team are you for ? ', ' Manchester United . What about you ? ', ' Me too . Do you think they are going to get the championship this time ? ', ' I have confidence in them . ']
["The weekend's finally here ! ", " And it's a long one . I have Monday off . It's Memorial Day or something like that . ", " Yep . It's the kickoff of the barbecue season . We're invited to a grill party in the park tomorrow . ", ' Sounds good . What do we need to bring ? ', " We need to buy some buns for the hot dogs and hamburgers , and I'm making potato salad . ", " I'll dig out the Frisbee and my kite from Taiwan . "]
['Hi , Martin . I ’ Ve been looking for you all morning . ', ' What ’ s up ? ', ' I want to say goodbye . I ’ m leaving for America tomorrow . ', ' America ? Did you get admit to MIT ? ', ' Yes . ', ' Congratulations ! Susan . I ’ m so happy for you . ', ' Thank you . ', ' Really going to miss you . ', ' Me too . I ’ ll write to you once I get settled . But I have so much to do . You might have to wait a while . But I really will write to you . I love to write letters . I think it ’ s more meaning than the emails even than the phone call . ', ' Ok . Take care . Have a nice journey . ', ' Thank you . ', ' Look after yourself . Bye . ', ' Bye . ']
["You know , Taylor's been in the hospital for a couple of days . ", " And I'm the one who put him there with my football moves . ", " But you're not to blame for them keeping him there . ", ' Yeah , what was all that stuff about running tests about anyway ? ', " I'm not sure , but we can find out . I bought some crosswords to keep him busy . ", " Great , then let's go visit him . I want to give him some flowers , too , to say sorry . "]
['Did you see Ally Mabel last night ? ', ' Yes , I did . Did you ? ', " Yes , wasn't it funny ? ", " Oh yes , I loved it . Wasn't the scene with the judge great ? ", ' Ha , yes , brilliant ! ']
['Look out ! Your tea water is running over . ', ' Oh , would you please turn off the fire ? My hands are sticky with the dough . ', ' Sure . ', ' Thanks . ']
['Did you see May today ? ', ' Yes , but why does she have such a long face ? ', " I don't have the foggiest idea . ", " I thought she'd be happy . ", ' Yeah , especially since she got a promotion recently . ', " I don't know . Maybe it ’ s some kind of personal problem . "]
["I don't think the teacher had a right to say that . The teacher was wrong to have accused her in front of the whole class . ", " You've got to be joking ! It's the teacher's right to say anything wants , and if she saw Myra cheating , she certainly had the right to say so . ", ' I agree she had the right to say something , but I feel she should have done it privately . ', " You're right . If I were the teacher , I wouldn't have done that . "]
['Come on in . I am so glad you are here . We have been expecting you . ', ' Am I late for the party ? Looks everyone is already here . Hope I didn ’ t miss something interesting . ', ' No , you are just on time . We haven ’ t really started yet . ', ' Great , here are some flowers for you . I hope you like them . I was not sure if the color will suit your new apartment . ', ' Thank you , they ’ re beautiful . You can hang your coat over there . Try this new couch , it is so comfortable . You will love it . Want something to drink , tea , coffee , juice or Cola ? ', ' Don ’ t bother . I will help myself . ', ' Make yourself at home . ', ' It is such a nice place . ', ' Well , I don ’ t mean to boast but all the designs are done by myself and some colleagues are already trying to copy some of them for their new apartments . Look , they are making photos now of my designed kitchen . ']
['Steven , would you like to go dance with us tonight ? ', ' John , I am just not in the mood for this . ', " You look so upset . What's going on ? ", ' I lost the table tennis game yesterday . ', ' Oh , what a pity ! ', ' I just don ’ t want to play table tennis any more . ', ' Is it that bad ? It ’ s nothing more than a game . ', " My opponent bowled me with the very first ball . I was wondering if it's appropriate for me to play table tennis . ", " Oh , come on ! Failure is the mother of success . Don ’ t lose heart . I'm sure you'll succeed . ", ' Perhaps you are right . But I still need some time to recover from the failure . ', ' I understand . ']
['The band is pretty good . How do you like the music ? ', " It's very nice . I haven't heard live music in a while . This is fun . ", ' Well , then , may I invite you for the next dance ? ', " Of course . But I'm afraid I'm not much of a dancer ... ", " Don't worry . I'm not much of a dancer myself . ", " You're dancing so well . ", ' You dance beautifully too . ', ' When did you learn to dance ? ', " In college . But I don't dance very often . What's your favourite dance ? ", " It's hard to say . It depends . But I love the waltz . ", ' How about tango ? ', " Oh , I like it . It's such a beautiful dance , but I can't do it well . What about you ? ", ' Tango is my favorite . Anything but hip-hop or the foxtrot . ( the music has stopped ) ', ' Thank you for the dance . ', " My pleasure . Let's go and have a drink . ", ' OK . ']
['I think the biggest environment problem in my country is air pollution . ', ' Yes , I agree . The air here is much more polluted than in my country . Of course , my country is more agricultural and has much less industry . ', ' We have reduced emission of air pollutants in recent years , but cars are still a major source of them . Factories have become cleaner as stricter environment pollution law have been introduced . ', " The problem is now on a truly global scale . I don't believe that any single country can do anything about it . ", " I think you're right . There needs to be an international response to this problem ? "]
['I just had a terrible week . ', ' What a shame ! ', ' I fell down and hurt my arm . ', " That's too bad . ", ' Then my son drove into a tree . ', " I'm sorry to hear that . ", ' The dog bit the delivery boy . ', ' What a pity ! ', ' And a storm blew our roof away . ', ' Ho , no ! ']
['I ’ m so excited , mother . Oh , a new baby ! ', ' My first grandchild . ', ' And my first nephew . He looks a lot like you , mum . He does . ', ' Do you think so ? Well , I guess . He does look a lot like me . Oh , he ’ s got Richard ’ s eyes though . ', ' Yes , he does have Richard ’ s eyes . The baby even looks like you than Richard does . ', ' Well , children usually resemble their parents . ', ' It ’ s true . Michelle is a lot like Henry in so many ways . And she is shy with new people just like he is . ', ' You often like comparing children with their parents . ', ' You ’ re right . ']
['When do you go to bed usually ? ', ' I go to bed at ten and get up at six . ', " That's helpful for your health . ", ' Sure . ']
['Have you been ever been to Disneyworld ? ', ' When I was young , my parents took me to the one in California . I always forget which — is that one Disneyland or Disneyworld ? ', ' The one in Florida is Disneyworld and the one in California is Disneyland , so you must have been to Disneyland . ', " That's right . Why do you ask ? ", " Well , I've never been to either so I was thinking of going to Disneyworld for my honeymoon . ", ' When are getting married ? ', " Some time next year . We haven't set the date yet . ", ' Congratulations ! I had no idea . ', ' Thank you . So what do you think ? Would we have a good time ? ', ' Do you like amusement parks ? ', ' For the most part , yes . Some of the rides are bit too scary for me , though . ', " If you don't think twice about the rides and go on every ride that you can , you'll have a good time . ", ' Even the roller coasters that go through tunnels in the dark ? ', " Even those . It'll be very romantic , I think . You'll have loads of fun . ", " Thanks for the advice . I'll talk to my fiance about it tonight . ", " I'm sure he'll love the idea . Just throw yourself into it and you'll enjoy it ! "]
['Can you speak French ? ', ' Yes , I can , but not very well . ', ' Can you understand your Spanish teacher ? ', ' More or less . How well do you understand Mr . Wang , your Chinese teacher ? ', ' About 40 percent , if he speaks slowly.When he speaks fast , I can only catch a word here and there . But Mr . Wang is an excellent Chinese teacher.With his help , my Chinese is getting better and better e ']
['you look better today . How did your test go ? ', ' much better than it did yesterday . ', ' did you pass ? ', " I not only passed my test , but I aced it ! I'm so happy ! ", ' you should be . You worked really hard last night preparing for it . ', " thanks for helping me with it . If you hadn't encouraged me to do my best , I wouldn't have ever been able to pass . ", " you don't have to thank me . It's just a part of my job as your counsellor . ", ' did you always do well at school ? ', ' no , in fact , I was terrible at taking exams . ', ' really ? ', ' sure , but my teachers always encouraged me to do the best that I could and that helped me a lot . When are your final exams ? ', " I'll get my finals in two months . ", ' when do you plan on studying for those exams ? ', ' most students just cram the night forehead . ', " do you think that's a good idea ? ", ' no , I think I should study a little bit at a time , starting a few weeks before the exam . ', " that sounds like a good idea . What are you going to do if you have any questions while you're studying ? ", " I'll go and talk to my professor or a learning support assistant . ", " it sounds like you've learned something useful this year ! "]
['Can I borrow your Cds for our school dance ? ', " Oh , you don't ask much , do you ? ", ' I promise I will personally guard every single one and they will come back in perfect condition . ', " I'll tell you what . Your class can rent them from me for the night and buy back any damaged ones . ", " That sounds fair . That's still cheaper than paying a band to come play for us . ", ' Not as fun though . A live band is way more exciting ! ', " Our class doesn't have enough money . We already checked into it . ", ' Let me know with your next dance . I know a band that may give you a break for the publicity . ']
['Do you want to go to the beach tonight ? ', ' Sure , which beach are we going to ? ', ' I wanted to go to Malibu beach . ', ' I like Santa Monica . ', ' The water there looks so dirty . ', ' I just like the pier they have at Santa Monica . ', " I like the pier too , because it's beautiful at night . ", ' Is Malibu beach nice ? ', " It's a lot nicer , and I really like it better . ", ' So you want to go to Malibu ? ', " If that's okay with you . ", " Sure , let's go to Malibu . "]
['There are so many environment problems in the world today . Do you think we can really solve them all or will destroy the world ? ', ' I hope that world leaders can get together and agree on a plan for action , but I doubt it ’ ll happen before it ’ s too late . ', ' We need to solve the problem of air pollution before we destroy the atmosphere . There ’ s lots of clean , modern technology , but companies in developed countries say it ’ s expensive . Developing countries put more emphasis on economic development than on environment protection . ', ' Everyone is looking at the issue in the short term , rather than the long term . It ’ s the same with the destruction of the rainforests . Countries and companies just want the wood . They ’ re not thinking about the long-term damage to the forests . We should also remember that the forests are an important natural habitat for thousands of species of animal and plant life . ', ' In other parts of the world , especially in Africa , there is a problem with desertification . Climate change and over-farming are causing farmland to turn into desert . In means that people cannot grow enough food . ', ' It also means that people sometimes fight over the famp 3land that remains . Damaging the environment actually leads to conflict between people . ', ' Have you ever thought about joining an organization committed to protecting the environment ? You could get involved with projects to improve the environment . ', ' I think I ’ d like to do that . I could take the things I learn here back to my country when I have finished my studies . ']
["Kathy ! How are you ? It's been ages ! What are you doing these days ? ", " I just opened my own restaurant . I'm also head chef . ", " You're kidding ! You've always hated cooking ! ", ' Well , I used to hate cooking , but now I love it . ', ' When did you change your mind ? ', ' After I tried French food . Before that , I used to cook really boring things for my family . ', " I still can't believe it ! So , did you go to cooking school or something ? ", ' Yeah . I went to California to study . ', ' Really ? How long did you stay there ? ', ' I was there between 88 and 90 . ', ' And what did you do after that ? ', ' Then I came back here . I worked for about three years to get some experience . ']
['Susan , I am inviting you and Frank to our house warming party this weekend . ', ' A house warming party ? ', ' Yes , Deborah and I are going to buy a new home in Woodlawn . ', ' Congratulations ! That ’ s wonderful . I bet both of you are quite happy . ', ' Well , we have always dreamed of owning our own home , but real estate 1 in this area is extremely expensive . ', ' I understand . That ’ s why Christopher and I want to find a place in a small town , far from the city . ', ' That ’ s a good idea if you can find employment nearby . ', ' I agree . That ’ s why Christopher is already looking for a job in Maine , or Wisconsin . ']
['What can I do for you ? ', ' I am trying to find this book . ', ' What ’ s the problem ? ', ' It doesn ’ t seem like this library has it . ', ' Have you checked the computer ? ', ' I have already . ', ' What did it say ? ', ' It says the book is on the shelf , but I didn ’ t find it there . ', ' I can always borrow the book from another library . ', ' You can do that ? ', ' I ’ ll make the call and contact you when it gets in . ', ' That ’ s fantastic . Thank you . ']
['ABC Rent-a-Car . May I help you ? ', ' I would like to rent a car . What kind of car do you have ? ', ' We have Volkswagen , Pinto , Plymouth and Datsun . ', ' What is the rate ? ', ' Twenty dollars per day for Volkswagen , Pinto and Datsun , and twenty-seven dollars for Plymouth . ', ' How about mileage and gas ? ', ' There is no charge for mileage . And fill up the gas when you return the car to us as it is not included . ', " OK . I'll try a Pinto . I want to rent a car for one week . ", " All right , sir . May I have your driver's license ? ", ' Here you are . ']
['Would you be willing to accompany me to the party tonight ? ', " Sure , I'd love to . "]
['Which film shall we see ? ', " There is nothing good at the moment.Let ' s do something different.Would you like to go to a concert ? ", " Yes , I'd love to.Here is a good one , Mozart and Beethoven.It ' s on the Festival Hall . ", ' Fine ! Do you want anything to eat now ? ', " No , I'm not hungry . ", " Well , let's go and have something to drink instead . I know a good place . It's a little expensive , but it's fun . "]
["Spring Festival is the most important festival in China , isn't it ? ", " Yes , that's true . ", ' How long is the holiday ? ', " It depends.But usually it's about 15 days . ", ' Do you eat any special food for the festival ? ', ' Yes , dumpling is a must.There is also other food.For example , people eat chicken for good luck . ', " That's interesting . I'm told the Chinese firework is very beautiful , isn't it ? ", " Yes , it's really wonderful ! ", ' Oh , great ! I hope I can spend this Spring Festival with you here in Beijing . ', " I'm sure you'll have a good time . "]
["I'm really sick of waiting for a bus . ", ' Yeah.Especially when you have something urgent to do . ', ' But a taxi costs too much . ', " That's true . "]
["I feel absolutely horrible . My temperature is 41 degrees Celsius , and I've got a headache and a runny nose . ", ' do you have any other symptoms ? ', " I've also got a terrible stomach-ache . Is my face still swollen ? ", ' just a little . Has your toothache gone now ? ', " yes , for the most part . It doesn't feel as bad as my other ailments , anyway . ", ' how about your tongue ? Does it still hurt ? ', " no , the burn ointment seemed to take effect right away . I think it's already healed . ", ' how did you get that burn again ? ', ' I scalded on the hot coffee a few days ago . ', " you haven't had much luck lately , have you ? ", " no , but I'm sure I'll get better soon . ", " when's the last time you took your tablets ? ", ' I took the red ones just before lunch and the white ones just after lunch . ', " I think it's time you took another does of each . What would you like to drink with them ? ", ' just some water , please . Do you have any ointment for my nose ? It feels so itchy after blowing my nose so much . ', " sure , I'll just go and get it now . what would you like to eat ? Some soup ? ", ' that sounds good . ', " soup always makes me feel better when I'm sick . I hope it makes you feel better , too . "]
["I haven't got enough evidence for prosecuting him . ", " Why don't you find someone who is in the know . ", " I'm just thinking about that , but the trouble is , I don't know who is well in the know . ", ' Did you ask his former secretary , Lora ? She knows a lot about him . ', " Thanks for reminding me . She's the right person to help me . "]
['What are you two doing in here ? ', " We heard you weren't feeling well , so we came to check on you . ", ' I was sitting there giving out nametags and all of a sudden , there she was . ', ' Who , Femi ? Yeah , Yi-jun saw her inside . ', ' All these memories of prom night came back to me . I had to be alone . You remember that night ? ', " I remember someone spiked my punch . You sat with me in the girl's bathroom ... "]
["You're not looking happy.What ' s the matter ? ", " Oh , nothing special . I'm just a bit tired . ", ' With the job ? ', ' With everything , with everybody , with all this ! ', ' A good suggestion for you.You need a holiday . ', " It wasn't always like this , you know . ", ' What do you mean ? ', " Well , I mean.We always do the same thing.There ' s no variety in our lives . ", " You need a holiday.That ' s what's the matter . ", ' Certainly , perhaps . ']
["Oh dear , Miss , you are soaked ! Wow , it's really raining heavily outside . ", " Yes , it sure is . I had to run here from work ! I need to rush as I'm on my lunch break . ", " Well please , why don't you go ahead of me in line ? I'm in no hurry . ", " Oh , that's so nice of you ! Thank you very much . ", " My pleasure Miss . Actually , could you recommend what to eat here ? I've never been here before . ", " Sure . Well , the avocado sandwich is delicious , and it's the healthiest thing on the menu . Personally , I think the beef salad is the tastiest choice . I usually get that . Also , the milkshakes are the best milkshakes in town ! ", ' Well , thanks for the suggestions . ', " Oh , don't mention it . "]
["Dad , what's the date ? ", " It's December eighteenth . ", ' In seven days it will be Christmas Day . ', ' Yes , I know that . ', ' So , can I buy some new shoes as a Christmas present ? ', ' Sure , a promise is a promise . ']
['What happen , John ? ', ' Nothing . ', ' Why do you look unhappy ? ', ' I ’ m rather disappointed at not being able to see my best friend off . ', ' Oh , cheer up . He ’ ll understand you . ']
['This man is your fiance , Dolly ? ', ' Yeah , how do you like him ? ', " He's handsome . ", ' Can you give me a touch of his character ? ', " He's outgoing and honest , but sometimes he's a bit conservative . "]
['Do you think I should buy this now and bring it with us ? ', " Don't bother . those are a dime a dozen where we are going . "]
['Brooke , are you still mad ? Is your mom mad ? ', " No ... mom said that we'll have the wedding at home on the 2nd . So let's hope your mom is right about that being a lucky day ... ", ' It will be . And today is , too . I just talked to the airlines ... ', " They're going to give us back the seats ? ", " No , they're giving us discount tickets on a honeymoon package in ... ", ' Hawaii ? My dream honeymoon destination ? ', " You got it ! We'll fly there directly from Texas . ", " Oh , Jack ! That's wonderful ! "]
['The world changes , the family changes too . ', ' What do you mean ? ', ' People now like a small family composed of two parents and one child . ', ' That is called a nuclear family . ', " I don't like such a family . ", ' What kind of family are you like ? ', ' I like a family composed of many people . It includes grandparents , parents , aunts and uncles , and children . ', " It's a traditional family . It may be too large to live well . ", ' We can live well , I think . ']
['What was that all about ? ', ' We had a difference of opinion . ', ' Is she going to be okay ? ', " She'll be fine . "]
['Is sailing fun ? ', ' You bet ! ']
['John dates her seven times a week . ', " Really ? That's a straws in the wind . ", " I think so . Maybe he's fallen for her . ", ' Yeah . They suit each other . A perfect match between a man and a girl . ', ' Right . ']
["I was told my friend Joe was speaking ill of me . That's a real let-down . ", " I don't think Joe has done such a thing . Don't believe things in haste . ", " Maybe I should go and ask him whether it's true . "]
['Good morning , Loans . ', ' Good morning , Mr . Smith . ', ' I would like to compliment you on your diligence . ', ' Well , thank you , Mr . Smith . But I was just doing my job . ', " Yes . And we're proud of you , Loans . ", " It's nice of you to say so . "]
['Which countries have you been to ? ', ' I ’ Ve been to most of the countries in Europe , several countries in asia-china , Japan , korea , and Thailand-and to the united states and Canada . ', ' I thought you had been to Australia too . ', ' No , but I ’ m planning on visiting Australia and new Zealand soon . I ’ Ve heard that they are beautiful countries . Which is the most beautiful country you ’ Ve been to ? ', ' I think I ‘ d say norway . It has many picturesque fjords , waterfalls , and mountains . ', ' Isn ’ t it really cold there ? ', ' Well , the north of Norway is almost always cold , but further south it can be fairly warm in summer . It ’ s a wet country , so there ’ s snow almost everywhere in winter . ', ' I ’ Ve been to other Scandinavian countries , but not to Norway . Perhaps I should go and do some winter sports there . ']
['Alison , would you like to have some more ? ', ' No thanks . I have had enough . ', " Actually you haven't have much . ", ' To tell you the truth , I am on the diet . ', ' That sounds ridiculous . Why ? ', ' Well , I am gaining weight these days , and I have to watch my calories . ']
['Welcome to my birthday party , I am so happy you can come . ', ' Thanks for inviting me . Here is the gift for you . Happy birthday , Francis ! Many more happy and healthy years for you ! ', ' Thank you , shall I open it now ? ', ' Yes , please do . ', ' Wow , a remote car model and my favorite brand . I really like it . That is so nice of you . ', ' Yeah , I was really struggling whether I should give you this nice little car . It was the last one they had and I really like it so much myself . ', ' Typical you , always wanting to keep the best things for yourself . The more I appreciate the gift now . ']
["Did you read the news that ' China's property prices rose at the fastest pace in 18 months in December , ending the year with rising fears of bubbles in the property market ' ? ", ' No . Does the newspaper say what has caused that ? ', ' Yes . It says the hike was a result of purchase rush in the fourth quarter on expectations of tightening politics . ', ' I think the government should make a serves of moves to cool the market . ', ' Right . The climbing property prices has become a headache for Chinese residents . ']
['I think that show biz stars have a really easy life . They have lots of money , so they can buy almost anything they want . They ’ re famous , so everyone loves them . ', ' I think they must have horrible lives . All the paparazzi take photos of them wherever they go and whatever they do . They must get sick of it . ', ' I bet they love it really . Sure , they complain about it , but that just gets them more publicity , doesn ’ t it ? ', ' I think that few of the show biz stars want any publicity for themselves . They only want it for their films . ', ' No way ! They want publicity for themselves , so that they get invited to make more films , go to lots of cocktail parties , and even make albums ! They have such an easy life . They don ’ t even pay for drinks when they go to a cocktail party . ', ' Show biz stars have plenty of expenses . That ’ s why they need so much money . They need million of dollars to buy big , seclude houses and wonderful dresses . I bet most show biz stars would prefer to wear jeans and a t-shirt , but they can ’ t because their managers force them to wear clothes they don ’ t like . ', ' I don ’ t understand how you can have any sympathy for show biz stars . They ’ re overpaid , over-ambitious , and over-adored . ', ' I think you should give them some credit . They ’ re very talented people and they deserve all the money they earn . They even donate money to charity to help people who are less fortunate than themselves . ', ' Come on ! They only do that to get even more publicity for their films and themselves 。 ']
['Hi , it is a pleasant surprise ! ', ' Yeah , it ’ s been ages ! So how have you been ? ', ' Couldn ’ t be better . And you ? ', ' Just as usual , you know . ']
['Hey , Mary , can you cut that out ? ', ' Cut what out I ’ m not doing anything . ', ' The tapping of your pen on your desk . It ’ s driving me crazy . ', ' Fine ! By the way would you mind not slurping your coffee every time you have a cup ! ', ' I don ’ t slurp my coffee . And plus , how can you hear it when you ’ re shouting into your phone all the time ? ', ' You ’ Ve got to be kidding me ! You ’ re complaining about me talking on the phone when you go out for a cigarette break ten times a day to shoot the breeze ? ', ' Look , we have a lot of accumulated anger from working in these conditions , and it ’ s probably okay to let off steam once in a while . But , it ’ s probably not a good idea to keep it up I ’ m willing to forgive and forget and if you are . ', " Fine . Let's call a truce . I'll try to more considerate and to keep the noise down . ", ' Yeah , I ’ ll try to do the same . So , I was wondering you wanna go out to dinner Friday night ? ']
['The weather in Beijing is just beautiful ! ', ' Autumn is the best season in Beijing , you know . ', ' Yes , I can see . The summer heat is over , and the winter cold is still far away . ', ' What is the weather like in Washington at this time of this year ? ', ' Autumn is also very nice in Washington . ', ' Is it very cold in winter there ? ', " No , it isn't . But sometimes it snows a lot in winter . ", ' Does it rain a lot in summer there ? ', ' Oh yes ! Sometimes it rains very heavily.How about here in Beijing ? ', " There's a lot of rain in summer , but it seldom rains in autumn . ", " I feel it's rather dry here . ", " That's true . Many people from the south don't like the weather here . ", ' Are you from the south ? ', " No , I'm from the north . I was born in Beijing , actually . ", ' I see.so this is your hometown ? ']
['Mike , come and look at this painting of shrimp ! It is so simple yet so vivid ! ', ' Yeah . It is incredible ! Is it the work of Qi Bakshi ? ', ' Yes , it is . How do you know that ? ', ' Well , Qi is famous all over the world , isn ’ t he ? Besides I am quite interested in Chinese painting . ', ' Cool ! What kind of Chinese painting do you prefer , free sketch or claborate-style painting ? ', ' I prefer free sketch , especially the landscape paintings . I can always feel peace and harmony from those landscape paintings . ', " That's true . Chinese art stresses the harmony between man and nature , which is an important part of China's traditional culture . ", ' I love this art exhibition ! ', ' So do I . Let ’ s go to other areas to see what they have got , shall we ? ', ' OK . ']
["Lousy weather , isn't it ? ", " It has stopped snowing , but it's even colder . ", ' Look at the ice there hanging from the eaves . ', ' And the streets are covered with snow . ', ' Do you know what the temperature is today ? ', " I missed today's weather forecast over the TV . ", " It feels like ten degrees below zero at least . I don't mind the cold weather but I do hate it when it gets slippery . ", ' The ice will soon be thick enough for skating . I am so fond of winter sports . ', " That's great . Let's go skating together tomorrow . "]
["Nick , it's very nice of you to see me off . ", " You're welcome . Did you have a good time on this vacation ? ", " Very well . If I leave I'll miss you . ", ' Me too . Please write to me as soon as you get Boston . ', " I'm sure and I remembered your phone number . I'll call you . ", ' OK , they begin to register . ', " It's time I left . ", ' Have a nice journey ! Do give my regards to your parents . ']
['What are your working hours ? ', ' Eight to twelve in the morning , two to six in the afternoon . ', ' Much better than mine . ', ' What are your hours ? ', " Mine aren't fixed . Sometimes I do the day shift , sometimes the night shift . "]
['Would it be all right if I went home next weekend ? ', ' For What ? ', ' Well , I want to surprise my brother showing up for his birthday . ', ' Well , that sounds like it would be OK . Just be careful . ']
['Could you tell me what university you went to , Mr . Smith ? ', ' I went to Yale University . ', ' Did you ? And what did you study ? ', ' I have a B . A . in Economics . ', ' Would you mind telling me how old you are ? ', " I'm twenty-seven . ", ' And could you tell me what other jobs you have had ? ', ' Yes , I have worked in a bank for the last years . ', ' And what was your salary at the bank ? ', ' I got $ 500 a week . ']
['Hi , Jane . How are you doing this morning ? ', " I'm all right , thanks . Just a little tired . ", ' Late night ? ', ' Yeah , I got home around two . ']
['I am going to celebrate my birthday with you all in a night club this year , what do you say ? ', ' Fantastic ! I enjoy clubbing , especially those clubs with live bands . The only fly in the ointment is that the air is bad , full of smoke , and the music is too loud , so conversations are not really possible . Once I nearly got burnt by a cigarette . ', ' How did that happen ? ', ' A wild dancer dropped it on my left foot and said nothing about it . If I had drunk enough and I would have had the bold to punch him in the face . ', ' Sounds cool ! But that is not what a lady should do . People are easy to lose head in a night club and being drunk . ']
['What do you do for a living ? ', ' I ’ m a doctor . ', ' Really ? Do you like it ? ', ' Yes , I do . It ’ s very interesting . What ’ s your job ? ', ' I ’ m a bus driver . ', ' Oh , do you enjoy it ? ', ' No , I don ’ t really like it . It ’ s boring . ']
['what a nice garden ! Look at these tulips ! ', ' that would be a good shot . Can you take my picture here , dear ? Please try to get the garden in the frame as well . ', ' all right . Would you please stand closer to the flower bed ? Good . Smile . Say " cheese " . OK , got you . That\'s terrific . ', ' thanks . Could you take one more from this angle ? ', ' no problem . ', " now let's have one together . ", ' do you know how to set the timer ? ', ' let me see ... set the timer first and push the button , oh , come here . ', " OK , let's have a try . ", ' cheese ... ', ' did it come out ? ', " yes , but it's blurred and a little dark . ", " never mind . Let's go to the falls and try again . ", " Ok , let's go . "]
['Did you watch television last night , Charles ? ', ' Yes , I did . ', " It was a good game , wasn't it ? ", " Oh , I didn't watch the football match . I wanted to but my wife preferred to see the old film . ", ' What a pity . It was quite exciting . Both teams played very well . ', ' How did it finish ? ', ' It finished in a draw . What was the film like ? ', ' It was quite good . But . I missed the beginning of it because I had to eat first . ', ' Did your wife enjoy it ? ', " No , she didn't . After half an hour she stopped watching and started to read a book . "]
['Hey , Vernassa . why be angry look ? ', " It's the new neighbor . I hate her guts . ", " I've never seen you so worked up . what did she do to you ? ", ' She made another white crack about my clothes . ', ' Are you sure she was trying to put you down ? ', ' Of course , I am sure . ', ' You shall go easy on her . she is new here . ', ' Just how am I supposed to do that ? ', ' You shall just take it in surprise . ', " I've tried , but she keeps pushing my buttons . ", ' Try to pull it together , Vernassa . I am sure things will turn note , ok ? ', ' I am not . she is no picnic . ', ' Well . if you think I can help , let me know . ', ' Thanks , Serena . ']
['I ’ m forming a music band . ', ' Do you already know how to play an instrument ? ', ' Uh ... Yeah ! I ’ Ve told you a thousand times that I ’ m learning to play the drums . Now that I know how to play well , I would like to form a rock band . ', ' Aside from yourself , who are the other members of the band ? ', ' We have a guy who plays guitar , and another who plays bass.Although we still haven ’ t found anyone to be our singer . You told me that you had some musical talent , right ? ', ' Yes , I ’ m a singer . ', ' Perfect . So you can audition this weekend here at my house . ', ' Great ! Wait here ? You don ’ t have enough room for the amplifiers , microphones or even your drums ! By the way where do you keep them or practice ? ']
["I've heard you're going to America tomorrow . I want to see you off at the airport . ", ' Oh , thanks a lot . ', ' What time are you leaving ? ', " 1 thirty P . m . But I've got to check in at 12 thirty P . m . ", ' What airline and what flight ? ', ' Pan American Airlines . Flight 282 . ', " I'll see you at the airport at 12 thirty P . m . ", ' Ok . See you tomorrow . ']
['I ’ m sorry , dad . But you can ’ t do that . It ’ s for me to decide . ', ' Oh , I see . You ’ Ve already decided , have you ? Now , you listen to me , you ’ re only 19 . ', ' I didn ’ t say I ’ d already decided , dad . I said it was for me to decide . There is a difference . ', ' Oh . So you think you can just do whatever you want , do you ? ', ' I didn ’ t say that either . I was hoping we could discuss the matter together . I want your advice but I don ’ t want you to tell me what to do . I ’ Ve got to make decisions for myself , dad . ']
['Hello , Friendship Restaurant . May I help you ? ', " I'd like to book a table tonight . ", ' Yes , Sir . For how many people , please ? ', ' Eight . ', ' What time ? ', " Eight o'clock tonight , would you please set us in a private room ? ", " So sorry , we're fully booked in that room . Would you like to make reservation some other time ? ", ' Maybe not , thank you all the same then . ']
["Hey , Zina . You're here early today . ", " Yeah , I'm going to be making phone calls all day . What a blast . ", ' I just wanted to say thanks for putting us on the map so fast . I appreciate it . ', " Save it , Vince . After I put my first million in the bank , I'll say you're welcome . ", ' Fair enough.Keep up the good work . ']
['That is the most beautiful sunset ! ', " Let's stop the car and enjoy it for a minute . ", " Here is a good place . Let's get out . ", " Wow . We don't get to see this in the city ! ", ' Mother Nature is quite an artist . ', " Look behind us at the mountains ! They're reflecting pink ! ", ' Amazing . The sun is almost gone and yet there is still color everywhere ! ', " Where is our camera ? Let's see if we can catch this on film ! "]
["What a nice day ! Why don't we go for an outing ? ", ' Sure.Where would you suggest ? ', ' How about going to the suburbs ? ', ' Sounds good . ']
["Why didn't you tell me you had a girlfriend ? ", ' Sorry , I thought you knew . ', ' But you should have told me you were in love with her . ', " Didn't I ? ", " You know you didn't . ", " Well , I'm telling you now . ", ' Yes , but you might have told me before . ', " I didn't think you'd be interested . ", " You can't be serious . How dare you not tell me you were going to marry her ? ", " Sorry , I didn't think it mattered . ", " Oh , you men ! You're all the same . "]
['Hi , Bill . ', ' Hi , Jim . ', ' Where is that cool guy , Dick ? I haven ’ t seen him for two weeks . ', ' He ’ s been sick since he came back from Italy . ', ' Bummer , I ’ m sorry to hear that , is he better now ? ', ' Yes , Doctor William said that he could come back to work ASAP . ']
["Where's Tom this evening ? ", " He's a little sick under the weather . ", " Really ! What's the matter with him ? ", ' He has the flu . ', ' Tell him I was asking about him . ', ' I will . ']
['Maybe you should talk to the teacher . ', " No , it's no use . ", ' You never know unless you try . ', " I know . She won't change my grade . "]
['well , I finished my last final today . ', " the end of all the hard work for my master's . what a nice feeling to get my degree ! ", ' do you want to attend the convocation ? ', " certainly . After years of hard work , I wouldn't miss it . By the way , where can I find cap and gown ? ", ' do you want to have them made or do you want to rent them ? ', " oh , I think they're provided by the school for that special day . ", ' no . those you have to provide for yourself . ', ' what do most of the students do ? ', " well , most of them only need a cap and gown for that particular convocation service , but some of the education majors have had them made , because they will be faculty members , and they'll need them f ", ' then , I might as well have them made . ', " Mary , don't move . Stand right there . It's a good shot . The background is very pretty . ", ' hold it a second . I want to fix my hairpin . ', " it doesn't matter . Say'cheese ' . ", " here's Lisa . May I take a picture with her ? ", ' Certainly . Ok , got you . ']
['Do you mind if I ask you a question ? ', ' No , not at all . Go ahead . ', ' What do you do in order to improve your English ? ', ' I go to movies ; I go to lectures ; I listen to the radio ; I do lots of things . Most importantly , I practice every chance I get . ', ' It ’ s a good idea to have a radio , isn ’ t it ? ', ' Sure . It ’ s like understanding on the telephone — — you can ’ t see the speaker ! It ’ s great for improving listening comprehension . ', ' It takes a long time to learn a language , doesn ’ t it ? ', ' It certainly does . But if you practice speaking every spare minute and learn useful sentences every day you can make big progress . ']
['Good morning , Sue . ', ' Good morning , Tom.How are you ? ', " I'm fine , thanks , how about yourself ? ", " Things couldn't be better.Where are you going now ? ", " I am heading for the library . I've got a research project to do.How about you ? ", " I'm going to the English class.It ' ll start in five minutes , I've got to run . ", ' See you later , alligator . ', ' After a while , crocodile . ']
['Is the environment a big issues in your country ? It is in mine . ', ' It is in mine too.The biggest issue is water . The climate is dry and so water conservation is very important . ', ' What methods do you use to conserve water ? ', ' Water is rationed . We can only use a certain amount each month . It means that we cannot use some modern household items , like washing machines . They use too much water . ', ' I see . I think the biggest environment problem in my country is air pollution . ', ' Yes , I agree . The air here is much more polluted than in my country . Of course , my country is more agricultural and has much less industry . ', ' We have reduced emission of air pollutants in recent years , but cars are still a major source of them . Factories have become cleaner as stricter environment pollution law have been introduced . ', ' The problem is now on a truly global scale . I don ’ t believe that any single country can do anything about it . ', ' I think you ’ re right . There needs to be an international response to this problem . ']
['Hurry up . Time is running out . ', ' I see . I have run as fast as I can . ']
['Hi Cody , how did practicing go this week ? ', ' Well I had several tests and an oral presentation this week so I didn ’ t get a chance to memorize the second page , but I think I mastered the tricky section . ', ' Great ! Warm up with some scales and arpeggios first . Good , good . This week , work on keeping the rhythm steady when you play the last part with the sixteenth note . Now let ’ s take a look at this ', ' Charles ? Before I start I was wondering if it was ok if I put a small crescendo in here and then decrescendo back to pianissimo again over here ? ', ' It might work . I ’ ll have to hear it.Show me what you ’ Ve done . ', ' It was horrible ! I played play it much better at home ! ', ' It ’ s just nerves . Just play the right hand for now . One two three four five six , ta ti tri-ple-ti . Good , good . Don ’ t forget the accidentals ! The key signature says that note should be a G-sharp b ', ' Is that better ? ', ' Yes , much better . Watch where you lift your foot off the pedal . What was that ? ', ' Sorry ! The stretch for that octave is always hard to make . ', " That's ok , keep going , you ’ re moving ahead by leaps and bounds . Watch your dynamics ! Keep your elbows lifted . Remember to stroke the keys , don ’ t pound . That ’ s better ! Remember that as a pianist or any "]
['Can you tell me the time ? ', " It's 5:30 by my watch . ", ' Is your watch right ? ', " Yes . There's only a few seconds in a whole month . "]
["I heard that you're going on your first date Friday night . ", ' Are you angry , Lisa ? ', ' Angry ? Why would I be ? ', " Please don't tell my mom . ", " Come on . Dating is a part of young people's social life . Besides , you're sixteen already . ", " I'm glad that you see it that way . ", ' Do you want to borrow my coat ? I have a black coat that would look smashing on you . ', ' Thank you so much , Lisa ! ']
['Hi , Mary , long time no see . ', ' I heard through the grapevine that your getting married . ', ' Yes , next March . ', ' Congratulations , I hope everything works out . ']
["Jim and you are bosom friends , aren't you ? ", " I wouldn't say so . ", ' What do you mean ? ', ' Well , I thought he was , but he ends up to be a con man . ']
['is everything alright ? ', ' yes , everything is fine . ', ' what took so long ? I thought your flight was supposed to arrive 3 hours ago ! ', " didn't they announce that our flight was delayed ? ", " I didn't hear anything about a delay . I thought everything was running on time . What happened ? ", ' we boarded the plane on time , but then we were held up for almost an hour due to a maintenance problem . ', ' then what ? Your plane was three hours late ! ', ' we finally took off , but about 30 minutes later , the captain came on the loudspeaker to warn us that there would be some bad turbulence for most of the flight . ', " turbulence is pretty normal , isn't it ? ", " yes , but this was the worst turbulence I'd ever experienced in my life ! Everyone started getting sick . The flight attendants had to stay in their seats . The captain decided to land early . ", ' so where did you land ? ', ' we landed in Southampton and waited an hour for the storms to pass and then took off again . ', ' that sounds like a nightmare ! ', " it wasn't too bad . At lease I'm alive . ", ' have you had anything to eat ? ', ' I managed to get a sandwich from a flight attendant . How about you ? ', " I had a few coffees while I was waiting . Let's get out of here ! "]
["I've got some bad news about the bike you lent me . ", " What's that ? ", " I fell on the way to school , and your bike got scratched . I'm really sorry . ", " Don't worry about it . It's not new , it already has a few scratches . Did you get hurt ? ", ' No , thank you . ', " That's the most important thing . ", " It's kind of you to say . I feel a little stupid . ", ' Forget about it . ', ' When you lent me the bike , it looked brand new , almost anyway . ', " Maybe , but really I have fallen a couple of times and it's been hit once or twice as well . ", ' I appreciate that , thank you . ']
['What date is it today ? ', ' Today is December 23,2002 . ', ' Oh , the day after tomorrow is Christmas . ', ' Merry Christmas to you ! ']
["Hello ! I'm Penny , I moved here just now . ", " Oh , Penny , I'm Leonard , glad to meet you . ", " Nice to meet you , too . I thought I should come and say hello to you . I haven't known anybody . ", " It is hard to get used to a new place , isn't it ? ", ' Yes . Would you like to come here later to have a coffee ? Bring all your family . ', " We'd like to . Can you tell me when we go ? ", ' About 4 . ', ' OK . Do you want us to bring something ? ', ' No , just come here . ', ' OK , see you later . ', ' Bye . ']
['You know what , last night I almost got hit by a vase falling from the third floor . ', ' Oh , how dreadful ! I ’ m ever so sorry . ', ' Luckily that was nothing serious . ', ' Thank God ! ']
['I do feel like a trip to Florida on such a gloomy day in New York , to enjoy the sunshine while lying on the beaches of Florida . ', " That's a great idea . It's the best season for tourists in Florida . You can also get a good sun-tan there . ", ' But if the sunshine is too strong , it might damage the eyes and the skin . ', " You can put on your shades . And remember don't make your skin look like a tomato . Or else after that your skin will begin to flake off . You may even wind up with skin cancer . ", ' I see . Overdoing it will do more harm than good . ', ' You said it . ']
["I just finished reading this article ' Getting Old Gracefully ' . It's a very good article . ", ' What does it say ? ', ' A lot of things . There is a part about how old people should accept being old and stop feeling restless . You really should read it . ', " Thank you . But I don't think I'll bother . ", " Why not ? What this article says makes good sense to me . If you read it , I'm sure you'll agree with me . ", " I don't think I'll have any trouble with getting old . But perhaps you can keep the article for a while , I may read it later . "]
['Thanks for coming shopping with me . ', " I'm so honored that you thought to ask me . ", " I've never given a speech in front of a thousand people before . ", " You're going to do great . And you're going to look great . ", " Thanks . Now let's decide which one of these suits looks best for this occasion . ", " I still like the olive one best . There's a tailor here who can take up the sleeves for you . ", ' The question is , can he have it done before Friday ? ', " These guys are professional . I think they can have it done tomorrow . Let's ask . "]
['I love slim girls , don ’ t you ? ', ' Not particularly . I like fat girls . ', ' And I like a girl with good skin , do you ? ', ' I can ’ t say I do . What I like a girl with good manners . ', ' Well , yes . But surely you like a girl with a nice figure . ', ' Yes . But I like a girl with a nice personality . ', ' But you like a girl to be rich , surely ? ', ' Not particularly . I like a girl to be good . ']
["What's going on here ? ", " We're waiting in line to get one of Master Li's Chinese couplets . I got one last year and I had good luck all year ! ", " Master Li ? Who's that ? ", " He's Taipei's most famous calligraphy master ! Quick ! Get in line ! ", ' I will ! I could use some good luck ! ']
['I suppose you like cinematography and costumes and that sort of stuff ? ', ' Yes , I do . The look of a picture is very important . ', " I think sound is even more important ! Guns , bombs , sirens--that's what makes a movie exciting ! ", " You wouldn't know a good movie even if it bit you on the nose . ", ' In my book , all a good movie needs is a chase scene and lots of things that blow up . ', " Enough ! If we don't finish the game , there won't be time for any movies tonight ! "]
['What day is today ? ', " It's Thursday , I think . ", " Tomorrow is Friday . It's going to be the weekend . ", " We're busy on weekdays , but we'll have a good rest at the weekend . ", " We'll meet again in a few days . "]
['I decided to go for this kind of life . ', " Try to keep cool . It's not an easy take . ", ' I know . I always hope for the best and prepare for the worst . ', ' Then you will be in line for a doom . ']
['What day is it today ? ', " It's Friday . "]
['Are you new to this school ? ', ' Yes , I ’ m new . ', ' Is this your first year in college ? ', ' I transferred from another school . ', ' Where did you transfer from ? ', ' I was at PCC before . ', ' Why did you transfer ? ', ' I was going to go here first , but my grades weren ’ t good enough . ', ' Did you like it at PCC ? ', ' PCC is an incredible school . ', ' Well , I wish you luck here . ', ' I ’ m sure I ’ ll like it here . ']
['There is something wrong with my girlfriend . ', " What's the trouble ? ", ' The department manager is all over her . He says he loves her . ', ' What about your friend ? Did she fall for him ? ', " Of course not ! She thinks he's an apple-head . She doesn't like an apple-headed man , you know . ", " Now you don't have the butterflies in your stomach , do you ? "]
['Are you ready to go to the bank ? ', ' Sure , what do you need to do there ? ', ' There ’ s problem with my bank statement . There ’ s a mistake on it . I also need to withdraw some money some the ATM . ', ' I have to exchange some money . ', ' that ’ s right . You ’ re going away next week . ', ' I also want to see if my salary has been paid into my bank account . There was a problem last week . ', ' I have to pay my credit bill too . If I don ’ t pay it soon , the credit card company will charge me interest . ', ' Their interest rates are usually quite high . It ’ s a good idea to pay off your credit card debts before they attract interest . ']
['It ’ s so relaxing , taking a walk in the country . The air is so fresh and clean . ', ' would you like to live in the country ? I ’ m not sure I ’ d like it . ', ' I can see a lot of advantage and disadvantage . The problem is that , for me , each advantage has its own disadvantage . ', ' What do you mean ? ', ' Well , I hate the noise in the city , but I love being around lost of people . The problem is that you can ’ t have lots of people and have peace and quiet . The two just don ’ t go together . ', ' I see what you mean . I love being far away from a city , but I hate being so far away department stores and sports facilities . ', ' People can ’ t have it both ways . If you live in the country , it is often less convenient . If you live in a city , it is noisy , but there ’ s more to do . ', ' I would love to be surrounded by hills and streams . They ’ re so much better to look at than concrete , rows of parked cars and tall buildings . ', ' I would love to hear the birds singing and feel the fresh breeze on my face . When the wind blows in the city , you get dust in your mouth and in your eyes . ', ' The view from the hill is so beautiful and relaxing . There ’ s so sign of pollution . The village looks so peaceful . ', ' Just remember that in that village there ’ s nothing to do . There ’ s not even a pub or restaurant . There ’ s just one small shop with a poor selection of goods . ', ' You ’ re right . I would have to travel to the city at least once a week to go shopping and see friends . I would hate living in the country ! ']
['Hey Mike . What are you doing ? ', ' Nothing much . What are you up to ? ', " I was just concerned about Sam . He hasn't been himself lately . ", ' He took the civil service exam and failed . ', ' That sucks . He must feel depressed . ', " Yeah . He's been sitting in his room everyday for the last 4 days . ", " Why don't we take him out ? We can try to take his mind off of it . In the least show him that we're there for him . ", " That's a great idea . Why don't you call him . I already talked to him a couple of times and it might be good for him to hear from somebody else . ", " Ok . I'll call you back after I'm done . ", ' Sounds good . ']
['Did you hear Peter just retired ? ', " Are you sure ? He is quite young , isn't he ? ", " He is not young as he looks . I think he's almost sixty . ", ' Really ? He looks so young . ']
['Hello , Steven . Congratulations ! ', ' Thank you . ', " How's your married life ? ", " We're happy together now . We both think that we're a well-matched couple . ", " That's very good . It's said that marriage is the Ab of love . But the words may not be right . ", ' The situation differs in person . ']
['We have waited for a long time . When will we start ? ', ' Take it easy . I have to cut my losses . ']
['are you working overtime again ? Over the last two weeks , you have worked overtime every day without a break ! Your company is draining the life out of you ! ', " I know , but I don't have a choice , my boss has complete control over our work schedules . I haven't made it out of the office before 9 PM a single day this week . ", " Well , I hope they're paying you the big bucks for all this work ... ", " No , not exactly , I'm working for minimum wage.And they don't give extra pay for overtime . Overtime is our own time . ", " What ? ! Isn't there a law against that , I think there is some legislation that requires employers to give their employees a fair rate of wages . You should know your rights ! If you are putting in so many hours , they should give you some kind of compensation . ", " They do give bonuses at the end of the year for the employees with highest productivity numbers , but frankly , it's not much of an incentive . They give us a bonus of ten dollars . ", " That's just wrong ! why don't you just quit ? ", " I would , but I'm afraid I would't be able to find another job . I don't have very many job marketable skills , there aren't so many jobs that I'm qualified for . ", ' it sounds like any job will be better than the one you have now ! ']
['The tranquility of the night , the chirping of some insects , everything is so natural ! ', ' I felt as if I had been in a different world . ', ' And I was overwhelmed by this scene , too . ']
["I'd like to reserve a table for three at 6:30 this evening . ", " Let me check . Hold on , please ... Yes , that's fine . Smoking or nonsmoking area ? ", ' Nonsmoking , please . ', ' All right . May I have your name ? ', ' My surname is Gao . ', ' How do you spell it , sir ? ']
['OK . Come back into the classroom , class . ', ' Does the class start again , Mam ? ', ' Yes , but to the health , this break has long enough . ', ' Oh , breaktime flies . ', ' come on , baby . It ’ s time now . ', ' Mam , another minute , could I ? ', ' Hurry up , little boy . ']
['why are you so upset today , Maria ? Cheer up ! ', ' oh , Iris , it ’ s about the job with the PR company . ', ' it ’ s a great opportunity . You should be happy with the offer . ', ' but my mother won ’ t allow me to accept any part-time job . I ’ m afraid she will say no again . ', ' why ? It ’ s unfair . You can learn a lot from it . ', ' she says a part-time job is cursed blessing . It takes so much time and energy that I won ’ t be able to focus on my studys . ', ' that may be true . But I ’ m sure you ’ re able to find a balance between them . Why not try it ? ', ' I turned down quite a few offers before for her sake . But I ’ m a senior now , I don ’ t want to miss the chance this time . ', " I agree with you but I think you really need to talk to your mother and tell her what's on your mind . ", ' I ’ ll try , but what if she insists ? ', ' just let her know that the experience will be both amazing and rewarding . And more importantly , you can manage both your study and the job . ', ' do you think it will work ? ', ' sure . Every cloud has its silver lining . Just try . ', ' ok , I ’ ll do that . Thank you , Iris . ', ' sure . Good luck , Maria ! ']
['Where did you go yesterday ? ', ' I went to play tennis in the public park . ', ' How often do you play tennis ? ', ' Twice a week . How about you ? ', ' I seldom play tennis . I prefer football and basketball . ', ' What is very difficult to gather team player together . ', ' I usually play with my school-mates . ', ' Do you like watching football matches ? ', ' Yes . I went to Tinge Sport Centre for football match last Sunday . ']
['Why are you all dressed up ? ', " I've got a date . "]
['I ’ m sick of my job , I always have to work late at night , and the company keeps me working in the office . ', ' Why don ’ t you find a new career where you can do what you enjoy , being outside working during the day ? ', ' What do you suggest ? I can ’ t afford to quit my job until I get a new one . ', ' Maybe you have two choices . You could attend school during the day , or you could get a position that provides training . ']
['I saw an interesting program on TV last night . It was about elderly people . ', ' And what did the program say ? ', ' It said that people with a positive attitude tend to live longer and happier . ', ' I think that many physicians now agree with that idea . ', ' And the TV program also said that physical exercise helps people deal with stress . ', ' And the most active older people seem to enjoy some kind of physical exercise . My father is over 60 years old , and he lifts weights every day . ']
['Saying you want to kill yourself , you terrified me out of my wits . ', ' I was playing a joke on you . ', ' That ’ s too much . ', ' Dear , forgive me . I won ’ t do that again . ']
['Where are you going this weekend ? ', ' I ’ m going to Hainan . ', ' Oh really ? It ’ ll be nice and warm there . Have you been there before ? ', ' Yes , actually it ’ s my second visit . I was there last October . ', ' I see . What ’ s it like there ? ', ' Well , the life style is much more relaxed than here in the city . And the seafood is tastier ! ', ' Well , have a great time ! ']
["Hurry up , Daniel , it's Barbie time . ", ' All right , Sis ! ', " Come on , it's cool outside . ", ' I really wish Mom and Dad were here with us . ', " Hey , Daniel , what's your favorite weather ? Snowy or sunny ? ", ' Me ? Er , I like hot weather , just like today . ', ' What ? Are you crazy ? ', ' I like to watch Barbie sticking her tongue out . ', ' Ew , Danny , gross ! ', " By the way , what's your favorite weather ? ", ' I love snowy , because it is very very romantic . ', ' Look , is that Tom ? ']
['My girlfriend dumped me . ', " Well , that's life . "]
['Did Roll win the race ? ', " Yeah , he did . But he only won it by a hair's breadth . ", ' But anyway , he won at last . ', ' Yeah . To win is the most important thing . ']
["What's this then ? ", " It's my geography , sir.The Map of Africa you set us . ", ' But this should have been handed in last Thursday . ', " Yes , I know , sir . I'm sorry . ", " Well , what's your excuse then ? ", " My mother's been ill and I had to stay at home . ", ' Oh , Yes ? ', " It's true , sir . "]
['Hey , This is your order . ', " Are you new here ? I come to this coffeehouse often . But I didn't see you here before . ", " Yes . I started this part-time job just three days ago . And my internship will last 1 week . I'm still a student now . ", " Do you mind if I ask you why you've taken the part-time job here ? ", " Of course not . You know , there are many foreign customers like you here . And I think it's good for me to improve my oral English . ", " Oh , are you an English student ? Or you just study English for interest's sake ? ", " No , I'm not an English student . But I do like English . I'm going to be a volunteer in the 2008 Olympics where I want to be helpful with the language . So I try to improve my English . ", ' Very nice . Thank you for your time . ', " Thank you , sir . But I'm not allowed to accept any tips . ", " OK then . I don't want to put you in trouble . ", ' Well , would you like something else ? The new-made cafe parfait is really good . Want some ? ', " OK . But I'd like some cookies . ", ' Sure . If you want more coffee , please go over there . There is self-help coffee maker . ', " I surely know that . Don't forget that I am a regular customer here . ", " Oops . Well , wait for a while . We'll get it done quickly . ", " It's OK . Thank you . "]
['Do you think the bad weather will last long ? ', " I don't think so . It changes so quickly this time . ", ' I hope so . We have planed to visit the square but we have to cancel it . ', " I think you can go to visit the museum . It's worth seeing . You can go to the square some other time . ", ' Good idea . Thanks a billion . ']
["Let's go in . ", ' After you . ']
['Could you tell me what university you want to go to , John ? ', ' Pardon ? ', ' What university would you enter ? ', ' University ? Why ? You asked me last year . ', ' Oh , I forget . Sorry . ', ' I went to Harvard University . ', ' Did you ? And what course did you take there ? ', " God save me ! Is there anything wrong with you ? Didn't I tell you ? ", " I've not known . Perhaps , I've got a bad memory . ", ' I did a B . A . in economics . Remember ? ', ' Terrific ! B . A . , again and again-B . A . ']
['I think he deserved his gold . ', ' Did you see his last dive ? ', " Yes , it's perfect ! ", " He's diving for the gold . "]
['You are studying here , aren ’ t you ? ', ' Yes . I have been here for three years . ', ' Do you like this campus ? ', ' Well . I ’ m rather disappointed with it . ', ' How come ? ', ' It ’ s too old . And it isn ’ t as specious as I expected . ', ' Oh.It ’ s awful , but it can ’ t be helped . ', ' I ’ ll just have to put up with it . ']
['How I wish my son Mark could be as excellent as your Joe ! ', ' Don ’ t be too humble . Few young men could be equal to Mark . And in some respects Joe and Mark are neck and neck . ', ' I agree . Both Joe and Mark are men of guts . ']
['Hi Mark . ', ' Hi . ', ' What are you planning to do today ? ', " I'm not sure yet . ", ' Would you like to have lunch with me ? ', ' Yes . When ? ', ' Is 11:30 AM OK ? ', " Sorry , I didn't hear you . Can you say that again please ? ", ' I said , 11:30 AM . ', " Oh , I'm busy then . Can we meet a little later ? ", ' OK , how about 12:30 PM ? ', ' OK . Where ? ', " How about Bill's Seafood Restaurant ? ", ' Oh , Where is that ? ', " It's on 7th Street . ", " OK , I'll meet you there . "]
['How have you been ? ', ' Fine , thanks . How about you ? ']
['Hi , Monica , congratulations ! Your presentation at the meeting was very successful and everyone was impressed by your speech . And it was so persuasive and I bet our clients will be convinced to invest their money in this project . You really made a big contribution to our company . ', ' Thank you , I just tried my best . I am very happy to know you like it . ', ' You must have been prepared for a long time . Some statistics in this presentation are not easy to find , right ? ', ' Well , yes . Several colleagues from different departments helped me with that . They are very supportive . I consulted an economic expert last week . He was very kind to give valuable suggestions . ', ' Now , the effort pays off . You have accomplished something . ', ' Come on , don ’ t flatter me anymore . I took the job because I love being challenged . But I can ’ t get this turned around without the support from you people . ']
["I hate to say goodbye , but it's late . ", " Can't you stay for a little bit longer , it's only 8 . ", " I wish I could.But I'm afraid I can't . I've got some serious studying to do . I have to go . ", ' OK.See you on Today . ', ' See you on Moday.Have a great weekend . ', ' You too.Thanks for dropping in . ']
['Are you really dating with Frank ? ', ' Yeah . But in my heart of hearts , I find he ’ s not very much to my liking . ', ' Then why not keep away from him ? ', ' The problem is that I just have no one to turn to right now . ', ' That ’ s stupid . ']
["Hi , Jim . How are you ? I haven't seen you for a while . ", " I'm fine . I've been out of town . I just got back . ", ' Where were you ? ', ' I was in New York for a wedding . ']
['What do you think of the novel you just finished reading ? ', ' I like it a lot . It has a very funny beginning , I think . It attracts your attention the moment you begin reading it . ', ' What do you like best about it ? ', " I like the plot . It's so full of twists and turns . I also like the main character . She is so humorous and smart . ", ' What do you think of the ending ? ', " The ending is a bit weak . It's so abrupt , like those of most other detective stories . "]
['Quite a few times , I had my back to the wall . ', ' Really ? Generally they will turn out to be a good thing . ', ' That ’ s right . ', ' You ’ ll exert all your energy and get out of it . ']
['Is that your phone ? ', " Yes , it's my new business phone . Do you like it ? ", " It's very impressive . Can you use the Internet on your phone ? ", " Yes , it's got wireless Internet access . ", " That's really convenient . Does it have the Bluetooth ? ", " Yes , but I don't really use it often . Have you ever used it ? ", " No , but I think it'd be really great for people like you who are always on the go . ", ' Yes , I guess I should try to use it . ']
['Good morning , Mary ! ', ' Good morning , John ! ', ' I want to have a few friends over for a dinner party to celebrate my birthday . Would you be able to come the next weekend on Saturday ? ', " I'd be delighted to , John . Saturday did you say ? ", " Yes , if that's all right for you . ", " I'm pretty sure I'll be all right . In fact , I'd be delighted to come over and celebrate your birthday with you . What time are you planning to start ? ", " Oh , good . If you could come around six thirty or seven o'clock , that would give us some time to chat a whit over a glass of wine before dinner . ", " That sounds fine . I'll be there around seven . "]
["Don't worry . I'm sure you'll do better next time . ", " I didn't realize it was so difficult though I know I'm always too nervous in such competition . ", " It doesn't matter . Forget it . ", " I don't think I performed well . ", " Oh ! That's much hetter than I did . ", ' Can you tell me how to improve myself ? ', " There's no secret at all . The only thing for you to do is to practice more . You will succeed . ", ' Thank you for your encouragement . ', " It's a pleasure . Come on . I'm on your side . "]
['I just dropped in to say goodbye . ', ' What time are you leaving ? ', " I'll leave at 10 o'clock . ", ' Take care and give my best to you parents . ', ' Thank you , I will . Hope to see you again next year . ']
["Come back . You haven't paid yet . ", ' May , just let him go . ', ' But he took some newspaper away without paying . ', ' I know . ', ' Why ? You make me confused . ', ' He lives nearby and he would just glance at the newspaper headlines , read the political sections and return them later . ', ' Why does he have such a privilege ? ', ' He used to be a hero during the war time and everyone respect him . ', ' I see . Does he live by himself ? ', ' Yes , he has no children and his wife passed away when he was in the battle . ', ' He must be lonely ? ', ' I bet . But he is always busy telling the children stories . ', ' How respectable ! ']
['How may I help you ? ', ' I need to get on the Internet . ', ' Do you have your library card with you ? ', ' Yes , I have it . ', ' You ’ re going to have to wait for a computer . ', ' That ’ s okay . ', ' Please put your name on this list . ', ' Then what do I need to do ? ', ' When there is a computer available , I will call you . ', ' What do I do to log on to the computer ? ', ' Just type in the number on the back of your library card . ', ' Okay . Thanks for your help . ']
['Are you coming to the bridal shower for Jane ? ', ' Yes , I am . When is the wedding ? ', ' Aug 8 . ', ' August bride . How nice ! By the way , who is going to be the matron of honor ? ', ' Mrs . White . ', ' Oh , yeah ? I wonder who is going to give Jane away at the wedding . You know her father passed away several years ago . ', ' Maybe her uncle will . ', ' I think so . The wedding will be held at her church , right ? ', ' Right . Red Rochester will officiate at the wedding . ', ' Do you know where they will go on their honeymoon ? ', ' Yes , Jane says they will go to China . ']
['Don ’ t do that again . You are riding the tiger . ', ' No problem . I can deal with it well . ', ' You will ask for it . ', ' All is best now , isn ’ t it ? ']
['Hurry up ! Time is money ! ', " Don't build a fire under me . I know the importance of time . ", ' But you are too slow to follow them . ', " Don't you see I'm trying my best ? "]
["Watch out ! You'll hit that car if you're not careful . ", " Oh no , I won't . But we will have an accident if you don't stop shouting . ", " You see . I told you you'd hit him if you weren't careful . ", " Oh , shut up , will you ? It was all your fault.If you'd kept quite this would never have happened . ", " Oh , so it was my fault , was it ? If I hadn't warned you in time it would have been much worse . "]
['Steve , you look pale . What happened ? ', " I didn't sleep a wink last night . ", ' Did you have something on your mind ? You look so concerned . Maybe I can help you . ', ' Well , I am under a lot of pressure . My boss is very pushy . He assigned me three projects . Now the deadlines are near , and I still have not finished all of my projects . ', ' Is there anything I can do to help you ? ', ' Well , I guess no one can help me but myself . For the moment , I just need someone to talk to , so that I can relieve my stress . ']
['Lodge , You must come around sometime , You have to check out my mew stereo . ', ' Sure , When is good time for you ? ', ' Can you make it on Tuesday ? ', ' What time do you want me there ? ', ' Anytime after six will be fine . ', " All right , It's a date . "]
['My friend Jean is very beautiful . ', " What's her figure ? ", ' Perfect , and I like her charming eyes too . ', " What's the color of her eyes ? ", ' Dark blue . ']
['What ’ s the life expectancy in your country ? ', ' I ’ m not sure , but probably about 75 years . How about in your country ? ', ' About 70 , I think . This newspaper article talks about the problems of an aging population . It ’ s a problem that will soon affect most of the world . ', ' I heard that the government might need to increase the retirement age , because otherwise there will not be enough workers to support the young and the elderly . ', ' Perhaps we need to have more babies ! Tina gave birth to a baby boy yesterday . ', ' Did she ? That ’ s great . However , if we have too many children , that will have a bad effect on the enviroment . ', ' How ’ s your son these days ? ', ' Oh , he ’ s fine . Kids seem to grow up very quickly nowadays . ', ' He ’ ll be a teenager before you know it ! Teenagers are often rebellious ! When do you think it is a good age to have a child ? ', ' I had mine when I was 24 . that ’ s a little young . I ’ d suggest you wait until you are in your late twenties . , or even in your early thirties if you have a good career . ', ' Yes , I think you ’ re right . I ’ m thinking about having a child , but not just yet . ', ' Is there a big generation gap between parents and their children in you country ? ', ' Yes , there is . Teenagers do not want to live traditional lives . They want to go out , have fun , and explore the world . They want to develop their own view of life . Parents usually try to discourage them , but they don ’ t often succeed . ', ' Parents usually give their children more freedom in my country . Sometimes they give them too much freedom . ', ' It ’ s almost impossible to get the right balance . If you are too strict , kids might ignore you . If you are too lenient , they might go wild . ']
["Hey Mike . I forgot about registration . I'm a day late , so all the classes are mostly full . What do you think I should do ? ", " You're screwed . You can't do anything about that . You have to hope that you get some classes that will be useful . ", ' Do you think going to the registration building will help at all ? ', ' No . They will tell you the same thing in a worse way . ', ' Did you register yet ? ', ' Of course . Registering for classes is not something you want to miss . ', ' What classes do you think are still open ? ', ' Well , I know psychology 101 is a big class , so there will always be seats in that class . You can also get into Sociology . ', " That's helpful . Thanks . But what do you think about philosophy . I wanted to take that class this semester . ", ' I took that class last year . The professor is really cool , so if you go to his office , you can have him sign a card that will let you in even if the class is full . ', ' He does that ? ', " I guess that's because so many people drop out of that class . ", " That makes sense . I think I'll do that . Thanks for all the help . ", ' No problem , man . ']
['Thanks for helping me move into my new house . ', " Any time . I'm just glad I could help . "]
["I've been so stressed these days . ", " What's the matter ? Are you OK ? ", " I don't know where to go for college , and what to major in . ", " Don't worry . You have plenty of time to decide . ", ' And I also want to get scholarships to help me pay for the tuition . I want to get the burden off my family . ', ' You always worry too much about everything . Take it easy , honey . You are good enough . You can go to the ideal college . ', " OK , OK . I'm so sorry . By the way , for you , is it more important to make money or to enjoy your work ? ", ' In a perfect world , I would enjoy my work if I do not have to do much , and make lots of money ! ', ' OK , honey , stop dreaming . You should face the reality . ', " That's only a joke . To be honest , I have to improve my English , because my English is not good enough . I still get confused about some simple grammars . Since you are quite good at it , do you have any suggestions ? ", ' En , first you should be concentrated on what the teacher said in class . Second , I suggest you to take an additional course in some training center . ', ' Is the training center helpful ? ', " I think so . Because I've taken one to improve my oral English during summer vacation . "]
["I'm glad we live in a small town . ", ' Why ? ', ' Because the houses look so nice at Christmas time . ', ' Yes , they do . Do you have a Christmas tree this year ? ', ' Yes , we have a big tree this year . I bought the decorations at the five-and-tencent store yesterday . Do you want to come and see it ? ', " I can't now because I have to buy a present for my mother . ", ' When can you come ? ', " I don't know when I can come . I'll let you know later . "]
['You know , smoking does do harm to your health . ', " Yes , you're right . ", " Why don't you try to give it up ? ", " I've tried to give up smoking several times , but it's no good . Smoking relaxes me . ", ' Have you ever thought of just cutting down ? You could do it gradually . ', ' Yes , maybe I should have another try . ']
['Hello , Jim . What was the film like ? ', ' Awful . It was a complete waste of time . ', ' Why ? What was it about ? ', " It was about a married couple . They had to live with the wife's mother , because they didn't have enough money to buy a house of their own . ", ' A lot of young people have to do that . ', ' Yes . but the husband had to work overtime three times a week , so he was always tired . ', ' lt sounds like the story of my life . ', " Yes , it does , doesn't it ? But this man was always over-tired , and he couldn't sleep.So he used to take two sleeping pill every night . ", ' I take sleeping pills sometimes . ', ' Yes , but not two every night . Anyway , the strain was too much for him . He had nervous breakdown and had to go to hospital . ', ' It sounds a very depressing film . ', " Not really . His wife was able to find a good job as an interpreter , because she could speak French and German fluently . After a few months ' work , she had a better job than her husband . So in the end , ", " I don't know . My wife used to speak French . I must tell her to brush it up . "]
['Would you like to stretch your legs ? ', ' Sure . ', " Let's get a soft drink . ", ' Do we have enough time ? ', " It's a fifteen-minute intermission . ", " The seats are excellent . We're right in the center . ", " It's a new concert hall and the acoustics are great . ", " I can't agree more . ", ' Is this your first time to come to a symphony concert ? ', ' In the United States , yes . But back in China , I went to concerts a couple of times with my parents . ', ' Do you have large concert halls in your city ? ', ' We have two . One is like this one . The other is a little smaller . ', " That's great . Well , we'd better get back to our seats . It's about to start . "]
['May I help you ? ', ' What time will the library be closing ? ', ' It closes at six . ', ' Does it always close at six ? ', ' No , not every day . ', ' Will the library be open on Saturday ? ', ' Absolutely . ', ' What are your hours on Saturday ? ', ' Saturday ’ s hours are from nine in the morning to six-thirty at night . ', ' All right . Thank you . ', ' What else can I help you with ? ', ' That ’ s it . Thank you . ']
['Whose part do you think is best played ? ', ' That of the old man . ', " You're absolutely right ! That's the very figure I like best . ", ' Some of the scenes moved me into tears . ']
['Vince , I think one of your programmers is spying on us for WebTracker . ', ' Pardon ? ', " I won't say who , because I'm not sure yet . But I'll know soon . ", " Zina , I hope you're not scheming to make Elvin look bad . ", " It isn't Elvin . ", " Dave then ? Dave is a spy for WebTracker ? You can't be serious . ", " Loan me that tape recorder you have . And don't say anything to anyone until I come back . "]
['Hello , Zhang lin ! Fancy meeting you here ! ', " Hi , Lin Tao . I have't seen you for some time . ", " How's life going , Zhang Lin ? ", ' Yes , the same as ever , thanks . What about you ? ', " Pretty good , thanks . I'm going to see my uncle . ", ' Good bye then , and keep in touch . ', ' Good bye . ']
['Fixing computer isn ’ t my cup of tea . You can leave this job to Jason . ', ' Yeah , he has a good commend of computer skills . But ... ', ' But what ? ', ' But he is always talking big . ']
['What a great weekend that was ! ', ' My feelings exactly . ', ' I really enjoy the beach in the summer . ', " I couldn't agree with you more . ", ' We should come here more often . ', ' You are absolutely right . ', " I'd like to come back next weekend . ", " That's exactly the way I feel . "]
['Aren ’ t you going to swim ? ', " Are you kidding ? Don't you know I can't swim ? ", ' You are not telling me that we drove 50 miles to come here for just sunbath , are you ? ', " Hey , don't shout . Come here ! Sit closer . Now , Jim , we ’ Ve had a lovely day . Don't spoil it now . ", " What about your beautiful bathing suit ? We shopped all day . Don't you want to show it off ? ", " Everybody who walks past me sees it . Besides , it's a good sunbathing suit . ", ' All right . Suit yourself . I am going swimming . ', ' Jim ! ', ' Yes ? ', ' Can you get me a beach umbrella and a deck chair ? I am really tired of lying in thousand . ', " I've got a better idea . Why don ’ t we hire a boat and go for a ride ? What do you think ? ", ' Are you serious ? That will be wonderful ! ']
['How dare you accuse me of stealing your computer ? ', " I'm sorry , but you were the only one who had access to it . "]
['The flood will come on the heels of the heavy rain . ', ' I wonder if the municipal government will take some preventive measures . ', ' I ’ m sure they will . ']
['Adam , could you show me around the school ? ', ' No problem . ', " What's the tallest building ? ", ' You mean the white building near the playground ? ', ' Yes . ', ' That is the library . And it has more than 1,000 , 000 books . ', " What's the building to the south of the library ? ", ' You know , our school is divided into two parts , the junior high school and the senior high school . That is the new classroom building for our senior high school . ', ' Is there a swimming pool in your school ? ', ' Yes . There is a large swimming pool , but it is only available in summer . ', ' I do envy you . And I hope I can enter your school one day . ', ' I believe that you can make your dream come true . ']
["Television is undoubtedly a great invention , but one of the main criticisms of it is that people just aren't selective enough . Lesley , got a television . how do you pick out the sorts ofprogrammes you want to watch ? ", " I try and look at the programmes that are on to decide which particular ones interest me , rather than you turning it on a seven o'clock and you leaving it on until half-past eleven when the programmes finish . ", ' Do you think of television though as a great time-waster ? ', " Un ... I think it can be a time-waster and it depends on how particular people are about what they want to see ... Mm , it can just be a sort total amusement for someone and totally consuming without reallyconsidering what it is they're watching . ", ' Aha , but how do you prevent it coming into your life and taking oversour evenings and at the same time perhaps get . . . get out of thetelevision some of the sort of best things ... best programmes that ... that undoubtedly are on television ? ', " Well , I suppose one of the problems is ... will depend on what a person's life style is , and that if he has other outside interests which are equally important to him as television , he will then , you know , hmm . be more careful about which programme she wants to watch because he has time which he wants to use for other things . ", " Do you think though that ... that in . . . in a sense television skilled people's own er ... sort of , creativity or their ability entertain themselves because if they're bored all they do is justturn on the television ? ", " Yes , I think that is a danger , and I think that . . in fact is what mishappening to a lot of people who use it as their ... their main ... um field of amusement and ... because they don't have other outside interests and even when people come round they'll leave the television and not be , you know , particularly interested in talking to them , you Know the television will be the main thing in the room . "]
["Don't be shy . Have some more chicken . ", ' Thanks . ']
['I feel pity for the old man . ', ' I feel the same way . ', ' It must be dreadful to grow old . ', ' Yeah . He has no one to count on . ']
["I'm going to see the doctor this weekend . ", " What's your trouble ? ", ' I think I need a thorough check-up . ', ' I got it . ']
['Professor , I am going to need to leave class early today . ', ' What is the problem ? ', ' I need to go to the airport to pick up a relative . ', ' Are you planning on having someone take notes for you ? ', " Yes , I've got that part covered . ", ' When , exactly do you need to leave ? ', " I don't need to leave until the very end of class . ", ' Fine , but next time try and not have to miss class again . ', ' Thanks , Professor . See you later ! ', ' See you later ! Drive carefully . ']
["I'm going to try sky diving this weekend . ", " I wouldn't do it if I were you . ", " It's sounds like fun . ", " It's very dangerous , you know . ", ' I want to try something exciting . ', " It's an easy way to get hurt , let me tell you . ", " I'll tell you all about it next Monday . ", " Well , take care of yourself , and don't say I didn't warn you . "]
["Does he know that he has already at his wits ' end ? ", ' I think he has realized that . But he is still whistling in the dark by putting up an act . ', ' He might be driven up a wall . You should not handle your relation with him with kid gloves . ', ' But when I noticed that he was left in the cold , I could not help wanting to help him to get out of the situation . ']
['I visited the famous variety show host , Dennis . ', " What's he like ? ", " Oh , he's a very serious person . ", ' You must feel very uneasy at his home . ']
['Hi ! My name is Mike . ', " Hi ! I'm Nancy . Nice to meet you . ", ' Nice to meet you , too . ', ' Where are you from ? ', " I'm from Shanghai . And you ? ", " I'm from Chicago . "]
['Why do you go fishing so often ? ', " It's fun . "]
['Hi , Cindy . I thought I ’ d missed you . ', ' Oh , I am very sorry , Hans . Thank you for waiting for me . You must have been here a long time already . ', ' It ’ s all right . ', ' I was caught in the heavy rain , or I would have come earlier . I am sorry I kept you waiting . ', ' I was in a comfortable place , so really , it ’ s no problem . I am happy to see you . Did the rain hold you up long ? ', ' Yes . When I came out of the subway , it was raining cats and dogs . And I forgot my umbrella . So I had to wait for the rain to let up . ', ' I totally understand . ']
['Good morning , Jim ! ', " Good morning , Emma ! A lovely day , isn't it ? ", ' Yes , it is . The sun is shining . There is no wind , only a pleasant breeze . ', ' It is the best season for a picnic right now . Have you decided the place for your picnic ? ', ' We have decided to go to the park this Sunday . Would you like to go with us if you have not decided yet ? ', ' What did the whetherman say ? ', ' He ’ s predicting clear skies . ', ' Well , I will think it over . ']
['Come in , come in , what can I do for you ? ', ' Professor Donald , are you giving your advanced geology course again next semester ? ', ' Yes , I am applying on it . ', " I wonder if I could enroll in it . I know it is a graduate course and I ' m a junior , but ... ", " Aren't you a bit young ? I have a lot of qualified seniors to take the course and they usually have a hard time keeping up . ", ' I know , but the geology of the American west is my major interest and I have done a large reading in the field . ', " Well , if you think you are ready , I'll let you enroll . ", ' Oh , thanks , professor Donald . This is really very nice of you . ']
["Management is going through a big turnover these days . With Bill's retirement , and department realignment , we have lost about 1/3 of our managerial staff . They've been dropping like flies ... ", " Isn't that a good thing ? Having fewer bosses means having less stress , don't you think ? ", " Actually , I don't think so . Supervisors are really important to make sure everything goes smoothly in the workplace . They are necessary for divvying up work and disciplining employees . If there is no one to keep an eye on us , no one would get any work done . You know what they say , when the cat's away , the mice play . ", " You're right , we do need leadership . But what we don't need is too many people to lead us . You know what they say about too many chiefs and not enough Indians ... ", ' Alright ... I get your point . ']
['How do you like your job here , Linda ? ', " It's interesting , I like being an editor . ", ' Why ? ', ' I like talking to writers , I get to meet a lot of interesting people . ', " I'm happy to hear that , but publishing is more than just talking to writers . it involves a lot of work , patience and responsibility . Most of the work is boring . ", " I don't feel bored at all . I'm getting along with my colleagues . I will enjoy working with them . People are great in this industry . ", ' Do you have any complaints ? ', ' No , I have no complaints . I hear there are many opportunities to move up in this company . is that true ? ', ' Yes , you have many opportunities to grow in this company as long as you do well . ', " That's perfect . I will definitely do well . "]
["I don't think we've met . ", " No , I don't think we have . ", ' My name is Dick Brown . ', ' How do you do ? Mr . Brown . I am Susan Heywood . ', ' Mr . Smith often talked about you . ', ' Really ? I am glad to meet you . ', " I'm honored to know you . "]
['Why don ’ t you sit down and relax , darling ? ', ' I don ’ t want to . ', ' Well , come and talk to me then . ', ' Certainly not . ', ' May I turn on the radio then ? ', ' Turn on the radio ? What for ? ', ' So that we can sit down together and listen to some music . ', ' Listen to some music ? And who ’ ll cook dinner ? Will you ? ', ' Ok , I will . But let ’ s go to a disco after dinner . ', ' To a disco ? Oh , no . You know I hate pop . ']
["David , why don't you clean your room ? ", ' I am not in the mood . ', ' Why are you feeling depress ? ', " I was told my girlfriend was speaking ill of me . It's a real letdown . ", " I don't think she would do such a thing . ", ' But she did and it made me disappointed . ', ' Oh , cheer up ! A girlfriend is not everything . ', ' But she means a lot to me . ', ' Then forgive her mistake . ', " Oh , I just can't forget it . "]
['My sister was taken to the hospital yesterday ', ' What happened ? ', " She was hit by a car . Luckily , she wasn't seriously hurt . ", " Let's buy some flowers , and pay her a visit ", " We'll have to hurry ; visiting hours will be over soon ", " OK . Let's go "]
['What are the good sights to see in Beijing ? ', " Well , I know you are interested in architecture , so you should't miss the Temple of Heaven , and the Great wall is a must too . "]
["Hello , let me introduce myself . I'm your new neighbor . My name is Andy . ", " Hi , Andy . I'm Judy . It's nice meeting you . ", ' Nice meeting you , too . ', ' Come over and visit when you have time . ', ' Thanks for the invitation . I will ! ']
['What do you do when you are angry ? ', ' I usually calm down first and think about the reason that caused my anger . ', ' That ’ s smart . What do you usually do to relieve your anger ? ', ' Something like listening to music is a good idea . ', ' Oh , what kind of music do you listen to ? ', ' Classic . Something that could calm your mind . ', ' I think that might work for me as well . ', ' Working out is another good way to relieve anger . ', ' Like what ? ', ' Jogging , yoga , or even just taking a walk . ']
["I'm sorry , but I can't come to your party . ", ' What a shame ! ']
["Taylor , you're sweating up a storm ! ", ' Your boyfriend , Bryan , wanted to toss the football . I think he wore me out . ', ' Yeah , you look a little shaky . And pale . You seriously need some time in the sun . ', " You're like the tenth person to say that . ", " We're just worried about you , Taylor . ", ' Whatever . I wish people would just leave me alone ! ']
['She is so stupid . ', ' Who cares ? She is pretty . ', ' So what ? ', " You're just jealous . "]
['Mrs.Smith , time has stood still with you ! ', " Thank you.You ' re partial . ", " I'm not flattering you.You ' re full of energy every day . ", " It's nice to hear that anyway . "]
['What a police officer ! ', ' I ’ Ve never seem such a scene either except in films . ', ' It ’ s really unimaginable . The police officer screamed at the driver and used bad language , but the driver took it on the chin . ']
['In my wedding ceremony , where do my parents sit in the church ? ', " The bride's parents ' seating arrangement is on the left side of the aisle and the groom's parents is on the right side . ", ' Do friends of the bride always sit on one side of the church and friends of the groom on the other ? ', ' They usually do . ']
["Hi , Mary ! You're here already . Where's Harry ? ", " He isn't a punctual person . We may have to wait for a little while . ", " That should give us time for a cup of coffee . I'll go and get some . ", ' Make it three cups . Here comes Harry . ']
['Why did the teacher criticise Myra in front of the whole class ? ', ' Because Myra was cheating on exams.and she spoke back rudely . ', " I don't think that Myra should have spoken so rudely to the teacher . I know she was angry , but that's still no excuse for rudeness . "]
['Is your city a historical place ? ', ' Not rally . 200 years ago , it was just a small insignificant village . ', ' How did it grow into such a large place ? ', ' Large deposits of coal were found nearly and so many industries located themselves here . The village quickly grew into a key industrial centre . ', ' As the city grew , it must have absorbed many village nearby . ', ' Yes , it did . The names of those village survive as the names of parts of the city . ', ' I see . Are there any building more than 200 years old in your city ? ', ' Oh , yes . Several of the buildings from the villages still survive . Many of them were inns for travelers and today survive as pubs . There was a castle near one village , so our city has a castle too . ', ' Really ? So your city does have some old history after all . ']
['What is wrong with your face ? ', ' My brother did it . ', ' Why ? ', ' I laughed up my sleeves at him . He ’ s seen his girlfriend off at the airport and had lipstick on his face and did not know it . ']
["How's Jerry's new school ? ", ' Very nice . He gets along with his classmates very well . ', " He's a team player . ", ' Yes , indeed . ']
['How many people are there in your family ? ', ' Five.My father , mother , brother , sister-in-law and me . ', ' Is your brother older or younger than you ? ', ' He is five years older than me , He got married last Sunday.My brother and my sister-in-law are the same age . ']
["What's the problem ? You don't look happy . ", ' I failed my oral test . ', ' How come ? ', " I'm not practicing enough . ", " Why don't you go to the English corner to talk to your classmates in English quite often ? ", ' When I talk to Chinese , I always want to speak Chinese . ', ' You should always keep in mind , the more you practice , the better English you can speak . ']
['It ’ s dangerous . I don ’ t dare to go . ', ' Come on . It ’ s quite safe . You really have no guts . ']
['Did you get the car you wanted ? ', ' No . Someone had stolen a march on me and bought it . ', ' What about the car over there ? ', ' It is marvelous , and the price is marvelous , as well . ']
['How may I help you ? ', ' I want to return this video . ', ' Is that all you need ? ', ' I also need to check this magazine out . ', ' You ’ re not allowed to do that . ', ' I don ’ t understand . ', ' It ’ s our policy . ', ' What can I check out ? ', ' Only books or videos . ', ' I need this magazine . ', ' You will have to read it here . ', ' That ’ s weird . ']
['Have you heard the news ? ', ' No . What happened ? ']
['Such bad luck , 200 yuan was stolen by a thief on the bus today . ', " Don't be angry , you lose money just to avoid misfortune . ", ' Well , you can just comfort yourself like that . ']
['Ok , so who are we going to invite to our dinner party ? ', ' Well , we have the Thompsons , the Greens , and the Anderson , about twelve people total . ', " Don't forget my friend Andy from the office . He has nothing to do on Friday , so I invited him over . ", " But that makes thirteen people ! We can't have thirteen people for dinner on Friday ! ", " Why can't we ? ", " It's an old superstition . If we have thirteen people at the table , then it means bad luck . Can Andy bring a date ? ", " I'm not sure . He just broke up with his girlfriend recently , and I don't think he's in the mood to start again so soon . ", " But we can't have thirteen for dinner ! ", " I think you're making a mountain out of a molehill . It's only a superstition . It really doesn't mean anything . ", ' Absolutely not ! I refuse to have thirteen people for dinner on Friday ! ', " Ok , ok . I'll ask my sister to come . That way we'll have fourteen for dinner . ", " That's better . "]
['Hello , 8520388 2 . ', ' Hi , this is Maria . Is that Shirley ? ', ' Hi , Maria , this is Shirley . ', " Shirley , do you know today's homework from our economic law class ? I have written it on a piece of paper but I can't find it now . ", " Hold on for a moment please . I'm fetching my textbook . ", ' OK . ', ' Oh , the homework is to explain what economic law is both in broad sense and in narrow sense . ', ' Explain the economic law ? An essay question again ? ', ' Yes . You can use your textbook for your reference . ', ' Are there any clear answers in the book to this question ? ', " I don't think so , Maria , but I think you can look for information on the Internet . ", ' OK , thank you , Shirley . You are very helpful . I have another question . When does the Economic Law of China come into effect ? ', " Oh , there isn't such a code called economic law . The Economic Law of China is a general concept for several laws . ", " There isn't such a code ? ", " Yes , it's a general name for several laws related to economics , like Commercial Law , and Law of Central Bank . ", ' Got it . Thank you , Shirley . ']
['I just dropped in to say goodbye . ', ' What time are you leaving ? ', ' I ’ ll leave at ten o ’ clock . ', ' Take care , and give my best to your parents . ', ' Thank you , I will . Hope to see you again next year . ']
["The performance is amazing . I'm curious about how they did it . I mean the way they sing . ", ' They must have practiced a lot . The perseverance has made them they are today . ', " So cool . Someone gave me this flier at the exit . What's it about ? ", ' Let me have a look . Well , it lists some shows that will be on next week . ', ' Oh , tell me about it . Anything interesting ? ', " Hmm ... Oh , this one , ' The Drunken Beauty ' . This is a real classic . ", " ' The Drunken Beauty ' ? It's funny that we have ' Sleeping Beauty ' in my country . Anyway , what's it about ? Is the beauty a drunkard ? ", ' Of course not . She was said to be the most beautiful woman in her time and that made her become the queen . They play was famous for its singing and dancing . ', ' Sure , people do that when they are drunk . What about the actress ? ', " She is an opera star in China . Her teacher's teacher is Mei Landfang . ", " Oh , I've heard about him before . He even created a special dance of sleeve shaking . ", " You are such an expert on it . I don't know that . ", ' You know , interest is the best teacher . ', ' So , want me to book the tickets again ? ', " Please do that . I can't wait to come back again . The performance must be really amazing . ", ' We can do that if you like . Maybe next weekend . ', ' That will be great . ']
['That was heaven ! ', ' The sea water treatments are supposed to be really good for you . ', ' Really ? ', ' But the water has to be kept at 34 degrees so that the minerals can be absorbed by your body . ', ' Well , whatever it does , I feel transformed ! ']
['You got a letter in the mail . ', ' Give it to me . ', ' What is it ? ', ' It ’ s from NYU . ', ' What does it say ? ', ' I didn ’ t get accepted . ', ' You can ’ t be serious ! ', ' I ’ m serious . ', ' Are you all right ? ', ' NYU was my first choice . ', ' I ’ m sorry that you didn ’ t get in . ', ' I ’ ll just have to wait for UCLA . ']
['What are you going to do for one year abroad , Tom ? ', ' Study , study , study . I want to learn a lot . ', ' You are going to take courses ? ', ' Yes . I am going to take some university courses there . ', ' Sounds hard . ', " Yes , but I think it's probably for the best . ", " Won't you get lonely ? ", " Hey , I am a pretty cool guy . I will make friends , and I'll have a lot of extracurricular activities too . You know , like fencing , or theater or something . "]
['I went shopping without my umbrella yesterday morning . ', ' Yesterday morning was beautiful i thought the sunning was going to continue . ', " So did i . that's why i didn't take my umbrella . i got cold in the rain in the afternoon.it was raining cats and dogs . ", ' I know . i could not believe it when i got hit by that storm.it was pouring with rain all afternoon . ', ' We really have some miserable weather sometime . i wish i would live somewhere which were sunning all year round . ', ' If it was sunning all year round there would be drought.you probably would not like it either . ', ' I guess you are right . maybe i just wish the weather could be a little more predictable . ', ' The weather forecasters are not good at predicting the weather would be like.our weather is so changeable . ']
['Those guys work at the same company and go to the same bars . They do everything together . ', ' Birds of a feather flock together . ']
['What ’ s your new job like ? ', ' Oh , it ’ s fine . I ’ Ve got a very nice secretary and a large pleasant office . ', ' Um . ', ' And a company car . ', ' Very nice . ', ' Yes , it is . But I ’ Ve got a lot of work too . ', ' Well , that ’ s life , isn ’ t it ? ']
['What a surprise meeting you here , Landy . ', ' I ’ m here as a tourist . ', ' It ’ s a small world , isn ’ t it ? ', ' Yes , it ’ s a small world . We never know where we ’ ll meet someone we know . ']
["So you're traveling around the world , aren't you . ", " That's right ", ' When did you arrive here ? ', ' Last night ', ' Did you have a good journey ? ', ' Yes , I enjoyed it very much . ', ' Where have you been on this trip ? ', " Let me see . Ah , yes , I've been to England , France , Germany , Italy and now I've been in Spain ", ' Really ? How long will your holiday last ? ', ' Two weeks ', ' All these countries in two weeks ? ', " That's right "]
["Please do excuse me for a moment . I've got diarrhea . ", " It's easy to get loose bowels in summer . ", ' It may have something to do with the food I had last night ', ' You ’ Ve got to be careful on the food you eat . ', ' I will . Thank you . ']
["Hi Mary , how's it going ? ", ' Well , last night I had a big argument with Ann . ', ' Terrible . It must be something serious . You two are such close friends . ', " Now that I look back at it , it wasn't that big a deal . I shouldn't have lost my temper . ", ' Really ? What happened ? ', " It's just we've been planning to go the beach for a while , and we decided we could both make it this weekend . Then out of nowhere she called me up , said her boyfriend had made plans and that she need to cancel the trip . I was so angry when she told me that I said she didn't care about our friendship at all . ", " That's pretty harsh . ", ' I know , but I was so upset . I mean , come on ! Does she have to do everything her boyfriend says ? ', ' You know she probably feels just as bad . ', " Well , I think I was being a little selfish myself . I know they don't get to see each other very often . ", " Well , in that case I guess maybe you can be more understanding . You shouldn't let a trivial thing like this stand in the way of your friendship . After all you can go to the beach anytime you want . ", " Yeah , I'll call later to patch things up . "]
["I can't bear you anymore . I am sick of your drinking . I am divorcing you . ", " Don't do that to me , honey . Give me a chance , please . I make a solemn promise never to drink alcohol again . ", " How many chances should I give you ? I've given up on you ! ", " Have a heart , honey . You know I am trying hard to quit drinking , don't you ? Just give me one more chance , please ! "]
['Finally the class is over . Be quick . Ben must have been waiting for long . ', ' Oh , I am so tired . My back is sore and my neck hurts . ', " That's normal . You have been sitting for three hours , with your attention highly concentrated . ", ' You are wrong , Shirley . I was always absent-minded in the class . I meant to concentrate on the class , but I was just so tired . Maybe I am old . ', ' No . You are just burning yourself out these days . Have a good rest and you will feel energetic again . ', ' One of my friends took the Adult College Entrance Exam last year . He filled the school column with his name , and his score was relinquished . ', ' How could he make such a silly mistake ? ', " He said he hadn't taken any exams for ten years , and couldn't get used to it immediately . He was extremely nervous then . ", " He lost a very good chance to go to college , didn't he ? ", ' Yeah . The test was fairly easy and almost every test-taker could pass that exam . Adult College Entrance Exam is much easier than college entrance exam . And there are fewer subjects . ', " That's a very good lesson . We must familiarize ourselves with the exam from now on . "]
['What did you do over the weekend ? ', ' I went a global warming rally . It was fantastic to be around so many people who care about the environment . ', " Do you think there's anything we can do to reverse the damage that's been done already ? ", " It might not be possible to fix the problems that we've created for ourselves , but there are lots of things we can do to prevent more damages from happening . ", ' Like what ? ', ' Well , we can use public transport instead of taking our cars for a start . ', ' What else can we do to protect the environment ? ', ' If you do have to drive , you should make sure that your car runs on unleaded petrol . Also , your home should use sources of renewable energy . ', ' How about recycling ? Does that actually help ? ', ' Yes . You should take your glass , paper , plastic , cardboard , and tin cans to a recycling center . ', ' What do you think the biggest worry for our future is ? ', ' I think that the issue of greatest concern is having enough sources of clean water for everyone . ', ' I had no idea you were such an environmentalist before ! ', " To be honest , in order for the earth to continue to be a habitable place , we're all going to have to become more interested in the environment . "]
['Merry Christmas , Bill ! ', ' Merry Christmas . Steven ! ', ' What do you want to do to celebrate Christmas ? ', " I'll have supper with my girlfriend and go shopping . What about you ? ", " I'll go to church first and then go to a Christmas party . Would you like to come ? ", " I'd love to . But I am going to meet my girlfriend right now . See you later . ", ' See you . ']
['So Emily , what do you like to do for fun ? ', ' I like to go to the movies . What do you do in your free time ? ', ' I also like going to the movies . ', " Well that's great ! It's nice that we have something in common . "]
['Who broke the glass , Peter ? ', ' That cat . ', ' I was not born yesterday . It must be either you or Adam . ', ' It ’ s me , mum , I am sorry . ']
['Can you read what this says ? ', " Yes , and you could too if your hair wasn't hanging down in your face . ", " Don't dis my hair ! I like it like this . ", " You like it , but it's getting to be a handicap for you . ", " Hey , that's enough about my hair . ", ' I know a great hairdresser not far from here and she is cute too . ', " I don't go to hairdressers because they're cute . ", " Did I mention she's good at cutting hair too ? "]
['Hello , Tony . Fancy meeting you here . How are things going with you ? ', ' Not too bad , thanks . And you ? ', ' Pretty good ! How are your parents these days ? ', ' Oh , they are fine . They are enjoying their retirement . ', " Oh , good . That's nice to hear . Well , I am going to a football match . I need to go . ", ' Say hi to your family for me . ', ' Thanks , I will , byebye ! ']
['Where should I sit ? ', " Why don't you sit in the back with me ? ", ' Okay . ', " By the way , what's your last name ? I forgot what it is . ", " It's Lin . It's spelled L-I-N . ", ' R-I-N ? ', " My pronunciation is not very good . It's L-I-N , Lin . ", ' I got it . Mary Lin . ', ' Lin is a common Chinese last name . ']
['You ’ re ready , right ? ', ' Ready for what ? ', ' Are you ready to transfer tomorrow ? ', ' Yes . I am ready . ', ' You ’ re not nervous ? ', ' Of course I ’ m nervous . ', ' What are you most nervous about ? ', ' I won ’ t know anybody at that school . ', ' You shouldn ’ t be nervous about that . ', ' Why not ? ', ' Meeting new people is a good thing . ', ' That ’ s a good way to think about it . ']
['What do you think of this one ? ', ' Eh , so so . ', ' And this one ? Too flashy ? ', ' Nah , not too flashy . ', ' Hug ! And this sweater from my aunt ? Isn ’ t it hideous ? ', ' I guess . ', ' Are you even listening ? I ’ m trying to have a conversation with you . ', ' And I ’ m trying to watch the game , but you ’ re yapping on about your new clothes ! ', ' Well I have to decide which gifts to keep and which to exchange for better ones when I go to the Boxing Day sales this afternoon ! ', ' Well could you do me the favor of making this quick ? It ’ s the third quarter and you ’ Ve been blabbering on since the first ! ', ' Oh , your precious game . You watch the same game every year , and each year your beloved hometown team loses by at least three goals ! ', ' Oh no you didn ’ t . You didn ’ t just insult the Sals-bury Seals , did you ? Why don ’ t you just . just go and return all of those stupid clothes and not come back until the sales are over ? ', ' I might just ! Enjoy your stupid game ! ', ' And Merry Christmas ! ', ' Merry Christmas ! ']
['Don ’ t be worried . Please sit down and take it easy . ', ' How could I feel easy ? I ’ m really pissed . ', ' But you should avoid finger-pointing when you haven ’ t got the real facts . ', ' Ok . I ’ ll try my best to calm down first . ']
["Hey , Mike . You've been surfing the Net for quite a while . What on earth are you searching for ? ", " It's something relative hackers . I often hear people talking about them , but I don't know much about them . ", ' Well , roughly speaking , a hacker is a computer buff . ', ' You mean a guy using enthusiastic and knowledgeable about the computer ? ', ' You can say that . ', ' But why are people always having such a negative attitude towards them ? ', ' They must have mixed hackers with crackers . ', ' What is crackers then ? ', " There is another group of people who loudly call themselves hackers , but they aren't . They break into computers and break the phone system . Real hackers call these people crackers , and want nothing to do with them . ", ' So they are two totally different concepts . ', ' Well , the real hackers mostly think crackers are lazy , irresponsible and not very bright , and feel that being able to break security does make you a hacker any more than being able to start cars without keys makes you an automotive engineer . Unfortunately , many journalists and writers have been fooled into using the word hacker to describe crackers . This irritates real hackers to no end . ', ' I see . Then the basic different is , hackers build things , crackers break them . ', ' You got it . ', ' Thanks a lot . ', ' You are welcome . ']
["I don't have my homework today . ", ' You usually are good about turning it in ; what happened ? ', ' I was really sick . ', " But couldn't you have done it when you felt better ? ", ' Yes , I probably could . ', ' You have already missed one other assignment ; when can I expect the make-ups ? ', ' Next class meeting . ', " That will be soon enough , but make sure you get next week's assignment in as well , all right ? ", ' That would work for me . ', ' Good . I know that you are capable of being an excellent student . ']
['What are you reading about in that science magazine ? ', ' There are several interesting articles on recent scientific breakthroughs . I just finished reading one about cloning . ', ' I ’ m not sure I like the idea of that . I don ’ t want people copying me or other people . It could be very confusing . ', ' According to the article , you have no real need to worry . Research nowadays is focussing on cloning parts of a human body to replace damaged or lost parts , not on recreating a whole human . ', ' In the future , that could be possible . ', ' In this article , scientists say that if you took the genes from someone and tried to create a copy of a person , there ’ s no guarantee that the copy would look or act like the original ! ', ' Really ? What else have you discovered ? ', ' I read about how scientists are using material from plants and animals to create new medicines . For example , an animal be immune to disease that affects human . So , scientists find out why it ’ s immune ', ' That ’ s great , because it uses natural materials rather than ones that scientists make themselves . I prefer natural remedies to man-made ones . ']
['Thanks for helping me up . ', " Are you OK ? I didn't mean to put you in danger . ", " I'm the hazardous one here . I made three people fall over ! ", ' That takes talent ... ', " I'm so humiliated ! What's that man saying ? Everyone's laughing ! ", ' He said you obviously prefer Greek comedies to Greek tragedies . ']
['How was the party yesterday ? ', ' Did you enjoy it ? ', " Oh , don't talk to me about yesterday ! It was the most awful evening I've ever had . ", ' Why ! what happened ? ', ' Well.John had promised to be my date , but he stood me up . I waited for a full hour in the cold wind . ', ' So how long did you stay ? ', " I left after the opening dance . I couldn't wait to get out of there . "]
['What is the most unexpected thing you experienced in space ? ', " I wasn't quite prepared for the view of the Earth as we left . It was just awe-inspiring . It emerged from just a slightly curved horizon to a whole Earth , where you could look across oceans and continents in a single glance . I wasn't quite prepared for that . It's inevitably etched in my memory . ", ' When viewing the Earth from space , do you feel detached from humanity or more a part of the totality of humankind ? ', " Detached . You're literally detached from one planet , captured by another . Your only link to reality is the Earth out there ; fortunate - 1y , it stays in view the whole time . ", " There're a lot of suspicions that the International Space Station is never going to become reality . Is it going to be some future project that never happens ? ", " I believe it's certainly for real . It without question has suffered a lot of delays . But there's hardware sitting on the pad right now and it's due to go off in December . It is a reality . It has just taken longer to get literally off the ground . ", " There were a lot of talks during the Bush administration about a not too distant future Mars mission . It seemed to fizzle out . Do you think that this Shuttle mission will reignite the public's passion for space and get us to Mars sooner ? ", " I hope this flight is not just a one-time affair , that it does re-ignite people's interest to push on . But only time will tell . ", " You had gone to the moon twice , orbited space around the Earth lots of times , and of course you have had the most amazing views that a human being can have . How long do we ordinary beings have to wait to feel the weightlessness ? I just can't wait . ", " If I were the man making the decisions , you could get in line tomorrow . I strongly support ordinary people going into space . Unfortunately , I don't think it will be in the near future . "]
['Where did you go yesterday ? ', ' I went to play tennis in the public park . ', ' How often do you play tennis ? ', ' Twice a week . How about you ? ', ' I seldom play tennis . I prefer football and basketball . ', ' But it is very difficult to gather a team of players together . ', ' I usually play with my schoolmates . ', ' Do you like watching football matches ? ', ' Yes , I went to the Than He Sports Center for a football match last Sunday . ', ' Oh , I watched it on television . It was an exciting match . ']
['Where is your native place ? ', ' My native place is Shanghai , which is a very beautiful cosmopolitan city . ', ' So are you a local ? ', ' Yes , I am a local resident . ']
['What ’ re you doing now ? ', ' I ’ m watching TV . ', ' You ’ re supposed to clean your teeth before you go to bed . ', ' I will . ', ' And don ’ t ever forget it . ']
['How can I help you today , Alice ? ', ' Well , I came to talk to you because I want to apply for a scholarship . ', " Oh , good . You're an excellent student . I'd be very willing to help you with that . ", ' Thanks . I really appreciate it.In fact , I do need a letter of recommendation for this scholarship . ', ' What kind of scholarship is it ? ', " It's an undergraduate scholarship offered by the American Minority Students Scholarship Association . I'm eligible for it because I'm Asian American . ", ' Fine . I know about that scholarship.You have to be a student in your junior year , and you have to have a grade point average of 3.7 or higher . ', " I'm a junior now , and my GPA is 3.92 . ", " Excellent . So you'll have a good chance of getting it . ", ' Well , I hope so . The competition is probably pretty heavy.And they want a writing sample too . ', ' Do you have an essay you want to send them ? ', ' No , they want a special essay . I must write an essay on a particular question they pose . ', ' What is the question ? ', ' They give applicants a topic.The topic is , The Place of Ethnic Minorities in a Democratic Society.My essay must be three pages typed and double-spaced . ', " That's a pretty short essay . ", ' Yes , but I need to write it by next week . ', " Good luck . I'm sure you will do a good job . ", ' I came here today to talk to you because ... Well , I need to ask two favors . ', ' Sure . What are they ? ', ' First , I need a letter of recommendation . ', " I'd be happy to write one for you . ", " And second ... Well , I'm not sure if it's normal . ", ' What is it ? Do you want me to read your essay ? ', " Yes , if you could . I mean , if you could read it to make sure there are no mistakes.Or maybe you'd have some suggestions . ", " Of course I could read it . That's no problem . But you need to get it to me soon . ", ' I will . I want to write the first draft tonight.So I could bring it tomorrow morning . ', " Alright . If you can bring it to me tomorrow morning , I can talk with you after class on Friday.So I'll have some feedback for you before the weekend . ", " That would really help me a lot . I'm very grateful . ", " Don't mention it . I'm always willing to help good students . "]
['Did you hear how cold it got last night ? ', ' I heard the radio announcer say it was 18 degrees below zero . ', ' It was so cold this morning . I could hardly start my car . ', " My car didn't want to start either at first . ", " Don't you have a garage ? ", ' Not in the new apartment . We have to leave the car in the parking lot . ', ' How much antifreeze did you put in your new car then ? You must have to keep it well below zero . ', ' I do . Right now I have it protected up to 30 below zero . ', ' Does it ever get that cold on here ? ', ' Not really . It sometimes gets to 20 below . ', ' Speaking of cold , how about going for a cup of coffee to warm up . ']
["What do you think of the new television channel ? Aren't the programs awful ? ", ' I quite agree with you . They are terrible . They are complete waste of time , but my wife disagrees with me . ', ' Actually , what bothers me is the violence . There are far too many detective and police shows . ', " I couldn't agree with you more . There aren't enough educational programs , and even the news shows are not well done . ", " You are absolutely right . They are too brief . They don't tell you anything . "]
["What's the matter with you , Paul ? ", " I'm not feeling well . I think I'm having a cold . ", ' Looks like it.You need to drink a lot of water and take a good rest . ', ' Yeah , I will . ']
['You look pale today . ', " I didn't wear make-up this morning . ", ' You should do sports to keep young . ', " You're right.Make - up can only disguise my age , but exercise may delay it . "]
['Steven , have you any friend in London ? ', ' Yes , my old friend Hanson lives there ', ' Are you close ? ', " Yes . He's one of my best friends . Our friendship formed at college . Why did you ask that ? ", " I'm going to London on business next week . But I know nothing about it . ", ' I get it . You want to find a guide , don ’ t you ? ', ' Yes , Steven . You always know what I want . ', ' Don ’ t worry . I will call Hanson , and ask him to help you . ', ' Thank you ! ']
['My word , you do look ill ! ', " I'm quite out of thoughts recently . ", ' You seem to have something on mind . Promise me , go to see the doctor right now . ', " I'm worrying about my exam . ", " A piece of cake . You'll be successful . "]
['Excuse me , you look familiar . Did you use to live in New York ? ', ' Yes . ', ' Did you use to work at NYU ? ', ' Yes , I did . ', ' Oh , did you know Hugh Young ? He was a music student . ', ' Hugh Young ? Didn ’ t he use to wear a funny yellow jacket all the time ? ', ' Yes . And he used to play the piano with a jazz group at the university . ', ' I remember Hugh . Most people thought he was a little ... uh ... peculiar . Do you know what he ’ s doing now ? ', ' Yes , he ’ s a millionaire in Houston now . ', ' A millionaire ? As a jazz musician ? ', ' Oh , no . He ’ s an executive for a large computer company . I saw an interview with him on TV yesterday . They were asking his opinion about future uses for computers . ', ' Well ! I guess people don ’ t find him so peculiar anymore . ']
['You look so happy , Anna . Any good news ? ', ' Yes . I ’ Ve won the first prize in the math contest . ', ' Really ? Congratulations ! ', ' Thank you , Paul . ', ' By the way , would you like to have dinner with me tomorrow evening ? Tomorrow is my birthday . ', ' Good , happy birthday to you ! ', ' Not so soon . It ’ s not my birthday today . Well , you ’ ll come , won ’ t you ? ', ' Sure , I will . Thank you for inviting me . ', ' My pleasure . ']
["Hello Gina ! We've spoken so many times on the phone but's it's so good to finally meet you in person ! ", ' Hello sir . Good to meet you , too . ', " Oh , please don't call me sir . Just call me Jason . ", ' Ok , Jason . So how was the flight ? ', " Pretty good . There was a bit of turbulence while we were over the Pacific Ocean but it wasn't too bad . The worst thing was the guy behind me . He snored all through the night ! ", ' Really ? But you were in first class ! Nobody woke that guy up ? ', " The stewardess said it's not company policy to wake people up for any reason . ", " That's terrible ! So you didn't get any sleep ? ", " Not much ... but that's ok ... I'm a night owl anyway . ", " So , aside from visiting our factory and offices , are there any other things you want to accomplish while you're in China ? ", " I'd love to squeeze in a trip to the Great Wall . ", " That's not a problem . We can have a company car take you there . It's only about a two hour drive . "]
['What are you going to do after you return from Washington ? ', " I'm going to stay in the city . ", ' What will you do all day ? ', " I'm going to work with my father at the store . In the evening , I'll read books.On weekends , I'll go to the beach with my family . ", ' Have you ever worked ? ', ' No , but I can learn . What are you going to do this summer ? ', " I'm going to camp . I've gone to camp for four summers . ", " I've never gone to camp . What do you do there ? ", ' We do many things . In the morning , we go swimming and boating . In the afternoon , we play basketball or tennis . We sit around a camp fire at night.We sing or tell stories . ', ' That sounds wonderful . ', " It is wonderful . What's John going to do this summer ? ", " I think he's going to the mountains with his parents . ", ' Well , so long , Mary . Have fun . ', " You too , Peter . Give my regards to John . I'll see you in September . "]
['Can you tell the result ? ', " It's love all . ", ' Now the score is in our favor . ', ' Can you tell which team seems to win ? ', ' Hard to say.Now the score is in our favor . ', ' Yes.Our guest team is really tough . ', " They're still fighting hard.Let ' s wait and see . "]
["Maybe you'll get another chance at the statue . ", " I don't think so . Did you ever go and look at your stamp ? ", ' And let them ruin my life ? Forget it ! ', " But you've been looking for that stamp for years . ", " It's not worth it . Besides , I have to save up to pay for some bills . ", " Bummer . I guess we're both out of luck . ", " Yeah . Well , I'll see you this weekend . "]
['Kate , what do you like to do tonight ? Do you often go to the movies ? ', ' Of course . I often go to the movies . ', ' There ’ s a good movie called Summer in Beijing . ', ' I heard it ’ s a very good movie . ', ' Let ’ s find out what time it starts . ', ' Let ’ s look at the newspaper . ', " Here it is . It starts at 8 o'clock . ", ' Wonderful . I ’ m so excited . ']
['I feel confused by all the diet options out there . I don ’ t know which one actually works . ', ' Most of them are not so practical . It will be very bad for your health if you skip lunches or supers as the recommended . I think making an exercise plan can be more effective . ', ' Maybe you ’ re right . It is very expensive to go to a weight-loss center . I ’ d better join in a fitness club . ', ' You don ’ t need to lose weight , you are not fat . ', ' I bought an exercise dress yesterday and I found it was hard to dress it up . ']
['I visited the Polar Aquarium today . ', ' Is it like a zoo of polar animals ? ', " Almost . There are a lot of polar animals sea birds , such as seals , whales and penguins , People don't get much chance of seeing them . ", ' It must have been fun seeing those unusual animals and birds . ', " Absolutely . To be frank , I learned quite a lot about those animals and polar areas . I'm thinking of my kids there one of these days . ", ' Maybe you should let me know about your plan . I want to take my kids there some day . too . ']
['How time flies ! ', ' May and Danny have already grown up . ', ' I can still remember our first date . ', ' Look at that big tree over there . ', " Yeah , oh my god ! It's still there . We have our first date right on there . ", ' Do you know that I fell in love with you at the first sight . ', ' You were dull at that time . ', ' But you agreed to go out with me at last . ', " I can't believe this for it's been 20 years since we got married . "]
['I can ’ t wait to retire . ', ' And then what ? ', ' And then I ’ m moving to Florida where I can play golf all day , every day ! ', ' That sounds boring to me . ', ' What do you plan on doing after you retire ? ', ' Yes , I think I will do something new . I ’ Ve always wanted to be a teacher . ', ' I admire your energy , Ruth . You are young at heart . ']
["Let's get together this weekend , is that all right ? ", ' Sounds good , when ? ', ' When is it convenient for you ? ', ' Any time is fine . ', " Could you and your wife be ready at nine o'clock ? ", " Please wait for us even if we're a little late . ", " Never mind . I'll be waiting for you . ", ' See you then . ', ' OK . Bye ! ']
['I wonder if I can ask you a question . ', ' Ask me a question ? What do you want to know ? ', ' Well ... er ... it is just ... just that I ... ', ' Just what ? Stop beating around the bush . Tell me what you want to know . ', ' I ... er ... I just want to know if you could lend me a few bucks . ', ' Lend you a few bucks ? No way ! Still remember the money you borrowed me last time ? ', ' Yeah . But I ... ']
["Hey , Mary , nice to see you again . I heard you're going back home to the U . S . ", " Yes . I'm leaving tomorrow . I came here just because I want to say good-bye to you . ", " You're so thoughtful . Wish you a good trip home . And we'll miss you . ", " I'll miss you too , my friends . "]
["Lovely day , isn't it ? ", ' Oh , yes . Beautiful . ', ' You are not English , are you ? ', ' No , I am from France . ']
['Good afternoon , would you mind if I sat here ? ', ' Of course not . ', ' I ’ m Jack . What ’ s your name ? ', ' Laura . ', ' Do you like this place ? ', ' I don ’ t think it ’ s very nice . And my father doesn ’ t like it . But my mother likes it very much . So we often come here . ', ' How often ? ', ' Well , we come here almost every month . ', ' Who ’ s that ? ', ' It ’ s my mother . She ’ s fond of swimming . And the man beside her is my father . ', ' Do you like swimming ? ', ' No , I hate swimming . I prefer playing tennis . ']
['What ’ s the area of your country ? ', ' It ’ s not very big . It ’ s a little over half a million square kilometers . ', ' That sounds quite big ! How many people live there ? ', ' There are about 30 million people in my country . Most of them live in the north . ', ' What ’ s the average income ? ', ' That ’ s the really hard to say . I think most people earn about two thousand dollars a month , if you convert the money from our currency into dollars . ', ' So your country is fairly rich . ', ' I think we are richer than most countries , but not as rich as countries in western Europe . Our biggest problem at the moment is unemployment , which is roughly 8 % . It has doubled over the last four years . ', ' Unemployment in my country is a fraction of that . ']
['Look at this headline - Elvis Baby Born on Spacecraft . Where do these tabloids get such crazy stories ? ', ' I ’ Ve often wondered the same thing . I also wonder who reads them . Then I realize that I ’ m standing here reading them myself . ', ' It looks as though everyone in line reads them , or at least looks at the headlines . ', ' I think we picked the right line . This one seems to be moving more quickly than the others . ', ' Maybe our checker is faster at scanning the food . ', ' I ’ m glad . We have only about twenty things here , and I ’ m in a hurry to get home . ']
['The answer is zero ! What a let-down ! ', ' I really want to take him over my knee . ', ' No hard feelings . After all , he is a child . ', ' If you say so ! ']
['Hi . ', ' Hi , Mary , Hi , Ken I hate to bring this up , but that new stereo , system you got ... ', ' Yeah ? ', ' You were playing it very late last night . ', ' Yeah ? ', ' It kept me awake . ', " Oh , I'm sorry . ", ' It kept me awake a couple of hours . ', " I'm so sorry , I .. I didn't realize it was that loud . ", " It was that loud , and it was pretty late , and check with Mary if you don't believe me . ", " It's true.It was a bit loud . ", " I'm very sorry . I didn't realize it . I promise I'll keep it down in the future . ", " Oh , it's no problem.It ' s OK.You know , it only happened once . ", " I am glad we've straightened everything out . "]
['My mother likes to split hairs . ', ' What do you mean by that ? ', ' She has keen to buy something which is much cheaper . ', ' Mothers like that . ']
['Hey Bob . Whatchy doing ? ', " I'm at home painting . ", " I didn't know you paint . What type of painting is it ? ", ' I enjoy oil painting . I learned it in one of my extra classes in college . ', ' That sounds so interesting . I wish I learned a hobby . ', ' Hobbies are never too late to learn . They offer a variety of classes at the local community college . You should look into it . ', ' I think I will . Thanks for the info . ']
['What does your friend Jim do ? ', ' He is a teacher , but he makes a little money on the side by repairing cars in his free time . ', ' He can repair cares ? I cannot believe it . ', ' Believe me , he is the first-class . ']
['Hey Jane . How are you doing these days ? ', ' Hi Martha . Everything is perfect . ', ' Are you enjoying married life ? ', " It couldn't be better . My husband is so supportive with my work and he helps around the house so much . ", " You're so lucky . I hope to get married to a guy like that . ", " I'm so happy . Even though we are both working , we get to spend a lot of time with each other in the evening and on the weekends . ", ' Do you guys do anything special ? ', ' In the evening , we just sit and talk over dinner . But on the weekend , we try to go out to the beach or hit a nice restaurant , or go to a nice cafe . ', ' Sound like everything is great . ']
["David , why don't you clean your room ? ", ' I am not in the mood . ', ' Why are you feeling depress ? ', " I was told my girlfriend was speaking ill of me . It's a real letdown . ", " I don't think she would do such a thing . ", ' But she did and it made me disappointed . ', ' Oh , cheer up ! A girlfriend is not everything . ', ' But she means a lot to me . ', ' Then forgive her mistake . ', " Oh , I just can't forget it . "]
['My brother joined the army last year . ', ' Oh , what does he look like ? Is he tall ? ', " He's tall and strong . ", ' I can tell it from your build . ']
['Look , Forest Gump is on at six thirty . ', ' Really ? It was on in 1994 for the first time . And it is really a classic . ', " Yeah , I am very impressed with Tom Hanks ' performance in the movie . ", ' I am also impressed with the lines in the movie . ', " Life is like a box of chocolates , you never know what you're gonna get . ", " That's my favorite . ", ' You know , it also won 6 Oscar awards in 1995 . Unbelievable ! ', ' It deserves . That film can give us a lot of inspiration . ', " Yes , the Forrest's experience can encourage the people in trouble . ", ' All in all , it will never lose its appeal . ', ' Gucci , I have an idea . Do you want to see this movie together ? ', ' Sure . Now you are talking . ']
['I hate this kind of weather ! ', ' When I was a kid , there was a weather who said there is no such thing as bad weather . ', ' I think he had water on the brain . This is bad . ', ' He said there are only all kinds of good weather . ', " Okay , Pollyanna , what's so good about this weather ? ", ' Well , for one , we have an excuse to stay home . ', " We ' get ' to stay home ? Do you know something that I don't ? ", ' I know that there is hot chocolate in the kitchen and some new Cds just waiting for us . ']
['What day is it ? ', " It's Monday , October 27 . Speaking of dates , when are you leaving ? ", " I'm leaving on November 10th . ", " Isn't it a Sunday ? ", " No , it's a Monday . ", ' So you are leaving two weeks from now ? ', ' Right . ']
['What are you reading ? ', ' Oh , it ’ s the latest novel by ray blue . It ’ s a sic-fi thriller . ', ' I thought he usually wrote horror books . ', ' He does . He ’ s good at this genre too . It ’ s a captivating read . ', ' We ’ re going to the bookshop . Would you like to join us ? ', ' Yes , I would . I need to buy a textbook for my course and , as you know , I love browsing through the latest paperbacks . ', ' Me too . I need something to read on the flight to new york . I can never sleep on planes . Sarah wants to pick up some children ’ s books for her daughter . ', ' I want to look at nelson Mandela ’ s autobiography . ', ' This is sure to be a worthwhile read . ']
['Do you know what the BBS is ? ', ' Sure . ', ' Tell me then . ', ' BBS means Bulletin Board Service . ', " Oh , I see , but what's it used for ? ", ' A lot of things ! ', ' Tell me in details . ', ' Okay . BBS , an online service , offers a wide variety of online games , files , one-on-one chat , message areas , private mail , and participate forums . ', " Oh , that's great . I want to try later . ", ' Why not ? ']
['Any plans tonight ? ', ' Not really , do you ? ', ' Well , I am wondering if we took a hang-out for a drink or something . You know , I just came back from a really tough interview . I was quite nervous during the interview . I really want to have the job . Right now , I am still a little on the edge . I am not sure if I could convince them during the interview . ', ' Take it easy . It is all over now . How was it going , anyway ? ', " I don ’ t know . I think I did well in the paper exams . I was prepared to answer a lot of questions , but they didn't ask those as I expected . To my surprise , the manager tried to talk about the Chinese poesy with me . ", " That's strange . But probably , it is the new interview technique they call it ' Getting to know you more personally ' . What about your answers ? ", ' Just did my best . ']
['How may I help you ? ', ' I need to return these books . ', ' What happened to this one ? ', ' The cover came off . ', ' You ’ re going to need to pay for the damage . ', ' How much are you talking ? ', ' It ’ s going to be $ 5 . ', ' That ’ s not bad at all . ', ' It really isn ’ t . ', ' Here you go . ', ' Thank you very much . ', ' You ’ re welcome . Have a nice day . ']
['When it comes to select a fund , you will always read “ Past performance is not an indication of future results ” , can you believe that ? ', ' Maybe it is right since everything is possible . You know the market changes quickly these days . But I still have doubted those funds with bad stock performance . For me , his stock record is the very important criteria to decide which to buy . I really want to decrease the risk reach the minimum and achieve the maximum returns . ', ' But I still have doubted those funds with bad stock performance . For me , his stock record is the very important criteria to decide which to buy . I really want to decrease the risk reach the minimum and achieve the maximum returns . ', ' If you refuse to take risk , you can ’ t have better returns . ', ' I will think about it . ']
["I don't know why people are just mad about David Peckham . Is there really anything so fascinating with him ? ", ' He appeals to the fans thanks to two things ', ' You mean he plays well ? Yeah , he often scores by free kicks in crucial games . But a football match is by no means merely a show of taking free kicks . ', " Certainly not . What really counts is to play as a team , passing the ball amongst each other , dodging defenders . Free kicks are a result of all the teammates ' collective efforts.However , a few free kicks often make everything different , especially scoring one such goal in the nick of time . ", ' In the case , maybe facial charm should be his leading card . After all , the majority of his fans are girls . ', ' Yes , his face looks are manly , with a straight nose and infinite eyes . As a man of medium height in the West , he keeps a powerful but elegant figure , looking neither lanky nor stout . ', ' And he is English ! He makes a model gentleman when he puts on a black suit and speaks with a typical British accent . ']
['Can you tell which team seems to win ? ', ' Hard to say . Now the score is in our favor . ', ' Yes . Our guest team is really tough . ', " They're still fighting hard . Let's wait and see . "]
['May I have a word with you ? ', ' Certainly . ', ' When will you be free ? ', ' Come by any time . ', " Shall I say around ten o'clock ? ", " Yes , I'll be waiting for you in my home by 10:00 . "]
['Office software like Windows might be one of the best inventions in this information age . It saves us from so much work and makes the communication even around the world much easier . ', ' Fully agree . I do enjoy the convenience though I am still a beginner in using Excel . The latest office equipment is more type-functional . It combines fax machine , copy machine and printer in one . It saves a lot of place one machine instead of three . ', ' Yes , this machine is even smaller than those before . ', ' When will we get one of those ? ', ' You know our boss always trying to save the last penny . We have to use up the equipment first . ']
['Congratulations ! Mr . Stuart ! You won the city marathon . ', ' Thank you . I am very excited . ', ' We are all very proud of you . ', ' I am very happy , too . It was a big game and I won . ', ' I watched the race with my children . We saw you run to the finish line . We all screamed with excitement . ', ' It was really an exciting moment . ']
['I really dislike reading academic books . ', ' That may be so , but reading them is an important way to expand your knowledge . ']
['Are you ok , Chuck ? You look pale . ', " I'm fine , Katherine . I just stayed up late last night working on my Chinese . ", ' Oh , poor you . You know what ? I found a new way to learn Chinese and it works very well . ', " You did ? Do tell me . I've spent all these months trying to learn something new about it , but I've made little progress ! ", " Sure . I'm learning Chinese through songs . ", " So you're learning Chinese songs ? ", ' You can say that . I can actually sing some of them now . ', " That's a real achievement . How did you do that ? ", ' I start by listening to the song a few times and after several times I am able to follow the singer . ', ' It makes sense . ', " It does . I've learned some Chinese folk songs this way . They are clearly presented and easy to follow . ", ' Can Join you , Katherine ? I do want to have a try . ', ' Why not ? I downloaded a beautiful song the other day . We can learn it together now . ', ' Great . Do you think we need a Chinese dictionary ? ', ' Yes , just in case we run into me new characters . ', ' Ok . I will bring it with me . ']
['Where to , miss ? ', ' Hi ! Crenshaw and Hawthorne , at the Holiday Inn that is on that corner . ', ' Sure thing . So , where are you flying in from ? ', ' From China . ', ' Really ? You don ’ t look very Chinese to me , if you don ’ t mind me saying so . ', ' It ’ s fine . I am actually from Mexico . I was in China on a business trip , visiting some local companies that manufacture bathroom products . ', ' Wow sounds interesting ! Excuse me if I am being a bit nosy but , how old are you ? ', ' Don ’ t you know it ’ s rude to ask a lady her age ? ', ' Don ’ t get me wrong ! It ’ s just that you seem so young and already doing business overseas ! ', ' Well thank you ! In that case , I am 26 years old , and what about yourself ? ', ' I am 40 years old and was born and raised here in the good old U . S of A , although I have some Colombian heritage . ', ' Really ? That ’ s great ! Do you speak some Spanish ? ', ' Uh ... yeah .. of course ! ', ' Que bien ! Sentences poems habeas en espanol ! ']
['Oh , boy , I hate to say this , but I really have to leave now . ', ' That ’ s all right . I understand . ', ' I ’ m so sorry . ', ' That ’ s ok . Don ’ t be sorry . We ’ ll talk later . ']
['Have you thought of moving at all , Sarah ? ', ' We ’ Ve thought about it , but my husband and I can ’ t afford it right now . The only thing we could afford would be living in the slums , which is something I don ’ t want to do . ', ' Buying a house can be expensive , but there are ways to find cheaper houses . ', ' Like what ? ', ' Well , sometimes the city auctions offer houses to the community . You ’ d have to make a quick decision about the offer in a day , but you would definitely save money doing it that way . ', ' That ’ s a good idea . Do you know anyone who has done that before ? ', ' Sure , my sister-in-law and her husband just bought a house that way . They ’ re pretty satisfied with it . ', ' Is the house pretty run-down . ', ' Not at all . The woman , who owned it , took good care of it . But when she died , she had no family left and no will , so the government had to sell it for her . ', ' Was it a very old house ? ', ' It was about 75 years old . There were a few repairs that needed doing , but it didn ’ t take a lot of money or time . ', ' Is it in a good location ? ', ' The area can be a bit rough in the evenings , but the neighbors watch out for each other , so it ’ s ok . ']
['Do Mona and Jim need a new house ? ', ' No , they have a big new fancy house . ', ' Does Jim make a lot of money ? ', ' Yes , he does . He is a science fiction writer . ', ' Does Jim need to make more money ? ', ' Afraid so . The more the better . ', ' What do they need all that money for ? ', ' Well , they spend it pretty quick . New clothes , new computers and new cars every year . And they ’ Ve got a cook and housekeeper.Mona used to be an actress , she likes to spend a lot of money . ', ' Do they have any children ? ', ' No . They want children but no luck yet . ', ' What does Jim like to do ? ', " Jim likes to travel around the world.That ' s expensive ! So he tries to make a lot of money . ", ' What does Mona like to do ? ', ' Oh , she enjoys spending money on fancy parties.Mona loves to wear sexy dresses , and she has quite a bit of jewelry . ', ' Wow ... She sounds like a high maintenance wife . ', ' I guess so . She is also interested in politics . She knows everyone in city government . ', ' Politics can be an expensive hobby . ', ' She is pretty serious about it . Her uncle is a mayor . She wants to follow in his footsteps . ', ' Politics is a hard game to play . ', ' She might do well . Everyone seems to like her . ']
['Are you alright , child ? ', ' Hey , I still know my name . ', ' What did the nurse say ? ', ' She said I have a fever but nothing major . ', ' In that case , you should go home and get plenty of rest . ', ' What if this small fever turns into a big fever ? ', " Then I'll phone our family physician and make an appointment for you . "]
['Who was the best teacher that you ever had ? ', ' That would have to be Miss Baymler , my fourth grade teacher . ', ' What was she like ? ', ' She was patient , kind , fun , smart , caring , and yet strict , too . I really learned a lot from her . ', ' What kind of things did you learn ? ', ' She taught us that you can do anything that you want to do . ', ' Anything ? Do you really believe that we can do anything ? ', ' If you really want to do something and you work hard at it , I believe you can do it . ', ' You said she was strict . Did she have a lot of rules ? ', ' She had some rules that helped us to feel comfortable . For example , the students had to treat each other with respect , or they would be disciplined . ', ' I see . She sounds like she really cared about her students . ', ' Yes . She treated us all fairly . She don ’ t have any teacher ’ s pets . ', ' Really ? Doesn ’ t every teacher have a teacher ’ s pet ? ', ' Well . To be honest , I usually sucked up to teachers because I wanted them to give me good grades . However , Miss Baymler didn ’ t treat me any differently . She really didn ’ t have any teacher ’ s pets . ', ' Do you know what she is doing now ? ', ' As a matter of fact , I do . After she taught our class , she got married and moved to another city . Then , she started writing children ’ s book . ', ' Have you ever read one of the books ? ', ' Of course ! Both children and adults enjoy her books . ', ' Why don ’ t you recommend one to me ? ', ' ok ! I ’ ll bring one to you next time . ']
['Mum , this is for you . ', ' Oh , flowers ! What for , my dear ? ', " Happy Mother's Day to you , Mum ! ", ' Oh , thank you.You are so sweet ! ']
['Did you like the party ? ', ' Not particularly . I was rather disappointed . ', ' Why ? What had you expected ? ', ' I ’ d expected it to be much more exciting . ']
["Look , daddy is on again . Don't you think he is handsome ? ", " To some extent , he is . And what do you think we move to a better place ? I can't see him clearly from here . ", " The seats in the middle of this stadium are great , but they're already occupied by somebody else . ", ' Oh , thank you for pointing that out . By the way , have you been following NBA for this season ? ', ' Of course , tomorrow evening there will be a most exciting game . ', ' Who plays who ? ', ' Rockets vs Lakers . Yao Ming , my idol , will appear in front of several hundred million of the worldwide audience . ', " It's amazing . And when did he begin to play in the NBA ? ", ' In 2002 . And since then he has attracted more attention than ever . ', " I can't consider you as a little kid any more . I know he is very tall . ", ' Oh , you know something . He is 2.26 meters tall . But he is also nimble and skillful . ', ' I also heard if a player has committed 5 fouls then he must be out of the game . ', " Yes , what's worse is he can't take any further part in the game . ", " That's really terrible . Oh , God , we forgot to cheer for Daddy . ", ' Never mind . After all he is not so attractive as Yao Ming , right ? ', ' You are always so naughty . ']
['Pretty ! Say beautiful rather . Can you imagine any thing nearer perfect beauty than she altogether-face and figure ? ', ' I do not know what I could imagine , but I confess that I have seldom seen a face or figure more pleasing to me than hers . ', " Such an eye ! The true hazel eye-and so brilliant ! Regular features , open countenance , with a complexion , Oh ! What a bloom of full health , and such a pretty height and size ; such a firm and upright figure ! There is health , not merely in her bloom , but in her air , her head , her glance . One hears sometimes of a child being ' the picture of health ' ; now , she always gives me the idea of being the complete picture of grown-up health . She is loveliness itself . "]
['Is that Mr . Green ? ', ' This is him speaking . ', " I am calling to inform you that we're happy to have you with us . Welcome aboard , I'm sure your friend would have given you a lot of information of our school and its motto , ways of teaching , etc . ", ' Yes . I am very glad to have the chance . ']
["I'm so nervous about this oral test . ", " Just calm down . I'm sure you'll do well . ", ' I just want to get it over with . ']
['I hear you ’ re taking a music class . I didn ’ t know you ’ re interested in it . ', ' Oh , I ’ m not . I ’ Ve never had a music class before . ', ' In my opinion , you ’ ll make it . ', ' You ’ re having me on again . ', ' No , I ’ m serious . ']
['What ’ s the date today ? ', ' December the fifteenth . The day after tomorrow is little Tom ’ s birthday . ', ' Right . What present should we give him this time ? By the way , how old is he ? ', ' Thirteen today and tomorrow . Fourteen the day after tomorrow . ', ' How time flies ! He ’ s a big boy now . ', ' And don ’ t forget Mary , Tom ’ s twin sister . It ’ s her birthday , too . ', ' OK . Let ’ s invite all their little friends to come and celebrate . ']
['Peter and Mary broke up . ', ' Are you serious ? ']
['I had a wonderful evening . ', ' I did , too.Come and visit us again , will you ? ', ' I will . ']
['Do you know Sally ? ', " Sally ? She is a bachelor girl . She is an excellent designer . Many of the company's advertisements are her child trains . ", ' Why is she still single ? She must have a face that would stop a clock . ', ' Oh , quite the other way round . She is a knock-out . She devotes much of her time to her career . ']
['Do you hear what happened to Sally ? ', ' No , what ? ', ' She had to go to the hospital . ', ' Why ? ', " She passed out in class . Seems she hadn't eaten anything in days . ", " Why on earth would she do that ? You mean that she intentionally did not eat any food for days ? That's crazy ! ", " Yeah , but that's what she did . ", " I can't believe that there are girls who are willing to do that to their bodies . And all for a certain look . ", " Well , it's not just the girl ’ s fault . It's also society's fault - magazines and ads that show - thin models all saying , It's in to be thin . It's hard for them not to listen . ", ' True , but there are limits . Being thin is one thing ; starving oneself to death is another . No one forces them to do this . ']
['Have you ever thought about Tom ’ s attitude ? ', ' I ’ Ve cut it up and come to the conclusion that hi is actually sick of Jenny ’ s brother . But he likes Jenny . She is a big apple in his eye . ', ' Love me , love my dog . He ’ s a sensible kind man . ', ' That ’ s why many people look up to him . ']
['Have you found another job yet , Sally ? ', " No , I haven't , but I've seen several interesting advertisements in the paper . ", ' What kind of job are you looking for ? ', ' Either something in the hotel business or something to do with travel . ', " You haven't had any experience in either of those fields . ", " I know.But I'd like to try.Look , here are some advertisements that I've cut out . "]
['Hi . Are you new in this class ? ', " Yes , I am . I really don't know anyone . ", " My name is Steven . What's your name ? ", ' My name is Bill . How are your lessons going ? ', ' Very well . And my favorite subject is Chinese . ', ' I prefer to learn English . In my opinion , English is easier than Chinese . ', ' I guess English has fewer characters . ', ' You are right . ']
['Robert , this is my friend , Mrs . Smith . ', ' Hi , Nice to meet you . ', ' Nice to meet you too . ', ' Mrs . Smith , what do you do for work ? ', " I'm a doctor . ", ' Oh . Where do you work ? ', ' New York University hospital in New York City . What do you do ? ', " I'm a teacher . ", ' What do you teach ? ', ' I teach English . ', ' Where ? ', ' At a high school in New Jersey . ', " That's nice . How old are you ? ", " I'm 32 . "]
['Hah ! For three hours while you threw up . And Femi dumped me for that . I really loved her . ', " I'm so sorry , Taylor . Go talk to her . I'm sure she'd be happy to see you . ", " She probably wouldn't even recognize me . She's probably married . ", ' Yi-jun said Femi was talking about you . So get out there , Tiger ! ', " Was she really ? So you're telling me there's a chance ? ", " Can't hurt to try . Carpe diem . Who can say if we'll be here tomorrow or not ? "]
['Oh , Ralph , I heard it is very dangerous traveling in space . Disasters have happened before . If the spaceship were out of order . . . ', ' You should be optimistic about this . Things have taken a good turn . You should remember that less than two centuries ago the dangers of train travel seemed similarly terrible . ', ' But is it possible that travelers could be hit by meteors ? ', " It's once in blue moon . ", ' What do you think is the real danger man faced in space ? ', ' The main one is radiation . There are two sorts of radiation man must fear in space . The first is radiation from the sun , and this is particularly dangerous when the sun is very active and explosions are occurring on its surface . The second , less harmful , comes from the so-called Van Allen Belts . ']
['Hi , Mark , did you catch the game last night ? ', ' No , I was out . Was it worth watching ? ', ' You didn ’ t hear ? Spain won , two to zero . ', ' Oh , really ? So , Spain is through to the next round ? ', ' Yeah . The final is next week . You have to watch it . ']
["Get up as early as six o'clock only to be jammed at every crossroad and still late for work . What a life ! I've had enough of it . ", " Cool down , man . Everyone is fed up with the rush-hour traffic . But life isn't really all that . You should take the initiative and make some changes first . ", ' What should I do then ? ', " I recommend you ride a bike instead of commuting by bus . It may offer you many benefits . First , it's good for your health . I'm afraid it's not necessary for me to further elaborate . While lots of people spend time like an hour each morning exercising , a bike ride to work not only builds you up , but also makes full use of time . You might as well sleep out for a longer hour . ", " I know cycling is always a more favorable choice than a bus . After all , it's a sport . But do you think it a pleasant experience to take in the dirty , polled air on the road ? ", " Well , such things are just unavoidable in a great metropolis like Beijing . I think a still more desirable benefit is psychological . Bicycling home after work can help release your stress . Life in the offices is miserable . You just sit there in a daze , gazing at the monitor and dealing with files and documents . Why don't you give a full play to your energy after work ? Enjoy the speed on the road . Just think , you are flashing past the poles with your own energy . How great ! "]
['How many people are there in your family ? ', ' Five . Besides my parents and me , there are my brother and sister . ', ' That ’ s a big family . How old is your brother ? ', ' Eighteen . ', ' What about your sister ? ', ' She ’ s not quite twenty-five . ', ' Do you miss your family ? ', ' Yes . ', ' Do you often go home ? ', ' No . But I often send e-mail to them . And make a call to my parents regularly . ', ' How often do you call to them ? ', ' Once a week . ']
["I'm terribly nervous . ", ' Calm down ! ']
["What's wrong ? You don't like ancient Egypt ? ", " Actually , I don't like history . Lately , these shows are always about the Pyramids . ", ' The Pyramids are amazing ! Millions of gigantic stones ... each one perfect ... ', " And nobody knows who built them , right ? It's a total mystery ! ", " You sound like the TV ! You're not going to tell me that aliens built the Pyramids , are you ? "]
["What's the problem , Nada ? You look down in the dumps . ", " I don't know . My life is a big mess . Everything is so complicated . ", ' Come on , nothing can be that bad . ', " But promise me , you'll keep it a secret . ", " Ok , I promise . So what's troubling you so much ? ", " I've fallen in love with my boss . ", ' Really ? Is he married ? ', ' Bo , of course not . He is still single . ', " Then what's your problem ? ", ' I try to keep it to myself . But there is a lot of gossip about us . ', ' Oh , I see . Office romance tends to be the subject of gossip . ', ' Worse still , he is trying to avoid me these days . ', ' Office romance is very tricky . ', ' It gives me a lot of pressure and I feel depressed . ', " Cheer up , Nada . You'll be fine . "]
['How may I help you ? ', ' I want to return this video . ', ' Is that all you need ? ', ' I also need to check these books out . ', ' Anything else ? ', ' That ’ s everything . ', ' I need your library card . ', ' I have it . Here you go . ', ' Do you need anything else ? ', ' That ’ s everything . ', ' Your books are due back two weeks from today . ', ' Thank you . Good night . ']
['Did you happen to bring that book that we were talking about yesterday ? ', ' I did . Let me go get it for you . Here you go . ', ' Thanks so much . ', ' I like the way that the gifts I get increasingly more lavish . ', ' I had no idea that there were specific things that should be given on different anniversaries . ', ' So what does it say you should give your wife this first anniversary ? ', ' It says that traditionally , give something made of paper . ', ' I can think of two things made of paper — stationery and money . ']
["I'm going to the park to play baseball with the guys . ", ' But you promised to play chess with me this afternoon . ', ' Yeah , but that was before the guys ask me to join the team . ', ' So what ? ', " You know how much I want to be on the team , and now there is an opening for me.If I don't go to practise today.They ' ll get someone else and I'll miss my chance . ", " I don't care about baseball.You know I need to practice for the chess championship and you promised to help with me if I washed the dishes for you last Sunday , and I did . ", ' I know , and I will . ', ' When ? ', ' After baseball practice . ', " And then , it'll be dinner time , then homework , and then your Show is on.You are going to break your promise . ", " No , I won't . I'm going to skip TV tonight and work on your chess game with you if that's ok with you . ", " Well , I'd rather do it the way we set up.But if you promise to give me your best game , it's ok with me . ", " No problem , I'll play as hard as I can and give you an extra game to say thanks . "]
['What stresses you out the most ? ', ' Probably my parents . ', ' How so ? ', ' Well , during school , they wanted good grades . Then after I got a job , they wanted me to get a better job . And finally , they want me to get married . ', ' You have to deal with a lot of pressure from your parents . ', ' Your parents are not like that ? ', ' Ever since I brought home some bad grades in elementary school , they never expected much . ', " You're lucky . ", ' What do you do to deal with the stress ? ', " Not much I can do . It's always there . I sometimes go out with some friends and drink , but that's only a temporary solution . The stress always returns in the morning . ", ' That sucks . You wanna go grab a beer ? ', " Sure . Sounds great . Let's go . "]
['Tony looks very handsome in the suit . ', ' He prefers suits to jackets . ', " Judge from his look , he's a very serious person . ", ' As a matter of fact , he is . ']
['Lily thinks that the job takes a back seat to the family after she is married . ', ' She must be a good wife . ', ' Not necessarily . This is only what she says , not what she does . ', ' I see . ']
["What's the weather like ? ", " I don't know . I just woke up . ", " Why don't you look outside ? ", ' Okay . It looks like rain . ', ' Why do you say that ? ', ' The sky is gray . ', ' Is it raining right now ? ', ' No . ', ' How do you know ? ', " The street isn't wet . ", ' I have to go shopping today . ', " You'd better take an umbrella . "]
['Hey there , you look a little lost . Are you new here ? ', ' Yeah how ’ d you know ? ', ' You can always spot the newbies . I can give you a few pointers if you want . Were you trying to use this machine here ? ', ' Yeah ! I just started my training today and I ’ m not really sure where to begin . ', ' It ’ s ok , I know how it is . This machine here will work out your upper body , mainly your triceps and biceps . Are you looking to develop strength or muscle tone and definition ? ', ' Well , I don ’ t want to be ripped like you ! I just want a good physique with weights and Carpio . ', ' In that case you want to work with less weight . You can start off by working ten to fifteen reps in four sets . Five kilo weights should be enough . Now it ’ s very important that you stretch before pumping iron or you might pull a muscle . ', ' Got it ! Wow is that the weight you are lifting ? My goodness that ’ s a lot of weight ! ', ' It ’ s not that much . Just watch ... I ’ m ok ... ']
["I don't know how John can put up with his son , who fools around without working . ", " He's out of John's hands . Nothing he can do about such a black sheep . ", ' If I were him , I would give him a good talking-to . I would insist on his stopping fooling around like that . ']
['Do you like ice skating ? ', ' I have never tried it . ', " Then you've got to try it . Let's go to the skating rink on Thursday . ", " Sorry , I don't think I can . ", ' Friday then . How about it ? ', ' Friday is great . ', " It's settled then . "]
["Gordon , you're ever so late . ", ' Yes , I am sorry . I missed the bus . ', " But there's a bus every ten minutes , and you are over 1 hour late . ", ' Well , I missed several buses . ', ' How on earth can you miss several buses ? ', ' I , ah ... , I got have late . ', " Oh , come on , Gordon , it's the afternoon now . Why were you late really ? ", ' Well , I ... I lost my wallet , and I ... ', ' Have you got it now ? ', ' Yes , I found it again . ', ' When ? ', ' This morning . I mean ... ', ' I am not convinced by your explanation . ']
["Let's have seafood tonight and then go see the new movie at Mall Cinema.Betsy told me it's a beautiful love story and I shouldn't miss it . ", " Oh , Goodness , please not again.That ' s what we did last week . ", " No , we didn't . Last week we went to see that movie about a man's struggle against mental illness . ", " Right , it was a chick flick , just like this one , so what's the difference ? Besides , this is the last week for the third movie in Destroyer series and I want to see that on a big screen . Action movies need to be seen in a theater on a big screen . ", " Oh , yeah , and I did promise to see it with you if we went to that movie last week.But you liked that movie , didn't you ? ", ' Oh , sure , it was great . I had popcorn for dinner and paid the price of a movie ticket to get a two-hour nap . ', " It wasn't that bad , and you're the one that insisted on skipping dinner.We went to an excellent restaurant . ", " That place doesn't have a single meat dish.Just fish and shellfish and you know I don't like fish that much . ", " And I don't like meat that much.The only meat I eat is chicken . ", ' But when I pick the restaurant , we go to a place that has both chicken and fish . I always respect your food preferences . ', ' Well , I suppose that , to be fair , you should get to pick the movie and we can go to a restaurant that serves meat . ', " Now you're talking , we can see that love story next time . "]
["How's your new job going ? ", ' Really well , thanks . ', ' How are you finding your new boss ? ', " She's not bad . She's a bit bossy , but I'm sure I'll get used to her . ", ' Would you rather have her or your old boss back ? ', " She's far better than my old boss . He didn't know how to express his opinion without putting at least one other person down . ", ' How about your new co-workers ? ', " They are all pretty easy-going . It's a very friendly place to work . ", ' Do you miss your old co-workers ? ', ' Of course . I spent so much time at my old workplace that I got to know them all very well . They were like family to me . ', ' Do people in different departments get along with each other ? ', ' Sure . Since we work together in teams , we have to get along with each other . ', ' Do you like working in teams with people from different departments ? ', " Yes , it helps everyone to understand what we're doing from different perspectives . ", ' Do you like working in teams ? ', ' I prefer it to working independently . I think most people do . ']
['Linda , John and I are going to get married next week . ', " That's wonderful . Congratulations . ", ' Thank you , Linda . We would love you to come to our wedding . ', " I'd love to . What date is it ? ", " It's May 1st . ", ' What day is that ? ', " It's Saturday . Could you make the time ? ", ' Yes , sure . What time will the wedding begin ? ', ' At nine sharp . ', " Very good ! I'm looking forward to it . Please give my best regards to John . And I wish you best luck ! ", ' Thanks . ']
['So do you think you can get to the office alone ? ', ' Sure , I ’ ll catch the train . If I can ’ t catch the train , I ’ ll get a taxi . ', ' Do you think the taxi driver will understand you ? ', ' If he doesn ’ t understand me , I ’ ll show him the office address on my business card . ', ' Ok but how will we know if you are going to be late ? ', ' I ’ ll call you if I ’ m delayed . ']
['You and Bob have finished ? ', ' Yes . ', ' Are you going to be okay ? ', " Yes , I'm used to being on my own . "]
['Tony looks very handsome in the suit . ', ' He prefers suits to jackets . ', " Judge from his look , he's a very serious person . ", ' As a matter of fact , he is . ']
['You are friend of Janet , right ? I am Andrew , Andrew Smith . ', " Nice to meet you , Andrew . I am Noirin , Noirin O'Neil . ", " I'm sorry , I didn't quite catch that . ", " Noirin , N-O-I-R-I-N , it's an Irish name . "]
['Wow ! It ’ s packed . ', ' The train station is indeed crowded . I think it ’ s hard for us to get on the train . ']
["it's getting cold . ", " yes . I bought a scarf yesterday . It's really nice and warm . Have a look . ", " Oh , it's made of wool . I like the striped pattern . ", ' yes , I adore simple fashions . How does it look on me ? ', " it looks great , but you need something to go with it . It's too plain on its own . ", ' how about this blue sweater ? ', " that's a good idea . When did you buy it ? Is it a name brand ? ", ' yes , but I bought it when it was on sale , 50 % off the original price . OK , what do you think ? ', ' that looks lovely . Just one more thing---you need a pair of earrings . ', " I've got a pair of pearl earrings . Here it is . ", ' perfect ! ', ' you have good fashion sense , Karen . ', ' thanks . We should be ourselves . There are so many fashion victims out there . ', " yes , but with our sense we'll always look good . "]
['Susan ? What brings you here today ? ', ' Well , I ’ Ve got some papers due . ', ' Really ? So what ’ s the news ? ', ' Not too good yet . Better than I was though . ']
['Hello , Mary . ', ' Hello , Brian . ', ' Here is my friend Bob . ', ' Hello , Bob . ']
['Are you free tonight ? ', ' Depends . ']
['Wanna chill out and watch cable ? ', " Wow ! Besides The Cosby Show , I've never seen a black sitcom . What's this program ? ", " It's a drama called Soul Food . This channel is BET-Black Entertainment Television . It has black shows , news and commercials . ", ' This show is like a black Friends . ', ' BET has black shows that are overlooked by mainstream white TV . ', " That's cool . I've heard LA has an all-Asian channel on cable . "]
['My boss wore a real stupid tie to work today . Can you guess why ? ', " He isn't a man of good taste for clothes , is he ? ", " He is , but I didn't mean that . His daughter bought him a tie as a Father's Day gift , and he was very happy to wear it and show it off to us in the office . ", ' It must be hard being a father . ', " No , it's great being a father , seeing your children growing up and loving you and admiring you . ", " Maybe you'll only feel that way on Father's Day . "]
['So Alex , you ’ re off to the Olympic stadium then ? ', ' Yes , I should get there just in time for the women ’ s 400m relay . ', ' Wow , that should be really exciting , especially with so many famous athletes there . ', ' Yes , I ’ m also going to watch the triple jump and the high jump . ', ' Well have a good time . Get me some autographs if you can . ', ' Ok , I ’ ll try my best . ']
['Where did you go yesterday ? ', ' I went to play tennis in the public park . ', ' How often do you play tennis ? ', ' Twice a week . How about you ? ', ' I seldom play tennis . I prefer football and basketball . ', ' But it is very difficult to gather a team of players together . ', ' I usually play with my schoolmates . ', ' Do you like watching football matches ? ', ' Yes , I went to the Than He Sports Center for the football match last Sunday . ']
['... And now , let ’ s go to Kenny Williams for today ’ s weather forecast . ', ' Thank you Bill , and good morning Salt Lake City ! ', ' What ’ s the weather looking like today , Kenny ? ', ' Well , it ’ s a bit of a mixed bag in Utah today . we ’ Ve got heavy cloud cover here in Northern Utah , and we ’ re calling for scattered showers throughout the day , with a day-time high of forty-five degrees.Now , if we move down to the south of the state , we can see that a cold front is moving in.We can expect clear skies , but it will be quite cold , with temperatures hovering around the thirty degree mark . ', ' It ’ s a chilly day folks , so don ’ t forget your coats ! What about tomorrow Kenny ? Do you have good news for us ? ', ' Well , it ’ ll be a rainy day for Northern Utah.we can expect some isolated downpours in the morning . Winds will be coming in from the North East , with gusts reaching twenty-three miles per hour . Salt Lake City can expect the rain to turn to sleet in the evening . Things are looking a bit better for the South.we ’ ll see cloudy skies with a chance of showers . Later in the day , we can expect partlycloudy skies , with a forecast high of thirty-eight degrees . ', ' You heard it folks ! It ’ s gonna be a cold one ! ', ' That ’ s right Bill . We will have more later on today on the six o ’ clock news . That ’ s the weather forecast for this morning . ']
["He's been compared to Rimbaud , you know . ", ' You mean as in Sylvester Stallone ? ', ' No , you idiot . I mean the poet , Arthur Rimbaud - R , I , M , B , A , U , D . ']
['I am having a hard time at my job . ', " What's wrong , Julia ? ", " My colleagues quickly get promotions , while I always get sidelined . I don't know what to do anymore . ", " Don't give up so soon . ", " But I don't know what else I can do . I am willing to work hard . Sometimes I make mistakes and the boss is not happy . ", ' Mistakes are just a lessons to learn from . ', ' Tell that to my boss . ', ' Do you know Abraham Lincoln ? ', ' Yes . ', ' He grew up poor in Kentucky and barely had a year of schooling , but he went on to become the President of United States . ', ' He was also assassinated because of his views . ', " He is known as American's greatest president . Do you know why ? Because he fought against slavery and secession at a time in history where others were too afraid to do anything . He succeeded because of his ambition and generous spirit . ", ' Well , if he can become president , then I can at least get a promotion . ', " That's the spirit . Never give up on your dream . "]
['Well , my particular interest is collecting stamps , especially the rare ones . What about you ? ', ' I ’ m afraid that ’ s not my cup of tea . I just find skin-diving attracting . ', ' So have you ever been to the stamp display of the town ? ']
['Hello ! ', ' Oh , hi ! ', ' Please allow me to introduce myself . My name is Tom . ', ' Pleased to meet you . My name is Alice . Did you just move in next door ? ', ' Yes , I did . Have you lived here long ? ', " Me ? I guess so . I've lived here for about six years now . Have you lived in America very long ? ", ' No , not really . When I left Vietnam , I came to America and I lived with a cousin in Dallas for two years . Where do you work , Alice ? ', ' I teach mathematics at a college . What do you do ? ', ' I am an accountant at a company . ', " Well , Tom . It's good to meet you . I have to go now . I am teaching a class this evening , and I need to get to the college . ", " It's nice meeting you too , Alice . ", ' See you around ! ', ' Goodbye , Alice . ']
['Excuse me . I am interested in getting a library card . ', ' Sure , let me give you an application . You can fill it out right here at the counter . ', ' OK , here it is . ', " Let me take a look at this for you . May I have your driver's license , please ? ", " Here's my license and form . ", ' You seem to have filled the form out all right . Are you familiar with our rules and fines ? ', ' Yes , I know what to do . ', ' The hours and limitations are printed on the card and this handout . ', ' OK . ', ' Thank you for joining the library ; we look forward to serving you . ']
['Hey , Frank . I heard you got a new job . ', ' Yeah , Judy . I will be working for the Post Office . It ’ s not a bad job . ', ' Is it true that you have a heavy work schedule ? ', ' That ’ s right . I report to work at 5am everyday , and I only get 45 minutes for lunch . ', ' So , why did you apply for such a demanding job ? ', ' Well , the government offers its employees excellent health insurance benefits . ', ' Oh , I see . And can your family utilize 5 the health insurance , too ? ', ' Yeah , that ’ s the best part . All of my children can get free medical care . ', ' That ’ s a great employment benefit ! ', ' Now you know why I wanted to work for the Post Office ! ']
['He has come to life in the end . ', ' Oh , thank God . We all felt frightened by the bad new about him . ', ' Yes . Fortunately , an ambulance passed in the nick of time , and we got him away to hospital . ', ' Right . Unless , who know what will happen . ', ' Wish him to be healthy soon . ']
['Harry , do you like the opera ? ', ' No , not really . ', ' Why is that ? It is called real art . ', " Well , it's very expensive and they're usually singing in another language . That kind of gets on my nerves . ", ' Yeah , that makes sense . ']
['Lisa wins the first prize in the English speech contest of her college . ', " Really ? That's really wonderful . I'm so happy for her . ", ' But I always feel disappointed . I have many problems with English learning . ', ' Honey , cheer up . ', ' I feel confused about the grammars . ', " I'm sure you'll do fine if you try your best . ", ' And my writing is not good . I feel so frustrated . ', ' Be confident , and never give up . ', " I know that , mom . But sometimes I'm just sad . ", ' Keep your chin up . Remember ? Nothing is impossible to a willing heart . ', ' Yes , mom . You are right . Nothing is impossible to a willing heart . I will keep going . ']
['how did you do on your BELTS exam ? ', ' fantastic ! I got an overall score of eight . ', " that's excellent ! Have you received your conditional offers yet ? ", " yes . I'm just waiting until I officially get admitted to the university with a conditional offer to apply for my visa . ", ' do you know where the visa office is ? ', ' no . ', " it's just near the Dong Si Shi Tiao subway stop . ", " that's not too far away . Do you think I'll get a visa ? ", ' have you ever gone abroad before ? ', " yes , I've been to Tailband , Egypt , and Japan . ", ' have you ever been denied a visa before ? ', ' never . ', " that's good . Are you planning on immigrating to another country ? ", ' no , I want to come back to China after I graduate . ', " that's exactly what the visa officers want to hear . Do you have enough money for tuition and room and board ? ", " I've received a full scholarship , so I won't need any other money to live off while I'm studying . ", ' I think you have a very good chance of getting a visa . I can help you prepare for the visa interview if you want . ', " that's be great . The more prepared I am , the better . "]
["Hi there , I'm Steve Saunders.What ' s your name ? ", " I'm Patti Whitney.Isn ' t this convention great ? ", " Yes it is , better than I expected it would be.The presenters have been first rate.Is this the first conference you've been to ? ", " No , I've been coming for the last 3 years.Each year keeps getting better.Where are you from ? ", " I'm from Long Island , New York.What about yourself ? ", " I'm from the other side of the coast--Los Angeles . ", ' Wow . I really like California ... the weather there is much better than the East Coast . ', ' Have you been to California ? ', ' Just once.Quite a few years ago we took the kids to Disneyland on our vacation.They had a blast . ', ' How many kids do you have ? ', ' Two , a boy and a girl.They ’ re already grown now . ', ' Well , California ’ s changed over the last little while.You should come back out sometime . ']
['I dislike Susan . She is always above herself . ', ' Don ’ t you know that she was the only one who had received the invitation in the office ? ', ' What of it ? ', ' Sure . ']
['Does it bother you that your husband goes away on long business trips ? ', ' No.The time we have spent apart has been good for us.Absence makes the heart grow fonder . ']
['What can I do for you ? ', ' I ’ m returning these books . ', ' Let me have them . ', ' Here are all of them . ', ' These books are two weeks late . ', ' I didn ’ t have time to return them . ', ' You ’ re going to have to pay late fees . ', ' How much ? ', ' 25 cents a day . ', ' 25 cents a day ? ', ' That means 25 cents for each late book . ', ' That ’ s expensive . ']
["I hear you're entering the speech contest , Mike . ", " That's right . I thought I'd give it a shot . ", ' Well , I wish you good luck ! ']
['What shall we do after the volleyball match ? ', ' How about going to the Olympic souvenir store to have a look ? I remember there is one in the gym . ', " That's a good idea . I was thinking of buying some gifts for my family . ", ' Me , too . What did you have in mind ? ', " I haven't decided yet , but I think the Olympic Mascots are a must . ", " I agree . They're very lovely , especially Huanhuan ", ' Is that the red one ? That is my favorite , too . Do you know how much they are ? ', " The five dolls are sold together as a set , and they're priced according to the size . The bigger they are the more expensive . ", ' Oh , I see . If I buy more than a set , can I get any discount ? ', " I don't think so . All the souvenirs of the Olympic Games are very hot right now . ", ' Any other ideas ? ', ' There are lots of things , such as postcards , key chains , posters and various arts and crafts . ', " It all sounds great . We can go there after the match . I can't wait to see what they have . "]
['It is time to butter him up . ', ' What do you have to do to grease the palm of him ? ', ' I don ’ t know . Let me see . ', ' You can go and ask your father . ']
['Cindy , I heard you got into that university . Congratulations ! ', " Thanks ! I'm so happy . It's like a dream come true . "]
['Hello ? ', ' Hi Vicky . ', ' Are you there yet ? ', ' Yes . ', " I just got off the subway . I'm almost there . Sorry I'm late . ", " That's no problem . I just wanted to tell you I'm inside . ", ' Where are you ? ', ' On the second floor . ', ' Should I come to the second floor or do you want to come to the first floor ? ', ' Come upstairs . ', ' What ? ', ' Oh , Can you hear me OK ? I said , come to the second floor . ', ' Oh , OK . What are you doing there ? ', ' Just looking at some books on how to learn English . ', ' Do you want to get something to eat later ? ', " No , I'm still full from dinner . ", ' What do you want to do ? ', " I don't know for sure . When you get here we'll talk about it . ", ' OK , see you soon . ', ' Bye . ']
["Who's that old lady trimming the trees ? ", " She's my grandma . ", ' She looks very healthy.How old is she ? ', ' 92 . ']
['What do you think are the main causes of war today ? ', ' I ’ d say the main reason is poverty . Countries and their people get frustrated because they have so little . If their neighbors have some resources , they try to steal them by military force . ', ' It seems that a lot of wars nowadays are really civil wars . People from different ethnic groups in the same country sometimes fight for power in that country . ', ' Several of those civil wars have been going on for years and years . It seems they will never end . ', ' How do you think they could be ended ? ', ' I don ’ t think that there is any easy way . The united nations could send peacekeepers into the country . At least then the warring parties could be forced to negotiate . The thing is to find the real problem form the war and solve that . ', ' So , if the cause is poverty , there should be a program to make the country richer . If the problem is resources , share them . ', ' It sounds easy when you say it like that . In reality , it ’ s harder to make peace between countries . ', ' Yes . It is . One way to stop countries fighting is to cut off their financial support . Wars are very expensive . ', ' The problem is that many poor people might suffer . ']
['Are you feeling better today , Bill ? ', " Well , it's hard to say . I cough a lot in the evening . ", " You'd better give up smoking . It's bad for your health . ", " You're right , but you know , it's hard to give up an old habit . ", ' But you should make up your mind first . ', ' You know , I often have to work til late at night . I need something to keep me awake . ', " Why don't you go to bed and get up early ? You'll have the same time for work . ", " Thank you for your advice ! I'll try it . "]
['Well , I must be off now . I have an appointment at six . ', " In that case , I won't keep you any longer . Drop in any time . ", ' Ok . Goodbye . ', ' See you later . ']
['Hello , Julia , I know a party that will begin at midnight . Would you love to go ? ', " I'd love to , but my mother asks me to go home before 11:00 every night . She will worry if I get home late . ", ' What a pity ! The party is very interesting . ', ' I have no choice . My mother is always very strict with me . ', ' Don ’ t complain about it . She is concerned about your safety . ', " You're right . Mother's love is the greatest love in the world . "]
['Steven , why are you so depressed ? ', " I'm feeling very sad . I just read the newspaper . ", " What's the news ? ", ' According to the newspaper , the town was razed by an earthquake and more than 10 thousand people died in the earthquake . ', " It's horrible . ", ' Yeah , we have to do something to help the people in the stricken area . ', ' Yes . How about donating some money ? ', " It's a good idea . But where can we donate money ? ", ' Just find the answer through Internet . ', " Yes , let's do it now . "]
['I don ’ t know how to deal with Jack . He is indeed a trouble maker . He has louse up my business several times . ', ' You mean Lily ’ s boyfriend ? ', ' Yeah . ', ' Well , he is a hard case . Everyone would feel headache about him . ']
["Who's that over here ? ", " That's the new teacher . ", ' What do you think of the teacher ? ', " She's very nice . ", ' What does she teach ? ', ' English , of course . ', ' Is she your teacher ? ', ' Yes.She teaches our class three times a week . ', ' Can she speak Chinese to her students ? ', ' Not very much . ', " It's a good thing you can speak English ! "]
['Judy , what is everybody talking about ? ', ' Haven ’ t you heard ? Richard was fired by our manager . ', ' You ’ re kidding . It can ’ t be true . ', ' Believe it or not . Everybody is talking about it in the company . ', ' Really ? I ’ m surprised . ', ' Me too . ']
["Hi , Mike . Haven't seen you for a while . How's Cathy ? ", ' We are not seeing each other any more . ', ' What happened ? Did you break up ? ', ' Yeah . I got sick and tired of her nagging all the time . ', ' Oh , I am sorry . Maybe you were just emotional at that moment . Do you think you guys can get back together ? ', " I don't know . There ’ s plenty of fish out there in the sea ! ", ' Oh , you are such a dog ! ']
["They're very good friends , aren't they ? ", " I wouldn't say that.They seem to be on good terms but actually they always speak ill of each other . ", " Oh , it's unbelievable ! "]
["I went to Jessie's birthday party yesterday . It was very good . ", " I didn't know about it . What did you do ? ", ' We ate a lot of things . We played games and gave gifts to Jessie . We had a lot of fun . ', ' You were really lucky . ', ' My birthday comes next month . I want to hold a birthday party , too . ', ' I hope I can go to your party . ']
["My friend finally dumped her boyfriend , and she's sworn she's going to abstain until she finds the right man to marry . ", " After going through an episode like that I'm not surprised . How's her headspace ? ", " She's doing great , she's getting her confidence back , and her self-esteem , has improved drastically.She ' s very happy . ", " I'm proud of you for standing by her . I think you've helped make a big difference in her life . ", ' Do you have any plans for next Sunday evening ? ', ' No , why ? ', ' My friend , who had the mishap , wants to take us to dinner to show her gratitude for helping her . ', " She doesn't need to do that , I didn't do anything . ", " She feels you gave me the freedom to be able to assist her and she appreciates that . Come on , Let's indulge her . "]
['Hey , Tom , what to go for a run ? ', ' No thanks . I like to run in the morning . I ran a couple of miles when I woke up today . ', ' I try to do that , but I can ’ t get up early enough . ', ' I couldn ’ t either at first , but you get used to it . ', ' It ’ s so hot at lunchtime ; I ’ d rather run in the morning . ', ' Well , why don ’ t you come tomorrow ? I ’ ll stop by your house on my way out . ', ' I could try , but I can ’ t say for sure if I ’ ll get up in time . What time do you want to go ? ', " I ’ ll give you a call around 6 o'clock and stop by around 6 thirty . ", ' O . K . , maybe if I have someone to go with , I ’ ll be able to get up in time for a jog . ', ' Great , I ’ ll see you then . ', ' See you . ']
["How's the weather today ? ", " It's cloudy . ", ' Is it going to rain today ? ', ' I doubt it . ', ' But I heard it might rain . ']
["Well , the way you drive , Jen ... I still don't think that's a good idea . ", " I really love this music . It's a compilation . ", " I know . It's a mix of all the latest songs . ", ' And you got them off the Net ? ', ' No . I recorded these from your Cds . ', ' Well , thanks for asking for my permission ... Now hand it over and let me record ! ', " I knew I shouldn't have shown you my new toy ... "]
['Um , which of them is the better typist ? ', ' Well , Mary types faster than Jones . But I think Jones types more carefully . ', ' Is there any difference in their short hand ? ', ' Jones can certainly take down letter more quickly , but Mary ’ s short hand is the best in her class . ', ' How about languages ? ', ' Both of them speak excellent French . But I think Mary speaks German more fluently than Jones does . ', ' Um . That doesn ’ t really matter . Because we have more French visitors than German . ']
['My friend George has been to Switzerland twice . ', ' Does he like that country ? ', ' Yes , he likes the people and the quietness there . ', ' Would you ask him to tell us more about the country ? ']
['Hello , Ann ! Is that you ? ', " Yes , it is . Hi , Tom ! It's a real surprise to see you here . ", " It's been a long time ! What's new ? ", ' Nothing much . What about you ? Is everything going well ? ', ' Not bad I guess . I just got back from Hawaii . ', ' How was it ? ', " I had a good time . You seem to be in a hurry . Don't let me hold you up . ", " Sorry , I've got a meeting in half an hour . ", " Ok , I won't keep you then . ", " Great ! It's good to see you . Goodbye ! ", ' Yes , stay in touch . Bye ! ', ' Give me your email , would you ? ', " Sure ! It's txyb@gmail.com . "]
['Ok ... I ’ ll talk to you later . Bye ', ' Carrie , are you ok ? You seem a bit down . ', ' I just got off the phone with my boyfriend . He is always getting upset and losing his temper over nothing . It ’ s so hard to talk to him at times . ', ' Maybe it ’ s just that he is stressed out from work or something . He does have a pretty nerve wracking job you know . ', ' Yeah but , he is always in a really foul mood . I try to find out what ’ s bothering him or get him to talk about his day but , he always shuts down and brushes me off . ', ' Men are like that you know.They can feel nervous , anxious or on edge and the only way they can express it is by trying to hide it through aggressiveness . ', ' I guess you are right . What do you think I should do ? He wasn ’ t always this grouchy you know ... ', ' Talk to him , try to cheer him up when he is down and if that doesn ’ t work , I say get rid of him and get a new one ! ', ' You are something else you know that ? ']
['Hi , my name ’ s Karl . My wife and I are moving in next door . ', ' Hello , Karl . I ’ m Chuck Jones . We ’ re going to be neighbors . ', ' I ’ m happy to meet you . It seems everyone in town is so friendly . ', ' This is a small town , and we like to be neighborly . We know everyone who lives around here . ', ' Well , I ’ m from Chicago . There few people take the time to get to know their neighbors . ', ' So , tell me , Karl , why did you come all the way to Minnesota to live ? ', ' We wanted to live in a more peaceful community and have more space . Another reason is , we can afford to buy a home here , but we can ’ t in Chicago ! ']
['Look ! It ’ s the start of the Olympic Games . ', ' So what ? ', ' You want to watch , don ’ t you ? ', ' Not really . I couldn ’ t careless about the Olympic Games . ', ' Please yourself . ']
["The question is easy for everybody.Don ' t you think so ? ", " Yeah , it's very easy . But it's above Nick's head ", ' Why do you say so ? ', " He's always confused by easy questions . "]
['I can ’ t believe it ! ', ' What ’ s wrong ? That was a great goal . ', ' Yes , but I bet $ 200 dollars on the Cougars ! ', ' Looks like you ’ re going to lose out on this game then . ', ' I can ’ t believe it ! I thought the Cougars were going to win for sure . ', ' What were the odds ? ', ' 20 to 1 , in favour of the Cougars ! ', ' Too bad . ']
['Jenny , I was wondering ... if you .. eh are you busy this Friday ? ', ' Yes , Friday I have a class , right after work . ', ' Oh , what about Saturday ? Are you free then ? ', ' Saturday my parents are coming to town . What ’ s up ? ', ' What about tonight ? Do you have plans tonight ? ', ' No , do you want to go and do something ? ', ' Yes , yes , I want to take you to dinner . ', ' Oh , that sounds great . How about 6 o ’ clock ? ']
['Excuse me ? Is this where I register ? I ’ d like to sign up for my courses for next semester . ', ' Yes , of course . I need your student ID please . ', ' Here you are . ', ' Okay , Susan . It says here that you are a business major and you are in your second year . Is this information correct ? ', ' Yes . I do want to take some additional credits this year to get a minor in psychology . ', ' Sure.That ’ s not a problem.Do you have the list of courses you want to taketh semester ? ', ' Yeah . Here ’ s my list . I ’ m not sure if the class schedule will allow me to take all of them though . ', ' Yeah , that ’ s perfect . What about the subjects for your minor ? ', ' Oh yeah ! Almost forgot ! I need to take fundamental linguistics , consumer psychology and neuroanatomy . ', ' Wow , you are going to be busy this semester ! Okay , here you go . You are registered now . you ’ ll have to make your first tuition payment before classes start . ']
['Is your city a historical place ? ', ' Not rally . 200 years ago , it was just a small insignificant village . ', ' How did it grow into such a large place ? ', ' Large deposits of coal were found nearly and so many industries located themselves here . The village quickly grew into a key industrial centre . ', ' As the city grew , it must have absorbed many village nearby . ', ' Yes , it did . The names of those village survive as the names of parts of the city . ', ' I see . Are there any building more than 200 years old in your city ? ', ' Oh , yes . Several of the buildings from the villages still survive . Many of them were inns for travelers and today survive as pubs . There was a castle near one village , so our city has a castle too . ', ' Really ? So your city does have some old history after all . ']
['Most of our customers are foreigners . How many foreign languages can you speak , Elizabeth ? ', ' Two . French and Spanish . ', ' And how well can you speak them ? ', ' Well , French was my best subject at school . I can read and write it pretty well . ', ' And how about your Spanish ? ', " Well , it's not as good as my French . I can speak it reasonably well , but my written Spanish isn't very good . ", " I see . Well , we have a lot of Spanish customers , but you wouldn't need to write any Spanish here . ", " In that case , I'm fit for the position I think . "]
['Did you watch the old-fashioned wrestling game last night ? ', " Yes , of course . And I'm amazed the those karate and judo boys were so helpless before the wrestlers . ", " You bet . The wrestlers had got sound defences and they simply couldn't make it . "]
['Do you mind if I get a lift in your car , please ? ', ' I don ’ t see any problem , only the car is a bit old . ', ' Oh you ’ re so kind ! ', ' Get in . ']
['Fred , can you tell me how I can open my QQ Zone ? ', ' Click your right key of mouse and choose QQ Zone . ', ' Well , I have to provide some of my information , right ? ', ' Yep ! The nick name for your zone , address , gender and so on . Some of them are privacy , so you have the right to keep secret here . ', ' All information is filled in and now I can design my zone . ', ' You can choose one type to make it as your background , and then find a music player and put your favorite songs into it , so your visitors can enjoy the music after entering into your zone . ', ' Now everything is OK . I can write my blog , right ? ', ' Certainly . ', " ( Half an hour , Janice begins shouting excitedly . ) What's the matter with you ? ", ' Look ! David gives his following-comment on my first blog . He is my first visitor . ']
['Do you remember Tina , my good friend ? ', ' Yes . ', ' She just broke up with her boyfriend . ', ' Well , that happens . I hope she is all right . ', ' But the problem is she and her ex-boyfriend are working in the same department . It is somehow embarrassing for them to see each other everyday . ', ' That is the down side of an office romance . I hope their work is not affected by the emotional stress . The boss must be very annoyed if that will be the case . ', ' Well , Tina says she would be able to handle it and concentrate on her own work , easier set them done . But working harder and concentrating only on the job might well helped to overcome the initial stress of the breakup . ']
['Hi Bill , I saw your grandma yesterday . ', ' Oh where was that ? ', ' I was running around the track at my college and there she was walking around the same track . ', ' Grannie always tries to stay fit and healthy . She is always making us kids eat the proper foods . ', ' Well , it pays off for her . How old is she anyway ? ', ' She will be 86 next month . ', ' That is truly amazing ! ']
['What time shall I pick you up ? ', ' How about 6:30 ? ', " That'll be fine . See you soon . "]
['Hi , Zhengjun , what make you so happy . ', " You know what , I've just got a new job with a computer company . ", ' Oh , congratulations ! ']
["Hi , Linda . I haven't seen you for ages . ", ' Yes . I miss you very much . ', ' So do I . ', ' Have you graduated from college ? ', ' Yes . I graduated last year and got a job in a press . ']
['Has the train come yet ? ', ' No , I ‘ Ve been waiting for ages . ', ' It ’ s so unreliable . I ’ Ve been late for my meetings all this week . ', ' Yes , me too . I think I ’ Ve lost some important clients recently because of this train ! ', ' Yes , my customers have started to complain too ! ', ' Oh look ! Here it comes now ! ']
["I've got some bad news about the bike you lent me . ", " What's that ? ", " I fell on the way to school , and your bike got scratched . I'm really sorry . ", " Don't worry about it . It's not new , it already has a few scratches . Did you get hurt ? ", ' No , thank you . ', " That's the most important thing . ", " It's kind of you to say . I feel a little stupid . ", ' Forget about it . ', ' When you lent me the bike , it looked brand new , almost anyway . ', " Maybe , but really I have fallen a couple of times and it's been hit once or twice as well . ", ' I appreciate that , thank you . ']
['Jenny is going to marry another man next month . ', ' Yes , I know . ', ' But , how can you be so calm . You loved her so much . ', ' At least I ’ m the one who rates with her . I ’ m glad we can still be friends . ']
["What's your favorite sport ? ", " Basketball , I'm a basketball fan . "]
['Hello , Jane . What do you do in your spare time ? ', ' Well , nothing special , reading , watching TV , walking , and so on . ', " Don't you have any hobbies , like stamp collecting or things like that ? ", " No , I don't have any hobbies . How about you ? ", " I like collecting antiques . It's expensive , but it's a lot of fun . ", ' Really ? How many collections do you have ? ', ' So far I have more than 500 collections . ', ' Among those collections , which is the most expensive ? ', ' A set of ancient china . It is really invaluable . ']
['It seems to me that everything is going digital nowadays . ', ' Yes . Speaking of digital wares , I bought a digital camera last week . ', ' Cool ! What brand ', " A Sony . It's only one third the size of my old camera and looks rather smart . ", ' What about the quality ? ', " Superb ! It's a 4 megapixel one and the photos it takes are very vivid and clear . "]
["It's four o'clock already . I hate to leave , but I think I must . ", ' Can you stay a little longer ? ', " I'm sorry , but I can't . "]
['Can I see your parents some time tomorrow ? ', ' Sorry , they are too busy these days . ', ' How about this weekend ? ', ' Yes , I think so . ']
['Happy Thanksgiving ! ', ' You , too . ', " Let's have pumpkin pie . ", " It's my favorite . "]
['Are you going anywhere for your vacation ? ', " Yes , we're making plans for a tour . ", " That'll be lovely . Where are you going ? ", " Well start out from Long Island this Friday . We've planned a four day drive to Salt Lake City , where we'll join my brother and his family on his fortieth birthday . ", " Well , you've got to prepare a lot of food and enough sleeping bags then . ", " Oh , we'll spend the nights in hotels and enjoy local food as we pass by . How does it sound , David ? ", ' It sounds good . You can do a lot of sightseeing , too . ', " Yes , we'll take our time . And we'll go to Five-lake Strict and the Wall Street . ", " So , you're going to have a really nice vacation . ", ' You can say that again . ']
['Would you like to book a table , sir ? ', ' Yes , would you arrange it for me the day after tomorrow ? ', ' Sure , when ? ', " Six o'clock in the afternoon . ", ' For how many guests , please ? ', ' Six . ', ' How much would you like to spend ? ', " We don't care about money . We'd like to have some good dishes of local specialties . ", ' OK . ', ' How many courses are there altogether , please ? ', ' Eight . ', ' Could you tell me some of entrees about the dinner ? ', ' Sure . The main courses are roast Beijing duck and fried eel slices . ', ' Very good . ']
['Did you watch TV last night , Rose ? ', ' Yeah . I saw a science program . It was quite interesting . ', ' What was it about ? ', ' Mars . Scientists say there might be water on it . ', ' If so , we may live there someday . ', ' I hope so . Did you know the US successfully sent two robotic explorers to Mars last month ? ', " Sure . I heard about this on the TV . On January 3rd , 2004 , Explorer Spirit landed near the so-called Guser Crater . And three weeks later , Spirit's twin explorer , Opportunity , landed on Meridian Planum named by scientists . ", ' Yes . Both have sent back pictures of the planet . And the latter did a better job . ']
['How is your job search going , Janet ? ', ' I found the ideal position . I ’ m working for a plumbing company . ', ' Are you serious ? You studied mathematics at college for four years , and now you have a job working with your hands ! ', ' Plumbing work requires mathematics knowledge , and creativity . I love this job . ', ' I can see that . But I didn ’ t know you had experience in that line of work . ', ' I didn ’ t , but I applied for an apprenticeship , and since I studied math , AND I have a good attitude , my application was accepted . ', ' Congratulations ! You do have the right attitude . ']
['We are going to the concert this evening . Will you join us ? ', " I'm very sorry I can't . ", ' Why not ? ', " I've been snowed under with work since my boss was away on business . "]
["Well , if it isn't the teacher's pet ! ", " Stop it . Teacher doesn't treat me any different than she does everyone else . ", " You can't prove that by me . I saw the score on your report . ", ' Hey , I worked hard on that report and I deserve the grade I got . ', ' It just happened to be the highest grade in the class . ', " You're just jealous because you didn't do as well as you thought you did . Admit it . ", ' I worked hard too . But she always gives me a lower grade . ', ' If you think that she is not fair with your work then you should talk to her in person instead of stewing over it . ']
['You won one million yuan in a lottery . What will you say ? ', " I don't know . I'm too excited to say a word . ", " I understand . It's too good to be true , isn't it ? ", ' Yes , too good to be true . ']
['I was supposed to meet with you at half past one . ', ' Yes , I see . What did you need to see me about ? ', " There's a problem with my schedule . ", " What's the problem ? ", ' Two of my classes occur at the same time . ', " Well , I can see that's a problem . ", ' Is it at all possible for you to fix that error ? ', ' Yes , I can . Would you still like to have both of these classes ? ', " I want to keep both of them , if that's possible . ", ' Well , let me find you one of these classes on a different day . ', ' Thanks a lot . ']
['I went bungee jumping yesterday . ', ' That sounds like fun . ']
['Hello , Tom , are you free next Sunday ? ', ' I think so . Why did you ask that ? ', " I'm going to have my first baby , so I plan to hold a baby shower next Sunday . ", ' Congratulations ! Why do people hold parties before the baby is born ? ', " It's the tradition . But baby showers as we know them today were not common until after World Warri . ", ' In any case , I like baby showers , because they allow friends and family to share the joy and excitement of welcoming a new life into the world . ', " So you will come , won't you ? ", ' Of course . I will prepare a good gift for the new arrival . ', ' Thank you very much . ']
['What are you doing ? ', ' What am I doing ? What am I doing ? Don ’ t you know what day it is ? ', ' Mumm . no . ', ' It ’ s only the day when the world ’ s biggest sporting event is kicking off . ', ' What ? ', ' The World Cup ! The first match is today ! It ’ s Mexico vs . South Africa ! It ’ s going to be a really good match ! Both teams have a very strong offense and have skilled players . I think that South Africa will probably dominate the first half since they are the host country , and all . ', ' I have no idea what you ’ re talking about . The only sporting event we watch at home is the Super Bowl . ', ' This is bigger than the Super Bowl , man ! Teams from 32 countries compete against each other every four years and fight to win that trophy . They first start in a group stage with bigger groups , each group having 4 teams . The top 2 teams pass on to an elimination stage before going on to the quarter final sand semifinals . ', ' Sounds interesting , but soccer doesn ’ t really appeal to me . ', ' Are you kidding ? Over seven hundred million people watched the final match of the World Cup ! It ’ s a very exciting and nerve wracking sport ! Each nation is cheering on their team , hoping they will become the next champion . So far Brazil is the team with the most titles under their belt ; they ’ re really good ! ', ' All I know about soccer is that you can ’ t use your hands and that players are always falling down , trying to get a free kick or penalty kick . It seems like a sissy sport to me ! ', ' Whatever dude , I ’ m going to go watch the opening match . ']
['We have absolute proof that you committed the crime . ', " That's absolutely ridiculous ! "]
['Where can I get the information , Kate ? ', ' Ask John . He is sure to know about it . ', ' Why ? ', ' He has a finger in the pie . ']
['That was a tough question . How did you get it right ? ', ' I just took a shot in the dark . ']
['There ’ s a letter here for you . ', ' Let me see it . ', ' What ’ s the letter about ? ', ' It ’ s a letter from NYU . ', ' Tell me what it says ! ', ' I didn ’ t get in . ', ' You ’ re lying . ', ' I ’ m not lying . ', ' Are you upset ? ', ' I had high hopes for NYU . ', ' I ’ m sorry you didn ’ t get accepted . ', ' Hopefully , I ’ ll get accepted to UCLA . ']
['The final examination will be held at the end of this month . Have you made good preparation ? ', " Sure . I've reviewed all the lessons I have learned this academic year . ", ' Are you sure you can do well this year ? ', ' I am 100 % certain . ', ' According to what you did last time , I have my doubts . ', ' I am sure I can get a 95 this time . ']
['What ? How could you forget to reserve the concert tickets ? ', " I'm sorry . I forget all about it . ", ' How could you ? I reminded you just this morning . ', " It's leap my mind . I really feel terrible about it . ", ' I have been looking forward to this performance all month . ', " I'm really sorry I let you down . I'll make it up to you somehow . "]
['Did you hear what happened to Mike last night ? ', ' No , what ? ', " Well , apparently he had too much to drink and got into some kind of trouble . Typical , isn't it ? ", ' Oh , no . What kind of trouble ? ', " Well , I don't know the details , but ... "]
['Did you hear ? The state is thinking of legalizing gambling in our city ! Soon we are gonna have amazing hotels and casinos here which will be good for our business ! ', ' Are you serious ? Gambling is a vice industry built on deception and fed by the intentional exploitation of human weakness for the sole purpose of monetary gain ! It disgusts me . ', ' What are you talking about ? How does it exploit people ? ', ' Well , to begin with , Gambling is addictive , ruins marriages , destroys families and bankrupts communities . Once you are addicted it is very difficult to stop . People have lost their houses , cars and been left out on the street after becoming addicted . Secondly , it exploits because men become addicted to gambling most often because of the action and risk . Women gamble to escape , and senior citizens will start gambling for the social interaction . Underage gamblers often start gambling on sports with friends and then illegal bookies . ', ' Geez ! Now that I think about it , maybe legalizing gambling isn ’ t such a good idea ! Although , I have been to Las Vegas , and I didn ’ t become addicted or anything like that . ', ' You cannot predict who will become addicted to gambling . Now excuse me , I have a protest rally to organize ! ']
["I'm tired of you always wearing my clothing ! ", " Aren't you the pot calling the kettle black ? You're wearing my pants right now ! "]
['I ’ m sure it will be wet when we arrive . ', ' Yes . I dare say it will be . ', ' It will be Sunday so I expected everything will be closed . ', ' No . I don ’ t think that ’ s possible . Some places are sure to be open . ', " But the bank should be closed so we shouldn't to be able to get any money . ", ' Mmm , you may be right . ', ' Do you think we ’ ll need our overcoats ? ', ' No . We couldn ’ t possibly . ', ' Why not ? ', ' It will be summer . So it will be hot . ', ' Is that very likely in England ? ', ' Yes . It could happen . ']
["Let's do something really nice for our family this Christmas . ", ' What did you have in mind ? ', " I don't know yet . ", ' I just know I want to get out of the mindless gift trap . ', ' I know what you mean . ', ' I want to give a gift that is really meaningful . ', ' Or do something that shows we have spent time thinking about them . ', ' Or what only we are able to give them . ']
["Uh ... that's Greek to me . ", ' That means they have tapered legs . ', " Well , mine are baggy . They're the kind of pants you can lounge around in . ", ' Mine are , too . ', " So maybe we shouldn't go out after all . ", " Yeah . Let's just lounge around ! "]
['Thanks . Sometimes talking with a friend is a great way to get over something . Do you mind if I vent a little bit ? ', " Of course not . If you're feeling bad and want to let your emotions out , you can just say whatever you want to me . ", " Great , because I am really mad at William . I mean , what kind of an idiot wouldn't be able to appreciate a smart , beautiful woman like me ? Anybody who would be friends with that guy has to be really dumb . ", " Uh , A ... you know I'm friends with William . ", ' Oh right ... present company excluded , of course ! ']
['Mary is really a diligent girl . ', ' What do you mean ? ', ' She learns to speak Latin by osmosis within three months . ', ' She is really something . ']
['Hello , this is David . ', ' Hi David , this is Marge . Can you meet me after work for a few minutes ? ', ' Sure ! How about the coffee shop right across the street from my office ? ', ' That will work . ', ' Does five thirty work for you ? ', ' That will be fine . What I have to show you will only take a few minutes of your time . ', ' Is it the plans for my new house ? ', ' Yes . I just need to double check a few details with you . ']
["I feel like going for a drink , it's been a long day . ", ' Great idea ! Peter , I could use the drink . ', ' How about the new bar across road ? ', ' Sounds good . The food there is fantastic too . ', ' I agree , I had lunch there last week . ', ' Excellent ! That sounds like a plan . ']
['I have an idea for Christmas this year . ', ' What is it ? ', " Let's not exchange any gifts at all . ", ' You big scrooge ! ', ' Hear me out . We can pool the money and give it to a family who could really use it ! ', ' But you may have some trouble convincing the kids . ', ' Actual 1y , it was their idea first . ', ' Now we know that they realize the real meaning of Christmas . ']
["Do you know anything about Dr . Miller's classes ? ", ' Yes . Are you in his class ? ', " I'm thinking of taking his class next semester . ", ' He really knew his stuff , but he graded hard . Would that be OK ? ', ' Yes , I really need someone who is really good . ', " I didn't find it overwhelming to earn a good grade if you work at it . Can you do that ? ", " Maybe , but I'm not sure . ", " Man , this guy was so funny when he was teaching . I like that , don't you ? ", " No , that stuff isn't important to me . ", ' Did you know that he is a fairly new teacher and very current in his field ? ', " I don't care about any of that . ", " We all are looking for different things in an instructor . I hope I've helped you . "]
['Hey , Ben ... did you catch the game last night ? ', ' Uh ... what game ? ', ' Baltimore defeated Texas by 17 points ! ', ' Um ... and what sport are we talking about here ? ', ' Football of course ! ', ' Oh ... football . Football is cool . I usually try to catch the World Cup finals . ', " No , I'm talking about American football . The World Cup is soccer . ", " Oh , I understand . I can't say I'm a big fan . I'm from China , and football doesn't have a really big following over there . ", ' So Chinese people prefer soccer or basketball ? ', " Yes , I think so . But to be perfectly honest , I'm not really a sports nut.When I was in high school I played on the school volleyball team . Are you a diehard football fan ? ", " Oh , certainly . I wouldn't miss a game for the world . My girlfriend says I have an addiction . And actually , if I had to choose between her and my games ... I'd probably pick football . ", ' It seems Americans are very passionate about sports . Is this just a part of your culture ? ', ' Oh , yeah ! I think the love of sports starts when kids are very young . Americans come from many different backgrounds so I guess sports are something we can all enjoy together . ']
["Julia , what's the weather forecast for tomorrow ? ", ' It says a storm may come tomorrow . ', ' Oh ! I hate rainy days ! ', " Me , too . I'm always in low spirits when it rains . Are you going out tomorrow ? ", ' Yes . I have to drive to Washington D . C . ', ' What bad luck ! ', ' Yeah ! But you know sometimes the weather forecast is not correct . Maybe tomorrow is a clear day . Who knows ? ', ' Yeah , maybe you are right ! ']
['Where would you like to have your dinner ? ', " I don't care as long as it's a Chinese restaurant . ", " You don't like Western food ? ", ' I really find Chinese dishes more to my taste . ']
["Thanks for offering to give me a lift . I'm looking forward to this party , but I didn't want to go alone . ", " Don't mention it . It's my pleasure . Have you been to one of these large , sit-down dinner parties since you got to New Haven ? ", " No , this is my first . Last week I went to a cookout 5 for new professors at Dean Barksdale's home . I took a taxi because I didn't want to be late . But I was the first one there . ", " I'll bet you were a little embarrassed . ", " You're right . The invitation said two to seven . I was there at two o'clock , but most people didn't arrive until three or four . They didn't start cooking until five o ’ clock . ", " Cookouts often start slowly . A two o'clock start means you arrive any time after two . ", ' Thanks for telling me this . ', " I was late getting back from the mall , but I'm hurrying . ", " Why are you in such a hurry ? They said , Dinner at eight , and it's only seven-fifteen . I don't want to be the first one there again . ", " Don't worry . We won't be the first . "]
['That ’ s really a let-down . ', ' Yeah . He really does let me down . ', ' But that should not be the reason for you to lose heart . ', ' I ’ m at the end of tether . I run out of ideas . ']
["Some people are always closing their handsets , so it's difficult to inform them . ", ' Why not send them short messages ? ', ' Can short messages reach them ? ', " Short messages will be kept in the short messages center . Once they open the handsets they will receive them , which is better than you can't find them . ", " Why haven't I thought of this skill ? ", " I use short messages quite a lot . If it's not too complicated I will send a short message , which can save much phone charge . ", " I am informed that many people used short messages to pay a New Year call , and only on the Spring Festival it amounted to 1 billion this year , didn't it ? ", " I almost can't live without messages , from which I learn about weather forecasts and stock quotations . "]
['Hey , sorry to be late . ', ' What happened to you last night ? You didn ’ t show up . ', ' My mother was ill . I had to look after her . ', ' I ’ m so sorry to hear that . ']
['Hi ! How are you going ? ', ' Fine , thank you . How are you doing this morning ? ', " Not bad . How about you ? Haven't seen you for a long time . ", " Yes . I've been to New York . I got back only yesterday . ", ' Did you enjoy yourself ? ', ' Very much . New York is such a nice place . Shall I show you some photographs ? ', " Thanks , I like looking at photographs . How nice ! Oh , I'm afraid I must be going now . I've got an appointment . Have a good day . ", ' You too . I hope to see you soon . Goodbye . ', ' Goodbye . ']
['My goodness ! What happened ? You have blood on your face . ', " Oh , don't worry . I just killed a pigeon . ", ' How could you have the heart to kill it ? We only have one ! ', ' It spoiled my painting ! ']
['How annoying ! ', " What's the matter ? ", ' Every time I try to start this program , the computer freezes . ', " Maybe there's something wrong with the program . "]
['I heard that James was fired because he got a keep back of 20 thousands dollars from a vender . ', ' That ’ s open secret . ', ' But mine could be a lie for his job . ', ' How did you know that ? ', ' A little bird whispered to me . Keep that to yourself . ']
['Who did the stupid thing ? ', ' It must be Kate . ', " No , I don't think you're right.Kate never does things like that.It must be a naughty boy who did it . "]
['Hello ? ', " Hi Tina , It's Joe . ", ' Hi Joe . ', " How's the weather there today ? ", " It's really cold . It snowed all day and the schools closed early . ", " What's the temperature ? ", " It's 30 degrees now . It was even colder this morning . ", ' Have you heard what the weather is going to be like tomorrow ? ', " I was watching the news a little earlier . They said it's probably going to snow tomorrow . ", " I really don't like the winter . I wish it were summer . ", " Me too . How's the weather where you are ? ", " It's not too bad , but it's pretty cold here too . It was about 45 today and it rained this afternoon . I heard it's going to be a little warmer tomorrow . "]
['Mike promised to help us . ', ' Mike ? How can you trust him to help us ? ', ' Why not ? ', ' He is too unpredictable . He says anything that pops into his head . And then he forgets it all . ']
['Hello , Ann ! Is that you ? ', " Yes , it is . Hi , Tom ! It's a real surprise to see you here . ", " It's been a long time ! What's new ? ", ' Nothing much . What about you ? Is everything going well ? ', ' Not bad I guess . I just got back from Hawaii . ', ' How was it ? ', " I had a good time . You seem to be in a hurry . Don't let me hold you up . ", " Sorry , I've got a meeting in half an hour . ", " Ok , I won't keep you then . ", " Great ! It's good to see you . Goodbye ! ", ' Yes , stay in touch . Bye ! ', ' Give me your email , would you ? ', " Sure ! It's txyb@gmail.com . "]
["Tom , I've got good news for you . ", ' What is it ? ', " Haven't you heard that your novel has won The Nobel Prize ? ", " Really ? I can't believe it . It's like a dream come true . I never expected that I would win The Nobel Prize ! ", " You did a good job . I'm extremely proud of you . ", ' Thanks for the compliment . ', " You certainly deserve it . Let's celebrate ! "]
['Tom ! How are you ? We missed you at the party last night . Are you OK ? ', ' I don ’ t know . I didn ’ t really feel like going out . I guess I ’ m feeling a little homesick . ', ' Come on . We ’ Ve been through this already ! Look , I know the adjustment was hard when you first got here , but we agreed that you were gonna try and deal with it . ', ' I was . It ’ s just that the holidays are coming up and I won ’ t be able to home because I can ’ t afford the airfare . I ’ m just longing for some of the comforts of home , like my mom ’ s cooking and being around my family . ', ' Yeah , it can get pretty lonely over the holidays . When I first got here , I ’ d get depressed and nostalgic for anything that reminded me of home . I almost let it get to me , but then I started going out , keeping myself busy and before I knew it , I was used to to it . ', ' I see what you mean , but I ’ m still bummed out . ', ' OK . how does this sound , let ’ s get you suited up and hit the dance club tonight . I hear that an awesome DJ is playing and there will be a lot of pretty single girls there ! ', ' You know , I could really go for that . You don ’ t mind being my wingman for tonight ? ', ' Not at all ! It be fun ! It will be like a boys ’ night out ... well kinda ... ', ' Great ! I must warn you though , whatever happens , don ’ t let me go on a drinking binge . Trust me , it ’ s not a pretty picture ! ']
['There was something wrong with the plane last Thursday . ', ' Which flight ? ', ' Flight 198 . Fortunately , there were few passengers . ', ' How about the passengers ? ', ' Well , all the passengers and crew members landed on their feet finally . ']
["There are some things I miss . But I love Chinese food.And I think the people in Taiwan are really hospitable.Besides , I grew up in Los Angeles , so I'm used to living in crowded places.Why are you going to America ? ", " I'm going to New York to visit my sister . She is in art school . I've never been to New York before . I'm kind of scared . ", ' Why ? ', " Well , I know a lot of people have guns there . I think maybe it isn't too safe . ", " Don't worry about it.Your sister lives there . She probably knows the places in town you shouldn't go.It ' s true there are some dangerous places in big American cities.But if your sister lives there , she must know the city pretty well already . ", " Yes , I'm not really scared . Maybe only a little . ", " Don't believe what you see on TV . You will have a good time in New York.What things do you want to see ? ", ' I want to see the museums , and I want to shop a lot . ', " The museums are excellent . And the shopping ! Well ! I'm sure you'll spend a lot of money there . ", ' Hmm . I hope not . ']
["I'm thirsty . Pull over to that store , I'll buy some drinks . ", " I'm afraid I can't . Parking is not allowed here . ", " Oh , that's too bad , Where can you park around here ? ", ' There is a square in front of us . We can park the car there . ', ' Is a shop there ? ', " I'm not sure , you know I'm not familiar with the city , too . "]
['Do you think I should ask Bob to help ? Will he come ? ', ' No problem . You know him . He ’ s the kind of guy that ’ s always willing to go the extra miles . ', ' That ’ s right . But I have bothered him several times . ', ' I bet he will come . ']
['Could you tell me what university you want to go to , John ? ', ' Pardon ? ', ' What university would you enter ? ', ' University ? Why ? You asked me last year . ', ' Oh , I forget.Sorry . ', ' I went to Harvard University . ', ' Did you ? And what course did you take there ? ', " God save me ! Is there anything wrong with you ? Didn't I tell you ? ", " I've not known.Perhaps , I've got a bad memory . ", ' I did a B . A . in economics.Remember ? ', ' Terrific ! B . A . , again and again-B . A . ']
['Did you have a good weekend ? ', ' Well I wanted to go for a picnic but it rained too much . ', ' Oh I see . So what did you do then ? ', ' I washed my car instead . ', ' Ahh . And how about on Sunday ? Did you watch the football ? ', ' No I didn ’ t . I worked in the morning then I played tennis with my husband . ']
['What do you want for your birthday from your parents ? ', " I don't know . Maybe a pair of new shoes . ", " Why don't you ask them to buy you a PC ? You will soon use it at college . ", " That's a dandy idea . Thank you for reminding me . "]
["Your husband is very helpful , isn't he ? ", ' Willing to help , maybe , but not as helpful as you think . ', ' Really ? ', ' Last night he told the children acliff-hangerstory and both of them were scared out of sleep . ']
["Doesn't she have any friends ? ", ' If she has , they must be fair-weather friends . ', ' Such friends are even worse than enemies . ', " She'd better keep away from them . "]
["Let me get last week's notes . ", " Yeah , sure , you didn't come to class that day ? ", " I couldn't come . ", ' Why not ? ', " I wasn't feeling well . ", ' Here they are . ', ' Thanks a lot ; are these all the notes ? ', ' Oh , no , this is the rest . ', ' Thank you very much . ', " It's no problem at all . "]
['I wonder if you agree that money is not happiness . ', " I don't entirely agree with you . ", ' Then how do you explain so many rich people committing suicide ? ', " Well , that's a thing . "]
['He has worked five years in that bank . ', ' He must be an experienced accountant . ', " You said it.Let ' s ask him to work in our bank . ", ' Great minds think alike . ']
['Did you pass the test ? ', " No , I didn't . ", " I'm sorry to hear that . "]
["I'm really curious . What is it like doing housework all day for a living ? ", " It's a little like being a mom , only I get paid for it ! ", ' I still think that it is a bitstrange that you like to do that kind of thing . Most women would rather hire a maid . ', " That's exactly why my business is doing so well ! ", ' How Ay clients do you have already ? ', " Well , I've been in business for one month now and I have ten clients . ", " Wow . Too bad I don't have a clue about housework . ", ' If you ever need a job , let me know . I can always train you . ']
['Hey , check out this new game I bought today . ', " Wow ! It's a trivia game all about the Academy Awards . ", ' I know you love the Oscars . This game has some great questions about all types of movies . ', " Does it have questions about foreign language films ? There's hardly any American films worth watching . ", ' Yes . In fact , one of the categories is on foreign language films . ']
['Hi , Mr . James , what ’ s the rush ? ', ' The bank closes in 30 minutes and I need to cash a check . ', ' I can lend you some money . ', ' Thanks . But it ’ s necessary for me to buy a TV set . ', ' Can I help you in anyway ? ', ' You can take me to the bank if you want to . ', ' Sure . Let ’ s go . ']
['I am so sorry that I must be off now . My girlfriend told me I must arrive at her home in ten minutes or she will break up with me . ', ' She can cope with it . Don ’ t be such a wimp ! ']
['I ’ m sure that the boy will become nobody when he grows up . ', ' Be careful of what you say , or you ’ ll have to eat humble pie . ', ' Eat humble pie ? Impossible , I ’ Ve never been wrong in judging boys like him . ']
["I've got a complaint about the noise next door . ", " Yes , it's most irritating . ", " Some people aren't very considerate . ", " We're going to do something about it . ", ' Yes , I think so . ', " We can't put up with it any more . ", " We'll play the CD loud , is that all right ? ", " I don't think so . ", ' What should we do ? ', " Why don't we call them ? ", ' Good idea . ']
['Jim , I heard you ’ Ve bought a new computer . ', ' Yes . Look , it is on my desk . ', ' Your office looks different with a computer . By the way , is it difficult to use a computer ? ', ' Not at all . It ’ s a piece of cake . ', ' A piece of cake ? ', ' Yes . It ’ s easy and convenient to use a computer . But it takes a long time to really master it . ']
['When I was at school , I was quite good at track and field events . I was on the school team for the long jump , 100 and 200 meter sprints and the javelin . ', ' Really ? I was quite good at the hurdles and the discus . ', ' I wish that I were good at the discus , but I could rarely throw it in the right direction ! I was awful . With the hurdles , I could never jump over them ! ', ' I thought you were good at the high jump ! ', ' No , I was good at the long jump . I liked the sprints best . ', ' Did you ever win any competitions ? ', ' I was regional champion for the 100 and 200 meters . I usually did well in the dong jump competitions , but I couldn ’ t compete with kids from other schools in the javelin . How about you ? ', ' I came second and third a few times in the regional championships , but I never won . Did you ever take part in the national championship for the sprinting events ? ', ' Yes , I did , but I didn ’ t do very well . I made the final in both events , but came last . At least I made the final . I was very pleased with that . ']
['May I have an appointment with you tonight ? ', ' Very sorry , I am occupied tonight . What about tomorrow night ? ', ' OK . where and when ? ', ' 7:00 in my staying hotel . ', ' OK , I am going to the hotel to pick you up . See you tomorrow night . ']
['Do you think people still have faith in the government ? ', ' I don ’ t think so . ', ' Why is that ? ', ' The government will never fulfill their promise . ', ' So it is no wonder people cannot keep faith with it . ']
['How do you feel about teaching my friend how to read ? ', " How old is your friend and why doesn't he know how to read ? ", " He's 78 and he's a new emigrant from South America and he's never been to school . ", ' Does he even know how to speak English ? ', ' No . But I thought that you could start with reading and then go from there . ', ' That was very thoughtful of you to volunteer me . ', " Come on . You're great at teaching and I know you will love him . He's adorable ! ", ' Oh , all right . Have him come over here for dinner . But you get to make dinner ! ']
["I've just had an argument with Bob . ", ' Really , who started the argument ? ', " He did and it's his entire fault . ", ' Did you know it takes two to tango ? ']
['Hi , Stephanie . I hear you have a new job . ', " Yes , I'm teaching math at Lincoln High School . ", ' So how do you like it ? ', ' Well , the salary is a little low , but the students are nice . How are things with you ? ', " Not bad . You know I'm an air traffic controller now . ", " Now that's an exciting job ! ! ! ", " Yes , but it's very stressful . "]
['Tom and Helen got married at last . ', ' How did you know that ? I heart Tom ’ s father didn ’ t agree with that . ', ' I was invited to attend their wedding . ', ' It ’ s great . Although his father didn ’ t agree with that , Tom went through with it . ', ' How moving love is . ']
["I'm better now . Want to play again ? ", " I'll let you break the balls this time . ", " Let's get all the balls out of the pockets . ", ' OK . How much do you want to bet on this game ? ', ' You are crazy . Gambling is against my principles . ']
['Give me a call tomorrow . ', ' Okay . ']
['I really need a new pair of trousers . ', ' Do you ? ', ' Yes , I do . This one is very old now . ', ' They look all right to me . ', ' They ’ re not all right . They ’ re uncomfortable and they look terrible . ', ' All right . All right . ']
['Would you mind if I ask you whether you are married or not ? ', " To be frank , I was married once , and now I'm single . ", ' Do you mean you got a divorce ? ', ' Yes , my first marriage was a failure . ']
['what did you do over the weekend ? ', ' I went a global warming rally in London . It was fantastic to be around so many people who care about the environment . ', " do you think there's anything we can do to reverse the damage that's been done already ? ", " it might not be possible to fix the problems that we've created for ourselves , but there are lots of things we can do to prevent more damages from happening . ", ' like what ? ', ' well , we can use public transport instead of taking our cars for a start . ', ' what else can we do to protect the environment ? ', ' if you do have to drive , you should make sure that your car runs on unleaded petrol . Also , your home should use sources of renewable energy . ', ' how about recycling ? Does that actually help ? ', ' yes . You should take your glass , paper , plastic , cardboard , and tin cans to a recycling center . ', ' what do you think is the biggest worry for our future ? ', ' I think that the issue of greatest concern is having enough sources of clean water for everyone . ', ' I had no idea you were such as environmentalist before ! ', " to be honest , in order for the earth to continue to be a habitable place , we're all going to have to become more interested in the environment . "]
['What a bother having to climb storeys home every day . ', " But it's also a sort of exercise and it's good to your health . ", " I don't care ! ", " You're complaining again . "]
["What do people usually do on Saint Valentine's Day ? ", ' On that day , boys are supposed to give roses to their sweethearts . ', ' What will the girls do ? ', ' They give chocolate in return . ']
['Excuse me , are you Dr . Smith ? ', ' Yes I am . And you ... ', " I'm David , Joanna's husband . She has to be at work late today . So she asked me to pick you up here . ", " So nice to meet you , David . Call me Bill . It's very nice of you to come here . ", ' My pleasure . ']
["Hey , Ann . You don't have a pen , do you ? ", ' Sure , here you go . ', " Thanks . I don't suppose you have some paper , too . ", ' Of course . There you are . ', ' Thanks so much . I owe you one . ']
['Please excuse me , but I really have to be going . ', ' Yes , of course . It was nice to see you . ', ' It was nice to see you , too . And please give my regards to Mrs.Robbins . ']
['Hey Mark . What are you doing ? ', ' Just watching some TV . ', ' Anything interesting on ? ', ' Not really . Just watching the sports highlight on ESPN . ', " So I take it you're pretty bored too . ", ' Just killing time until I find something to do . What are you going to do ? ', " It's Saturday and we are sitting at home doing nothing . What's wrong with us ? ", ' You wanna shoot some hoops ? ', ' I already tried to call up some of the guys , but they are all busy . ', " Where's your girlfriend ? I thought you were going out with her today . ", " She's out shopping with her friends . ", " Let's go to Starbucks and think of something to do then . ", ' Aright . Do you have any cigarettes ? ', " I only have a couple left . Why don't you pick some up on the way . ", ' Ok . See you there in about 30 minutes . ', ' Aright . See you there . ']
["Bob's sister will go to America . ", ' Why tell me ? She has nothing to do with me ! ', ' I thought you wanted to know more about her . ', " No , I couldn't care less ! "]
['hey , Tom , did you enjoy your lunch ? ', " oh , don't mention it . It was terrible . ", " what ' the matter ? ", ' the food station was as crowded as usual . I waited for 20 minutes for my sandwich , and when I finally got it the chicken was underdone . ', " I see . You simply can't blame the server for this . ", ' yes , I know . Fast food is so popular in this district . ', " that's true . ", ' anyway , how was your such , Catherine ? ', ' it was good . I brough lunch from home today . ', ' you did ? I thought you must feel right at home here as we get as many fast food restaurants as you do in America . ', " well , I personally don't like then because i don't believe they are healthy . ", " i guess you're right . More often than not , people go there only for convenience . The foods may taste good , but generally speaking , they are high in calories , salt and fat . ", " yes . I am wondering that you must believe fast food is your lifestyle , don't you ? ", " you bet . Almost all top brands such as McDonald's and KFC are from America . ", ' well , actually two-thirds of Americans may avoid these places . ', ' seriously ? ', " yeah , it's hard to believe but true . "]
["What's your favorite TV Program ? ", ' I like variety shows . ', ' I also like variety shows , but sometimes the host lacks a sense of humor . ', ' I prefer a variety show without a host . ']
["What's up ? You look low . ", " It's my girlfriend . I guess she's playing the army game . ", ' How come ? ', ' I saw her dating with her ex-boyfriend again . ', " I understand that . But I think maybe it's not a date . You are taking the matter too much to heart . ", ' Maybe . But it still gets on my nerves . ']
['Did you hear about car accident on Spring Road yesterday ? ', ' Yes , I did . I heard that they took both drivers to hospital . One needed surgery . ', ' Yes . I heard he had a few broken bones too , but that the doctors have set the fractures without any problems . ', ' The second driver was luckier . He had a concussion and needed some stitches for his head wound . ', ' Yes . He was released from hospital yesterday evening . The other man could be there for weeks . ', ' I understand that he ’ s connected to a heart monitor and breathing apparatus . His condition can ’ t be very good . ', ' The hospital announced this morning that his condition is poor but stable . What does that mean ? ', ' It means he ’ s really badly injured , but he will almost certainly survive . ', ' His family will be pleased to hear that . They must have been so worried . ']
['Happy New Year , Bill . ', ' Happy New Year , Steven . ', ' Do you have any plans for the New Year holiday ? ', ' My whole family are going to Hainan for visiting . What about you ? ', ' How happy you are ! I have to stay at home to prepare my final exam . ']
["Are you sure Lucy has it bad for you ? If she does , she will certainly bend over backwards for you . But if she doesn't , it would be a job to change her . ", " I don't know whether she has it bad for me , but she enjoys being with me . ", ' And do you really love her ? ', " I think I do . I don't think I can be happier with another girl . "]
['A friend of mine is now in the big house . He was caught red-handed for selling cocaine . ', ' That is a deadly risky business . He should have it coming on him . ', ' He must be regretting about having done the business . ', ' I bet he is . He domed his own life . ']
['I met Mark yesterday . He looked blue . ', ' He ’ s been on the gravy train these years , hasn ’ t he ? ', ' It belongs to the past . He lost his job the other day , and he ’ s up a tree now . ', ' It seems that nobody can always expect things to pan out well each time . ']
['Look , the aliens are sending a message to Mulder . This rocks ! ', " Whoops . That's my pager . I had to get it for work . ", " You have a pager ? ! That's a little high-tech for you , Stu . Are you sure you know how to use it ? ", ' Well , I know how to turn it off ! ', " No , you don't ! It's still beeping ! Come on , hand it over and I'll turn it off for you . "]
['I want to meet you . Are you free this evening ? ', " Well , actually , I'm not free today . Do you have anything urgent ? ", ' No , I just want to meet you . ', ' How about tomorrow instead . ', " Hmm , that's all right . Shall we meet at the bar near the beach ? ", ' All right . See you then . ']
["Do you have any tissue , Eve ? I've used all mine . ", ' Here . Are you all right ? ', " Thanks . I am all right . It's just my nose . It must be an allergy . Do you have any aspirin ? I have a terrible headache . ", " I don't have an aspirin . Perhaps you should go to a doctor . ", " No , no . I am okay . It's the weather . It was warm and sunny this morning and now it's chilly and raining . ", " Really , John . I still think you should go to a doctor . You've been sneezing ever since you entered the office this morning . Why don't you take this afternoon off ? If you don't want to see a doctor , at least you can go home and have a good rest . ", " I can't . I am already behind the schedule . Besides , you know Mr . White . He would think that I was putting him on . ", " You didn't do anything but sneeze this morning , and you can't do anything this afternoon like this . Gee ! You've got a fever . ", ' Do I ? Oh , no . ', ' Listen to me . You go home now . I will call my doctor and have him go over . Ok ? ', ' What about Mr.White ? ', " I'll handle him . Now go home . I'll call you after work . ", ' Thanks a lot , Eve . Goodbye . ']
['How about a movie on Sunday , Mum ? ', " Well , I'm afraid your father's not interested in modern films . ", ' We could find a classical one . ', ' That sounds fine . ']
['You are in love with Mary , right ? ', ' You are pulling my legs ! ', ' I am not blind . Anyone can see that with half an eye . ']
["I'm going on a cruise this summer . ", ' No kidding ? ', " My brother won a free trip and he's taking me . ", " You can't beat that . "]
['Where do you spend the weekend ? ', " We've a country house . ", " That's nice . ", ' Join us , will you ? ', " That'd be great ! Thank you . "]
["How's your work ? ", ' Good , thanks . How about you ? ', ' Not bad . But we have lost a few of staff lately . ', ' Why ? ', ' Because of the low salaries . ', " But your company is huge . Can't they afford to pay the staff decent wages ? ", " I don't know why . ", " Why don't you give them a suggestion ? ", " May be I can have a try . But I'm on vacation now . "]
['Good morning , Linda . How have you been ? ', ' Pretty bad . I ’ Ve had a bad cold for three days and still can ’ t get rid of it . ', ' I ’ m sorry to hear that . Is there anything else I can do ? ', ' No , thanks . ', ' Well , I hope you ’ ll feel better soon . ', ' Thank you for your concern . ']
['Are you going to watch the Indy Five Hundred on TV this weekend ? ', " I'm not really into racecar driving . ", ' You were when we were in high school . That , and baseball . ', " Yeah , well , times change . Look at you-you're a father now . You can't say that you haven't changed . ", " True , but I still have to watch my baseball . The season's in full swing now . ", " I mean , I know spring training's over , but I'm just not into all that . ", ' Hello ? Is the real Taylor in there ? ']
['How do you feel ? ', " I'm nervous as can be . "]
["I can't believe it ! I lost . ", " It looks like you have to buy tickets for us , Jason . And we're not going to see an action movie ! ", " That's not fair , you got all the easy questions . ", " I guess that's just the luck of the draw . ", " I want a rematch . Let's play again . ", ' Sorry , not tonight ! ']
['do you need a hand ? ', ' no , I can handle it . Thanks anyway . ', " are you sure you don't need any help ? ", " well , maybe just a little . I can't seem to make it fit . ", ' I swear , the overhead compartments on these planes just keep getting smaller and smaller ! ', " that's so true . thanks for your help . Are you in the aisle seat in this row ? ", ' yes . What about you ? ', " I'm in the middle seat . ", " oh , I guess I'll let you through then . ", ' thanks . sorry for making you get out of your seat again . ', " that's alright . I notice you have a few newspapers there . Would you mind lending me one ? ", ' no , not at all . Which one would you like--the New York Times or the Guardian ? ', " I prefer the British paper , but I'll read whatever one you aren't going to read right away . ", ' I was just going to do a little Sudoku while we wait for the plane to take off , so the Guardian is all yours . ', " thanks a lot . That's really nice of you . Would you like a piece of gum ? ", ' that would be great . thanks . ']
['Are you listening to me , Dan ? ', " I'm with you , Jane . ", ' What did I just say ? ', " Well , uh ... I didn't catch the last part . ", ' Just what I thought ! ']
['Man , I ’ m freaking out ! You gotta help me ! ', ' Whoa , whoa , take it easy , relax . Geez , you ’ re sweating like a pig ! What ’ s going on ? ', ' I can ’ t go through with this ! I just can ’ t ! I ’ m not ready for marriage ! What was I thinking ? I ’ m only thirty five years old ! I ’ Ve got my entire life ahead of me , adventures waiting ! I can ’ t settle down yet ! ', ' What are you talking about ? It wasn ’ t more than a month ago that you were rambling on about how you are tired of living the life of a bachelor and how you envy your friends that have a family ! ', ' I know . I know ! ', ' Let ’ s think this through . First of all , you cannot leave Amy at the altar . Not only will she be humiliated and kill you , but she is the woman that you love and the woman of your dreams ! Why would you want to end that or jeopardize it like this ? Second of all , you are just getting cold feet . You know deep down inside that you want to marry her , so cut the crap and do it ! ', ' You ’ re right . I ’ m being crazy ! Ok , I ’ m ready , let ’ s do this ! ', ' Great ! Phew ! That was a close one ! You had me going there for a minute I thought I was gonna have to slap some sense into you . ']
['Hi , why do you look so depressed today , Mike ? ', ' I had a terrible quarrel with my neighbor yesterday . ', ' How come ? ', " It is a long story . Basically , she thought I had laughed at her while I didn't . ", ' I know everyone suffers when he is misunderstood . But why not take it easy ? ', " Yeah . It's so nice of you to comfort me . "]
["Who's that over here ? ", " That's the new teacher . ", ' What do you think of the teacher ? ', " She's very nice . ", ' What does she teach ? ', ' English , of course . ', ' Is she your teacher ? ', ' Yes . She teaches our class three times a week . ', ' Can she speak Chinese to her students ? ', ' Not very much . ', " It's a good thing you can speak English ! "]
['The teacher just canceled the test . ', ' Are you kidding ? ']
['Hello ? ', ' Hi Steve . This is Mike . What are you doing ? ', ' Oh , hi . I was just watching TV . ', " There's nothing to watch right now . ", ' I know . I was watching a re-run . I have nothing to do and I was bored . ', " Me too . Let's get together and do something . ", " I'd like to , but I have to meet my parents in an hour for dinner . How about tomorrow ? ", " Yeah . Let's plan something tomorrow . ", ' Did you hear the weather forecast for tomorrow ? ', ' I think it is going to be the same as today . Clear and sunny . ', " That's great . We can do something outdoors then . ", ' Are there any special events going on tomorrow ? ', " Yeah . I think there's a live outdoor concert by the river tomorrow . ", " Oh yeah . I heard about that too . Let's go check it out . ", ' Do you know what time it starts ? ', ' It starts at one PM . ', " Let's meet for lunch at eleven thirty and afterwards , we can head over there . ", " Perfect . I'll see you in front of the apartment at eleven thirty . "]
['Would you go to the bookstore with me ? ', ' It sounds a good idea . Let ’ s go . ', ' Do you know Jeffery has published his second detective novel ? ', ' Yes . I heard about that . And I know you want to buy it , but I ’ m not interested in detective novels . ', ' So what are you interested in ? ', ' Magazines about fashions , such as Cosmo Polian . ', ' I know that magazine . It ’ s very popular . ', ' Yes . I can lend you some . ', ' Thank you . But I ’ m not interested . ']
['When can we expect you for dinner ? Can you come tonight ? ', ' Not tonight . I promised to go to a concert with my sister . ', ' Well ... How about Friday then ? ', ' That sounds fine . ', " Good . Shall we say seven o'clock ? ", " I'll be there . You're still a fabulous cook , aren't you ? ", " That'll be for you to decide . I've got a new dish that I want to try out on you . ", " I'm ready . I'll look forward to it all Friday ! "]
['I don ’ t understand why you always look so happy , so energetic . It seems like you ’ Ve got good news everyday . ', ' Really ? Do I look happy all the time ? ', ' All I know is you look quite differently from other teachers . ', ' Oh , do you know why ? Actually , it ’ s easy . Because I always exercise . My exercise , I think , is very hard . I often feel very good after conquering these difficulties . I feel alive ! ', ' Oh , I know . I saw you doing pull-ups one time on the campus 5 and some students trying to imitate you . ', ' Yeah , they are doing it for fun . Seldom would people like my exercise . It ’ s difficult and boring . ', ' It ’ s true . Many students do the exercise when they have to . We have P . E . once a week . ', ' But I think Chinese students need to exercise more . Besides exercise will help them learn new things better . Don ’ t students want to have a good memory ? ', ' Of course . I didn ’ t know that . I only know exercise makes bodies stronger . I should take some exercise then . Do you have any suggestions ? ', ' Well , do what you like to do . It can be anything . Jogging , doing aerobics , going bicycling , and playing ping-pong . Absolutely anything . Doing three or more workouts a week is good for you . But remember to do some stretches first . ', ' Oh , I know . Thank you . ']
['Which kind of sport do you like to watch ? ', ' Basketball , football , table tennis . I will watch them on TV . ', ' So you must like NBA game . ', ' Yeah , it is my favorite . Many Chinese people including women and children would like to concern the game . I think they want to see the performance of coming and YiJianLian , the Chinese players in NBA . ', ' What kind of sport do you like to participate in ? ', ' I am good at tennis and skiing . What about you ? ', ' I prefer the indoor sports , such as bowling , badminton and squash . ', " Moderate exercise is really important for health . ' Life lies in movement . ' ", ' How about playing tennis with me ? ', ' Good idea . I will take the racket . ']
["Good morning , Jerry.How ' s everything ? ", ' Fine , just fine.Thanks . ', ' Doing anything for lunch ? ', " Well , as a matter of fact , I've got a lunch date with Bob Thomas . "]
['Excuse me . Can you tell me how to get started using these machines ? ', ' Of course . Are you a new member here ? ', ' Yes . ', ' Welcome . My name is Johnson . ', ' Nice to meet you . ', ' Do you have any experience using weights ? ', " No , I don't . So I need some help . ", " Well , first it is important to go through a good stretch.You must warm up properly so that you don't hurt yourself on the machines . ", " Yes , I know that.Derek just led me through the warm up in the aerobics room.So I'm ready , I think . I can start using the machines . ", ' Alright . Great . Then we must get a card for you . ', ' What do you mean--a membership card ? I already have one . ', ' No . Not that . I mean a training card.The card allows you to keep track of how much weight you use on each machine.Here , let me show you . ', " I'm ready . ", ' Now , you can see that on this card there are all the machines listed.So , when you go through the series of twelve machines , you enter in the number of repetitions you do.And you also enter in the weight at which you set the machine . ', ' I see . So this card helps me to keep track of my progress . ', ' Yes . And it also reminds you what is a suitable weight for each machine.Today , I will go through the machines with you one by one . I will show you how to use them.And we will determine what is a good starting weight for you . ', ' Alright . Great . ', ' So you write your name and member number at the top of the card.And then , after you exercise each time , you file the card here . ', " Great . Why don't we start on the machines ? ", ' Are you alright ? Can you do more ? ', " I'm sorry . I know there are still seven machines . But I'm exhausted . ", " That's okay . Don't worry.It ' s important not to push yourself . Especially not at the beginning . ", " What can I do though ? I don't know the proper settings for the rest of the machines . ", " We can just go through them next time . It's no problem . Really.The most important thing is to know your limits.So if you feel burned out now , it is good to stop.Because if you strain a muscle or hurt your back , then you won't be able to exercise for a couple weeks . Right ? ", " Yes . I suppose it's best to stop . "]
["Don't be afraid . Give it a try . ", ' Okay . ']
['what are you doing ? ', " I'm just trying to complete today's crossword puzzle . Whenever I get the time , I like to do the crossword puzzles in the paper . ", " you really like brains that make you think , don't you ? ", ' I guess you could say that . What kind of games do you like ? ', " I guess the games I like the most are the ones that I'm good at ! ", " Doesn't everyone ? Which games are those ? ", ' Well , I like to play darts . Whenever I go to a bar , I usually play for a few hours . ', ' Did you play a lot of games when you were little ? ', ' My parents used to love to play checkers and dominoes . We used to have family tournaments every weekend . ', ' Do you still like playing those games ? ', ' Not at all . I never really did , to be honest . What about you ? Did your family used to play games together ? ', ' Everyone in my family really enjoys playing card games . ', ' Some of my friends play cards on the internet . Have you ever tried that ? ', ' No , I prefer to play with people I know . ', ' How about mah-jong ? ', " It's a popular game with some people , but I've never played it . ", ' I thought everyone in your country were experts at mah-jong ! ', " I hate to disappoint you , but unlike what most people think , we aren't all exactly the same ! "]
["I didn't like my brother's batting around without doing anything useful . ", ' Maybe he is trying to find a job . When he finds one , everything will be settled . ', ' I hope so . ']
['They got a divorce at last . ', " It's inevitable . Their love wasbuilt on the sand , and this is why their marriage has landed on the rocks . ", ' You said it . Love but on the sand will soon be on the rocks . ', ' That give us a good lesson . ']
['Do you like traveling , Kathy ? ', ' I like traveling for pleasure to get places for vacation for instance . But I don ’ t like traveling to work , waiting for buses , or ... ', ' Or getting stuck in traffic jams when you ’ re driving . ', ' Exactly . ']
['Can you believe that Susan got married ? ', ' Really ? I remember she said if she would remain single . Is the man very rich ? ', ' No . That ’ s what is surprising me . ', ' You means she didn ’ t marry a rich man . ', ' He ’ s a postman . ', ' I thought she would marry a fortune . ']
['What sort of things do you grow in your garden ? ', ' I grow a variety of things , so that something is in bloom all year round . ', ' When is your garden at its best ? ', ' It looks best in spring , when the plum and cherry blossoms are out . ']
['Good afternoon ! ', ' Good afternoon ! Sit down , please.How are you ? ', " I'm very well , thank you.How are you ? ", " Very well too , thank you very much.Isn ' t it a lovely day ? ", " Yes , it's beautiful , but it's also very hot . ", ' Yes . ', " What's the weather like in your country ? ", " Mm ... It's quite warm now . ", ' Where do you live ? ', ' In London.Where do you live ? ', ' Here.Near this school . ']
["Oh , no ! Now I'll be late . ", ' Can I give you a hand ? ', " Yes , I'd appreciate it if you could drive me downtown . ", " Sure thing . I've got time . "]
['What a great weekend that was ! ', ' My feelings exactly . ', ' I really enjoy the beach in the summer . ', " I couldn't agree with you more . ", ' We should come here more often . ', ' You are absolutely right . ', " I'd like to come back next weekend . ", " That's exactly the way I feel . "]
["What's this , I wonder ? ", " I'm not sure.Let me have a look ... It could be a coffee grinder . ", ' A coffee grinder ? ', ' Yes , it must be used for grinding coffee beans . ', ' Oh , that would be very useful . ']
["We've got a new manager in our department . ", " Oh ? You hoped to get that job , didn't you ? ", ' Yes , I did . ', " I'm sorry . That's too bad . Who is it ? Who got the job , I mean ? ", " Someone called Drexler . Carl Drexler . He's been with the company onlytwo years . I've been here longer . And I know more about the job , too ", ' Hmm . Why do you think they gave it to him and not to you ? ', " Because I'm the wrong sex , of course ! ", " You mean you didn't get the job because you're a woman ? ", " Yes , that was probably it ! It isn't fair . ", ' What sort of clothes does he wear ? ', ' A dark suit . White shirt . A tie . Why ? ', ' Perhaps that had something to do with it . ', " You mean you think I didn't get the job because I come to work in jeansand a sweater ? ", " It's possible , isn't it ? ", ' Do you really think I should wear different clothes ? ', ' Well . . . perhaps you should think about it . ', ' Why should I wear a skirt ? Or a dress ? ', " I'm not saying you should . I'm saying you should think about it . That's all ! ", " Why should I do that ? I'm good at my job ! That's the only important thing ! ", " Hmm . Perhaps it should be the only important thing . But it isn't . Not in this company . "]
["It's a sunny day , isn't it ? ", " Yes , it is . I'm Jennifer . Nice to meet you . ", ' My name is David . Nice to meet you , too . ', ' Are you American ? ', " No , I'm a Britisher . Where do you come from ? ", ' I come from America . Are you a freshman ? ', ' Yes . What about you ? ', ' Me , too . ', ' Great . Maybe we can study and play games together . I think we can be good friends . ', ' Yeah . Anytime . ']
['You keep bowling spares but no strike . ', " I don't know why , but I think there's something wrong with my hands . I couldn't seem to be able to control it on the first ball . ", " I don't think it was the problem with your hands , you did several excellent spares . You have no problem with your hands . ", " Then why couldn't I get strike on the first ball ? ", " The problem is you are too nervous . You want to have a strike so much , so you deliver the ball too hard . And when it comes to the I second roll , there's no pressure . That's why you could bowl all those spares . ", ' Really ? I will try again . ']
['Nice to see you , Patrick . ', ' Bob ! I hear your team won the match . ', ' Yeah . All of us tried our best . ', ' Congratulations ! ', ' Thanks . ']
['Are you free on the thirteenth in the afternoon ? ', " No I'm afraid not . I'm meeting Ruth then . How about the fourteenth in the morning ? ", " I'm sorry . I'm attending a meeting at the Hilton then . ", ' What about the next day ? ', " No . I'm busy then too . I'm meeting Dorothy Heath at North Bridge Road . Are you free on Thursday afternoon ? ", " Yes , I think I am . Let's meet for lunch at mouth restaurant . ", " Good idea ! Is two o'clock okay ? ", " That's fine . See you there ! "]
['Did you enjoy the movie ? ', " Oh , it's really a drag . ", " Sorry to hear that . I think it's even better than On the Golden pond . ", ' Hell with it ! Nobody will give it an Academy award ! ']
["Hi Jackie . You don't look too well . What's going on ? ", " It's nothing . I'm just a little stressed out . ", " Why ? What's stressing you out ? ", " School . Since I was working part time , I had a difficult time keeping up with class . Now that we have exams coming up , I'm totally freaking out . ", " The best thing to do is study as much as you can . I'm sure you'll do alright . ", " I hope so . I guess I won't be sleeping for the next 3 days . That's what it'll take . ", " I have to study for an exam too . Why don't we study together . We can encourage each other . ", ' That will be great . ']
['The new webpage design is much more effective than before . I feel confident it will rope in a lot more business because of its user-friendly format . ', " Why do you think the new page is so much better than the old page ? I thought the old page wasn't half bad ... ", " The old page was okay , alright , but there wasn't a big influence in our sales volume , because the site wasn't developed with an eye towards the marketing aspect . Now it's different . We got our marketing department team in on the action , and the results are smashing ... ", ' What changes were made from the old page to the new page ? ', " First , the visitors to the site are encouraged to give their contact information . They can sign up for a free monthly drawing . Once we've got their info , it goes into a database for future marketing mailers and advertising targeting . Also , there are clear links to descriptions of our products and services , so as to give confidence to new customers . We also added a specific area for on-line customer service ... So far we've gotten a ton of positive feedback ... ", ' Great ! ']
['Did you know that drinking beer helps you sing better ? ', ' Are you sure ? How do you know ? ', " Well , usually people think I'm a terrible singer , but after we all have a few beers , they say I sound a lot better ! ", ' Well , I heard that if you drink enough beer , you can speak foreign languages better ... ']
['Pardon me . Could you please pass me the tissue ? ', ' Sure , here you are . ', " Thanks , I didn't expect the dish to be so spicy . Are you ok ? ", " Yeah , I think the food is alright , it's not too spicy though it's a little salty for me . But you are Chinese , you should have known better . ", " Well , not every Chinese can handle spicy food in the way people from Sichuan and Guizhou provinces can . Back where I come from , people don't eat a lot of papers and chilies . ", " Oh , I see how this food can be really hard for you . I can sympathize with that . I stayed in Sichuan for a year . The food was difficult at the beginning . Every dish was so spicy . After a while though , I got used to the taste , and now I won't consider anything a real dish if it isn't spicy . ", " Yeah , you can increase you tolerance for spicy food , but so far , I haven't had the need or the opportunity . Every time I try spicy food , it is a total disaster for my nose and eyes . ", " I completely understand . I didn't intend on liking spicy food at first either , but when you have no other choices , you've got to adapt . ", " Yeah , I guess that's a typical example of ' when in Rome , do as the Romans do . ' ", ' Exactly . ']
['Tom , Christmas Day is coming . Merry Christmas to you . ', ' Thank you . And a merry Christmas to you ! ']
['Could you lend your bike to me for several days ? ', ' How long would you like to keep it ? ', ' Till the end of the week . ', " Yes , that'd be all right . "]
["Don't you feel a little strange taking the place of your old boss after he was demoted ? ", ' Yes , at first I felt very awkward . After Bill was demoted and then resigned , it was kind of like somebody died ! I mean the atmosphere in the office was like a funeral parlor or something . And then I was afraid people would look at me as a traitor for filling in his spot when the management asked me to ... ', ' Did they mutiny ? ', " Thankful , no . I guess everyone understands the opportunity I had to step into a leadership role is so great for my career . I'm really moving up the ladder now that I'm considered a supervisor . After a couple weeks , it was like nothing happened . ", ' It is a really good chance for you to get more exposure at work . supervisors get to take the credit for all the hard work of the people under them . ', " Yeah , and they also take the blame , that's what happened to my old boss ... "]
['How about a game of tennis ? ', ' Okay . Loser has to take out the trash for a month . ', " It's a deal . ", ' See you in the court . ']
['Are you feeling better today , Bill ? ', " Well , it's hard to say . I cough a lot in the evening . ", " You'd better give up smoking . It's bad for your health . ", " You're right , but you know , it's hard to give up an old habit . ", ' But you should make up your mind first . ', ' You know , I often have to work till late at night . I need something to keep me awake . ', " Why don't you go to bed and get up early ? You'll have the same time for work . ", " Thank you for your advice ! I'll try it . "]
['Hi , John , how was your vacation ? ', ' Awesome , we went to Australia and New Zealand . ', ' That must have been wonderful . Do anything interesting ? ', ' Well , we went bungee jumping when we were in Australia . ', ' Wow ! Isn ’ t that dangerous ? ', ' A little , but the rush was worth it . ', ' Tell me about it . ', ' We jumped off a bridge and fell 500 feet before the bungee cord caught us . ', ' 500 feet ! I would never be able to do that . ', ' Yeah , It was scary , but exhilarating . ']
['What did her boss say to you ? ', ' He asked me to beef up in the work . ', ' Yeah . You look so unhappy recently . What ’ s the matter . ', ' Nothing , thanks . I am just not in the mood these days . ']
["Hi , Tina , it's Joe . ", ' Hi , Joe . ', " What's the weather like there today ? ", " It's really cold . It snowed all day and the school closed early . ", " What's the temperature ? ", " It's 20 degrees below zero now . It was even colder this morning . ", ' Have you heard what the weather is going to be like tomorrow ? ', " I was watching the news a little earlier . They said it's probably going to snow tomorrow . ", " I really don't like the winter . I wish it were summer . ", " Me too . How's the weather where you are ? ", " It's not too bad , but it's pretty cold here too . I heard it's going to be a little warmer tomorrow . "]
['Mom , I just finished my paper . Can you proofread it before I hand it in ? ', ' Sure , let ’ s take a look . Sweetie , this is terrific . Your ideas are so original . ', ' Thanks . ', ' I can tell you worked hard on it . ', ' I really did ! I started thinking about what I wanted to say three weeks ago . ', ' Well , it was definitely worth all the time . ', ' Let ’ s just hope my teacher agrees . ']
['How about doing shopping this weekend ? ', " What're you going to buy ? ", ' Sportshoes.Will you go with me ? ', ' OK . ']
['Merry Christmas ! ', ' Huh ? ', " I said Merry Christmas ! Don't you know that Christmas is almost here ? ", " It is ? Oh , that's nice . ", " Huh ? Didn't you know ? Aren't you excited ? ", " Actually , I'd forgotten about it . ", ' Forgotten about it ? How could you ? ', " Because I'm not Christian , I'm Jewish . ", " Oh , I'm sorry . I didn't know . ", " It's all right . There are so many Christians in America that everybody takes it for granted that I'm Christian . ", ' I guess so . So what do you do around this time of year ? ', " Well , I'll celebrate Hanukah soon , but that's not as important to us as Christmas is to you . Mainly I'll just enjoy the holiday break . ", ' Well , would you be horribly offended if I invited you to a Christmas party at my house ? ', " Not at all . A party is a party . I'll be happy to come . "]
["It's all over . I'm bankrupt . ", " Don't worry . Everything will be fine . "]
['Bill , Happy Halloween ! ', ' Happy Halloween ! What creature are you going to dress up as ? ', ' I will dress up as a vampire with big fangs . ', ' May I have a look at your costume ? ', ' Sure . Wait a moment . ( Several minutes later ) Here you are . ', ' I like your black clothes and your fangs are cool . ', ' I will bite many beautiful girls on the neck tonight . Maybe I will suck their blood . ', ' Haha . Wish you good luck . ']
['I think that ’ s settled . ', " I'm tired of your cut-and-dried opinions . Who do you think you are ! ", ' How dare you speak to me like this . ', ' Why not ? ']
['Hey , Karen . Look like you got some sun this weekend . ', ' Yeah ? I guess so . I spent the weekend at beach . ', ' That ’ s great . Where did you stay ? ', ' Some friends of my parents live out there , and they invited me there . ', ' So , what did you do out there ? I mean besides bask in the sun , obviously . ', ' I jogged up and down the beach and played volleyball . You know I never realized how hard it is to run on sand . I couldn ’ t get through a whole game before I had to sit down . ', ' Not to mention cooler . Did you go swimming ? ', ' I wanted to , but the water is too cold , and I just wetted in up to my knees . ', ' It all sounds so relaxing . I wish I could get away to the beach like that . ', ' It looks like you could use it . Don ’ t tell me you spent the weekend in the library again . ']
['OK class , so today we are going to continue with our anatomy class , today we will review everything we have learned . Can anyone tell me what the first major organ is ? ', ' The brain ! ', " That's right , the brain ! It serves as a control center for the body , handling the processes of the central nervous system as well as cognition . Then what major organ is in our chest ? ", ' The heart ! ', " Very good ! It pumps blood throughout the body , using the circulatory system such as blood vessels and veins . Now let's not forget that our lungs provide oxygen to our heart and body to keep us alive ! Now what about the organs that help us digest food ? ", ' The stomach and intestines ! ', " Very good ! Let's not forget that the stomach is the one that breaks down our food and our intestines process that food and then expel the waste . Are we forgetting anything ? ", ' Yeah ! Our kidneys , liver and bladder ! ', ' Oh yes , you are right . Very important organs indeed . ', ' So what do these organs do , teacher ? ', ' Well , mumm , they ... Time for a break ! We can talk about it when you get back . ']
["It's not good for business recently . ", " Not good for business ? I don't see eye to eye with you.The new policy offers new opportunities . ", " Too risky anyway.It ' s necessary to look before you leap . "]
['Do you know how to play go ? ', " It's easy . All you have to do is to use your pieces to surround the opponent's pieces and then take over all of his territory . ", ' But I heard it is very difficult to play . ', " It's easier said than done . When you actually play , it can be very frustrating . "]
["Linda ? Is that you ? I haven't seen you in ages ! ", " Hi George ! It's good to see you ! ", ' What have you been up to ? ', ' I just opened up my own business not long ago . ', ' Good for you ! What are you doing ? ', " I'm a professional party planner here in the city . I do catering and all that . ", ' I knew some day I would be able to profit from your love of fun ! ', " Well , I don't know about the profit part yet . But I am really having fun ! "]
['So , what ’ s new in the kitchen ? That refrigerator is new , isn ’ t it ? ', ' Yes . I needed a large one . Before , I had a separate refrigerator and freezer , but this has both combined into one . ', ' That ’ s usual nowadays . You ’ Ve added a few shelves too . ', ' Yes . You know I ’ Ve been cooking more kind of food recently and I needed some extra space for spices and ingredients . ', ' Did you buy new cupboards too ? ', ' No , I didn ’ t . I gave them a really good clean , so they just look new . The worktop was in poor condition , so I had a new one added . ', ' I see that you have bought several new pots and pans and utensils . ', ' Yes , I have . I need them to help me with these new dished I ’ m trying to make . I need a little more practice before I invite guests over . ', ' Looking at the spice rack , I ’ d say you ’ Ve been learning how to make asian food . ', ' Yes . I ’ Ve always likes Indian and thai food , so I ’ Ve been trying to make dishes from those countries . I ’ m pretty good at making curries now , but I still need practice at making thai food . ', ' Both kinds of food are becoming popular.Nowadays , it ’ s very easy to pick up the ingredients at the supermarket . ', ' I hope you can stay for dinner . I need a guinea pig ! ']
['How do you like skiing , Pat ? ', ' I love it . All my life I wanted to learn to ski . Finally I took lessons last year . ', ' I suppose skiing is easy for you . ', " No , quite the opposite . I thought I'd never stop falling down . Then all of a sudden I started skiing much better . ", ' I see . Do you ski often ? ', ' Every chance I get . On weekends I ski all day long . Sometimes I even ski at night . ', ' That sounds great . ', " Oh , yes . The ski slopes are well lit . It's really nice to ski at night . Why don't you learn to ski ? ", " Not on your life ! I know I'd break my leg ", " Don't be so frightened . It's just a skill . "]
['Hi , Dave . This is Zina . ', ' Zina ? Zina the Snake ? ', ' I got your e-mail a couple of months back . ', ' Yeah ? Which one was that ? ', " The one that said , You're a creep . From me you won't hear another peep . I hope you wreck your jeep . ", ' Right . That one . Did it work ? ']
['Hello , my name is Bill Martin and we have a reservation for party tonight . ', ' Yes , what can I do for you ? ', ' I need to cancel that . We have had a last minute change of plans . ', ' I see . Would you like me to reschedule you for another night ? ', ' OK , we will let you know as early as possible . By the way , will we be able to get a refund on this cancellation ? ', ' Certainly . ', ' Thank you very much . ', " That's all right . I hope we can help you at some other time . Good-bye . ", ' Good-bye . ']
['Can I use your laptop for a while ? ', ' Sure , go ahead . ', " Oh , isn't your computer Wi-Fi capable ? ", ' Yes , it is . You want go online ? there are no wi-fi hotspots around . ', ' Oh my , no internet access is killing me . ', " Can't you wait till you get home ? then you can surf the internet using the broadband , wireless connection or whatever you like . ", " No , I'm not feeling myself . I just want to check my emails , visit my favorite websites and chat with my friends . ", ' Now I see , you must be suffering from discomgoogolation . ', " What does that mean ? there's nothing wrong with me . ", " Well , the term ' discomgoogolation ' comes from ' discombobulate ' and ' google ' . Because floods of information are just a mouse click away , net users are very likely to become addicted to the web . ", " That's alright . I just can't bear losing track of all the latest information . It almost drives me crazy . ", " Then , you're probably addicted . "]
['Sally , I ’ m tired of this Western food . I really miss my mother ’ s Sichuan cooking . ', ' I ’ m sure you do miss that type of cooking . But can ’ t you try to get used to Western food ? ', ' I have tried . But Americans like butter , bread , sugar , and cream too much . ', ' I suppose you ’ re right , Lee . Maybe that ’ s why so many Westerners are overweight . ', ' It ’ s interesting that Americans work very hard at their jobs , do not take naps during the day , and yet they can be so heavy . ', ' You see , because we are often busy working , we eat too much fast food , and that food is very fattening . ']
["Tell me something about your Valentine's Day . ", ' Ok , on that day , boys usually give roses to the sweet hearts and girls give them chocolate to return . ', ' So romantic . Young people must have lot of fun . ', " Yeah , that is the holiday is hot , isn't it ? "]
['What will happen to the children if you break up ? ', " That's a relief for me and a misery for the children . ", " Why don't you make up with John . ", " It's too late . "]
["Have you ever been to Japan ? I'm going in the fall . ", " Yeah , I've been there twice . ", " Really ? Tell me about it . What's it like ? ", " Oh , it's fantastic . ", ' Where did you go ? ', ' On my first trip I went to Tokyo , and on my second trip I visited Kyoto . ', ' What did you think of Tokyo ? ', ' Very big and exciting , but very crowded , too . ', " Yeah . I've seen pictures of the crowds ! ", " And the restaurant are excellent ... but they're kind of expensive . ", ' And how about Kyoto ? ', " Kyoto is lovely . It's full of beautiful old temples and gardens.It ' s a very historic city . ", ' How was the weather ? ', ' I was in Tokyo in August , and it was really hot and humid . I went to Kyoto in October.It was hot and sunny , but there was no humidity . ', " Sounds perfect . I can't wait ! "]
['Where do you live now ? ', ' I live in Haitian District where there are lot of universities . ', ' Which street do you live on ? ', ' I live at No . 50 Xingu Street . ']
['Who did the stupid thing ? ', ' Maybe it was Dick . ', " I don't think so . Dick has been on the ball and never does things like that . ", ' Then it must be a naughty boy who did it . ']
['Can I help you ? ', " Yes . I'd like to borrow these books . ", " Just a second . I'll see if I can find them for you . ", ' Thanks . ', ' Here you are . You must return them within a month . ', " What happens if I'm not finished with them in a month ? ", ' You can come in and renew them unless someone else has reserved them . ', ' OK.Thank you very much for your trouble . ', ' No trouble at all . So long . ']
['Hi Sam , would you like to come for a curry with us next Friday ? ', ' Sure , I love curry . Who else is coming ? ', ' Jane , Susan , Pete and two colleagues of mine from work . ', ' I have no plans for Friday , so curry would be great . Which restaurant do you have in mind ? ', ' Susan suggested the one on Main Street . She says it is very good . ', ' Which one is that ? ', ' You know , the one just on the corner with Oxford Street . There is a large pharmacy next door . ', ' Oh yes , I know which one you mean . I have never been there , but I looked at their menu once and it did look good . ', ' Okay then . I think we will all meet outside ? ', ' What time ? ', " At 8 o'clock . I will make the reservation . ", " That's good . See you on Friday . "]
['Did you have a part-time job when you were still in school ? ', ' No , I was way too busy studying all the time . How about you ? ', ' Yeah , I worked about twenty hours a week in a pizza restaurant . ', ' What was that like ? ', ' It was always very busy there . ', ' What did you do ? ', ' I stood behind the register and took pizza orders . ', ' Did you get any perks on the job ? ', ' Yeah , I got to eat as much pizza as I could for free . ']
['Did you like the play ? ', " Not really . It's a dull one , and the production isn't satisfactory , either . ", " You're absolutely right . The acting could be better . ", ' To be fair , though , both the costumes and scenery are marvelous . ']
['I need some books on hardware . ', " There's many books here.What about these ? ", " Great ! They're the very books I want.May I borrow two books ? ", ' Sure.But you can only keep them for a week . ', ' I see.Thank you . ']
['I don ’ t know why I married him . ', ' What is the matter ? ', ' He never see eye to eye with me . ', ' That is to say , love is blind . ']
['Why is the long face ? ', " I'm getting sick of work man . I can't take the political bull in the company any more . ", ' Did you just get your review or something ? ', " Yeah , but that's not why I am upset . I just found out another guy got a promotion . He doesn't know how to do anything . He sits there and kisses the managers butt all day long . ", ' That sucks . ', " I'm just pissed that management can't see behind his smooth talking lies . ", ' Look on the bright side . At least you have a job . ', " Yeah . I shouldn't stress about this anymore . It's not like I can do anything about it . ", ' Exactly . Instead , we should have some drinks tonight . ', ' How about a cold bottle of beer . ', " Now you're talking . "]
["You're so witty ... ", ' So why is the face tilted to the right ? ', ' This watch is supposed to be worn on your left hand . ', " So it's not as convenient for left-handed people ? ", " It's better for right-handed people like me . See , I don't even have to move my arm to see the time . ", " I'm left-handed . You bought that watch so that I won't borrow it ... ", ' Bingo ! ']
["Is there any ticket left for tonight's concert ? ", ' I am sorry , sir.All the tickets have been sold out . ', ' What a shame . Will there be the same performance tomorrow evening ? ', ' Sorry , sir . The only tickets of the same performance available are on 21st . ', " That's fine . I want 2 tickets . "]
['Does Tom drink a lot ? ', ' Yes , he does . He of ten has had one to many . But I advised him not to drink too much , he just boasted that he had hollow legs and nobody had ever drunk him under the table . ', " That's a problem . He has sort of Dutch courage and that will egg him on in doing anything . "]
['Do you offer a course in business management ? ', ' Yes , we do . ', ' How many nights a week is it ? ', " It's 3 nights a week , Monday , Tuesday and Thursday . ", ' And how long does the course last ? ', ' It lasts for 9 months . ', ' When does it start ? ', ' The next beginning class starts on October 25th . ', ' What time is the class ? ', " From 7 to 9 o'clock . ", ' How much does it cost ? ', ' It costs 125 dollars a month . ', " Yes , that's all right . I want to enroll in the course . ", ' Thank you , please fill out this form for us . ', ' Do you want me to fill it out now ? ', ' Yes , please . We need a record of you education and your work experiences . ']
['How many passengers are there aboard the ship ? ', ' Seventy-six , I think . ']
['What ’ s your schedule like this year ? ', ' Pretty busy . I have to pick up a lot of credits this year . ', ' What ’ s your major ? ', ' I ’ m majoring in French literature . ', ' Oh , don ’ t you have to take that class on 18th century poetry ? It ’ s really difficult . I hear the students in that class have to write a paper 100 pages long . ', ' That ’ s right . We got the assignment last week . ', ' When is it due ? ', ' Next Monday ! ', ' Remind me never to sign up for that course ! ']
['Okay , next question . If Eric asked you out on a date , what would you say ? ', ' Duh ! I would say yes ! Eric is the most popular kid in school ! Okay , my turn . What would you do if you won the lottery ? ', ' Let ’ s see ... If I won the lottery , I would buy two tickets for a trip around the world . ', ' If you buy me a ticket I will go with you for sure ! ', ' My dad will freak out if I even mention a trip like that ! ', ' Alright this is a good one . What would your mom say if you told her you are going to get married ? ', ' If I told her that , she would faint and have me committed ! ']
['Something wrong ? ', ' Yes . My car is having problems . ', " What's wrong ? ", " It won't start . ", ' Do you want me to take a look ? ', ' No , thank you . I think I can handle it . ', ' Well , if you change your mind , let me know . ', " I will . Thanks . That's sweet of you . ", ' No problem . ', ' I might need some tools though . Do you know where I can get some ? ', ' Sure . I have all kinds of tools . Just ask . I ’ ll be happy to get them for you . ', ' Thanks . That would be very helpful . ', ' Anything for you . Seriously , I don ’ t mind helping . ', ' OK . If you really insist , I could always use the company . ']
["I've been standing here since half past seven . Where on earth have you been ? ", " I'm terribly sorry I'm late . I just couldn't help it . ", " It's really very easy saying you're sorry . ", ' Look , just give me a chance . I can explain it . ']
['Dalian is a beautiful city . Do you agree ? ', ' I suppose I do . ', ' The climate here is pleasant . ', ' They use said it ', ' This city is really comfortable to living . ', ' It sure is ', " No other city can match it . It's heaven . ", ' Well , if you live in other as long enough you love them just as much . ', ' Maybe . ', " That's for sure . "]
['Do you know that Mary an Ben have already separated ? ', ' Yeah , I know . ', ' I didn ’ t know it until yesterday . I put my foot into it , and was even stupid enough to ask when they would get married . ']
['Alice , your father is amazing . He ’ s 90 years old and he lives alone in that big house . ', ' I know . He doesn ’ t like to ask anyone for help . My dad insists on paying his own bills and taking care of himself ! ', ' That sounds like my Grandmother . She was always stubbornly independent . ', ' It seems that folks like my father and your grandmother are determined to be on their own . ', ' They see their independence as a kind of character strength . ', ' Sometimes they are too independent . ']
['How are you making out ? ', " I'm doing fine.Don ' t mind me.It ' s a wonderful birthday party.Everyone is enjoying himself . ", ' I hope so . Thank you again for your delightful gift . ', " Don't mention it . "]
['Happy Birthday , Mary ! ', ' Thank you . ', ' Here is a gift for you . I hope you like it . ', ' What a lovely dog ! How did you know I love this ? ', " I had my own ways of finding out . It's a secret . You look so beautiful today . Your new shirt goes well with your skirt . ", " Maybe you don't believe it , but it was made by my grandmother . ", ' Really ? It looks so nice . ', ' Thank you . Please have a cup of tea . ', ' All right . ', ' How about some fish ? ', " No , thanks . I've had enough . Now , Mary , before you blow out the birthday candles , you have to make a wish . After that , you may cut the cake . ", ' OK , let me make a wish ... Do you want a big piece of cake ? ', " No , just a small one . Next let's sing ' Happy Birthday ' to Mary . ", " It is very kind of you . I'm so moved by you . "]
['How did you meet your girlfriend ? ', ' I met Amanda through a friend . ', " That's great . Did you start dating right after you met , or did you become friends first ? ", ' We started dating right away . ']
['Is there anything available for tonight ? ', ' There are some seats in the rear mezzanine . ', " Isn't there anything else available ? ", ' No , the show is almost sold out . ']
["I haven't seen your father in like 5 years . How is he doing ? ", " He's not doing too well . ", " Why ? What's wrong ? ", ' About a year ago , he started feeling weak all the time . ', ' Is it due to old age or is he sick . ', " Maybe a little of both . The doctor's can't point out anything specifically . I think it is because he didn't take care of himself during his youth . ", " That makes sense . It's important to take care of your health early in life . ", " That's what my father tells me almost everyday . ", ' Well , I hope he starts feeling better . Say hi to him for me . ', " Thanks . I'll let him know . "]
['Wedding rings ! ', ' Oh , no ... ', " Aren't they cool ? I like the settings . ", " Jen , is there someone you're not telling me about ? ", ' No . I just like looking at wedding rings , OK ? ', ' Women are such dreamers . ', ' These are specially designed for the year 2000 ! ']
['Hurry up , get in . ', ' I ’ m in , let ’ s go ! ', ' OK , make a left here . . . no wait , I meant make a right . Come on , speed up ! ', ' Geez ! What ’ s the rush ? ', ' Don ’ t worry about it , just drive . Oh , no , the light is about to change . . . step on it ! ', ' Are you nuts ! I ’ m not going to run a red light ! ', ' Whatever . Just turn right here . . . . The freeway will be packed at this hour . . . . let ’ s take a side street.Go on ! Get out of our way ! Move , move ! ', ' What ’ s your problem ! Geez . Having a fit is not going to help ! ', ' Here , I know a short cut ... just go down here , and we ’ ll cut though Ashburn Heights . Let ’ s go , let ’ s go ! Watch out for that lady ! ', ' I ’ m going as fast as I can ! ', ' Yes ! We made it . 5:58 , just before the library closes . ', ' You ’ re such a geek ! ']
["I've heard so much about Japan . Is it a beautiful country ? ", " Not everyone thinks Japan is beautiful , but to me its beauty is breathtaking.You feel the same way about France , don't you ? ", ' Yes , I do feel the same way about France . The swift rivers , the fertile valleys , the large cities-its scenery is beautiful . Will you describe the geography of Japan ? ', " Well , it's made up of four large islands and many smaller islands located off the coast of the Asian main lands . France isn't an island , is it ? ", " Oh , no , France isn't an island . It is located in the western part of the European continent . But France does have many fine harbors and port cities on its southern and western coasts . Does Japan have good harbors ? ", " Good harbors ! Yokohama is one of the most famous port cities in the world , and Japan is the largest shipbuilding nation in the world . Also , there are long mountain ranges in the southern is hands . France isn't very mountainous , is it ? ", " No , France isn't very mountainous . But it does contain the Pyrenees , a large mountain range with high peaks and deep canyons . What kind of Climate does Japan have ? ", " The Japanese climate is warm and moist in the south , mild in the central part and cold in the north . Except for Hokkaido , we don't get much snowfall at all . France has a mild climate , doesn't it ? ", ' Yes , the climate of France rarely has severe winters . In southern France , one can live in comfort the whole year . Is Japan good for farming ? ', " Yes , Japan is good for farming . Rice is the main crop , but Japan is also an industrial center . Fishing is very important , too . Rice isn't grown in France , is it ? ", " No , rice isn't grown in France . But farming , fishing and industry are also very important in France . I'd like to go to Japan some day . Would you like to visit France ? ", " Yes . I'd like to visit France . I'd like to travel all over the world . As you describe it , France seems to be very much like Japan . I would like to see it for myself . "]
["I don't know why Mark often comes to me and asks me for advice . I smell some rat in it . ", ' He is sly . He is actually angling for compliments . But he may have got the crush on you . ', " Nonsense ! There's no indication that he's in love with me . ", ' Keep your fingers crossed . He may pop the question one of these days . ']
['Hi , why do you look so depressed today , Mike ? ', ' I had a terrible quarrel with my neighbor yesterday . ', ' How come ? ', " It is a long story . Basically , she thought I had laughed at her while I didn't . ", ' I know everyone suffers when he is misunderstood . But why not take it easy ? ', " Yeah . It's so nice of you to comfort me . "]
["Maybe we'd better go now . ", " It's still early . ", " Gosh , it's already 10.Stay here if you like . ", " Since we're late , let's go to see a film . ", ' OK.Hurry up . ']
['My uncle passed away last night . ', ' My condolences . ']
['Diana , in your opinion , which is more important , IQ or EQ ? ', ' Why are you asking me the strange question , Jerry ? ', ' I watched the movie Forrest Gump last night . And the question just lined in my mind . ', " Well . I think IQ matters more . But it won't work without EQ . ", ' Why ? You seem pretty sure about it . ', ' Because an intellectual mind can only be a beneficial thing in life . ', " But IQ is decided at birth.One can't expect to make a lot of improvement in it . ", " That's why people's achievement varies greatly . ", " That ' s true , but what if one comes across some difficulties . He must rely on his EQ to deal with them . ", ' Yes , Jerry , can you share your understanding of EQ ? ', ' I think it is independent of IQ and plays a prominent role in deciding the way we live our lives . ', " Quite right . Have you noticed that a high IQ is not a must for one's success ? ", ' Just as Forrest ? ', ' Yes , his IQ is high enough for him to embrace the success as long as he can manage his EQ . ', ' I got it . ']
["Come on ! It's time to go ! ", " Wait a minute ! Just hold your horses ! What's your hurry , anyway ? ", " Well , I've got to stop and get gas in the car , first . ", " That won't take long . ", " Well , it won't if there no line at the pump . ", " Well , I'm not quite ready . ", " I'll give you five more minutes , then I'm going on without you ! ", " You wouldn't do a thing like that ! ", ' Oh , yes , I would ! ']
["How's business ? ", ' So so . ']
['Wow , that terrible movie is finally over . Next time I ’ m picking the film , because I don ’ t want to end up seeing a chick flick . ', ' Well you should have picked , in the end you always complain about everything . ', ' Not everything , just this film . Even the title is ridiculous . and it ’ s so long , those are the two and a half most wasted hours of my life , so much so that I ’ m thinking about asking them to give me my money back . ', ' I ’ m thinking of taking you back home . I thought we could have a nice evening , but you ’ re always so negative . ', ' I ’ m only complaining about a movie that I could have rented or bought and then thrown in the garbage . ', ' You see , that ’ s what I ’ m talking about , I can ’ t stand your sarcastic jokes anymore ', ' Next time , go with your gay friend who is more in touch with his feelings . ', ' Well he ’ s more of a man than you are ; at least he appreciates love stories . ', ' Love stories ? More like one-night-stands . ', ' Don ’ t criticize Mario or else I ’ ll start on those fat , drunk friends of yours ; they ’ re no saints . ', ' My friends ? Fat ? What about those whales you call friends ? ', ' You ’ re unbearable ; you can walk home , I ’ m leaving . ']
['Which language do you speak ? ', ' Well , I studied French at school , but I ’ Ve forgotten most of it . I learnt some Russian while I was studying there and now I study Spanish in evening classes . Do you speak Japanese at home with your parents ? ', ' Yes , I do . I ’ m learning Chinese now on the internet . ', ' How do you find studying a language on the internet ? ', ' It ’ s not easy , particularly with listening and speaking , because sometimes the connection isn ’ t too good . ', ' I bet you find the character difficult to write ! ', ' Actually , many of the characters are the same or very similar in both Chinese and Japanese , so they ’ re easy for me . ', ' So , you can read and write much better than you speak and understand other speakers , right ? ', ' Yes . How are the Spanish classes going ? ', ' In a way , it ’ s similar to your experience of learning Chinese . Some Spanish words are very similar to English ones . But I need to practise listening to native speakers and saying the words myself . ']
["Why didn't you tell me you had a girlfriend ? ", ' Sorry , I thought you knew . ', ' But you should tell me you were in love with her . ', " Didn't I ? ", " You know you didn't . ", ' Well , I am telling you now . ', ' Yes , but you might have told me before . ', " I didn't think you would be interested . ", " You can't be serious . How dare you not tell me you are going to marry her ? ", " Sorry , I didn't think it mattered . ", ' Oh , you men ! You are all the same . ']
['So , did you go out with Richard ? ', ' Yeah . We went to a movie last Saturday . We saw Police Partners II . ', ' Did you like it ? ', " Richard did , but I didn't . Of course , I told him I liked it . ", ' Yeah . So did you do anything else ? ', ' Well , we went to a dance club . ', ' Did you have fun there ? ', " Yeah , we had a great time . And we're going to go there again next week ! "]
['Would you like to go to work or continue your studies after graduation ? ', " I think I will continue my studies . Now it's not easy for a graduate with bachelor's degree to get a job since there are so many graduates with master's or doctor's degree . We are likely to lose in competing with them in the job market . ", " So you will continue to study for a master's degree ? ", " Well , I think so . But I am thinking of going aboard to get a master's and doctor's degree . If can get a Ph . D . abroad , it will be much easy for me to get a job at home . ", ' How can you finance your education abroad ? It is very expensive to study abroad . ', " I think I will try to get the scholarship since I really don't have so much money to study abroad . Actually now I am preparing for the TEFL and GRE exams . If I can get high marks in the two exams and if I am lucky enough , I may get a scholarship . ", ' It could be pretty tough studying abroad . Being so far away from home ... ']
["It's hard to get tickets for the movie . ", ' Did you get any ? ', ' Yeah , two at the tenth rows . ', ' How much is the ticket ? ', ' 3.5 dollars each . ']
['What a great weekend that was ! ', " My feeling's exactly . ", ' I really enjoy the beach in the summer . ', " I couldn't agree with you more . ", ' We should come here more often . ', ' You are absolutely right . ', " I'd like to come back next weekend . "]
["I think Andy's party will be fun . ", ' Yeah , I think so . Oh , by the way , I need to ask you something . ', " What's that ? ", ' Could I get back the sweater you borrowed ? ', ' Sure . Oh , that reminds me . Could I borrow your black leather boots ? ', ' My boots ? Er ... Sure , ok . ']
["Hi , Mr . Smith . Are you enjoying the cookout ? You don't look too happy . ", ' I spent the morning at the cemetery . I put flowers on the graves of my old war buddies . ', ' Is that what people usually do on Memorial Day ? ', " They should . This holiday is about remembering our war dead . But people these days think it's just a holiday for summer sales and cookouts ! ", " I'm sorry to hear that . Thank you for telling me a little more about it . "]
["I went to Super Junior's concert last night . It was fantastic . ", ' Really ? Their songs are very popular all round Asia now . I am also a big fan of theirs . ', ' Yes , their new album just came out last week . It is number one on the billboard . ', ' I really love their dancing . They are all excellent dancers . ', ' The lyrics of the new song are beautiful , too . Can you sing ? ', ' Sure . I think you can hear the song everywhere you go now . ', " Let's go buy their new album . Want to come with me ? ", ' Why not ? ']
['I am a little nervous about my presentation on Friday . ', ' If you would like me to , I could help you with that . ', " Wouldn't that take you away from your project ? ", " I have plenty of time to do this . I promise you it won't be a problem for me . ", ' Is there a good time for you to help me ? ', ' If we work on this tomorrow night , you could easily be ready by Friday . ', ' How about meeting in my office ? ', ' That would work out well . Bring any concerns that you might have . ', " Sounds like you'll be able to help me a lot . ", " Don't worry . Everything will go well . I promise ! "]
['If you can choose , will you marry a foreigner or a Chinese ? ', ' Why ? Did tom pop the question ? ', ' Not yet . But I wonder if I can get my parents ’ consent . ', ' Let me guess , your parents want you to marry a Chinese man , right ? ', ' You are right . It is giving me a real headache . I feel like I ’ m between a rock and a hard place . ', ' I used to have the same problem when I was with my ex . ', ' Oh , how did you deal with it ? ', ' I just let it go and continued dating with my Korean boyfriend . But finally we broke up . ', ' Oh , it ’ s a pity . What was the matter ? ', ' Simple . We had personality clashes and there were too many cultural differences . ', ' Like what ? ', ' He hoped to live in the Korean way and asked me to give up working and stay at home to take care of the family . ', ' Oh , I see . In their culture women should put family first . ', ' Yes , he said it would be better for me and for the whole family . But I simply can not quit working . ', " So that's why it ’ s hard to have a happy marriage with a foreigner . ", ' Not really . There are many successful mixed marriage around us . ']
['Where is Tom ? ', ' He is in the bedroom and fallen asleep . ', ' What ? It ’ s only 9p . m . Now . Why today he went to bed so early ? ', ' He ran four miles and came back dead beat . ', ' Oh , I see . ']
['Hi , Ann . ', " Hi . You look excited . What's happening ? ", ' I just heard that our school will hold a singing contest in 5 days . ', " And you're planning to enter ? ", ' Of course . This is a great chance for me to show off my beautiful voice . ', ' Is there a prize ? ', ' I heard that the winner gets a Panda Radio . ', ' Do you think you have a chance ? ', " A chance ? Not just a chance , I'm a hundred percent certain.Everyone says my voice is beautiful . ", " But you haven't practised all that much . ", " I still have 5 days to practise . It's in the bag ! ", " Don't be too sure . You're still going to need some help . ", ' Yeah , maybe . ']
["I've got to go to bed . Have to work tomorrow . ", ' OK . Good night , then . Have a good sleep . ', ' Good night . See you tomorrow . ']
['I wonder if it is possible that we organize a dinner party for all the colleagues in our departments . They are working very hard these days . Maybe it is time for everybody to relax a little . ', ' That is a good idea , I love it . What time do you think is convenient ? ', ' Well , what about this Thursday evening after we finish the weekly meeting ? ', ' Ok , I will inform everybody when they come back from lunch . It has been a long time since we had the department dinner last time . I am sure they don ’ t want to miss it . ', ' I hope so . Let me know how many will come . Then I will book the restaurant . ']
['What day is today ? ', ' Today is Thursday . ', " What's the date today ? ", ' Today is May first , 2003 . ', " Oh , today's International Labour Day . Is it our working day ? ", " Well , I don't think so . "]
['Can you take part in our picnic this Saturday ? ', ' That would be fine . Where are you going ? ', ' We plan to go to a forest in the suburb . There is a beautiful river there . We can do some fishing . ', ' Great . ', " And don't forget your fishing tackle . ", ' Ok . I like fishing very much . ']
["Daniel , what are you doing here ? Aren't you supposed to be at school now ? ", ' The same question to you . ', ' Well , we shall make it a secret between us . ', ' Deal , Where is Gucci ? ', ' She is the cheer-leader . They are required to put on a performance . Look ! Here they come . ', ' Oh , look at her . She looks like one is the basketball babies in NBA . ', ' I want to be like her . ', " Get real . Don't be so pathetic . ", " Hey , young man ! I'm your sis . Don't talk to me like that . ", ' Oh , man , look at her , go ! She is amazing ! She should be my sis . ', " Boy , you've got such a crush on her , haven't you ? ", ' Yes , I want to be her boyfriend . Just like in the movie . ', ' Are you out of your mind ? ', ' She told me she liked my new haircut . She thought it was cool . ', ' Go ahead , have a try and be a joke . ']
['You know John ? ', ' Which John ? Mr.Turnbow ’ s son ? ', ' Yes . I ’ Ve read news about him in today ’ s paper . ', ' And he ’ s bright and intelligent . I ’ m sure he can pass the university entrance exam . ', ' I wish he could too . ', ' How ’ s your boy , Jack ? ', ' He ’ s a bit tired , you know . It often takes him a couple of hours to brush up . ', ' Poor boys ! They work harder at school nowadays , don ’ t they ? ', ' Good luck to them . ']
['You have made a poor meal . Let me get you some more fish . ', ' No , thanks . I have had enough . ', ' What about some drink ? ', ' Please bring me a cup of coffee . ']
['Good morning . I want to apply for a library card . ', ' Give me 10 yuan , your ID card and a photo of you please . ', ' But I hear that the card is free . ', ' Yes , it is . But you must pay a deposit for the card . ', ' There will be a refund when I return the card , right ? ', ' Yes , if the card is well kept and has no dirt and scratches . ', ' OK , here you are . ']
['I am very proud of John . ', ' Me too . No one has expected he can really get somewhere with his business . ', ' But he has suffered a lot . ']
['What do you think of the plan for the new airport near here ? ', ' Perhaps they should give it a second thought . The residents are getting up in arms about it . ', ' I think they will . ']
['What do you think of that situation comedies showed every weekend ? ', " To tell you the truth , I don't think much of them . ", " You're becoming a real television watcher . ", ' A lot of people feel the same way . ']
['May I invite you for a dance ? ', ' With pleasure . ', ' You dance well . Do you breakdance ? ', ' Me , what brought that on ? ', " There's a story about breakdancing in the paper . ", ' What does it say ? ', " According to the story , it's some sort of modern dance style . ", ' Like disco ? ', ' Well , breakdancing is more a physical exercise than a dance . ', ' And disco a kind of nightclub . ', ' Right , a disco is a place where people dance according to nonstop recorded music ... ', ' So ... disco is what the music is called and a disco is a place where people go to dance to it.And breakdancing is a different sort of thing altogether . ', ' You are witty . ']
['Could we borrow the company van for a fundraiser this weekend ? ', ' That would be a possibility . Where is this fundraiser taking place ? ', ' It is in the hotel ballroom down the street . ', ' Do you need it for the whole weekend ? ', ' We will need it for both days . ', ' We will need to know who will be driving the van . ', ' The van will be driven by Mary and me . ', ' It needs to be back on Sunday night . Can you arrange for that ? ', ' Oh yeah , no problem . Would you mind if we borrowed a few of the chairs from the lunchroom . ', ' Just keep track of everything and get it all back where you took it from by Sunday evening . ']
['Guess who I saw yesterday ? ', " I don't know . Who ? ", ' Avril Lavigen ! ', ' the Canadian rock singer ? But I heard you had a part-time job yesterday . How did you see her ? ', ' yeah , I worked as temporary staff in her concert . Look , her poster , a CD ... ', " so you're a big fan , eh ? ", " not really . But I like some of her songs . She's actually very talented . She's a song writer and fashion and fashion designer , too . ", ' and she was in a movie once again , right ? ', " yes , though I don't think her acting skills are that great . ", ' what was your impression of her when you saw her in person ? ', ' she looked sweeter than her pictures . ', ' did you take a photo with her ? ', ' no , there were too many people . When she got out of the car , her fans were all screaming , trying to give her flowers and ger her autographs . ', ' crazy ! ']
['Can you lend me fifty bucks ? ', ' What ? Again ? Why do you keep running out of money ? ', " I guess I don't earn enough . ", " No , I think it's how you budget your life , that's the problem . ", " That's my business , not yours . ", " True enough , until the time comes that you need to take my money . I don't know where you're wasting your money but I think you need to take a look at what's really important . ", ' So how do you survive from pay day to pay day ? ', " I don't just survive . I put money away as well . I know when I get paid where most of the cash will go , and I stick to my plan . If I follow a budget I don't have any nasty surprises . ", " I'm not disciplined enough I guess . ", " In a few months I'm planning to invest my money into some foreign companies . I think you need to reevaluate your spending habits . "]
['How do you think the transport system in our city could be improved ? ', ' I think that the public transport system could be made simpler . I never know where the bus routes actually go . The routes seem to twist and turn rather than going roughly in a straight line . ', ' I think we just need to build more roads . Then there would be more space for cars to drive and we ’ d have fewer traffic jams . ', ' If we built more roads , people would just fill them with cars again . I think we should discourage people from using their cars . ', ' How would you do that ? ', ' I think we should do a few things at once . Improving public transport would encourage people to use that . If we also charge people to use their cars in the city centre , they won ’ t use their cars as much . ', ' I don ’ t know . I think it ’ s unfair to make drivers pay more money . They already pay a lot of tax-petrol tax , for example . ', ' I think that they should pay more tax . Look at the damage they cause to the environment and people ’ s health by discharging all those exhaust fumes . ', ' The air would certainly be cleaner if there were fewer cars being used in the city . The problem is that people will see it as reducing their freedom . It well be unpopular . ', ' That ’ s a good point . Car owners will probably be against it , but people who use public transport will be in favor of it . ']
['What day is today ? ', ' Today is December twenty-third , two thousand and two . ', ' Oh , The day after tomorrow is Christmas . ', ' Merry Christmas to you . ']
['You ’ re new here , right ? ', ' Yes , I am . ', ' Will this be your first year ? ', ' No , I transferred here . ', ' What school did you come from ? ', ' I transferred from PCC . ', ' Why ’ d you transfer here ? ', ' I wanted to attend this school originally , but my grades out of high school weren ’ t good enough . ', ' Is PCC a good school ? ', ' PCC is great ! ', ' I hope you enjoy it here . ', ' Thank you very much . ']
['The bridegroom looks a bit nervous . ', ' On this occasion , most people do . ', ' Oh , they are playing the wedding March . Here they come . ', ' She is a beautiful bride . ', ' I am so happy for them . ', ' Are you crying ? ', ' Yes , I always cry at weddings . ', ' Harris and Anne are perfect for each other . ', ' Yes , they are . ', ' You and Tom also make a great couple . ', ' In fact , we are beginning to make preparations . ', ' For the wedding ? ', ' No , no , for the engagement . ', ' Try to catch this bouquet then . ']
["Jessica is going back to Holland next week . I've been thinking a lot about what to give her as a parting gift , but I still have no clue . ", ' is that the girl you spent almost every weekend with ? ', " yeah , that's her . We had a lot of wonderful times together . She is really a special friend , and I want to get her something meaningful . ", " I am not good at picking gifts . Maybe you can ask if there's anything she needs to make it easier ? ", " I don't think so . That way it would lose all the charm . I want it to be a surprise . I want to show her that I care about her and I hope our friendship will last . ", " yeah , that's nice . ", " hmm , I think I've got an idea . Maybe I can get her an ever-green plant to take back home . ", " a plant ? That's creative . I'm sure ever time she waters it she'll think of you . But there is a problem . Do you think it'll be able to go through the customs ? ", " I hope so . I'll make sure to get a small one so she can put it into her suitcase . I hope it won't cause her trouble at the border . ", " I don't know . I think the idea of a plant going across borders with a friend is really exciting but maybe seeds would be safer . You don't want to get her in trouble . "]
['Have you got your invitation yet ? ', " My invitation ? No , I haven't . My invitation to what ? ", ' The house warming party . ', ' Whose house warming party is it ? ', " Tom and Bill Smith . They are both working now you know ? And they've bought a new house . ", " Oh , they have ? I didn't know . I haven't seen Tom lately . ", " It's out in the suburbs . ", ' Have you seen the house ? ', ' Yes , I have . I went out with them last weekend . ', ' Is it nice ? ', " Yes , it is . There are three bedrooms , a living room , a dining room , and a big kitchen . There's also a garden . ", ' Well , that does sound nice . Have they moved in yet ? ', " They are moving today . Tom's taken the day off . He's rented a truck , and they should have all their furniture in the house tonight . ", ' When are they going to have the party ? ', ' Next Saturday night . You should get your invitation today or tomorrow . ', ' Wow , that would be something to look forward to . ']
['Have you ever been to Xi ’ an ? ', ' Yes , I ’ Ve been there several times on business trips . But I have never really seen the terra-cotta warriors as it is outside the city . ', ' I ’ Ve heard many people saying that it is a place worth touring . I really want to see the old walls and terra-cotta warriors one day . Of course I won ’ t miss the local food either . You know , the sites interests a food in scenery , food is a key factor when visiting a place . ', ' I agree . As long as the food is not too bizarre once I saw some people eating insects . That is frightening . ', ' Sure it is . Is it convenient to get there by plane ? ', ' Well , the airport is quite far from the downtown area , but it is still more convenient than taking the train . ']
["Tomorrow is Sunday . Let's go out and get some fresh air . ", ' I know there is a beautiful farm in the countryside near Taipei . Are you interested in going there ? ', ' why not ? I love animals and I love nature . ', ' You can see many cows and horses there . lf you are brave enough , you can try horseback riding . it is fun . ', " sounds very interesting . I can't wait to go there . ", ' Wow ! It is huge and you can do many activities here . ', ' That is true . Some people go camping , some people pick fresh fruit , some people go boating and some people go grass skiing . ', ' I never knew there were so many fun things to do on a farm . ', " Well , now you know . Let's go to the lake over there . Some people are fishing over there . I haven't had a chance to fish in a lake , I really want to try . ", ' I think we need to buy some baits and borrow some fish poles first . ', ' Yes . we can get what we need at the stands right by the lake . Who do you think will catch a big fish first ? ', ' Of course . I will . ', ' Wait and see . I want to try horseback riding after fishing . It looks very exciting and fun . ', ' It is . However , you will suffer from muscle pain for many days you are a first-time rider . ', ' No problem . It is always worth trying something new once in your life time . ']
['how are you doing ? ', " I'm ok . I wish I could say the same for my friend . ", ' what happened to him ? ', ' he was arrested by the police for drinking and driving . ', ' was it his first offence ? ', ' unfortunately not . He was charged with a DUI when he was in university . ', ' what happened to him then ? ', ' not much ; it was a minor offence back then . He got away with a fine of $ 500 . ', ' did they take his license away ? ', ' no , they were really easy on him . The problem is that that was a long time ago . They are much tougher on crime now . ', ' what do you think will happen to him ? ', " well , he'll definitely lose his license , pay a fine , and maybe even spend some time in jail . ", " that doesn't sound too promising . Does he have a defence lawyer ? ", " not yet . If we can't find a lawyer for him , then the state will appoint him with one . ", ' my sister is a lawyer . I can ask her if she can help him . ', " that'd be great ! I know he'd appreciate your help . "]
['Well , sir , we are asking all our guests to wear a jacket and a tie in our restaurant . ', " Is that so ? I didn't know it.Can I possible borrow a jacket and a tie ? ", " I'm sorry you can't borrow a jacket and a tie . ", ' Then we return to the hotel and come back.Will you change the appointment ? ', ' Certainly.What time will you come back ? ', ' At seven , please . ', ' How many in your party ? ', ' A party of three . ', ' All right.We are waiting for you at seven . ']
['You know Ernie , it seems we both like the same artists . ', ' Yes , we do . I think we have the same musical tastes . ', " But if we're going to start a band , we have to be able to sing and dance . Can you do that ? ", " I'm not a very good singer , but I'm a really great dancer ! I love hip hop dancing . ", " Great ! I'll sing , and you can dance in our band . "]
['I wish I had access to the public library . ', " it's easy ! Just go and get a card . "]
['Are you ready ? ', ' Not yet . ']
['Is this your brother-in-law ? ', ' Yes , he married my sister ten years ago . ', " From his looks , I'd say he's a man of character . ", ' Yes , my sister loves his personality . ']
['You seem to very busy these days . What are you doing ? ', ' I am swapped with work after 10 - day holiday . ', ' Where did you spend your holiday ? ', ' I went to Paris . ']
['Our team just scored a goal . ', " That's more like it . ", ' Tell me about it . ', ' They might actually win the game . ']
['Want to meet for lunch this Saturday ? ', ' Sorry , I can ’ t . I ’ m busy . ', ' What are you doing ? ', ' I always do volunteer work on the first Saturday of every month . ', ' What kind of volunteer work ? ', ' I help out at the children ’ s hospital . I help plan activities . ', ' Oh , yeah ? ', ' Yeah . It ’ s exciting . This month we ’ re doing crossword puzzles . ']
['Tom , is Jenny crying ? ', ' Can you take he away from me ? ', ' I ’ m just coming for that . ', ' She kept on bothering me . ', ' She ’ s your sister.What she asked was only duck soup for you.Why can ’ t you be good to her ? ', ' But I am her brother , not her servant . ']
['You ’ re making my blood boil . ', ' Calm down . Madam . ', " I'm about to explode ! You ’ Ve made a mess of this matter . ", ' I am very sorry to hear that you ’ Ve been having so many problems . ', ' Sorry isn ’ t good enough ! What can you do to help me ? ', ' I understand why you ’ re angry , Mrs . Wilson , and believe me , we are doing everything in our power to work this out . ', ' Well , obviously , what you ’ re doing is not good enough ! ', ' If you could just give us a few more days , we should be able to get this straightened out . ']
['Can you tell me something about financial aid ? ', ' What exactly ? ', ' How to apply for it ? ', ' In your first letter , that is , when you apply for admission , you should also tell them you need their financial aid . ', ' Then ... ', ' If the aid is available , they will give you two or more application forms , One is for admission , the others are for the aid . ', ' What if not ? ', ' They will tell you the aid is impossible . ']
['How was Mei ’ s party on Saturday ? ', ' Oh I didn ’ t go . I stayed at home with my family . ', ' Oh really ? What did you do ? ', ' We watched lots of television and films . ', ' I see . Anything else ? ', ' Yes , we ate a delicious meal and drank some very good wine . ', ' Well , it sounds like you really enjoyed yourself . ']
["What's the temperature today ? ", " It's about 5 degrees centigrade . ", " What's the weather forecast for tomorrow ? ", " The weatherman says it's going to snow tomorrow . ", ' Are you used to the climate here ? ', " I think I'll soon get used to it . ", ' What is the average temperature of Beijing ? ', " lt's about 180C , but in winter the temperature may fall to 10-15 degrees below zero . And we have a long winter . ", ' Which season do you like best ? ', ' I prefer spring when little by little everything becomes green and the weather is almost always nice . ']
['I simply couldn ’ t help giving him the fish-eye when I knew all that . ', ' But Ben is not a bad man . I know him from A to Z . ', ' However , he disappointed us very much this time . ', ' I can understand that . But ... ']
['Kelly , the guys and I think you should run for senior class president . ', ' Me ? Why me ? Why not you ? ', ' We talked to our older brothers and sisters last night and got the scoop on what that job is all about . ', ' And you think I fit the qualifications ? ', " Yes . Did you know that the senior class president works for the class for life ? The job doesn't stop when we graduate . ", ' Really ? What is there to do after we graduate ? ', ' Every class reunion is organized by the president and council and anything our class does for the school in later years is headed by the president . ', " I'm honored that you think I would be qualified . But I would really have to think about this first . "]
["Wow ! You look like a drowned rat ! Didn't you know there is a thunder-storm today ? ", " I knew there would be a shower , but I didn't realize it would rain cats and dogs today . ", " Well . You'd better take a hot shower right now , or you will catch a cold . ", " I know . I don't want to get sick , especially during finals week . "]
['Why are those people crying ? ', ' They must have just come back from tomb sweeping because today is Tomb Sweeping Day . ', ' Tomb Sweeping Day ? What is it ? ', ' Tomb Sweeping Day is a traditional festival in China , on which many Chinese mourn the dead . ', ' What do they do ? ', ' People go to the cemetery to pay their respects to the dead . ']
['Er ... Alison ? ', ' Ohm , hello , Marcia . I was ... ', ' I just wanted to congratulate you ! I mean , it was a good race and you deserve to win . ', " Well ... thanks , Marcia.It ' s very nice of you to say so . I mean ... ", ' It was that final sprint ! You were great ! Really ! ', ' Do you really think so ? I mean , was I ? Er ... you ... must be disappointed . ']
["Why aren't you at work ? ", ' I called in sick . ']
['How is the college search going ? ', " It's a huge headache . I have no idea what I want to do . ", " But don't you want to study music ? Shouldn't it be easy ? ", ' It should be , but there are too many options . My grades are good enough that I have a lot of choices , but after that ... ', ' I know . You have to decide if you want to attend a school in a city or in the country , a big school or a small school , a public or private school ... ', ' Yup , you understand . And my parents are trying to pressure me into going to a Catholic college . They both attended one and think that it combines a good education with good discipline . And the tuition 3 is usually pretty low . ', " I see . Well , don't forget to talk to the college counselor at the school . He usually gives good advice and can help point you in the right direction.He gave me some information , and next week I'm going to take a look at some of the colleges he recommended . ", ' Thanks for the information . And good luck in your college search . ']
['I ’ m trying to decide what school to apply for . ', ' Are you thinking about a public school or a private one ? ', ' I ’ m not sure . What ’ s the difference between them ? ', ' Public schools are usually state funded , whereas private schools usually get their funding elsewhere . ', ' Which is better ? ', ' One isn ’ t necessarily better than the other . It depends a lot on the school administration and the teachers . ', ' I hear you have to wear uniforms at private schools . ', ' Yeah , sometimes . ']
["Excuse me , Professor . I am going to miss next week's class . ", ' Is this something that you could schedule for another time ? ', " No , I have to do this ; it's important ! ", ' Have you arranged for someone to take notes for you ? ', " I've made arrangements with a friend to help me . ", " You know that I only allow one absence per semester , don't you ? ", ' Yes , I know . ', ' Write down your name and the date on a piece of paper and give it to me . ', ' OK , I can do that . ', ' Well , have a good day off from class . ']
["It seems so strange to be here , burying you , but it's not you . ", ' Ashes to ashes and dust to dust ... ', ' This has been the worst and best day of my life , Taylor . They kept you in the hospital , and ... ', " I'll tell you all about it another day . ", " But you're OK ? It was nothing serious , was it ? ", " You ladies look very elegant in black . But I don't want you to wear black in my honor for a long time yet to come ... "]
['The air quality in this city is horrendous . The pollution levels are so high that we are not supposed to go outside with a face mask again ! ', ' Exhaust fumes from vehicles cause a great deal of damage to the environment . ', ' On top of that , there are a few large chemical factories in the suburbs , which are contributing to the high pollution levels in the water and the air in this city . ', " As much as I love this city , I think I'm going to find a greener city to live in . Living in a polluted city like this just can't be good for my health . ", " I know what you mean . However , there are so few places left that have not been affected by global warming . If it's not the pollution , then it's the natural disasters , deforestation , or the greenhouse effect . ", ' What is the greenhouse effect exactly ? ', " It's the gradual rise in the earth's temperature . ", " I see , so it's similar to global warming ? ", " They're related to one another , yes . ", " I heard that some people in England are pleased with the fact that the climate is becoming warmer because it's making their towns a more pleasant place to live . ", " People joke about the benefits of the increase in temperature , but it's not all good news . They've been experiencing a lot of deadly storms there as well . ", ' People always seem to make jokes as a way to deal with unfortunate situations . ', ' I think if everyone pitches in , the world will be a better place . ']
['What would you like to do tonight ? ', " I'm not sure . ", ' What about going to a movie ? ', " OK , let's go to the cinema to see what's on . "]
['Mary , be calm . ', ' It is impossible . You cheated on me . ', " No , listen to me . I always regard you as my best friend . I admire you , and of course you've helped me so much . I should thank you . ", ' Shut up ! ', " No , listen to me . Perhaps it's my fault that I treat everybody so well . Maybe in other people's eyes , I want you to be my girl-friend . but ... but ... ", " But you have had lily already ? You should have told me about her , but you didn't . ", ' OK ... OK ... Anyway . I will treat you as my best friend . I hope you can do the same . ', ' Leave me ! Go away ! ']
['Would you mind doing something for me ? ', ' I would if I could . ', ' Would you please explain the meaning of the word ? ', ' Yes , With pleasure . ']
['Our maths teacher is rather humorous . ', " On the contrary , I think he's very serious . ", ' No , not at all.His examples are really interesting . ', " So they're easy to remember . ", ' Yeah , how about your maths teacher ? ', " He's an old antique , very serious . ", ' Bad luck , Anne . ', ' Hey ! How about your history teacher ? ', " She's another antique . ", " I'm sorry to hear that . "]
["Hey , if you're not busy this weekend , would you like to go see a movie ? ", ' Sounds good . What should we see ? ', ' How about that European movie ? ', ' You mean the one starring John Travolta ? ', " Yeah , that's the one I've heard the special effects and the plot are outstanding . ", " Sounds like an interesting film . Let's meet at five o'clock on Saturday . ", ' Okay , see you then . ']
['Could you do me a favor ? ', ' What is it ? ', ' Could you possibly give me a lift home ? ', ' All right . ', " Are you sure ? I don't want to inconvenience you . ", " No problem . I'd be happy to . ", ' Thanks . I really appreciate it . Thanks so much . ']
['I have an appointment for half past one . ', ' What can I help you with ? ', ' Well , I have a problem with my class schedule . ', ' What is it ? ', " It seems that I've been given two classes scheduled at the same time . ", ' I can understand the problem with that . ', ' Is there any way that you can fix my schedule ? ', ' No problem , do you want those classes still ? ', ' Yes , I do . ', ' Let me see if I can find one of these classes on another day . ', ' Thank you very much . ']
["It's said that the government will clamp down on the new policy . ", ' Are you sure of that ? ', ' I am not certain about that . ', ' They may have some difficulty in doing it . ']
['Did you hear that Mary ’ s marriage is on the rocks ? ', ' So I hear . ', ' Yesterday I met Mary , and she told me her husband often made pass at his secretary . ', ' After all the crises they have survived together , her husband should do such things . She must feel that she ’ s been stabbed in the back . ']
['Are there any interesting articles in today ’ s newspapers ? ', ' The headlines are all about the presidential election in the united states . Few other stories made the front pages . ', ' Is there anything of interest to us in the business sections ? ', ' There ’ s an interesting feature article in the chronicle about doing business in china and the daily news has printed a report about the special economic zone near pairs . We have a subsidiary company l ', ' Are the reports favorable ? ', ' Generally , the reporters take positive lines . They do point out a few problems that we need to be aware of , but there ’ s nothing worrying in the reports . In the classifieds , one of our competitors is a ', ' That ’ s interesting . They must be thinking of moving into that market . Are there any interesting editorials ? ', ' Not really . They all seem to focus on the election . There have been several letters printed in the chronicle regarding that controversial article on drugs that they printed last week . ', ' I ’ m not surprised . That article certainly added fuel to the debate . Ok . Thanks . Can you leave two articles and the advertisements with me ? I ’ d like to read them . ', ' Sure . There you are . ']
['Can you imagine a boat letting in the river ? ', ' That would be terrible . ', ' Sure thing . I have an experience like that . ', ' Oh , how were you saved finally ? ', ' I was in such a panic at that time . Fortunately another boat came along and I was saved from drowning . ']
['I am looking for some information about home stay . ', ' Well , I have been in a host home before . During my first year in the us , I stayed with a family . They are nice . ', ' How did you pay them ? ', ' Well , that depends . If you stay for a long time . They will offer a discount . ']
['He followed me all the way home ! ', " That's about five blocks . And around corners too.So he was definitely following you . ", " Yes , he was . I'm not imagining it.Finally , just when I got home , I turned around and looked at him.He was just standing there . He didn't smile . He just stood there . It was so obvious.What should I do ? I'm so scared . Can I call the police ? ", " Actually , I don't think you can call the police . Not yet at least.He hasn't done anything . And probably the police will just ignore it.But if anything happens again , then maybe you should call . ", " Why can't I call the police now ? He was definitely following me ! ", " Of course you can call the police if you want . That's not what I mean . I'm just saying that they probably won't do anything . ", " I suppose . What can they do ? I don't even know who he is . ", " Listen , Carol . Don't let this bother you too much.Probably it's nothing . Just keep your eyes open when you go out.If you see him a third time , and if he follows you again , then I think we should go to the police.But for now , just try not to worry . ", " Alright . And I won't go to that cafe for awhile . "]
["What's your favorite book ? ", " It's Gone With the Wind . ", ' Why do you like it best ? ', ' I enjoy the various characters and the plot . ', ' Well . I like the Thorn Birds best . ', ' Is it very interesting ? ', " Sure . I like the writer's language , too . ", " If I have a chance , I'll enjoy the book . ", ' Would you like to go to the bookshop with me ? ', " That's a good idea . Let's go ! "]
['May I help you ? ', ' I would like to check out these books . ', ' May I see your library card , please ? ', ' Yes . Here you go . ', ' Apparently , you have unpaid late fees . ', ' I do ? ', ' You owe some money . ', ' Exactly how much do I owe ? ', ' You owe $ 24.50 . ', ' I won ’ t be able to pay that right now . ', ' Until you pay it , you can ’ t check out books . ', ' I will pay it . Don ’ t worry . ']
['How did you choose courses when you were abroad ? ', " That's a very good question . Choosing proper courses and effectively planning a college schedule is very important to the progress toward your educational goal . In order to do these wisely and effectively , you should consult with a Program Adviser or Academic Counselor . ", ' Wait a minute . There are some new terms for me . I can hardly follow you . ', ' Ok , I will go into more detail . A Program Adviser or an Academic Counselor is usually an experienced professor who is responsible for all the necessary academic counseling through graduation . You can discuss with him the program selection , changing or adding a program , the requirements for graduation , and other problems related to your study . You will choose some courses , and then discuss with the adviser whether your choice can meet the requirements for graduation . ', " Everything is so new to me . I think I'll have to experience a very difficult period when I get there . ", ' Sure , very difficult . ', ' I am very grateful for your advice . ', " It's my pleasure to talk with you . "]
['So it is hard to be a black student on campus ? ', ' Yes , in many ways it is . There are many stereotypes I have to deal with in my daily life . ', ' Stereotypes ? Like what ? ', " Well , like since I'm black , I must like rap music , come from the inner city , or play basketball well . ", ' I do know you like rap music , but the other two are definitely false . I ’ Ve seen you play basketball . ', " Hey ! But that's not the only problem . There's also the affirmative action stigma . ", " You mean that people look down upon you because they think you're in school because of a quota ? That's not true at all , you're really a smart guy . ", " I know that , but some people don't think like that . And I get problems from teachers as well . ", " Teachers ? I didn't think that they would be racist at all . ", " Racist ? Not exactly . It's how they look at me and ask for my opinion on a topic , as if I can speak for all black people and give them the black opinion on a subject . Suddenly I become the representative of the black race , as if we all had the same opinion . ", ' I see . It looks like there are still a lot of issues we need to work on in the US . ']
['Could you help me ? ', ' What do you need ? ', " I can't seem to find my class . ", ' What building is it in ? ', " It's in the C building . ", ' Oh , I know exactly where that is . ', ' Do you think you can tell me where it is ? ', ' Sure , what room number is it ? ', " It's room number 261 . ", ' I have a class around there right now . ', ' Could you show me where it is ? ', ' No problem , come on . ']
['John , have you ever watched Beijing Opera ? ', ' Yes , I watched once . ', ' What do you think of it ? ', " Well , honestly speaking , I went to watch it out of curiosity . I'd say it's really a special art form . ", " I couldn't agree more . Actually , I'm a Beijing Opera fan . ", ' Really ? Good for you . ']
['Let ’ s play a game ! ', ' OK ! How about Scrabble ? ', ' No , no , a friend of mine taught me this really fun game . I ’ m going to describe someone ’ s face , and you guess who it is ! ', ' OK ! ', ' Let ’ s see . He has a roman nose , bushy eyebrows and dimples ! ', ' Our cousin Pete ! My turn ! She has a pointy nose , sunken eyes and a mole on her chin ! ', ' Aunt Rose ! That mole is so huge ! OK , my turn . He has a crooked nose and full lips . He has quite a few freckles and an oval face . Oh , he is also bald ! ', ' Your future husband ! ', ' Not funny . ']
['Hi Julie , how are things going ? ', ' Everything is great , Tad . How are you ? ', " I'm doing really well . ", " Tad , I'm pretty hungry right now . Want to walk over and check out the food table ? ", ' Julie , do you know who that woman is over there by the window ? ', " That is Mary . I heard that she's just moved in with Lee . ", ' I thought that he was with Malia . ', ' Oh , that relationship is history . Malia hooked up with a guy she met on holiday . ', " I bet that Lee wasn't too happy with that ! ", " Actually , he was OK with it . They hadn't been getting along too well . "]
['You can take this car into consideration . It works well and its price is reasonable . ', ' I was not born yesterday . ']
['So , Emily , how was your day ? ', " I don't think you really want to hear about it . ", " It can't have been that bad . Go on and tell me about it . ", ' To be honest , it was horrible ! My manager is such a pain in the neck ! ', ' Why ? What happened ? ', ' Well , he made quite a few mistakes on the monthly report and when his supervisor found them , my manager blamed them on me ! ', " That's not very fair . What did you do ? ", " There wasn't really anything that I could do . There's always been a lot of bad blood between my manager and myself . If I had said anything , he would have fired for me for sure . ", ' Does he treat everyone in your department like this ? ', ' He treats everyone pretty poorly , but the way he treats me really takes the cake ! ', ' Do you have any idea why he treats you worse than the others ? ', ' I really have no idea . All I know is that the thought of him really curls my hair ! ', ' Is there anyone else you can talk to about it at you company ? ', " Not really . I'm hoping to live with it for a while until I get a promotion . ", " That's very sensible . It sounds like you have a good head on you shoulders . ", " I try to be sensible about it , but it's not very easy . Sometimes you just have to grin and bear it . ", " That's so true . When you have a taste for success , you can't let dishonest people like your manager get in the way . "]
['Can you speak English ? ', ' Yes I can . I speak it very well . ', ' Where did you learn it ? ', ' I lived in England when I was a child . ', ' What else can you speak ? ', ' Well , I know a little Italian . ']
['Hi , Maggy , Did you hear about David ? ', ' About David , No , I didn ’ t hear anything . ', ' You know , about David and new boss . ', ' Sorry , I don ’ t quite follow you . ', ' Well , I hear David have been fired . ', ' Oh , that is a shame . He is really hard working . ']
['How would you describe your relationship with our boss ? ', ' We have a fairly good working relationship , but there was also a rough spot . ', ' What do you think his strengths are ? ', ' Well , he has an amazing ability to analyze information and he is very good at making the right decision in tough situations . ']
['Which school is your children in ? ', ' She is now in a private school . ', " Oh , it costs too much . It's more expensive than the public school . ", " It's idea of my husband . He is always banging the drum for better schools . ", ' But the private school amount to better schools . ']
["I am very interested in a new apartment near the Taxing Plaza , but the price is very high , I really can't afford it . ", ' How much is it for each square meter ? How large is the apartment ? ', " It's 7500 yuan per square meter , and I really like the one with three bedrooms and a large living room . Its total area is about 80 square meters . ", ' That surely will cost you a lot of money . Are you going to make a full payment ? ', ' Do you think I am rich enough to make it ? I am thinking about buying the apartment by installments . The real estate agency says if I pay a 25 % down payment , I can move in at once . ', ' If sounds so tempting . Why not go applying for a loan from the bank ? They charge very low interest , so you can choose whether to pay up the balance in 10 or 20 years . ']
['I really like the record you lent me the other day . ', " I'm glad you like it . ", ' And thank you very much for letting me keep it so long . ', ' Not at all . ', " I'm most grateful . Everyone in our class enjoyed it . ", " I'm glad . ", ' Would you mind my keeping it for another week ? ']
["We'd like to have a look around your house ? ", ' Yes , of course , please follow me . ', ' Thank you . ', ' This is our courtyard . ', " It's so spacious , about 40 square metres , right ? ", ' Yes , about 46 square metres . ', ' Are these corn ears hanging on the tree branch ? ', ' Yes . ', ' Very beautiful and very interesting . But why do you hang them in the tree ? ', " They don't have enough time to peel it after they harvested them , so they hung them in the tree . Then in winter , they can peel corn ears in their leisure time . ", " Very good idea . Sometimes such pictures can show the house's richness . "]
['So , where are you going to spend your winter vacation ? ', ' Oh , I ’ m going to meet my girlfriend in Thailand . ', ' You have a girlfriend in Thailand ? Interesting . How come I have never heard of that ? ', ' Actually it will be my first time to meet her . ', ' You mean you haven ’ t seen her before ? Then , how could she be your girlfriend ? Maybe you don ’ t even know her . ', ' That ’ s true . But we have known each other over the Internet for a few months now . Actually we are on an intimate level . We even plan to be engaged next month . ', ' Congratulations ! It ’ s good to follow your heart . But I just didn ’ t expect to be so fast . ', ' The Internet is making interaction much faster . People are getting to know each other much more quickly this way . ', ' Probably you ’ re right . ']
["Hi ! Susan ! I haven't seen you for ages ! ", " I've been really busy . How is everything ? ", " Oh , fine . Hey , why don't we grab a bite to eat and do some catching up ? ", " Yeah , why not ? I've got a little free time on my hands . Where do you want to eat ? "]
['Oh , George , what a beautiful day it is today ! The sun is hot and there are just a few clouds scattered here and there ! What a perfect day to be at the beach ! The kids are going to have so much fun ! And we ’ ll be able to relax in the sun while they ’ re playing . ', ' It does seem like the perfect day ! I ’ m glad we chose to get out of the city and enjoy the nice weather ! This looks like the perfect spot ! Ok kids , put on your sunscreen while your mom and I set up camp . Here , Mary , help me lay down these beach towels . ', ' There we go . Can you help me with the umbrella ? Perfect . ', ' Ok kids , here ’ sa beach ball and a Frisbee , a pail and a shovel . I want to see an impressive sandcastle by the time we leave . Don ’ t stray too far . Wait ! Leave your sandals here or put on your wet shoes . ', ' And stay in the shallow area . I don ’ t want to see you go any farther than that sandbar ! It ’ s too deep out there and we didn ’ t bring your floatier . ', ' You ’ re back already ? The water was too cold , huh ? I ’ ll tell you a secret . Do you see that small pool of water over there ? It ’ ll be warmer in there . Go see if you can find some seashells or catch some minnows . ', ' What is that ? A jellyfish ? Jeremy , put that down right now ! It could sting you ! ', ' Ah ! Not on me ! Ow ! ']
['Hello ', " Hi Angela , it's Dan . ", ' Hi B . How are you ? ', ' Good . ', ' I called you yesterday . Did you get my message ? ', ' Yes , I was taking a shower when you called . I saw that you called and I tried to call you back , but I think your phone was off . ', " No problem . I wanted to remind you that my friend is getting married next week . You're still coming to the wedding with me , right ? ", ' Oh , is that next week ? ', ' Yes . Did you forget ? ', ' No , of course not . I already bought them a present . ', " That's good . I want to invite Megan also . Next time you see her , can you tell her for me . ", ' Sure . Does she know your friend ? ', " Yes , I think they might have gone to the same college or something like that . I'm not exactly sure how they know each other . ", ' Are we all going to drive together ? ', " Yes . I'll pick you up first , and then we'll go get Megan . "]
['Hey , look at the offer I got in my e-mail . It says that I can get rich quickly while working at home ! ', ' Do you also believe in Santa Claus and the Tooth Fairy ? ', ' What do you mean ? ', " I mean that you're gullible . You shouldn't believe everything you read , especially on the Internet . ", " But it seems like a good idea . All I have to do is first send some money to the person who sent me the letter . After that he'll tell me how to earn much more money . ", ' Sounds like a pyramid scheme . Have you heard of those before ? ', ' Pyramid scheme ? What is that ? ', " It's a scam 7 that's based on a hierarchy , like a pyramid . The person at the top asks the people below him for money , and then tells them to go and ask other people for money while sending some of it back to him . ", ' Sounds good to me . The guy at the top gets money and so do the people below him . ', ' Not exactly . The scam keeps on going , with the people at the bottom paying more and more money until they reach the very bottom . ', ' What happens then ? ', " Nothing . The people at the bottom give their money to the people above them , and they get nothing . They end up losing . That's why it's a scam . ", ' I see . I guess I should be more careful about what I read , especially on the Internet where you have no idea who anybody is . ']
["We've been cramming for tomorrow's history exam since early this morning . What do you say we take a break and listen to some music , okay ? ", " Now that you mention it , I'm getting a little bumed-out from studying nonstop , too . Listening to some music for a while would suit me just fine . ", " While you're picking out a record to play , I'll grab a couple of beers out of the refrigerator . ", ' You sure have a lot of discs here . ', " Yeah , I've got everything from rock n ' roll to the latest new - wave stuff . ", " To tell you the truth , I'm strictly into classical music . You don't happen to have any Bach or Mozart , do you ? ", " Sorry , my taste in music doesn't go back any further than the 1960 ' s . Music written before then is just history to me . ", " Well , speaking of history , let's get back to the books.We ' Ve got an exam tomorrow , remember ? "]
['When can we expect you and your daughter for dinner ? Next Saturday ? ', ' Next Saturday ? I ’ m sorry . I ’ Ve promised to go to a Chinese Opera with my daughter . ', ' How about Sunday then ? ', ' Yes , Sunday sounds fine . What time ? ', ' Does 6,30 suit you ? ', ' It suits us fine . We ’ ll see you then . ', ' Thanks , goodbye . ']
['I was thinking of holding the company retreat in the mountains . ', ' I agree , I think that that would be perfect ! ', ' I was thinking it could take place sometime in January . ', ' That might be a little too cold for some people . ', ' Yes , you are right . ', " What about April ? April has good weather that isn't too cold or too hot . ", ' Yes , that would work out better . ', ' You know , maybe we could take a survey to see how that works for everyone . ', " Good idea ! We'll have to get right on it . ", " Fine ! Well , I'll get right on it now ! "]
['How may I help you ? ', ' I need to check these books out . ', ' Do you have your library card ? ', ' Here it is . ', ' It appears that you have late fees . ', ' Really ? ', ' Yes , really . ', ' How much do I owe ? ', ' You owe $ 24.50 in late fees . ', ' I don ’ t have that much today . ', ' I ’ m sorry , but until you pay it , you won ’ t be able to check out any more books . ', ' I ’ ll pay it as soon as possible . ']
['Merry Christmas ! ', ' Huh ? ', ' I said Merry Christmas ! Don ’ t you know that Christmas is almost here ? ', ' It is ? Oh , that ’ s nice . ', ' Huh ? Didn ’ t you know ? Aren ’ t you excited ? ', ' Actually , I ’ d forgotten about it . ', ' Forgotten about it ? How could you ? ', ' Because I ’ m not Christian , I ’ m Jewish . ', ' Oh , I ’ m sorry . I didn ’ t know . ', ' It ’ s all right . There are so many Christians in America that everybody takes it for granted that I ’ m Christian . ', ' I guess so . So what do you do around this time of year ? ', ' Well , I ’ ll celebrate Hanukah soon , but that ’ s not as important to us as Christmas is to you . Mainly I ’ ll just enjoy the holiday break . ', ' Well , would you be horribly offended if I invited you to a Christmas party at my house ? ', ' Not at all . A party is a party . I ’ ll be happy to come . ']
['Do you want to go shopping with me ? ', " That's a good idea.What time is good for you ? ", ' How about Saturday morning ? ', ' Sounds good . ']
["Welcome , young man . No offence , but I haven't seen you here before . ", ' Of course , this is my first time here . My Mom has a membership here . Here is the card . ', ' Okay then . You are the younger customer here ever . ', " It's not so wise that you do not explore the children's market . ", " It's the marketing's fault , I suppose.What do you want to do ? ", ' Well , I want to become just like Bruce Lee . What should I do ? ', " That's a long way to go , I'm afraid . First of all , you gotta grow up . ", " I am still young . And I'm growing every minute . ", ' Sure . Then what about trying the treadmill or the skipping rope . ', ' I love running . Anything else ? ', ' Please change your clothes first ! ', " I'm perfect with my clothes . And I do not have anything else with me . ", ' Sorry , but no jeans here . ', " Oh , that's the only place where jeans are not popular . I'd better just go home . "]
["I hear that the Students ' Union is going to take new members . ", ' Really ? Can I join it ? ', ' Of course you can if you like it . ', ' How can I join it ? ', " There will be an information session about the Students ' Union this Tuesday . You can apply for it then . ", ' OK , thank you . ']
['Is that girl your girlfriend ? ', " No , it's not . ", " She doesn't look like our classmate . ", " Don't mistake her as somebody . She ' s my older sister . ", " Really , she's so pretty . "]
['What do you do in summer ? ', ' I love going out into the countryside for walks or bike ride . I love being out in the fresh summer air . How about you ? ', ' I don ’ t often go for walks , but I either play sports outside-you know , tennis or badminton-or just sit in the sunshine and read a good book . ', ' What do you do in winter ? ', ' Well , I play sports indoors quite often . If I ’ m feeling lazy , I just watch a film at home . I prefer summer to winter . ', ' I think most people do . I like wearing nice , colorful clothes in summer , you know , a nice dress or skirt . It ’ s too cold for those kinds of clothes in winter . ', ' Yes . I like wearing shorts in summer . My legs would freeze ! ', ' Do you think we ’ ll have a nice summer this year ? ', ' Thanks to global warming , it could be hotter than ever ! ']
['Happy new year ! ', ' Thank you . Same to you . ', ' Have you got any plans ? ', " I've been invited over to a friend ’ s , and you ? ", ' My roommate ’ s having a party . ']
['Do you offer a course in business management ? ', ' Yes , we do . ', ' How many nights a week is it ? ', " It's 3 nights a week , Monday , Tuesday and Thursday . ", ' And how long does the course last ? ', ' It lasts for 9 months . ', ' When does it start ? ', ' The next beginning class starts on October 25th . ', ' What time is the class ? ', " From 7 to 9 o'clock . ", ' How much does it cost ? ', ' It costs 125 dollars a month . ', " Yes , that's all right . I want to enroll in the course . ", ' Thank you , please fill out this form for us . ', ' Do you want me to fill it out now ? ', ' Yes , please . we need a record of you education and your work experiences . ']
['Which social problem do you think the government needs to concentrate on most ? ', ' I think housing is a big problem . There are thousands of homeless people on the streets . ', ' How would you solve the problem ? ', ' I have a good idea to solve it . The government could provide some money for homeless people to build their own homes . ', ' It would probably be very expensive . ', ' I think the government can afford it . Besides , there are many advantages . Homeless people would find it easier to get jobs if they had an address . They would learn some useful skill for finding jobs i ', ' It ’ s not a bad idea . I think education is the biggest problem at the moment . Schools don ’ t seem to have enough money to educate kids properly . ', ' If we are to invest more money to education , we will need to raise taxes . That wouldn ’ t be popular with voters . ', ' Most voters what everything both ways . They want the government to pay for lots of things , but without increasing taxes . ', ' The government should show that it is using money efficiently . Sometimes you hear about how the government has wasted money on a project . ', ' Yes . The government has limited funds and must show that it is using the money responsibly ']
['Do you keep any pets , such as cats , dogs ? ', " No , I'm scared of cats . ", ' Oh , but why ? ', " I feel they're dirty . "]
['Would you like to see our new shirts ? ', ' Sorry , but I ’ m not really that interested in those things . ', ' Well , they are very nice you know . ', ' Really ? ', ' And not expensive either . ', " Oh , I don't care about that . ", ' Everybody is buying them . ', ' Are they ? ', ' Yes , they are very fashionable , you see . ', ' I am afraid I am not interested in fashion . ', ' I see . ', ' But thank you very much all the same . ', " Sorry I couldn't help you . "]
['Come in , come in ! ', ' Hi , Gary , what happened ? I was waiting for you at the theater . Why didn ’ t you meet me there ? ', ' I thought we were supposed to meet HERE . ', ' Don ’ t you know our movie starts at seven ? And we were going to meet at the theater at five to seven . Then it doesn ’ t make sense to meet at the apartment . ', ' I ’ m sorry . We must have misunderstood each other . ', ' Why don ’ t you try to be clearer about your intentions ? ', ' You ’ re right . I am sorry . Let ’ s go and watch the movie . ', ' It ’ s okay . I don ’ t want to go now . We ’ Ve already missed ten minutes of the movie . I don ’ t want to see a movie without watching the beginning . ']
['how was school today , Dominic ? ', ' I hate school ! ', ' why ? What happened ? ', ' I messed up my mid-term exam so badly today ! ', " it's just one exam . Can you re-take the exam ? ", " yes , but it's so humiliating ! I don't want my friends to know I failed ! ", " why didn't you do a good job ? ", " I don't know . I sat down in my seat , looked at my paper , and then my mind just went totally blank . ", ' do you think you studied enough for the exam ? ', ' no ... ', ' what did you do last night ? ', ' I watched TV . ', ' did you study at all last night for your exam ? ', ' no , not really . ', ' I am sure if you had studied , you would have done well . When can you re-take your exam ? ', ' tomorrow . ', " alright . Get out your books and I'll help you prepare . "]
["I haven't met the Smiths for a long time . ", ' They have moved to Chicago . ', ' Why ? ', ' Mr.Smith has changed his job . ']
["Did you hear about Joe ? She hasn't eaten for days . ", " Why ? What's eating her ? ", " Love sick . You know who she's in love with ? ", " I don't have the slightest idea . ", " Someone you're living with . ", ' What ? Not my Dad , I hope ! ? ', " Come on , Mary , it's your brother , Jack . ", " No kidding ! Jack is such a log ! He's never dated a girl . ", " The problem with Joe is that she's too shy to tell him . ", " And the problem with Jack is that he seems to have no interest in girls . He's putting his heart into his stamp collection . ", ' Well , if you want to help your friend , you should do something about it . ']
['Oh , they all went out ! Did you make a wish ? ', " Yes , but I doubt if I get it . I've never got it . ", ' Better luck this time ! ']
['How do you like the food sold in this sidewalk snack booth ? ', " At least , it is better than my boxed lunch at work . I'm so fed up with the bland food . Thank you for having lunch with me ! ", " Any time . But I don't mind eating boxed lunch . The food sanitation is really good too . ", " It's hard to believe that you like it . You are so easy to be satisfied . ", " Hey , it's not that bad . The food is nutritious and it's really convenient . I don't want to spend too much time on eating stuff . ", " Eating is important . You are what you eat . It's not only a daily routine . ", ' Well , will you just go back to work after lunch ? ', " No . I'm going to pay the bill for the company's lunch . ", " But you didn't eat anything today . ", " Well , the bill is paid by month . That's probably the only thing that I like about a take-out restaurant . ", " All right . I'm going to the McDonald's . ", " For what ? I thought you didn't like western food . ", " No , I never did . It's for my son . He loves it , and I made an agreement with him that he can eat it once a week . ", " That's really smart . My son Daniel is the same with your son . I just don't get it , why all the kids prefer western food to traditional food . ", " Me , either . But , it's for sure that the children market is a really big one . ", " That's for sure . It's always hard for the parents to say no to their children . "]
['What can I do for you today ? ', ' I need to return a book . ', ' Can I do anything else for you ? ', ' I want to check these books out . ', ' Is that all ? ', ' That ’ s all . ', ' May I see your library card , please ? ', ' It ’ s right here . ', ' Will that be all for today ? ', ' Yes . That ’ s it . ', ' These are due back in two weeks . ', ' All right . Have a good night . ']
['Which sports are popular in your country ? ', ' Most people like football . More boys like football than girls . A few girls play it really well . Some people like playing basketball . ', ' Do many people like tennis ? ', ' More and more people like it now . fewer people play table tennis than before . Many people like swimming , because it is fun and keeps you fit . ', ' In my country , many people enjoy golf , but it is too expensive for some people . A few people like extreme sports , but I think the vast majority of people are afraid to try them . ', ' Extreme sports are only for a small minority of people . Several people from my university enjoy them , but most of us just watch . No one I know plays golf . ', ' I know loads of people who play it regularly . There are plenty of golf courses around the country . In the past , only a tiny number of people played . ', ' A great deal of people follow rugby in my country . ', ' There are plenty of rugby fans in my country too . ']
['Thank you for letting me borrow your portable CD player . ', " Oh , you're welcome . "]
["You seem to be in the seventh heaven . What's put you on ? ", ' Sarah and I could see eye to eye with each other . ', ' Did she give up her decision to marry Dick ? ', " No , I encourage her to go her own way , but she's now having a change of heart . "]
["I've come to say goodbye . ", ' When do you leave ? ', " I'm catching the eleven o'clock train . ", " Take care of yourself and don't forget to keep in touch . ", ' Goodbye . Hope to see you again next year . ']
['The weather is terrible . ', ' Yes . It was sunny and warm yesterday but the wind is really blowing hard now . ', " I'm wearing my heavy jacket . ", " I'm going to put on more clothes , too . ", ' Will it snow today ? ', " I don't know . Do you like snowing ? ", " Yes , when it snows , every where is white . It's very beautiful . ", ' You can read the newspaper . Maybe it will tell you whether it will snow or not . ', ' Good idea . ']
['This city is far too polluted . We should do something about it . ', ' I agree . We need to recycle our trash and use public transportation more often . ']
['I am looking for a comfortable convenient way to see the country . ', " Have you heard of motor coaching ? It's one of the fastest-growing segments for the travel industry . ", " No , I've not heard of it . Tell me about it . ", " It's almost like going on an ocean cruise except that you go by land . Everything is planned for you from the moment you step on board a luxury coach . ", ' Is it just a bus ? ', ' Oh . no . The motor coach is air-conditioned , there is a galley for food preparation , movies or music are available for your entertainment and attendants are there to take care of your every need . ', ' Wow ! That sounds like pure luxury . ']
["Who's your favorite film star ? ", ' Tom Hanks is always my favorite film star . ', ' What films feature him ? ', ' Many ! ']
['My Chinese friends told me that the Spring Festival is coming soon . Can you tell me something about it ? ', ' Certainly . It ’ s actually the Chinese New Year and is regarded by the Chinese as the most important holiday of the year . ', ' What happens on the holiday ? ', ' Family members usually get together on the Eve of the New Year and have a special dinner to celebrate . Relatives and friends often visit each other during the holiday to wish each other a happy new year . ', ' Do people cook a lot of special dishes for the holiday ? ', ' Yes , just like Christmas in western countries , it is a time for eating lots of special food . ']
['Rachel has decided to quit smoking . ', ' Really ? Why ? ', ' You never guess she is going to have a baby . ', " Oh , it's unbelievable . She is such a chain smoker . ", ' Yes , yes . She said she is going to stop drinking coffee too and quit all the unhealthy habits just for the baby . ', ' Oh , she is going to be a great mother . ']
['Do you know who ’ s just got married ? Old McDonald . ', ' Never ! He ’ s over 80 , isn ’ t he ? ', ' He ’ s nearly 90 . ', ' Good gracious ! Are you sure ? ', ' I am . What ’ s more , his wife is 84 . ', ' Is she really ? ', ' Yes , she is . And guess what , he is her sixth husband . ', ' Really ? Quite a woman , isn ’ t she ? ']
["It's almost midnight ! We are about to start a brand new year ! ", " I know it's so exciting ! A new year is always like a clean slate . Fresh start to accomplish any dreams , objectives and goals . ", " Do you have a New Year's resolution ? ", " I was thinking about it , but I'm never able to keep my New Year's resolution . Last year for example I joined a gym and only went twice . ", " Yeah I know what you mean . That's why this year I am keeping things more simple . Maybe like getting together with friends I haven't seen in a long time , or doing some volunteering work . ", ' That seems reasonable . We should get together and watch the ball drop in Times Square . ', " Sure , as long as you don't try to kiss me at midnight ! ", " Well , we can't break tradition ! It's bad luck ! "]
['Excuse me , are you Sara Wilson ? ', ' Yes , I am.You must be Tom.Nice to meet you . ', ' Nice to meet you too.Let me help you with your bags . ', ' Be careful , Tom.Those are pretty heavy . ', " Wow , you're not kidding.Hold on a second.Hello , could you give us a hand , please ? "]
['Are you working or are you a student ? ', " I'm a student . ", ' Which school are you studying at ? ', ' Tsinghua University . ']
["I'm really tired of my job in the bank . I'm thinking about changing it . ", ' Have you any definite idea ? ', " Not yet , what's your opinion ? ", " I think you'd better try an active job . "]
["Mike ! What's going on , man ! Long time no see ! ", ' Hey , Pat ! Yeah , I haven ’ t seen you in ages ! How is going ? ', ' Things doing great ! It ’ s funny running into you like this . Smell well , just last week I ran into Matt as well . ', ' Yeah ? How ’ s he doing ? ', ' He ’ s doing well . We went out for a couple of beers and the funniest thing happened . ', ' Oh yeah ? ', ' Well , we were talking and catching up on what we ’ Ve been doing , talking about work and family , when all of a sudden , Matt saw a mouse run under his chair and he completely lost it ! He started freaking out , and screaming ... ', ' Ha ha , really ? ', ' Yeah , and the funniest thing was , that he jumped on to his chair and started shrieking like a girl . You had to be there ! Everyone was staring and laughing ... it was hilarious ! ']
["Hey , Jack , where's your car ? ", ' I got rid of that clunker . This is my new one . ', ' Is that right ? It sure beats the old one ? ', " Jump in , I'll give you a ride . ", ' Ok . Boy , this looks expensive . ', ' Yeah , it costed a bundle alright . ', " Wow , this's sinking a hole . ", " Yeah , this sucker is the fastest thing I've ever owned . ", " I believe it . Hoo , this car corners like it's on rails . ", " We are on the high way . I'm the * * . ", ' Wow , this car can really burn rubber . ', " It's a great feeling . ", ' You made a perfect choice , Jack . ', ' Thanks , Daisy . ']
["What's your email address ? ", " It's bulldog 123 . ", " Bulldog 123 . Are you sure that's all ? ", ' Yes . ', " No . That's incomplete . ", ' What do you mean ? ', " What's your mailing address ? ", ' 456 Cherry Drive , Pasadena , CA 91170 . ', " That's correct . ", " So what's the problem ? ", ' Bulldog 123 is just the street . You have to give me the city , state , and ZIP code . ', ' Oh , I get it . My email address is bluedog123@yahoo.com . ']
["I'm here for my appointment . ", ' What can I do for you today ? ', ' I have an issue with my schedule . ', ' Tell me the problem . ', ' I have two classes on here that are at the same time . ', ' Oh , I see . ', ' Can you change that for me ? ', ' Do you still want both classes ? ', ' Yes , I would like to keep both classes . ', " I'll try to change one to a different day . ", ' I would greatly appreciate that . ']
['I ’ d love to have my own farm . ', ' It would be very hard work . Are you sure ? ', ' I wouldn ’ t mind getting up early morning and the physical work would make me fit and healthy . ', ' Running a farm would be totally different to you current job . ', ' That ’ s one reason I ’ d like to try it . I ’ d really like to get away from working 9 to 5 in an office . ', ' You ’ d need a lot of training before becoming a farmer . It ’ s not something you can just walk into . ', ' My uncle owns a farm and I ’ Ve spent some time working with him . I love being in the countryside with farm animals and green fields . ', ' Well , I ‘ d certainly come and visit you . It would be great to take a working holiday on a farm . I ’ d love to get away from hustle and bustle of the city for a while . ']
['We still have one more day to go before we return home . What will we see tomorrow ? ', " no idea . We've enjoyed both the natural scenery and the city sights . What else is there to see ? ", ' what about a factory tour ? ', ' you mean visit a factory ? ', " yes . I heard there's a lager motor company nearby which open to the public every weekend . We can go to see how a car is manufactured and learn more about the automobile industry . ", " good idea ! I've always been interested in that . How much is the entrance fee ? ", " I'm not sure , but as far as I know , most factory tours are free . They are sponsored by the company providing the tour . ", ' really ? What do the companies do that for ? ', ' I believe most of them think of it as good public relations . They can promote their product and make their company better-known . ', ' oh , i see . So factory tours are good for companies as well as visitors . ', ' exactly . ', ' do we need an appointment beforehand ? ', " I'll call the tourist information centre to check . "]
["Look , here're two coins named Kai Yuan Tong Bao — the sort of coin made in memory of the founding of a new dynasty . These two coins were made in different periods of the Tang Dynasty . ", ' How can you tell the difference ? From what I see , they look almost the same . ', ' The one made in the early Tang period is bigger and has more characters on it , while the one with smaller and elegant characters was made in late Tang period . Look carefully , and tell me if you see the difference now . ', " Yes , they are different ! But it's too professional . What I need is just being able to tell the real from the fake . Do you know any method we can use to tell a fake ancient coin ? ", ' Various methods were used in history to produce fake coins . We usually send the coin to an authorized unit to have it tested by experts with special machines . We can judge it with naked eyes . ', ' I see . By the way , China was more than once ruled by foreign tribes in history . Did they issue their own coins in China ? ', ' Certainly , they did . Liao Coins and Song Coins , for example , coexisted in circulation during the Southern Song and Yuan period some 800 -1000 years ago . The Liao Coins look plain and bold in style , just like the characteristics of the Mongolian tribe . Let me look for one and show you . ', " If you happen to find one , please bargain with the owner for it . I'd like to have one . It's interesting to see the integration of the Han and Mongolian cultures on this small piece of metal . "]
['There will be another sandstorm here tomorrow . ', " It's the fourth one this year . Isn't it horrible . ", ' Yes . We should plant more trees and grass to stop the sand from spreading . ', ' It may take many years for the trees to grow . I hope people will stop cutting down trees . ', ' But we need the wood . ', " But we can't destroy our forests to get the wood . "]
['What are you guys doing ? ', ' Just having a chat . ']
['What ’ s wrong with you , Mr . Polly ? ', ' What ’ s wrong ? I want a break from this horrible job . ', ' Then , buy a bottle of soft drink . ', ' Would you like to buy a bottle for me in the shop ? ', ' It ’ s a problem , because my boss is in that shop now . ', ' Ok , I will go there myself . ', ' Sorry , Mr . Polly . ', ' It doesn ’ t matter . Oh , God , I have only four dollars in my wallet . Is that possible for me to buy one ? ', ' Have a try . ']
["I'm bored and got nothing to do tonight . ", ' How about coming with me to meet my American friends ? ', ' Hey , that sounds great . ', " Okay , I'll pick you up at eight o'clock . "]
['What ’ s the first thing you do when you go to the bathroom in the morning ? ', ' I look at myself in the mirror . Sometimes , it ’ s not a pleasant sight , especially if I have been out late the late before . ', ' Do you usually shower or take a bath ? ', ' I usually don ’ t have time for a bath in the mornings , so I just take a shower . Sometimes I need a cold shower to wake me up and sometimes I need a hot one , especially if it ’ s winter and I need to warm up . ', ' Do you shave every morning ? ', ' I shave every workday , but I only shave at weekends if I ’ m going out somewhere . If I ’ m staying at home , I don ’ t shave . ', ' Do you brush your teeth twice a day as dentists recommend ? ', ' Yes . I brush my teeth in the morning , just before I go to work . It ’ s actually the last thing I do before leaving . Then I brush again before bed . ', ' Your dentist must be proud of you ! ']
['Miss Wang , would you mind my asking you a personal question ? ', ' No , not at all.Go ahead . ', ' Are you married ? ', ' Yes.Is that so important ? ', ' Frankly yes.We like to employ married people.By the way , do you have any children ? ', ' Yes , I have a three-year-old son . ']
["I'm not satisfied with it . ", " Why not ? What's wrong with it ? ", " Sometimes it goes fast . And sometimes it goes slow . And the alarm doesn'twork , either . ", ' Would you like another one ? ', ' No . Can I have my money back ? ', ' Hmm ... have you got a receipt ? ', ' A receipt ? ', " Yes . I must see your receipt . You can't have your money back without receipt . ", " Oh , I'm not certain , but I think I've lost it . "]
['Morning , Tom . ', ' Hi , Mary . ', ' You seem to be in a hurry . ', ' Yes . I ’ Ve got a meeting in a minute . ', ' Okay . I won ’ t hold you up then . ', ' Right . I ’ ll see you later . ', ' See you later . ']
['Would you mind if I ask you whether you are married or not ? ', " To be frank , I was married once , and now I'm single . ", ' Do you mean you got a divorce ? ', ' Yes , my first marriage was a failure . ']
['Let me clear away the broken glass . ', ' No , I can manage it myself.Just sit down , please . ', " It's very careless of me to have broken your glass . ", ' Never mind . ']
['Have you followed the value of dollar lately ? ', " How could I help but follow it ? The fluctuation of dollar is killing my company ! The exchange rates are eating into our profits , and we can't do anything about it . ", " It's really frustrating , isn't it ? I have the same problem . I would feel a lot better if the currency was a little more stable . With the way the dollar plummeting lately , my securities have gone up in smoke . ", " Every day I have less money ! I haven't spent anything , it is just melting away because of the shifts in exchange rate . ", " What we really should be making investment in is the Euro . I've followed the Euro's progress over the last quarter , I think it's about time to buy in . ", ' What about the Yen ? ', ' Are you kidding ? The Yen is in worse shape than the Dollar ! ']
["What a lovely day . The sun is shinning and the sky is so blue . It's a perfect day to go to the beach and get a beautiful tan . ", ' Great idea . Unlike you , I just want to enjoy watching the sea and playing with the sand . I do not want to get a tan because I look good in pale skin . ', ' Come on . Getting a tan symbolizes health and wealth in western countries . ', ' While the pale color symbolizes beauty and elegance in most Asia countries . ', ' That is a really interesting fact . ', ' I will bring a big hat and apply a lot of sunscreen before setting off the beach . ', ' Just do whatever you feel like doing . ', " ( At the beach ) My bag is so heavy . Let's put the stuff under the tree . ", ' Good idea . It is always cooler in a shade . ', " I can't wait to play in the water . My feet are burning when I stand on the sand . "]
['What time is it , Tom ? ', ' Just a minute . It ’ s ten to nine by my watch . ', ' Is it ? I have no idea if I ’ m so late . I must be off now . ', ' What ’ s the hurry ? ', ' I must catch the nine-thirty Train . ', ' It ’ s plenty of time yet . The railway station is very close . It won ’ t take your twenty minutes to get there . ']
['Did you bring some lunch with you ? ', ' Yes , I packed it myself . ', ' Wow , that looks beautiful . ', " It's my health-conscious lunch , good for my health and beauty . ", ' I might try it myself . ']
['Can you name some festivals of religious nature ? ', ' Yes , such as Christmas and Easter . ', ' What about historic festivals ? ', ' Thanksgiving Day , Independence Day . ']
['I wonder how Sarah and Mat are . ', " Don't you know they've already broken up ? ", " I'm not surprised . She's a plain Jane . ", " And he's so handsome . "]
["Where's Bob ? ", " It seems like he's not coming . ", ' Can you give him a call on his mobile ? ', ' Sure . ']
['excuse me ; is this seat taken ? ', " no . It's all yours . ", " thank you very much . My name is Ashlan . It's nice to meet you . ", " Carson . It's nice to mee you , too . ", " the weather is so warm for December , don't you think ? ", ' it is unusually warm . I blame it on global warming . ', ' global warming is wreaking havoc everywhere . ', ' so sure . Are you from around here ? ', " no . I'm new here . I just moved here a few months ago . ", ' where are you from ? ', " I'm from China . What about you ? ", ' I am from Texas . I was in China once , but it was a long time ago . ', ' did you enjoy it ? ', ' I did . I especially liked the food . What do you think about the food here ? ', " it's very different from Chinese food , but I am getting used to it . ", " Is that the Da Vinci Code that you've got there ? ", ' yes , have you read it ? ', ' no , but I saw the movie . What do you think about it ? ', " well , to be honest , I've only gotten though 10 pages of it . So far , though , it's interesting . ", ' well , this is my stop . it was nice talking with you . ', ' likewise . Bye ! ']
['Would you like a cup of coffee ? ', ' Yes . That would be good . ', ' Oh , no . ', " What's the matter ? ", ' This machine is out of order . ', " You shouldn't have used the machine . Did you lose your money ? ", ' I sure did . ', ' You ought to complain . These machine are always out of order . ']
["Hello , Mary . Nice day , isn't it ? ", ' Yes , what a wonderful day ! The sky has cleared up in the end . ', " I do feel like an outdoor exercise . After all , we haven't had such a beautiful day for a long time . ", ' How about taking a walk in the park ? ', " OK . It's delightful to have a walk in the park with the air so fresh . ", " ( After they entering the park ) Great , it's so quiet here . We have the park to ourselves , only you and me . ", " Are you kidding ? Don't you see many people over there ? Just on your right . ", ' Oh , I see them . Beautiful weather should be shared by all the people . ', ' Ah , you changed so fast . ']
['How was the party last night ? Did you enjoy it ? ', ' Oh , don ’ t talk to me about last night ! It was the most awful evening I ’ Ve ever had . ', ' Why ? What happened ? ', ' Well . Mary had promised to be my date , but she stood me up . I waited for her for a full hour in the cold wind . ', ' What about the party ? ', ' It was boring . The music was too slow and the food was lousy and , above all , I was really sick of the same old crowd all the time . ', ' So how long did you stay ? ', ' I left after the opening dance . I couldn ’ t wait to get out of there . ']
['Do you think my briefcase is big enough to put in all these stuff ? ', ' Let me see . Laptop , flash disk , a ballpoint pen , a pencil , a notebook , a pair of glasses , cell phone , charger , moisture , notion , ... Oh , that is too much . You are not going to a business trip . ', ' I guess I need all of them . ', ' Actually , the company will provide you with all of these supplies . So , you can leave this very thick notebook at home . ', ' I know . But it is my lucky charm . I carry it all the time . ', ' Suit yourself . Don ’ t forget to set the alarm clock . ']
['Why do all girls appear feminine after sophomore year ? ', ' Because they are full-grown . Look at their curvy figures . ', ' I feel they all talk and behave in a different way . ', ' They suddenly become shy when they speak to boys . ', " Some even do make-up slightly . Are you aware that previous ' small potato ' Ma Xiaoxiao becomes a piece of cheese cake recently ? ", ' She is certainly not my kind of girl . ', ' Stop preaching your dream love Marilyn Monroe to me . I know those sexy women are your tastes . ', " You are so Platonic . Those naive girls will eventually grow into real women . They can't resist love , and men cannot resist their attraction either . ", " I appreciate the saying ' Love consists in this , that two solitude protect , border and salute each other . ' "]
['This one looks great ! I love the seashore . ', ' So do I . The sun ... the sand ... the ocean ! ', ' And listen to this ! What do you think of sailing , swimming , windsurfing , and fishing ? ', ' Oh , Tom ! They sound fantastic . I really like all those things . ', ' Yeah ... me , too . ', ' Well , except fishing . To be honest , I hate fishing , but I love all the others . ', ' Hey ! Look at this ! We can stay in a big hotel or we can stay in a little cabin by the beach . ', " You know . I really don't those big hotels . ", " Neither do I . Let's stay in a cabin.It ' ll be much nicer right beside the ocean . "]
["May , look , what's that in the cage ? ", " Don't you know that ? It's panda . ", " Of course I know . I just can't see it very well . ", ' OK , then put on your glasses , and do you know what does the panda eat ? ', ' Of course , Bamboo ! ', " That's right . ", ' I also know they are given to other countries as gifts for friendship . ', ' You sound quite knowledgeable . ', ' Not really , panda is my favorite animal . ', ' Actually , it likes milk too . ', ' Any way , in a word , panda is our friend . ', ' Do you know other famous animals in the world ? ', ' Yeah , let me think , the kangaroo and koala bear from Australia are very famous . ', " That's right . OK , let's move on . "]
['You look fresh recently.How do you make it ? ', ' I attend an aerobic class three times a week . ', " Aren't you tired ? ", ' No , I feel young , fresh and energetic . ']
['John , did you have a dream when you was a little boy ? ', ' Of course I did . I dreamed to be a pilot when I grow up . But unfortunately , I didn ’ t realize it . ', " I had the same experience with you . When I was a little boy I dreamed to be a great scientist . But now you see , I'm just a common office clerk . ", ' Okay , forget about that . S , do you have some practical dreams at present ? ', " I do . And now I'm working hard to learn English , and I want to be an interpreter some day . ", " You're promising . Just follow your dream and never give up . ", ' Thanks , I will . ']
["Hi Joe . You've met my new assistant , right ? ", " Emm ... yes . But I wasn't too impressed . I found her a little stuck up . ", " You are kidding , but she's so helpful . ", " Tom ... you are her boss , you down . Of course , she's helpful to you . ", " Come on . She's like that with everyone . ", ' I don\'t think so actually . She never even says " hello " to me . ']
['Eric , how long will you be in China ? ', " I don't know . Well , my contract here is for one year , and I don't know what I should do after that . Maybe going around for a while . ", ' Well , have you ever thought about learning some Chinese ? ', " Actually , I am learning that now . But it's too hard for me . You know the four tones and the stuff . It really freaks me out . ", " Don't worry . All things are difficult before they are easy . ", ' You hit the nail right on the head . ', ' Well , are you invested in some language-exchange program ? ', ' What is it ? ', " It's where I teach you Chinese , and in exchange you teach me English . ", " Awesome . I've been giving this a lot of thought . When can we do this ? ", ' How about this sunday ? ', ' Ok , cool . ', " Good . I'll give you a call tonight . ", ' No problem . ', ' Bye . ']
['Great party , isn ’ t it ? ', ' Yeah , really . ', ' By the way , my name is Liu Wei . ', ' Hi , I ’ m Susan Marshall , You can call me Susan.Nice to meet you . ', ' What do you do , Susan ? ', ' Well , I ’ m a college student.How about you ? ', ' I work for the Bank of China , in the International Section . ']
['Happy Birthday ! This is for you , Kate ! ', ' Thanks.Miss Zhang . ', " You know in China we usually don't open presents until the guests leave . ", " Really ? I've already opened this one.Say , this is sweater , and it's just what I need to go with my new suit.Thank you ever so much . "]
['The May Day holiday is coming . Have you made any plan ? Are you going to stay here or go out for a traveling ? ', ' I haven ’ t decided yet . But I may go out . ', ' Where have you planned to go ? ', ' I want to go to Shanghai , but I also want to visit Hainan . ', ' Then which will be your first choice ? ', ' I don ’ t know . How about you ? are you staying here or somewhere . ', ' I have decided to go to Tasha . ', ' By train or by plane ? ', ' By plane . ']
['What a pin-up she is ! ', " Can you imagine she's over forty ? ", " That's incredible ! She has such a sharp figure . ", " Absolutely.She ' s a teacher of aerobics . "]
['Do you have spare time tonight ? ', " What's the matter ? ", ' There will be a live show of football tonight . ', ' What teams are playing tonight ? ', ' AC Milan versus Real Madrid . ', ' That will be a tough match , right ? ', ' Absolutely . ', " What are we waiting for ? It's already 7 pm now . Let's buy some drinks and desserts now . ", ' Great idea ! Here we go ! ']
["I didn't expect to see you at this hour . You must have goofed off again . ", " Goofed off ? Maybe , but I'm not a clock-watcher . I finished doing what I should do and then knock off an hour earlier . ", " You'll be sorry if the boss finds it out . He may probably give you the bag . ", " I'm sure of what I'm doing . "]
['Hey , Leo . How come you look so terrible ? What ’ s going ’ on ? ', ' You can say that again . Susan ’ brother dropped in from out of town , so I offered to put him up for a few days . But he ’ s driving me up a wall . This guy is bottomless pit . ', ' How gross ! I can ’ t handle people like that . Does he at least give you a hand around the house ? ', ' He doesn ’ t lift a finger ! I bend over backwards cleaning up all day and he sleeps in until noon . ', ' Man , what a freeloader . You better do something quick or he ’ ll never hit the road . After all , he ’ s got it made in the shade here . ', ' You think he might stay even longer ? ! ', ' Now , don ’ t go losing your temper . If you tolerated all you can , just kick him out ... but do it with gloves . I know ! Tell him a white lie like you ’ re getting the house fumigated ! ', ' That wouldn ’ t be a lie ! ']
["I've got an idea . Let's make this game even more interesting . ", ' How ? Do you want to play strip-trivia or something ? ', " Well , if you want to ! Seriously , though , let's make a bet . ", " Why don't we just make it a friendly game ? ", " Don't be such a chicken ! Whoever loses has to treat everyone to a movie . "]
['What ’ s wrong with it ? ', ' It ’ s broken . I just bought it yesterday , you know , it costs me $ 556 . ', ' It sounds too bad . What will you do ? ', ' Mike suggests me to return it . ', ' That ’ s what I want to say . ']
["What do you think of the new television channel ? Aren't the programs awful ? ", ' I quite agree with you . They are terrible . They are complete waste of time , but my wife disagrees with me . ', ' Actually , what bothers me is the violence . There are far too many detective and police shows . ', " I couldn't agree with you more . There aren't enough educational programs , and even the news shows are not well done . ", " You are absolutely right . They are too brief . They don't tell you anything . "]
['I like your new skirt . ', ' Do you think it fits me ? ', ' Yes . It looks terrific ! ', ' I bought it at half price . ', ' You were lucky to find it . ']
['Do you like tea ? ', " Yes , but I don't know much about it . ", " Tea does good to people's health . There are many kinds of tea.Say , black tea , green tea , scented tea , brick tea , milk tea , Jas - mine tea , chrysanthemum tea and so on . ", ' My favourite is Jasmine tea . I like its aroma . ', ' Yeah , but scented tea is now in fashion . ']
['David , why didn ’ t you clean the room ? ', ' I ’ m not in the mood . ', ' Why are you feeling depressed ? ', ' I was told my girlfriend was speaking ill of me . That ’ s a real let-down . ', ' I don ’ t think she will do such a thing . ', ' But she did and made me disappointed . ', ' Oh , cheer up . A girlfriend is not everything . ', ' But she means a lot to me . ', ' Then forgive her mistake . ']
['This small town has many serious problems . ', " What's the cause ? ", ' The mayor and high officials practice cronyism and a large number of guys who are good at nothing occupy many important positions . ', ' I see why it lags behind other towns . ']
['Do you love me ? ', ' I ’ m very fond of you . ', ' Yes , but do you love me ? ', ' why ? You mean a lot to me . ', ' why didn ’ t you answer my question ? ', ' what question ? ', ' Do you love me ? come on , I ’ m eager to hear . ', ' you know that I care for you . I---I ’ m proud of you . ', ' Don ’ t cherish your words , dear . ', ' I---I don ’ t feel like saying it . ']
["You missed the film.That ' s a shame . ", ' Is it stimulating ? ', ' Yes . I got very excited . ', ' I hope I still have chances . ']
['Hello , this is the admissions office . Can I help you ? ', ' Hi . I ’ m calling about your continuing education program . ', ' What would you like to know ? ', ' I want to become certified in computer programming . Do you offer any part-time courses for adult further education ? ', ' Yes , we offer both night and weekend courses in a number of different subjects . ', ' How do I sign up ? ', ' If you give me your address , I can mail you an information packet and the application forms . ', ' Great ! ']
['How nice of you to come ! ', " It's been a long time , hasn't it ? How have you been ? ", ' Just fine , thanks.And you ? ', " I've never been better , thanks . "]
['Marquet , do you think I should enroll in the science course ? ', " Yes , I think so . If you want to graduated this year , you've got to take a science course . ", ' Right , I figure since you are doing premedical , you know about the very courses . ', ' Well , I have to take biology , chemistry , maps and physics . What you need is a good introductory course for non-science majors . ', " Yes , I'm really weak in maps , I did poorly in high school . ", " That's a problem . "]
['Earning extra income on the Internet is easier than you might think . After I started selling traditional craft items on the Internet last year , I have really been able to make bank doing something I love . ', ' Is that right ? I hear all these horror stories of internet business crashing because there is not enough of a customer base yet . How can you be sure your idea will cash in ? ', " To run a successful internet business , it requires a little research and relatively small investment . You've got to have a good idea of some kind of product that is in demand or would be popular . ", " That's marketing research ... But what about getting started once you have an idea ? ", ' After you have your great idea , then you can set up shop by registering a domain name , creating a website , an email address , and a hosting service . If you want to go all out on your website , you can put together shopping cart technology , but that can be pricey to start out with . ', ' Sounds like a lot of work ! ', " Anything worth doing takes work . Money doesn't grow on trees ... Most of us have to work for it . "]
["You went out on a date last night , didn't you ? ", " Yes , I did , but Linda stood me up . She didn't keep the date for the first time . ", ' How come ? ', " I don't know . ", " Why don't you phone her for a date again ? ", ' I did phone her this morning , but she hung up on me . I think she is going to walk out on me . ', " Don't jump to conclusions . Look at the bright side , try to make another date again . ", ' I will . Thanks for your advice . ']
['Happy birthday , Aims ! ', ' Thank you , Lisa . ', ' Here is a present for you . I hope you like it . ', " Oh , great ! I love it ! You know I've been expecting this for a long time . ", " I'm very glad to hear that . ", ' Come here ; let me introduce some friends to you . ']
["Bill , do you know when did the Chinese begin to celebrate Teachers ' Day ? ", ' I know the Chinese teachers had their first festival in 1985 . ', " So , it is the 27th Teachers ' Day . ", " What will you do on Teachers ' Day ? ", ' I am going to send Mr . Li some flowers . What about you ? ', ' I intend to invite him to dinner . ']
['I hear scientists in the US have discovered a new AIDS vaccine . ', ' Does it work ? ', ' I don ’ t know . The report says it is better than the old vaccines . ', ' Don ’ t count on it . I think the best way to prevent AIDS is to keep yourself clean by having clean sex and keeping a regular sex partner . ', ' Right . That ’ s why doctor say AIDS prevention means cleanness . ']
['Harry was angry last night . ', " That's because he's getting nervous . Anyway , this is the first time he's directed a play . ", " But he used to be very relaxed and cheerful . It's not like Harry to do a thing like that . ", " Yes , you're right . Maybe there's any other reason . "]
['Did you get any pizza ? When I got there , only small one was left . What a pity ! ', ' I got the short end of the stick . ']
['Hello , Kevin . I hate to do this , but I have to cancel our appointment . ', ' Oh , no ! Why ? I was looking forward to seeing you at my new place . ', " Yeah , I really wanted to come , too . But something unexpected in Shanghai have come up . I have to fly out for a few days , but I'll be back soon . ", ' No problem . Call me when you get back . ', ' I should have some free time next week . Say , next Wednesday evening ? ', " That's good for me , but do you think you'll be back by then ? I'd really like to see you . ", " Yeah , I'm expecting to come back on Tuesday . ", " Great ! That's settled then . ", ' OK . ']
["Hi , my name is Lean , and I'm from Russia . ", " Nice to meet you , Lvan.My name is Alike . I'm from Japan . ", ' To me English is a difficult language . ', ' A second language is always difficult . ', " True , but English is harder than most.It ' s a crazy language . ", ' A crazy language ? Why do you say that ? ', ' One letter can have several pronunciations and one word can have several meanings . ', ' No wonder you say English is a crazy language . ']
['May , is this the Hall of Ancient China ? ', ' Yes . Look at these historical relics here , amazing ! ', ' Why are they all in glass boxes ? ', ' For protection . Some relics will turn to dust if exposed to air . ', " So there isn't air in the glass boxes ? ", " No , there isn't . There is a vacuum in every box . ", ' I wonder how old these things are . Thousands of years ? ', ' Yeah , they all come from a very ancient time . ', " Hey , look at the tripod . I've seen it on TV . ", " It was made 4,000 years ago . It's priceless ! "]
['Honey come on ! We are going to be late ! Honestly , you take longer getting ready than I do ! ', ' I was drying my hair and ironing my shirt ! Can you come here for a sec ? I need your help . ', ' What is it ? Why are all these clothes on the bed ? ', ' I don ’ t know what to wear ! Ok , give me your opinion . Do you like the way this looks ? The striped short sleeved shirt with this checkered sweater and my lucky sandals . I like the cut and hemline of these shorts so I think I ’ ll wear these as well . ', ' Are you joking ? What am I going to do with you ? We are going to a dinner party not the beach ! Wear the shirt with the silk tie I bought you and these corduroy pants . It ’ s chilly outside so you can wear this coat . ', ' Thanks honey ! You have such great fashion sense.Now , what am I going to do with my hair ? ']
['How may I help you ? ', ' I need to return these books . ', ' Give them here . ', ' Here they are . ', ' It appears these books are two weeks late . ', ' I forgot they were due . ', ' You do realize you are going to have to pay late fees , right ? ', ' How much is the late fee ? ', ' The late fee is 25 cents a day . ', ' So I have to pay 25 cents for each day the books are late ? ', ' It ’ s 25 cents for each book . ', ' That ’ s a lot of money . ']
['So what kind of music turns you on ? ', " Rock'n'Roll , I guess . ", ' You mean the kind of stuff like Nirvana ? ', ' Not really . That ’ s pretty heavy metal . ']
['Hi , Robert . What happened to your face ? It looks swollen . ', ' I had to go get a cavity filled today . ', ' Did it hurt ? ', " I don't even wanna talk about it . It killed me ! ", ' How long were you in the chair ? ', ' It took quite a while , but the worst part was getting numbed . They had to give me 3 shoots . ', " Well , I guess you've learned a good lesson , huh . You have to take good care of your teeth . ", ' No kidding . Not only can ’ t I stand the pain , but man ... dentists are expensive . The bill is going to be humungous ! ', " Don't you have a dental insurance ? ", ' I do , but it still does not cover everything . ']
['Merry Christmas ! ', ' The same to you ! ', ' Are you doing anything special ? ', " We're having some friends over.What are you doing ? ", " Oh . I'm just going to take it easy . "]
["OK , guys . Here's the plan . Get the ball to the goal , and keep it away from Rich and Taylor ! ", ' Why ? Are they good ? ', ' They played ball at school . Here we go . Yi-jun , go out for a pass ! ', " I'm ready ! Whoa , what a hard throw ! I can't get that ! ", " Catch it , Yi-jun ! Run to the ball ! Uh-oh ! Slow down , you're going to hit ... ", ' Ummmph ! ']
['What are you doing ? ', ' I ’ m just looking at this map of the world . I ’ m preparing for a geography class . ', ' There are no countries marked on the map . ', ' No , there aren ’ t . this map just show the geographical features . Look at the Himalayan plateau with the highest peaks in the world . ', ' The thing that I find most surprising is that most of the world is covered with water . Compared to the oceans , most countries are tiny . ', ' I find it incredible how millions of years of volcanic activity have created mountains thousands of metres tall . ', ' Rivers have created deep valleys and canyons like the grand canyon . ', ' The oceans and landscapes all influence our climate . ', ' It ’ s all so interesting . I ’ ll have to find more information about it on the internet . Or perhaps I should try and attend your geography class . ']
['What are you up to tonight , Steve ? ', " I'm going to a disco with my friends . ", ' That sounds like fun . Have a good time . ']
['Well , I can ’ t believe your uncle and aunt came to stay with us for a week , and they did not even call us in advance . ', ' John , they are old-fashioned people from the Chinese countryside . That ’ s their custom . ', ' I know , but it is hard for me to get used to your relatives coming to visit us , and without warning . ', ' Don ’ t your relatives visit other relatives ? ', ' Yes , but Americans never visit without calling in advance , and they almost never stay overnight . ', ' I think that maybe Chinese families are closer than your families . ', ' I think you ’ re right ! ']
['What is today ? ', ' Thursday . ', ' So the weekend is coming ! How about seeing a film ! ', " I'd love to . "]
['Oh , George , what a beautiful day it is today ! The sun is hot and there are just a few clouds scattered here and there ! What a perfect day to be at the beach ! The kids are going to have so much fun ! A ', ' It does seem like the perfect day ! I ’ m glad we chose to get out of the city and enjoy the nice weather ! This looks like the perfect spot ! Ok kids , put on your sunscreen while your mom and I set up ca ', ' There we go . Can you help me with the umbrella ? Perfect . ', ' Ok kids , here ’ sa beach ball and a Frisbee , a pail and a shovel . I want to see an impressive sandcastle by the time we leave . Don ’ t stray too far . Wait ! Leave your sandals here or put on your wet shoes ', ' And stay in the shallow area . I don ’ t want to see you go any farther than that sandbar ! It ’ s too deep out there and we didn ’ t bring your floatier . ', ' You ’ re back already ? The water was too cold , huh ? I ’ ll tell you a secret . Do you see that small pool of water over there ? It ’ ll be warmer in there . Go see if you can find some seashells or catch some ', ' What is that ? A jellyfish ? Jeremy , put that down right now ! It could sting you ! ', ' Ah ! Not on me ! Ow ! ']
['What do you think about studying in the U . S . ? ', ' Well , for many international students , coming to the United States and living here and studying can be quite a daunting experience , especially when finding a house on campus or off campus . ', ' Do you have any advice ? ', ' I think first of all for first-time students , coming and living on campus in dormitories can provide a certain level of security . ', ' Anything else ? ', ' Uh , when you live off campus , there might be a certain amount of flexibility in choosing roommates that you might not have when living on campus . ', ' I will think over your advice . ', ' Well , of course , the choice is up to you . Good luck ! ', ' I really appreciate your help . ']
['Who is that guy ? ', " It's Clive of course . Where did you come from ? Every girl knows Clive ! ", ' Really ? He is my type . ', " He is everybody's type . ", ' What position does he play ? ', ' Shooting guard . The same as Michael Jordan ! ', " Oh , I love Michael Jordan . He fills people's lives with great excitement . ", ' Used to . But now he is too old to play in a fierce game like this . But Kobe is the upcoming superstar now . ', ' Kobe is a good player but I heard he is a womanizer . ', ' That is not true . They are just jealous of him ! ', ' Jordan is a legend , anyway . An idol that no one can replace . I think Clive can make a good professional basketball player . He is not just about muscles he also plays smart . ', ' You know what , he is also an outstanding football player . He is surely to be a star of tomorrow . ', ' By the way , do you know if he has a girl friend ? ', ' You are so not here ! His girlfriend is one of the cheer leaders . ', ' Oh , My chance is slim then . ']
["Here are the leads from last week's exhibit as a trade show . There are about forty or so that are hot . You should contact them immediately , in the next twenty-four hours if you can . The rest are categorized according to potential and interest.You can see we've got our hot stack , our warm stack , our lukewarm , and our cold but not dead stack . ", " Haha ... please don't tell me you've got a dead stack . I hate making cold calls ... ", " Don't worry , most of the leads on mildly interested , if not strongly interested . We've just got to make sure the Hot ones are contacted right away . And even the contacts that for what ever reason aren't prepared to make an order now , they might be interested in the future . Please be conscanciouss about getting a hold of everyone of these leads . We've spent a big chunk of marketing budget to find these people . I don't want our investment to go down the drain . ", " Don't worry , I've gotchy covered . "]
["Where's your hometown ? ", ' Shandong . ']
['I just got laid off . The awful business , you know . ', ' I ’ m very sorry to hear about that . So are you all right ? ', ' Yeah , I ’ m better after talking to you . ', ' Oh , you poor thing ! ']
['What will you do now ? Propose to her . ', " Of course I won't chill out . Opportunity knocks only once . ", ' You should strike while the iron is hot . ', " You're right . I will have a talk to her about that . "]
['How do you usually get to school ? ', ' I usually ride my bike . Which form of transport do you prefer to use ? ', ' I feel that I can see more when I pedal a bicycle , but when I feel lazy , I drive my car . ', ' I think we should discourage people from using their private cars . They produce too much pollution ! ', " I agree , but I would find it difficult to stop using my car . It's just so convenient . ", " Cars might be convenient , but they're so bad for the environment . ", ' Do you have a car ? ', " No . I used to have one though . Once I started using my bicycle to get around , I found that I didn't really need it . ", " Maybe if I sold my car now , I wouldn't be so tempted to use it . ", ' You could try . It would save you a lot of money . ', " That's true . Every month , I spend hundreds of dollars on gas , insurance , and repairs . ", ' If you got to class by riding a bicycle every day instead of driving , you will get lots of exercise , too ! ', ' I could stand to lose a few pounds . Having a car has made me lazy . I never end up walking anywhere ! ', " Let's go to a car dealership . I'll help you try to sell your car for a good price . ", " Sounds good ! Let's go ! "]
['Bob is really handsome . ', " That's why he's very popular among girls . ", ' I wish I were just as handsome . ', ' You are ! ']
["How's your new work , Carl ? ", ' A tough job . They even offer in-service training every Wednesday afternoon . ', ' Good for you . ', " I don't like it . I am not used to this kind of 9 to 5 work hours . Above all , I hate talking to those poker faces everyday . ", ' Well , you have to take the bad with the good . ', ' I guess so . I am badly off and I need this job . ']
['What can I help you with today ? ', ' When does the library close ? ', ' The library closes at six o ’ clock . ', ' Does it close at that time every day ? ', ' Not always . ', ' Is the library open on Saturdays ? ', ' Yes . ', ' What time do you open and close on Saturday ? ', ' The hours are from 9 am - 6 ', ' Okay . Thank you very much . ', ' Do you need anything else ? ', ' No , that ’ s all . Thanks . ']
["I can't wait until my car is repaired . The commuting with public transportation is killing me . ", " It can't be that bad . ", ' But it is ! Take this morning for example . The subway was so packed this morning , I got totally squished by about a hundred busy commuters on the way to work . ', " At least the subway is better than the bus . It's faster for one thing . And usually less crowded . But the drawback is that the subway is more expensive than the bus . It adds up over time , if you take it every day . ", " That's true . The bus is even worse . Just thinking about taking the bus every day makes me tired ! Hey , how do you get to work every day ? ", " I ride my bike . I don't live too far away , so it's pretty convenient . it's only about a ten minute bike ride from my house to the office . ", " I'll bet it's good exercise , too ... a good way to keep fit . ", " Yes , not only a good way to keep in shape , but a good way to relieve stress as well . While you're stressed out by your commute , I'm releasing all the stress of the day with mine . "]
['Why are you so rude to your wife ? ', " I didn't like her butting in where I didn't want her . She's a chatter box . ", ' But she means to help you , not to trouble you . ', " I know . But I just can't stand her butting in when I was trying to emphasize a point . "]
['What he said disappointed me . ', ' What did he say ? ', ' He advised me to change to a more suitable course . ', ' Why ? ', ' He said that career in law was unsuitable for a women . ', ' It is stupid to say so . ']
['What do you think is harder , reading or writing ? ', ' Well , they ’ re completely different . Reading is passive , and writing is active . ', ' I don ’ t think I understand what you mean . Could you explain a little more ? ', ' In reading you need to recognize language by seeing the words on the page and knowing what they are . In writing you have to produce language , you have to create your own words on a blank page . ', ' Oh , now I see what you mean . When you ’ re reading , you are just looking , but when you are writing , you are actually doing something ! ', ' A reading knowledge of a language is larger and different from a writing knowledge . Don ’ t you think so ? ', ' I think I see what you mean . I can read Shakespeare but I definitely can ’ t write it . ', ' Exactly . ', ' So I have another question for you . What do you think is harder , speaking or understanding ? ', ' They ’ re both harder than reading or writing . ', ' In what way ? ', ' Because they are direct communication with another person , and there ’ s a time limit . This time limit is the most serious problem for foreigners , even for those who know lots of English . ', ' You are making me feel really discouraged . ', ' I ’ m not trying to discourage you . I ’ m trying to help you . You have to live with these difficulties . Isn ’ t it better to know about them ? The more you know about what you have to face , the better you ’ ll do . I promise ! ']
['You look happy . ', ' I am happy . I just bought a new car . ', ' Wow ! Is it a good car ? ', ' It ’ s a great car . It ’ s very comfortable and it goes really fast . ', ' Was it expensive ? ', ' Put it this way – it wasn ’ t cheap . ', ' What colour is it ? ', ' It ’ s red and black . ']
["Let's meet tonight at the Thai restaurant at about 5 . ", " Fine , I'll take a taxi . ", " Why don't you walk ? It's only about 20 minutes walking and it's a nice evening . ", " Never thought about it , I sure you are right . It's quite a short walk . ", ' Ha-ha , see you then . ']
['Professor , do you have a few moments when I could meet with you ? ', ' I schedule my appointments from two to four on Saturday ; what works best for you ? ', ' Three would be a good time . ', ' Great , do you need directions to my office ? ', " I'm not sure . ", " Well , just make sure to go through the double doors , and I'll be on the right . ", " OK , I'll find it . ", " It's very easy to find . ", ' See you then . ', ' I will enjoy seeing you ; have a good week ! ']
['The boy threw up . ', " That's disgusting . "]
['Bill . Bill ! You gotta help me ! ', ' What ’ s wrong ? Slow down or you are gonna give yourself a heart attack . ', ' Tomorrow is Christmas and I haven ’ t bought my mom anything ! I ’ m such a bad son ! ', ' Take it easy ! Let ’ s go to the mall , window shop a little and see if there is anything she might like . ', ' That ’ s just it ! I don ’ t know what to get her ! Last year I got her a ring that was two sizes too big and a pair of shoes five sizes too small ! I suck at getting presents for people . ', ' That ’ s where you ’ re making a big mistake ! You can ’ t just guess peoples ’ likes or sizes ! Especially with clothes or jewelry . On top of that , I think that you should get your mom something that shows how much you love her . At the same time you should show her that you took the time and effort to look for something that she would really like ! ', ' Yeah , you ’ re right . When it comes down to it , I can be pretty tacky . ', ' Yeah , tell me about it . I know ! Your mom is trying to learn Spanish , right ? Why don ’ t you get her a gift certificate for this great website I saw called SpanishPod . ', ' Now that ’ s a great idea ! ']
['Happy birthday , Ms . Lin . Here is a present for you . ', " Oh , thank you ! It's very kind of you . Ah , it is a porcelain vase . ", ' I hope you like it . ', ' Yes , it is lovely . I have been expecting something like this for a long time . Thanks ever so much . ', ' I am glad you like it . ']
['Cheer ! ', ' Cheer ! ', ' So what time tomorrow ? ', ' Half past seven in the morning . ', ' Where to meet ? ', ' In the market . ', ' OK . Bottoms up . ', ' Bottoms up . ', " It's on me . ", ' Thank you . This place is nice . ']
['Wow , Is winter always this cold in Taiwan ? ', " Not really . It's much warmer usually . Your are not used to cold weather ? ", ' No , I am from south California . This is my first real winter . ', " Well , You'd better get some more warm clothes . ", " What's the temperature today anyway ? ", " I would say it's about 5 degree Celsius . "]
['Good evening , Mr.Brown . ', " Good evening , David.Good evening , Mary.It ' s so good of you both to come . ", " It's nice of you to invite us . "]
['what are you listening to ? Is that Beethoven or Mozart ? ', " it's Beethoven . Do you like it ? ", " I think Beethoven's music is incredible . I've heard that listening to it can make you more intelligent , too . Do you believe that ? ", " I don't know about that , but I do think that it helps people relax . ", ' what other kind of music do you listen to ? ', ' actually , I mostly just listen classical music . What about you ? ', ' to be honest , I think classical music is too complicated for me . ', ' what kind of music do you prefer then ? ', ' I like pop music . Do you ? ', " not really . I don't think pop music has much depth . ", " I see what you mean . I think that's way I like it so much . ", ' how long have you been in to pop music , then ? ', " I've always been into it . Have you always liked classical music ? ", " not really . When I was little , we didn't really listen to music at all . ", ' so , how did you become interested in it ? ', " well , when I was about 10 years old , I started playing the piano . I think that's how it all started . ", ' do you still play piano ? ', " yes , it's one of my hobbies . "]
['Want to join me for a midnight snack ? I need to grab something to eat . ', ' Fine with me , but no more chafing dish . ', " Let's go to the food stall . There's a good one just around the corner . ", " I'd love to try some snacks . ", ' ( Later .. ) Everything looks tempting . What do you want to have ? ', ' Kebabs and roast squid . ', ' Can I have a bite ? ', ' Help yourself . ', ' Super ! ']
['Can I help you , sir ? ', " Yes , I've been sitting here for a few minutes . I'm waiting for someone to put gas in my car . ", " I'm sorry , sir . But this is the self-service pump . ", ' Self-service ? ', ' Yes . You must fill up the car yourself . ', ' Are you serious ? ', ' Yes . Are you traveling here ? ', " Yes , I'm from Taiwan . I never heard of a gas station where you fill up your own car . ", ' In America , most gas stations are like this . ', " Do I really have to do it ? I don't know how . ", ' Well , since this is your first time , I will do it for you.But next time , if you want a full-service gas station , you should look at the sign . ', ' What sign ? ', ' Under the sign for the gas station , there will be a smaller sign that says Self-Serve or Full-Service.And some gas stations have both.But if they have both , some pumps will be self-serve and some will be full-serve.You have to look at the signs . ', ' I see . ']
['Oh , no . It looks like my computer really has caught a virus . ', ' Why ? Did you open an attachment ? ', " Yes , something called “ George W . Bush . ” An hour later , all I see are pictures of George W . Bush in women's clothes . ", " I kind of like it . He looks better that way , doesn't he ? More presidential . ", ' I preferred the forward with pictures of him side-by-side with monkeys . ', ' Yeah , their expressions were exactly the same ! ']
['John seems to be in high cotton . He may well become a big shot . ', " I bet my button dollar that he won't . He is no more than a nine day's wonder . ", ' What is your idea ? ', ' Many people like him get a flying start but soon disappear . ']
['Millions of amateur investors like you , have to rely on a dizzying array of financial newspapers , magazines and commentators to get investment information . ', " Yes.It ' s sometimes scary if you think of the tremendous amount of media we face every day . ", " It's like information overload , not to mention the reliability of these papers and magazines . ", ' Which financial magazines and newspapers do you think do the best job of checking facts ? ', " Well , for example , The Wall Street Journal is very , very good . Even though it's used on occasion ( as all news organizations are ) by Ces or bankers who leak their mergers in advance in order to get a positive spin . ", ' I like to read Fortune . ', ' Good . Fortune is usually ahead of the curve.And Business Week is very solid , too . ', " Where does a broadcast company get most of their information ? I hope it's not just from press releases . ", ' A good broadcast company usually does far more than press releases.Their people go out and do real reporting , talking to people at the stock exchange , fund managers , analysts , etc . ', " But sometimes when a flimsy report , or even a rumor gets on television , there's going to be a terrible ' echo chamber ' effect . ", ' You are right about that . ']
["Hi , Li Ming . You look upset . What's the matter ? ", " There will be a parents ' meeting in our class this Saturday and I am worried about it . ", ' Why ? We can leave school earlier that day . ', " I didn't do well in last exams . If my father knows it , he will beat me up . ", " I can't believe it . My parents never beat me . ", ' You know that my father is irritable . ', ' You can ask the teacher for help . ', ' Good idea . ']
["Did your company go union ? I heard that many companies in out industry are being unionized , so It's getting harder and harder to compete on a level playing field . ", " Yes , we're hopping on the bandwagon and signing up for the union . Mostly people are pretty happy about it ... I guess it depends on if you are in management or in the labor force . ", " Management isn't looking on the labor unions too favorably , I'd guess . I don't blame them ... labor unions can really put the squeeze on the executives . ", " Sure ... but it's probably better for the workers , because the union's whole purpose is to look out for the little guys . The only way that the little guys can take on the big bosses is if they unite . Labor unions are all about getting a voice for the underdog . "]
['I hope the host team loses . ', ' That all depends on how the visiting team shapes . ', ' According to the papers , the visiting side is a strong team in America . ', ' But two players of the team have been booked and one is out . ']
['Hi honey ! You ’ ll never guess what ! My friends Julie and Alex are getting married ! ', ' Wow that ’ s great news ! They ’ re a great couple ! ', ' I know ! Anyways I just talked to Alex ’ s best man and he is organizing the bachelor party It ’ s gonna be so much fun ! All the groomsmen are thinking up all the wacky and crazy things we are going to do that night . ', ' You aren ’ t going to a strip club , are you ? I don ’ t want you getting a lap dance from some stripper with the excuse that it ’ s your friends party . ', ' Aw come on ! It ’ s just some innocent fun ! You know how these things are ! We are gonna play drinking games , get him some gag gifts and just have a good time . Nothing too over the top . ', ' Well , I don ’ t know . ', ' Come on ! If one of your friends was getting married I wouldn ’ t mind you going to her bachelorette party ! ', ' Good , because my friend Wendy is getting married and I ’ m organizing her party ! ']
['Aren ’ t you interested in watching the Olympics ? There have been some excellent performances by athletes from all over the world . ', ' I just don ’ t find it very interesting . ', ' I think it ’ s wonderful to see people from all over the world taking part in such a great event . ', ' I think that for a lot of people , it ’ s just a way to try and show their country is better than other countries . ', ' I think the Olympics help to promote world peace . ', ' I ’ m not sure about that . We still have many wars in the world . I think that the idea behind the Olympics is a good one , but the reality is that during the Olympics countries compete . There ’ s no real spirit of cooperation and people are usually not very friendly to each other . ', ' You are so pessimistic ! The Olympics is a great opportunity for athletes to demonstrate their speed , skill , agility and strength . Most people hope to see someone from their country win , but I think that they are just happy to see good performances by any athlete . ', ' Well . I think that the most amazing performances are by athletes who participate in the Paralympics . ', ' Now there we are in agreement ! ']
['You have a lovely house , Jack . ', ' Thank you . But a number of things have been going wrong lately . ', " That's too bad . What problems are you having . ", " Oh , the whole house needs re-painting for starters . The carpet in the living room is worn out , and I'd like to put in new wall-to-wall carpeting . Last week , I had to call the plumber to fix the toilet . Anyway , all par for the course when you own a house , I guess . I think I am going to hire an interior decorator to look the place over . ", ' I ’ Ve studied home decoration as a hobby . Could I make some suggestions ? ', ' Go right ahead . ', ' Well , I think a crystal chandelier would look great in your living room , and maybe some new drapes for the windows . Also , a grandfather clock would look great in the den . Perhaps you could buy some potted plants for the dining room ', ' Well , you really do have a talent for this , Alice . Thanks for the suggestions . ', ' You are welcome , Jack . Glad to be of help . ']
['What are you hiding in your coat pocket ? ', " It's a camera . ", ' You want to take pictures of the inside of your pocket ? ', ' Not even funny , Billy . This is my new snapshot sticker camera . ', " What's that supposed to mean ? ", ' Well , there are adhesive strips on the backs . You can stick them anywhere . ']
['Sorry.What was that you said ? ', " I'll meet you at the Gate round about seven . ", ' Where ? ', ' At the Gate . ', ' When , did you say ? ', ' Round about seven . ', " Who's coming ? ", " Peter.Peter Brown , you know.Don ' t forget to bring the letter . ", " Sorry . I didn't quite catch what you said.There ' s a lot of noise outside . ", ' I told you not to forget to bring the letter . ', " Loretta ? No , she can't come , she's busy . "]
["I broke my sister's mirror . I'm sure it'll get her back up . I really don't know how I can escape the punishment . ", " You'd better tell your sister what happened and face the music . "]
['My accountant thinks she can save me lots of money on my taxes this year . ', ' That sounds great ! ']
["How's it going ? ", " I'm in a good mood today , actually . How about you ? ", " To be honest , I'm a bit fed up . ", " What's wrong ? ", " There's a girl in my company that I really like but I always get shy when she is around . ", ' I see ! Do you want to ask her out ? ', ' Sure , but how ? ', ' You can ask her out for drinks after work . ', " But for what reasons ? She doesn't even know who I am . ", " Then you've got a lot of work to do . You need to get her to notice you first . ", ' Easier said than done . ', " You can start by meeting her at the bus stop and saying ' hello ' to her . ", ' But I always get tongue-tied when I see her . ', " That's something you need to overcome . Men should make the first move as most girls prefer being chased . ", " I see . I'll try . ", ' Good luck ! ']
['Excuse me . May I come in ? ', ' Sure . Come on in . ']
["i saw lily for the first time . and fell like i'v been struck by lightening.she is a girl of my dreams . i have a date with her on Friday , but i really can't decide what to do . ", ' what about taking her for a dinner or a movie ? ', ' not bad , any other ideas ? ', ' well , there is a play on campus this weekend . ', " good idea . that ' s why i think i have culture . you have any other suggestions ? ", " what's the matter with these ideas ? ", ' They are good , but i still need a few more . ', ' what about going on a picnic ? ', ' Cool , but what if the weather is not ideal ? ', ' you can also take her to the art museum or a cafe . Certainly , i must come up with something you can use . how do you like the ideas i am giving you ? ', ' they are all good . ']
["Hi , Sue . What's up ? ", " Hey , Andrew . How's everything with work ? ", ' Ok , I guess . My boss has been on my back recently . ', " Really ? What's he been doing ? ", " You know , just giving me lots to do . I'm really busy right now . ", ' Are you ? What are you busy with ? ', ' Oh , lots of things . Mostly training new people . ']
['Hey , Karen . Look like you got some sun this weekend . ', ' Yeah ? I guess so . I spent the weekend at beach . ', ' That ’ s great . Where did you stay ? ', ' Some friends of my parents live out there , and they invited me there . ', ' So , what did you do out there ? I mean besides bask in the sun , obviously . ', ' I jogged up and down the beach and played volleyball . You know I never realized how hard it is to run on sand . I couldn ’ t get through a whole game before I had to sit down . ', ' Not to mention cooler . Did you go swimming ? ', ' I wanted to , but the water is too cold , and I just wetted in up to my knees . ', ' It all sounds so relaxing . I wish I could get away to the beach like that . ', ' It looks like you could use it . Don ’ t tell me you spent the weekend in the library again . ']
['Jenny , are you having fun here ? ', ' Yes , of course . This is really a nice party with wonderful people and lovely wines . ', ' I ’ m glad you ’ re enjoying it . ', ' Thank you for the invitation . ', ' It ’ s my pleasure . Would you like another glass of champagne ? ', ' Yes , please . Thank you for everything . ']
['Excuse me , do you know where the visa office is ? ', ' Yes , I do . I ’ ll walk you there . ', ' Thanks . ', ' Are you applying to study or work abroad ? ', ' I want to study abroad . ', ' What do you want to study ? ', ' I hope to study English Literature . ', ' Have you got your visa yet ? ', ' Not yet . I have an interview with a visa official today . ', ' I see.Is it your first interview ? ', ' No , I ’ Ve already been here for 3 interviews . ']
['Do you have a park in the city ? ', ' Yes , there is a lake in the park . It is very beautiful . ', ' That ’ s great . We can go boating on the lake in the afternoon . ', ' It ’ s a good idea . But I am afraid it ’ s too cold . It is very windy on the lake . ', ' Then we can take a walk and enjoy the scenery in the park . ']
['It is difficult for old people to do away with old ideas . ', ' So the reform can not be carried out well . ', ' The government is making efforts to change situation . ', ' Easier said than done . ']
['The sun is up ! Time for all the campers to rise . Time to get paddling . ', ' Oh , no ! No more paddling ! My arms are sore ! ', ' Do not worry . Today will be easier . ', ' Beth , what date is today ? ', ' Today is Saturday . ', ' What is the date today ? ', ' Today is July 4th . ', " Oh , i almost forgot . Today is my mom's birthday . ", ' Call her on my cell phone . Wish her “ Happy Birthday ! ” Tell her you are out exploring the great American wilderness . Tell her I said she is lucky to be born on Independence Day . ', ' Thanks ! I will do that ! When is your birthday ? ', ' It is December 25th . ', ' Wow ! What a lucky girl ! Your birthday is on Christmas Day . ', ' Yes , I am lucky . I was born on Christ ’ s birthday . Maybe that is why I usually go to church on Sundays . When is your birthday ? ', ' April 2nd . I missed being a target of a lot of jokes by one day . I guess I am lucky , too ! ', ' That is true ! Here , have some Granola for breakfast . ', ' Thanks . ', ' After eating , we will take down our tent . Then we will pack everything into the canoe , We can shove off by 6 ', ' I guess so . ', ' How about going for swim around 10 ', ' That should work out great . You are miracle worker ! You have got me awake and motivated . ', ' Happy Independence Day ! ']
['Jane , what do think about this dinner ? ', ' Very good ! Chinese food rules ! I expect the next time . ']
['The band is pretty good . How do you like the music ? ', " it's very nice . I haven't heard live music in a while . This is fun . ", ' well , then , may I invite you for the next dance ? ', " of course . But I'm afraid I'm not much of a dancer ... ", " don't worry . I'm not much of a dancer myself . ", " you're dancing so well . ", ' you dance beautifully too . ', ' when did you learn to dance ? ', " in college . But I don't dance very often . What's your favourite dance ? ", " it's hard to say . It depends . But I love the waltz . ", ' how about tango ? ', " oh , I like it . It's such a beautiful dance , but I can't do it well . What about you ? ", ' Tango is my favorite . Anything but hip-hop or the foxtrot . ', ' thank you for the dance . ', " my pleasure . Let's go and have a drink . ", ' ok . ']
['Bang ? ! Bang ! Bang ! What are the Kings doing at seven o ’ clock on Sunday morning ? ', ' Well , Mr . King is singing . ', ' Yes , but what ’ s the banging noise ? ', ' He ’ s standing on a ladder and banging some nails into the wall with a hammer . Now he ’ s hanging some strong strings on the nails . ', ' And what ’ s Mrs . King doing ? ', ' She ’ s bringing something pink for Mr . King to drink . Now she ’ s putting it ... OK . ', ' What ’ s happening ? ', ' The ladder ’ s falling ? ', ' What ’ s Mr . King doing ? ', ' He ’ s hanging from the string . He ’ s holding onto the string with his fingers and shouting to Mrs . King . ', ' And is she helping him ? ', ' No , she ’ s running toward our house . That ’ s her ringing the bell . ', ' Well , I ’ m not going to answer it . I ’ m sleeping . ']
["Mr . Wilson , here's a present for you . ", ' Oh , you are so nice . What a lovely scarf . ', ' I hope you will like it . ', ' Of course , I like it very much . Thank you . ']
['Would you like to go to the theater with me tomorrow ? ', ' Yes , of course . Have you got the tickets ? ', " That's coincidence , someone's just returned two tickets and I picked them . ", ' Matinee or evening ? ', ' Evening . ', ' Circle or stalls ? ', ' Stalls . ', " Wonderful , I'll go with you . "]
['I need to find somewhere to park . ', ' Off campus or on campus ? ', ' I need to find a space on campus . ', " Why don't you park in the parking structure for students ? ", ' Where is the parking structure at ? ', " It's on the west side of the campus . ", ' Do you know if the parking structure is full or not ? ', ' It was empty last time I went up there . ', ' How long ago was that ? ', ' I went up there early this morning . ', " Do you think it'll be full now ? ", " It might be . You'll have to go see for yourself . "]
['Shall we go to cinema this evening ? The new blockbuster starring mel gibson is showing . It ’ s supposed to be really good . ', ' What kind of movie is it ? I don ’ t like many of his movies , actually . ', ' It ’ s a thriller . It has Julia Roberts playing the female lead . ', ' I like thrillers and I like Julia Roberts , so it might be interesting . I read a review today and the critic didn ’ t seem to be very impressed . ', ' What did the critic say ? ', ' He didn ’ t say it was bad , but he said that it wasn ’ t as good as it could have been , particularly as there were some good actors and actresses in it . ', ' The movie starts at eight o ’ clock , so we have plenty of time to eat and get ready . ', ' Good . Dinner is nearly ready and I ’ d like to watch the news before we go . The Oscars were last night and I want to see the results . ', ' I won ’ t spoil your enjoyment by telling you who won . There were a few surprises . ']
['this is tough to say , Jordan , but I think we should break up . ', ' are you serious ? ', ' yes , I mean it . ', ' but why ? Did I do anything wrong ? ', ' no , we are just too different . This isn ’ t working . ', ' hey , come on . It ’ s too early to say that . We can fix things . ', ' I have thought about it for a while . I think it ’ s time to move on for both of us . ', ' but I still love you . ', ' I ’ m sorry . ', ' I knew this would happen some day ... ', ' then why didn ’ t you talk to me ? ', ' well . It ’ s not all my fault , Anna ... ', " I don't want to argue with you anymore . This is going to be tough , but Let ’ s try and be friends . ", ' I would like that Anna , but I think I ’ ll need a little space for a bit . ', ' I think we ’ ll be better off if we are apart . ', ' shall we keep Our friendship ? ', ' sure , let ’ s just be friends . ']
["Our company's wei-ya is tomorrow night ! It's your first Chinese New Year in Taiwan--you must be excited ! ", " Excited ? What's there to be excited about ? It's just another company dinner , right ? ", " You have no idea ! There's a banquet with prizes , performances ... you name it ! ", ' Really ? What kind of prizes ? ', ' Well , I heard that last year Vivian from accounting won a new car ! ', " A new car ! You're kidding ! ", ' No , really ! And she told me the secret to winning , wear red underwear ! ', ' Wear red underwear ? ! Does that really work ? Are you going to try it ? ', " Of course ! I'm not only going to wear red underwear , but I'm going to wear red socks and a red shirt , too ! ", " Gee , I don't think I own any red underwear , but I can buy some ! "]
['Have you ever witnessed any crimes or accidents ? ', " I don't quite remember . Why did you ask that ? ", ' I was taking a walk in the park early this morning when suddenly I heard someone calling " help " . I rushed over and saw a man beating a woman . ', ' Oh , my . What did you do ? ', ' I guess I was stunned for a moment , then I quickly ran away to get help . ', ' Did you call the police ? ', ' Yes . Fortunately , I had my cell with me this morning . I called the police as I was running to get people to come to help . ']
['I heard that you went to the concert the day before ? How did you like it ? ', ' It was terrific.The concert was really a hit.The symphony orchestra was so good that I was completely absorbed in their performance . ', ' Who was the conductor ? ', ' Oh , speaking of the conductor , he is indeed a genius.He did a perfect job.His name is Menuhin , a descendent of Russian American immigrants . ', ' Oh , I learned that he is also a legendary violinist . ', " Absolutely right.He gave a performance of Felix Mendelssohn's violin concerto.That caused a sensation.The audience were stunned by his pure tone . ", ' Obviously you did enjoy the concert . ', ' Yes , I did . ']
['Have you heard about Alice and David ? ', ' No , have they had another fight ? ', " No , they've got engaged . ", ' You must be joking . Those two ? ', " Well , my dear , I didn't believe it either . But I got it straight from the horse's mouth . David called me this morning . ", ' So when did this all happen ? ', ' Last weekend , while they were on their ski trip . ', ' Well , I believe it now , and when are they are getting married ? ', ' Next June . ', ' I can hardly believe it . ']
['All the routine work really browns me off . ', " Oh , come on.You ' Ve just started . ", " I wish I hadn't chosen this job . "]
['Yuck . The carrots taste awful and salty . Hi sis , how do you like them ? ', ' I like them very much . They are delicious . ', ' Well , you can have all my carrots . ', ' Daniel , hold on for a minute . What are you trying to pull there ? ', " Nothing . Just that I don't care for these carrots.Hi , sis . , I saw you buy some chocolate cakes . I am done with the main course . It's about time for some dessert . ", ' Oh , you want my chocolate cakes , so to speak ! ', " No , no , I'm just thinking of some dessert . And I have had enough carrots . ", ' Daniel , carrots contain much Vitamin C . It is good for you . ', ' I know , but chocolate cake is even better . ', " Oh , stop it ! You know you need vegetables . You will end up fat if you don't watch your diet , now . ", " Well , actually , I don't mind eating carrots , but chocolate cakes are much better . You know I was born with a sweet tooth . "]
['Oh , no ! I ’ Ve been assigned to work with Jerry for our group project . ', ' Oh ! I heard that he loves to boss people around . ']
['Flowers for my favorite girl . ', ' How did you know that I love red roses ? ', " That's a secret . Here , let me help you with your coat , and we'll be on our way . ", ' ( at the dance ) That band is playing good music . Shall we dance ? ', ' Fine , what do you call this ? ', " Foxtrot . Oh . you're a good dancer . ", ' Really ? Thank you . I am thinking the same thing about you . ', ' I prefer the old style of dance because I enjoy holding a pretty girl like you closely . ']
['On Saturday night I ’ m going to have a small get-together . ', ' Good . ', ' Would you like to come ? ', ' Do you mean this Saturday ? ', ' Yes , this coming Saturday . ', ' Thanks for inviting me , Jack , but I ’ Ve already made plans for this weekend . I won ’ t be able to come , I ’ m afraid . ', ' I ’ m sorry to hear that . ', ' Yeah , that ’ s too bad . ', ' Well , perhaps , another time . ']
["Hey . I'm a visitor from China . I love your music . It's the best I've ever heard . Will you please spare a little bit of time for me ? ", ' Sure . Thank you for saying that . Actually , those songs were sung for the first time today . I wrote them in the past two months . ', " Oh , you wrote them all by yourself . That's amazing ! Are you a regular singer here ? ", ' You can say that . But my band and I also sing regularly in several other places , too . ', ' Cool . Your guitar skills are very impressive . How did you learn to play like that ? ', ' I picked up guitar at an early age , maybe around 8 years old . Afterward , I taught myself by listening to some records of top players . ', " Wow , that's unbelievable ! You play so well , but you've never been to a real teacher . You will definitely be famous in the near future . "]
['Could you come and spend the weekend with us ? ', " Oh , I'm afraid I can't . I've had a date already . ", " That's too bad ! ", ' Maybe some other time . ']
["Excuse me . I don't think we have met before . My name is Mary Jenson . ", " Oh , hello . I'm Bias Chettri . ", ' Good to meet you , Mr Chettri . ', ' Pleased to meet you too , Ms Jenson . ']
['Welcome to our university ’ s fifties anniversary , Sir . Please have a seat . ', ' Thank you . Wow , your school has so many honors . Congratulations ! ', ' Thank you . ', ' Excuse me . I wonder see Dean Mr . Lee first . I was wondering if could you tell me where his office is ? ', ' Certainly . Mr . Lee ’ s office building at the south end of the campus , just beside the library . ', ' Excuse me ? ', ' Let me show you the way . Please follow me . ', ' Thank you very much . It ’ s very kind of you . ', ' My pleasure . ', ' This is it ? ', ' It ’ s up on the second floor . You have to use the stairs . The elevator isn ’ t working . ']
['Finding an excuse is obviously down your alley . And trying to avoid taking care of the children is what you are good at . ', " Listen , Nancy . If I don't work hard , I will be laid off . ", " You are passing the buck . I'll be hanged if I ask you to go to the park with us . ", ' Come on , Nancy . Play it cool . I go with you and burn the middle night oil tonight . ']
['Hi , Mr . Zhang . What ’ s wrong ? You don ’ t look so happy . How was your date ? ', ' I was turned down again . It ’ s frustrating . I guess you ’ Ve got to teach me some skills . ', ' Me ? I ’ m even less experienced than you are . ', ' At least you know what American women generally like in a man . ', ' Believe it or not , I guess American women like a man in good shape , which Chinese women may not care about so much . That ’ s my honest opinion . I know you have been trying very hard . ', ' American men are naturally taller than Chinese men . So even if I exercise , there aren ’ t many chances . ', ' No , that ’ s not true . I ’ Ve met two American women who were married to Chinese . But those Chinese look very strong and healthy . So if you exercise more often , I bet it will surely be easier for you to date American girls . How old is Jacky Chan ? He ’ s small and short . But I bet he can have any American woman he wants . ', ' You know , that ’ s going to be a tremendous change for me . Because I never exercise . ', ' Why don ’ t you try then ? Even if it doesn ’ t help you find an American girl , you could still have a stronger and healthier body . You won ’ t lose anything by doing that . ']
['Have you heard that new song by the Beastie Boys ? ', ' Why do you listen to rap ? ', " It's not much different from that heavy metal music you like so much . ", ' Heavy metal music is a lot different from rap music.You can dance to heavy metal . ', ' Hey , you can dance to rap music ! ', " I can't dance to it . And I know you can't either . Because I've seen you try . "]
["What's your new girlfriend like ? ", " Katherine ? Well , she's good at languages . ", ' Does she know how to speak Spanish ? ', ' She knows how to speak Spanish and Japanese . ', ' Wow ! ! ! ', " And she's good at sports , too . She knows how to play tennis and basketball . ", " That's terrific ! ", " But there's one thing she's not good at . ", " What's that ? ", " She's not good at remembering things . We have a date , and she's an hour late ! ! "]
['Are these your text books ? Biochemistry , General Ecology , Botany , Cell Genetics , Molecular Genetics ... ', ' Yes . I gotta review all of them for the final exam . It is just around the corner . ', ' Oh , right ! Do you have many exams at the end of each semester ? ', " That depends . Some semesters have many , some don't . And some courses don't have exams but only ask for papers . That's easy . ", ' And when do you prepare for your final exam ? ', ' Honestly speaking , most students prepare it one month before the exam . ', ' Really ? You only review your lessons in one month ? Does it work ? ', " Of course , it's useful . And it's very crucial to have the copies of teacher's notes , because most questions in the exam are based on them . ", " Wow , and all the key points are included in them ? You're so smart ! ", ' But the exam is not as simple as you may imagine . We have to stay up late . ', ' Do you have the classrooms open for the whole night ? ', " Yes , some people even pack up his bed quilt and sleep there . That's a little bit crazy . "]
["What's today's date ? ", " It's January . "]
['You know , Mary , I feel we meet somewhere before . Where were you born ? ', ' I was born in Beijing , but I spent most of my childhood in London . ', ' What was your childhood like ? ', ' I had a pretty strict upbringing , and my parents taught at universities so they have extremely high expectations for me . ', ' Where did you go to university ? ', ' My parents wanted me to stay in Beijing , but I decided to go back to England . I graduated from University of Newcastle upon Tyne with a degree in Cross Culture Communication . ', ' What is your current occupation ? ', ' I am a journalist . I write for China Daily . ', ' Did you know that you wanted to be a journalist right after your graduation ? ', ' No , I didn ’ t . I started working at a university in London but as time went by , I found I did not really like my job . I decided to explore other fields . Journalism is great fit for me as well as a challenge . ', ' Do you like your current job ? ', ' Yes , I came to Beijing two years ago looking for new opportunities . I was lucky because my friend introduced me to my current company . ']
['Do you want a cigarette ? ', " No , thank you . I've given up , you know . ", " You don't mind if I have one . ", ' Well , all tight . But you know , smoking does do harm to your health . ', ' Yes , you are right . ', " Why don't you try and give it up ? ", " I've tried to give up smoking several times , but it's no use . "]
['Hey , Jordan , is that you ? Long time no see ! ', " Oh , hey , no kidding ! I haven't seen you since orientation three months ago ! So how've you been ? Settling into college life OK ? ", " Yeah , I think so ! I pledged Phi Iota Alpha , so I'm living at the frat house now . ", " Oh , so you're a frat boy now , huh ? ", " Yeah , yeah , I know , it's totally cliche , but really , I think it's been a good decision . I've got a lot of support and good suggestions from the guys . What about you ? What have you been up to ? ", " Not much . I'm still living at home and commuting to school . I ended up dropping that metalworking class I was so excited about . It just wasn't as interesting as I'd hoped . The guidance counselor suggested that I focus on my prerequisite courses so that I can make sure the credits count . ", ' That sounds smart ... but kind of boring . ', " Yeah , it is , a little bit . I joined the Great Outdoors Club , though , which has been a lot of fun . We've gone on two camping trips already , and I've made some good friends . ", " That's cool . Hey , so have you decided on your major yet ? ", ' Definitely pre-med . What about you ? ', " I still have no clue ... but we don't have to declare a major till our sophomore year , so I've got time ! Oops , I'm late for class . Gotta run ! ", ' OK , take care ! Hey , nice running into you ! ', ' Yeah , you too ! ']
['Whatever we do , we should do it above board . ', " You are right . We shouldn't do anything under the table . ", ' Well , since you agree with me , we should put the issue above board instead of talking about it through other channels . ']
['How did you get into hip hop ? ', ' Well , all my friends listen to it , so I became a big fan too . ', ' Who is your favorite hip hop artist ? ', " I'm a big fan of Snoop Dog . "]
['It ’ s over . ', ' What is over ? ', ' Our relationship . I mean my friend and I ... ', ' Any reasons ? ', ' The cause is another boy . ', ' Oh , that ’ s too bad . ']
['How did you do on your BELTS exam ? ', ' Fantastic ! I got an overall score of eight . ', " That's excellent ! Have you received your conditional offers yet ? ", " Yes . I'm just waiting until I officially get admitted to the university with a conditional offer to apply for my visa . ", ' Do you know where the visa office is ? ', ' No . ', " It's just near the Dong Si Shi Tiao subway stop . "]
['We ’ Ve been over this a thousand times . The data is irrefutable ! Look , we ’ Ve done extensive research , built studies , and read the literature , and there is conclusive evidence to support my theory ! ', ' Horowitz , I beg to differ . Even in your most recent study , the investigative approach was flawed ! You know as well as I do that the collection of data was not systematic , and there is a large margin of error . To draw a definitive conclusion based on that data would be misleading ', ' That is preposterous ! ', ' You are trying to single-handedly solve one of the world ’ s greatest mysteries , and yet you are oblivious to the fact that you are wrong ! ', ' I am not wrong ! The chicken came first ! ', ' No ! The egg came first ! ']
["My husband goes out drinking with his friends every night . I'm fed up with it . ", ' Maybe you two should go see a marriage counselor . ']
['Charles , have you finished your homework ? ', " Not yet , Grandma , What's the matter ? ", ' I want you to have a walk with me . ', " I'll finish soon . "]
['Did you lock the doors ? ', ' All except the back door . I left that open for Tim . He took the dog for a walk . ', ' Well , I ’ m going on to bed . I ’ m beat . ', ' Ok , I ’ m going to stay up awhile . I ’ Ve got to go over the household budget , We ‘ re a little over-spend this month . ', ' Please told Tim to close the door to the basement . I don ’ t want dog down there tonight . ', ' Ok , Good night , see you at breakfast . ']
['Have you ever played Making ? ', ' Not really , but I know it is very popular a traditional Chinese gambling game . ', ' Yes , some friends play it all day , all night , and sometimes a whole weekend . I tried to read about some basic rules online , but it is hard to understand . So I went to watch people play yesterday only to find I was even more confused . I think I have to work hard on those rules and more learning by doing . Practice makes the master . ', ' Typical Francis , whether you are at work , or engaged in leisure time activities , you always show the same eagerness and curiosity to learn something new and improve yourself . ', ' It is important to keep your mind up-to-date and active . ']
['My German teacher thought it would be a good idea to have German pen friends to write to in German . ', ' What a great idea ! Now you have a friendly audience to practice with ! ', ' The only thing is that my pen friend will be writing in English . ', ' Oh , he wants to practice his language skills , too . ', " That's right . And it's a B that I'll be writing too . Her name is Olga . ", ' Maybe Olga can introduce you to some of her friends who can write to you in German and you can do the same for her with your friends to write her in English . ', " That's a great idea ! Why didn't I think of that ? ", " I don't know , but you know how to surround yourself with great friends ! "]
['I just had a terrible week . ', ' What a shame ! ', ' I fell down and hurt my arm . ', " That's too bad . ", ' Then my son drove into a tree ', " I'm sorry to hear that . ", ' The dog bit the delivery boy . ', ' What a pity ! ', ' And a storm blew our roof away . ', ' Ho , no ! ']
['Hi , Jenny . You look like you are in a hurry to somewhere . Where are you going ? ', ' I am going to the bank . I need to cash some checks . ', " That's great . We can go to the bank together . ", ' Why are you going there ? ', ' I will go to Japan on business for 5 days next Tuesday . I want to exchange some Japanese yen . ', ' I see . Will you bring a lot of money with you ? ', ' Not really . I plan to bring some cash and withdraw money at the ATM in Japan . ', ' Do you have the bank card in Japan ? ', ' Nope . You can use the credit card to withdraw the money in foreign countries . ', ' That sounds really convenient . Do you pay extra money to enjoy this service ? ', ' No . It is free of charge . ', ' Great ! I will apply for a credit card when I go to the bank later . ', ' I think we are running out of time . The bank is going to close soon . ']
['Does she make any sense to you ? ', " No . It's all Greek to me . ", " She's speaking French , not Greek . ", " I know that . I mean I couldn't understand her at all . ", ' Me neither . All I have to do is study French hard . ', ' I wish you the best of luck . ']
['Do you love me ? ', ' I ’ m very fond of you . ', ' Yes , but do you love me ? ', ' Why ? You mean a lot to me . ', ' Why didn ’ t you answer my question ? ', ' What question ? ', ' Do you love me ? Come on , I ’ m eager to hear . ', ' You know that I care for you . I---I ’ m proud of you . ', ' Don ’ t cherish your words , dear . ', ' I---I don ’ t feel like saying it ']
['What do you do in your spare time ? ', ' I have many hobbies . I like almost all kinds of sports and I also like to listen to classical music . ', ' What kinds of sports do you like ? ', ' I like playing basketball . Basketball is a very exciting game because it keeps you alert and I also enjoy the team spirit of basketball . ', ' Who is your favorite author ? ', " I like the novels of Dickens very much . I've read almost all of them in Chinese translation . ", ' Are you a music lover ? ', " Yes , I like listening to Beethoven's works . ", ' What kinds of films do you enjoy ? ', ' I like all kinds as long as they are exciting . ']
['Do you have any hobbies ? What is it or what are they ? ', ' I am interested in watching TV or other relaxing games . ', ' How do you spend your spare time ? ', ' I usually read or entertain myself . ', ' What kind of books are you interested in ? ', ' My favorite books are those about detectives . ', ' Well , those books are really good . I like them too . How do you entertain yourself ? ', ' When it comes to the entertainment , I think I enjoy dancing . There is nothing I like more than modern dance . ']
['It depends on where you are and what position you are in . For instance , if you are in an elevator and you smile , you will make other takers uncomfortable . ', ' That ’ s an exception . But I am fed up with those who keep a straight face in front of me . ', ' I cannot see eye to eye with you here . You see , I am fed up with those who keep smiling to me . I mean , they smile for no reason at all . ', ' That means you don ’ t like them . If you hit it off with them , you will like to see their smiles . ']
["It's nice and bright today , isn't it ? ", ' Yeah.The autumn is marvelous here . ', ' How about winter ? ', " That's a hard time.The air is cold and damp , and the road is often icy . ", " It's boring , right ? ", ' Sure . ', ' Do you get much rain during the summer ? ', ' Plenty.We never worry about lack of rainwater in our area . ', ' So you should bring an umbrella often . ', " That's right . "]
['I ’ m betting the New York Yankees win . How about you ? ', ' Well , I ’ m favor of the Red Sox . They ’ Ve had a good season . ', ' Sorry , guys . Could I just interrupt for a moment ? My money is on the Yankees ! ', ' That ’ s not a very good pick . I ’ m against the Yankees . ', ' Hey , Ken . Good luck if you already put your money on the Red Sox . ', ' Yeah , I ’ m with you on that . ']
['When in Rome , do as the Romans do , they say . ', ' What do the Romans do ? ', ' They live in Rome , of course , and go to work by car or bus . But sometimes it takes too long that way because of the traffic jams , so they walk . ', ' In other words , the Romans do what everyone else does . ', ' Yes , but they do it differently . Everything is different . ', ' What do you mean ? ', " Well , the climate's different for a start . It doesn't rain so much as it does in England . The sun shines more often . ", ' I envy them the sun . ', " I know . You hate the rain , don't you ? ", ' I certainly do . ', ' And a Roman really Ioves life . Eye knows how to enjoy himself . ', " They always eat spaghetti and drink wine , don't they ? ", ' Not always . But they like a good meal . Lots of tourists go to Rome just for the food , you know . ', ' Really ? How much does it cost to fly to Rome ? ', " I don't know exactly , but it costs a lot of money . "]
['What does your mother do , may I ask ? ', ' My mother works in a company as an accountant . ', ' Is she busy ? ', " Not always , she's rather busy at the end of the year . "]
['Please fill out the form . ', " All right . ... What's the date today , please ? ", " It's August the thirteenth . "]
['Are you going to the cafeteria downstairs ? ', ' Yes . ', ' Could you please get me a takeaway ? I have some urgent work to finish . So I don ’ t have enough time to go out for lunch . ', ' No problem . What should I bring ? ', ' I am not picky on food . Just bring me the day menu . ']
['So , are you enjoying the performance so far ? ', ' Well , the costumes and the set are marvellous , but the acting is a bit stiff . What do you think ? ', " I think you're being a little critical . The actor in the lead role is fantastic . I suppose the chorus could be a bit better , though . ", ' Do you know anyone in the play ? ', ' Actually , the woman playing Ophelia is a past classmate of mine . ', ' Really ? Is that why you wanted to come to the play ? ', " That's only part of it . I absolutely adore this director . Every play he works on turns out great . ", " So you've seen other plays that he's directed ? ", " Quite a few actually . By the way , after the play , there's always a big party for the cast and their friends . My friend has invited us . Do you want to go ? ", " Sure , I'd love to meet the cast ! Have you ever been in a play ? ", " I've never had a part in a play before , but I used to be a part of the stage crew in high school . ", ' What did you do ? ', ' I helped build the sets and find props for the plays . What about you ? ', " I once helped out with costumes , but I didn't enjoy it very much . ", ' Why not ? ', ' I spent over three weeks sewing sequins on a coat . ', " That sounds kind of boring . Oh , look . They're dimming the lights . I think we should get back to our seats for the second half of the play . "]
['Many congratulations on your winning the game . ', ' That ’ s very kind of you , but it ’ s nothing special . ', ' You were doing great out there ! ', ' Well , actually it ’ s just about luck . ']
["That's good to know . We'll watch for crazy drivers . ", ' Hey , guys . Ready for a pick-up game of touch football ? ', " Football ? Sounds dangerous . Maybe I'll just be a cheerleader . ", " C'mon , Yi-jun . It's lots of fun . You've seen football played on TV . ", " Uh , yeah . And I've seen guys in pads tackled . We have no pads . I don't want to be tackled . ", " There's barely any contact in touch football . People just tag you to stop the play . ", ' OK , but they better tag lightly ! ']
['Hi , Cindy . I thought I ’ d missed you . ', ' Oh , I am very sorry , Hans . Thank you for waiting for me . You must have been here a long time already . ', ' It ’ s all right . ', ' I was caught in the heavy rain , or I would have come earlier . I am sorry I kept you waiting . ', ' I was in a comfortable place , so really , it ’ s no problem . I am happy to see you . Did the rain hold you up long ? ', ' Yes . When I came out of the subway , it was raining cats and dogs . And I forgot my umbrella . So I had to wait for the rain to let up . ', ' I totally understand . ']
["How's your thesis going ? ", " Don't mention it . The thesis due date is coming , but my thesis isn't even close to being done . ", " I've finished the first draft , but the professor said it's poorly written . I have to rewrite it . it's so depressing . ", " Don't worry . Anyway , you are better than me . "]
['I am trying to decide what school to apply to ? ', ' Are you thinking about a public school or a private one ? ', " I am not sure . What's the difference between them ? ", ' Public schools are usually state funded , whereas private schools usually get their funding elsewhere . ', ' Which is better ? ', ' One isn ’ t necessarily better than the other . It depends a lot on the school administration and the teachers . ', ' I hear you have to wear uniforms at private school . ', ' Yes , sometimes . ']
["You'll soon graduate from your university . Do you have any plans for the future ? ", " I'm planning to go to graduate school , but I also want to find a job . Otherwise , I'll have nowhere to go if I fail the entrance exam . ", ' Do you have a clear career path to follow ? ', " career path ? I'm not sure . ", ' what kind of job do you want after graduation ? ', ' I want to become a professor , a lawyer , an editor , a civil servant ... ', " wait ! You can't do so many things at the same time . What exactly do you want ? ", " I don't know . Do you have any advice for me ? ", ' yeah , you should first decide what kind of career you really want , plan your career path , and then try your best to achieve your goal . ', ' I think perhaps I need to buy a few years while I figure out about my career . ', " no , you can't waste your time wandering around . If you want a job that requires a higher degree or diploma , you should focus on your graduate school entrance exam ; if you want a job that needs working ", " thank you so much for your advice . I'll think it over . "]
['Look at these clothes designed by top fashion designer like Versacci , Calvin Klein , and Vivienne Westwood . What do you think of them ? ', ' Well , they look lovely , but they ’ re not very practical . I mean , would you wear that dress to the office or walking down the street ? ', ' I know what you mean . People would stare at you in amazement if you wore something like that in an everyday situation . I suppose only extravagant rich people wear them at cocktail parties . ', ' Maybe . I ’ m not sure why they have fashion shows like this . Hardly anyone will buy those clothes . The clothes you see are nothing like the ones that ordinary people wear . It seems like a waste of money . ', ' I think that the designers hold these fashion shows for a few reasons . First , it ’ s just like a big party . They can meet each other and network . The other thing is that it is great advertising . All the journalists and photographers are there . Thirdly , it give them a chance to show what they would like to see people wearing . ', ' You meant it ’ s an expression of their fantasies ? ', ' Yes . I think the designers are saying that these clothes are what they would like to see people wear if those people weren ’ t concerned with what other people might think . In a way , the designers are saying ‘ don ’ t worry about what others think . Wear what you like ! ’ . ', ' Very philosophical . I think they design these clothes more for publicity . They try to see who can be the most extreme and outrageous , but still stylish . ', ' Come on . All this fashion has reminded me that I want to buy some clothes . ']
['David , I ’ m going to China . ', ' Really ? How do you get the chance ? ', ' You know . I took part in the Chinese contest . I was the best and they gave me this reward . I don ’ t have to pay for my trip . ', ' Congratulations . How lucky you are ! ', ' Thank you . I ’ m leaving tomorrow morning . ', ' I ’ m sure you ’ ll enjoy the trip . China is such a beautiful country . ', ' I ’ m sure I will . ', ' Have a nice journey , Lily . ', ' Thank you , David . ']
['Dora , are you interested in going to the museum with me tomorrow ? I read the newspaper this morning . I know there is an art exhibition in Taipei Modern Art Museum . ', ' Sure . I am free tomorrow . It sounds interesting to me . Can we buy the ticket online ? ', " I don't think so . I think we had better go there earlier , or we may have to spend a lot of time waiting . ", ' I guess that is the thing we can do with we really want to visit the museum . ', ' Look at the ticket booth in the center . There seems to be not as many people as we thought it would be . ', " Yeah . We are lucky . Let's go buy the tickets first . We can have breakfast later . I am so hungry . ", ' Good idea . ', ' ( After the breakfast ) Which floor is the art exhibition we are going to ? ', ' I have no idea . Let me take a closer look at my museum map ', ' Sure , take your time . We have a whole day . ', " It's on the 2nd floor . We are going to see some beautiful paintings about the history of ancient Greece . ", " Look at the museum guide.It says there are also some sculptures and potteries in this area . Let's rent an audio guide . "]
['Good afternoon ! ', ' Good afternoon ! Sit down , please.How are you ? ', " I'm very well , thank you.How are you ? ", " Very well too , thank you very much.Isn ' t it a lovely day ? ", " Yes , it's beautiful , but it's also very hot . ", ' Yes . ', " What's the weather like in your country ? ", " Mm ... It's quite warm now . ", ' Where do you live ? ', ' In London.Where do you live ? ', ' Here.Near this school . ']
["I've been looking forward to the new semester . ", ' I hope we can make great progress in this new semester . ', ' Hope so . ', " I hear we'll have a new English teacher this semester . ", ' Really ? I hope we will do much better under her guidance . ', ' I am sure we will . ']
['Post office offer lots of services nowadays , don ’ t they ? Years age , you only really used the post office to send mail , save money , and send or collect money . ', ' Nowadays , they offer so many services , you hardly know which one to choose . Take mailing for example . Do you send something first class or second class or do you use EMS ? ', ' I save money in a post office saving account . There used to be just one kind of account , but now there are several . They each have different conditions and interest rates . ', ' You can buy things at post office that were never sold there before . You can buy sweets and chocolates , newspapers , birthday and Christmas cards ... ', ' Post offices are still the place to go to collect welfare benefits , like unemployment benefit and child support benefit . The queue are very long on the days when people collect those payment . ', ' My son likes going to the main post office . They have a philately counter where he can buy stamps for his collection . ', ' Do you think that the service at post offices has improved ? ', ' I think it ’ s better for some things , like sending and receiving money , but if you need to post something it sometimes takes longer than it used to . ', ' I like being able to buy newspapers and magazines at the post office . It means that I don ’ t need to go to two places ']
["She is really pretty , isn't she ? Her skin looks so baby-smooth ! ", " Well , it's just that she put a lot of makeup on her face . Actually , natural beauty comes from within . ", ' Ah , I can smell jealousy in the air . ', " She has nothing that deserves my jealousy . I don't have to put things on my face and I still look pretty . Don't you think so ? ", ' Yeah , right . But what did you put on your face last night ? Those little greenish things . ', " They are cucumbers . They are natural skin soothers , natural healers of the skin.Haven ' t you heard them say on TV that ... eh ... they soften the skin , wipe out the roughness , counter irritation and build strength and resilience ? ", ' Yeah , yeah , yeah ! They wipe out tight , tired feelings and remove lines and age signs . Blah , blah ... See , I can even recite it . ', " That's right . You have learned a lot , haven't you ? "]
['It sounds that you have a high opinion of him . ', ' He is an all-right guy . I have no bone to pick with him . ', ' Birds of feather flock together . ', ' But he is not a fine wether friend who could sell you down the river . ', ' You cannot judge a person that way . I have a hunch that he is a sly dog . ', ' Depends on with whom . He may be doing things on the sly , but he is honest with me . I trust him . ', ' You can never tell . He might do you in when he sees an angle in doing it . ']
["Welcome ! Welcome to Little Italy . We're the most Italian family here ! ", " So I've heard . That's why I'm having such a great time . ", " If I hadn't married an Italian man , I probably wouldn't be pregnant so often . And maybe I could raise pigs instead of bambinos ! ", " Huh ? Um ... well , it's nice to see that some people still have big families . ", " It is nice , but it would be nicer if my macho husband would get off his tush and help me . Ha-ha ... Have this . It's from Italy ! "]
['What was that noise ? ', ' It was the pilot putting the wheels down.We must be coming into land.Are you frightened ? ', ' Frightened ? You must be joking ! ']
['Two people were robbed last night near the park . ', ' Again ? The area around the park is too dark at night . There should be more lights there . ', ' I am afraid of the dark . I don ’ t feel safe in the dark . I feel someone is hiding in the dark to attack me . ', ' Your feelings might be right . You should never walk alone there at night . It is too dangerous . ', ' I Know . And you should be more careful , too . ']
["Well , that's it . 7 appointments in Paris at beginning of next week , and 4 in Frankfurt at the end of the week . ", " It's certainly a tight schedule . ", " Now it's a question of getting there . I need a flight to Paris on Sunday evening and a hotel in Paris for 3 nights . I have to be in Frankfurt by 11 on Thursday morning . And I will need a hotel for one night . I will head home on Friday . ", ' At what time ? ', ' My last appointment is at 3 , so I should be free by 5 at the very latest . I think I could get to the airport by 6 . ', ' Do you know how far you will be from the airport at 5 ? ', ' No , not really . ', ' So you are not sure how long it will take to get there ? ', " No , but I am sure it won't take more than an hour . ", " Don't forget it's Friday nighty . If Frankfurt's anything like London , everybody will be leaving for the weekend . It will be a rush hour and traffic might be moving very slowly . ", ' You are a pessimist . ', ' I am a realist . ']
['What is the best place to park ? ', ' What vehicle do you usually bring to school ? Is it an automobile or a motorbike ? ', ' I drive a motorcycle . ', ' OK . That means you can park in the student lot or on the street . Have you seen the handicapped spots ? ', ' I am not sure what a handicapped spot is . ', ' Look for the blue signs and blue marked spaces . Do you usually park in the daytime or the evening ? ', ' I park days and evenings . ', ' Be careful about the time limits on the streets . Have you seen the signs for time limits ? ', ' What signs ? ', ' As long as you are careful reading the signs , you will always know how long you can park and what days are OK to park there . Are you aware of the curb colors ? ', ' What curb colors ? ', ' If you can remember that red means absolutely no parking and white means that you can only load and unload , you are going to be OK . ']
['Would you like to play golf with me ? ', " I would like to . but I'm not good at it . ", " It doesn't matter . I will teach you . ", " That's great ! When will we go ? ", ' Borrow morning . ', ' All right . What should I take ? ', ' Just take your golf club . I will pick you up Borrow . ', ' Thanks . I will wait you at my home . ', ' See you Borrow . ']
['Hi , Mike , what gives ? ', ' Hi , Bill , this is my new car . ', ' Hey , great set of wheels . ', ' You like it , huh ? ', " Who wouldn't ? Wow , that's out of this world . ", " It is special , isn't it ? ", ' Yeah , too cool . How much did they sold you for ? ', " Lots . Looks like I'll have to moonlight for the next two years . ", ' I can imagine . ', " Hey , let's go for a spin . You can try it out . ", " I'd love to . ", " Ok , let's go . "]
['Would you like to go to the natural history museum with me ? ', ' Have you ever been to it before ? ', ' Yes , lots of time . I was quite impressed by the wide variety of exhibitions they have . ', " Let's go . It sounds interesting . "]
['Oh , my god ! My wallet is lost . What should I do ? It drives me bonkers . ', ' Dear , don ’ t worry . The police can help you . ']
['Good morning , Mr.Jones ! ', ' Good morning , Miss Bell ! ', ' Nice to see you again . ', " Nice to see you too . It's been a long time . ", ' How is everything ? ', ' Just fine , and you ? ', ' Quite well , thank you . ', ' Did you drive yourself to the airport ? ', ' No , I was driven by my husband . ', ' Did someone meet you at the airport here ? ', ' Yes , thanks . ', " Is this where we'll be holding the meeting ? ", ' No , the meeting will be held on the fourth floor . ']
['Is there a lot of snow in this region at this time of the year ? ', ' Yes , the snow is often falling thick and fast here . ', ' Well , I think I like it . I appreciate the snow very much . ', " Yes , It's really so beautiful with all the things covered by snow . ", ' By the way , where can I go ski ? ', ' There are so many places around . Take a look at the advertisement . ']
['Hi , Sandra . how was your weekend ? ', ' Great ! I went hiking in the mountains on Saturday . ', ' Fantastic ! how was that ? ', ' Really good ! you should try it sometime . ', ' I might . what did you do yesterday ? ', ' Uh , nothing much , just went to bed early . I was still tired from Saturday . ']
['Do you know that scientists replicated a sheep into an identical clone . ', ' I heard about that . It was successful . ', " It's a big jump in science . Maybe more like a leap . ", " I should say , it stunned me . I can't imagine what they will think of next . "]
['She has contributed to a new school . ', ' Oh , I know . She is a famous woman and a focus of the newspaper now because of this thing . ', ' I hear the school is very modern . It has the best equipments . ', ' Yes . Do you know its name . ', ' She said she would name it after her father . ', ' Oh , I think she wants to do this thing in memory of her father . ']
['What are you doing over the weekend ? ', " I'm planing to go bolling tonight.Tomorrow I was hoping to see a movie.What about you ? ", " I want to go camping , you know , just get a way for the weekend . I'm not sure I'll be able to , though . ", ' Why not ? ', " Well , I have a lot of work . I'll see how to goes . "]
["OK , Mr . Wu . You may come in . I'm Anne Smith and on my right , my colleague , Anna Duncan , and on my left , Angela Lamb . Do please sit down . ", ' Thank you . Good afternoon Mrs . Smith , Miss Duncan , Miss Lamb . ', ' Your English is fluent . ', ' Thank you . ', ' How do you think of the weather today ? ', " I don't like the weather like this . Cold and rainy . Hope it become sunny as soon as possible . "]
['Hello , Betty , how are you ? ', ' Quite well , Tom.And you ? ', " Just fine , thank you.How ' s your father today ? ", " He's much better today . ", " I'm glad to hear that.Bye . ", ' See you later . ']
['I am so happy to know that the promotion campaign for our new product is very successful . We just made a record sale this season . ', ' That is very encouraging news . I heard that the marketing department has done a three months research , they sent the feedback information to the research and development center by the end of every month . That is to say , the R & D center redesigned the product twice before it was launched into the market . ', ' It is not an easy job . How do you like the advertisement for the new product ? ', ' That is the best one I have seen . I am sure our target customers , young people will love it . ', ' Certainly . ']
['Mary , I think we should stop seeing each other . ', ' But , Bob , we were so good together . ', " I'm sorry but it's for the best . ", " I don't understand . We were getting along so well . "]
['Do you like jazz , Tom ? ', " No , I don't like it very much . Do you ? ", " Well , yes , I do . I'm a real fan of Wanton Marsalis . ", ' Oh , does he play the piano ? ', " No , he doesn't ! ! ! He plays the trumpet . So , what kind of music do you like ? ", ' I like rock a lot . ', " Who's your favorite group ? ", ' The Cranberries . I love their music . How about you ? Do you like them ? ', " No , I don't . I can't stand them ! ! "]
['Ugh . Another advertisement . They ’ Ve added two hours of advertisements to a two hours movie . ', ' Yeah . We ’ re never going to get to the end of this one . ', ' Why are we watching it anyway ? ', ' Well , it does have a lot of girls in it . ', ' True . True . ', ' Do you think Bruce Willis just drank a Coke for his health ? ', ' Really ? Did Coke pay him for that ? ', ' Of course . ', ' You want something to drink ? ', ' Yeah , Got a Coke ? ', ' Sure . ', ' Hurry , the movie is coming back on . ']
['Good morning ! ', ' Good morning , Gav ! Did you sleep well last night ? ', " I slept like a baby . I fell asleep right away last night , didn't wake up once , and didn't have any nightmares ! ", " That's great news ! You look much more relaxed than you did yesterday . ", " I feel much better , but I'm still worried about something . ", " What's that ? ", " Well , I have to drive to school for a meeting this morning , and I'm going to end up getting stuck in rush-hour traffic . ", " That's annoying , but nothing to worry about . ", " For me , traffic jams are quite stressful , because I'm pretty impatient . How can I prevent myself from getting stressed if I get stuck in a traffic jam ? ", ' Just breathe deeply when you feel yourself getting upset . ', " Ok , I'll try that . ", ' Is there anything else bothering you ? ', " Just one more thing . A school called me this morning to see if I could teach a few classes this weekend and I don't know what to do . ", ' Do you have any other plans this weekend ? ', " I'm supposed to work on a paper that'd due on Monday . ", ' Try not to take on more than you can handle . ', " You're right . I probably should just work on my paper . Thanks ! "]
["Speaking of classical music , we should never forget about the New Year's Concert of the Vienna Philharmonic . ", ' Of course not . People all over the world watch it on TV , or listen to it on the radio . ', " Sure . It's one of the biggest classical music events . Have you ever been to the live show ? ", ' Yes , I went to the New Year ’ s Concert in 2010 . ', " Wow , you're so lucky . I saw it on TV . But it must be so different to be there in the concert hall . ", " That's for sure . You know , I had the greatest time ever . "]
['It seems to me that you are on very good terms with him . ', ' We actually met at a dance party . He fell for me . ', ' He must be all over you the first time he saw you . ', ' He said that I put all other girls in the shade . ', ' That means he was head over heels in love with you . ', ' Well , he indeed likes me . ', " But I think he can't hold a candle to you . I don't think he has ever popped the question . ", ' No , he is the sort of man who likes to hide his candle under a bushel . ']
['How about the matter ? ', ' I heard it has been finally settled under the rose . ', ' It ’ s the only way to preserve her reputation . ', ' Yeah , fortunately it did not cause a disaster . ']
['can I see your passport , please ? ', ' is this line for non-residents ? ', ' yes it is . Residents can queen up in the lines to my right . ', " Ok . Here's my passport . ", " what's the expiration date on your passport ? ", " I think it's soon , maybe in a few months . It was renewed in Beijing , so the new expiry date is on the last page . ", " I see . Yes , you'll need to renew your passport in a few months . Make sure you don't let it expire while you are in the UK . ", " I won't . ", ' do you have anything to declare ? ', " no , I don't have anything to declare . ", ' how long will you be staying in the UK ? ', " I'll be here for about a year . ", ' what is the purpose of your stay ? ', " I'll be studying . I'm doing an MBA at Nottingham University . ", ' where will you be staying ? ', " I have a housing contract with the university . I'll be in a dorm room on campus . ", ' how do you plan on paying for your living costs and tuition fees while you are here ? ', ' my father has already paid for that in advance . Here are the receipts . ', " ok . Have a good day . Here's your passport and documents back . ", ' thank you very much . ']
["I can't even imagine you snorkeling ! ", " Well , you'll see . With this new watch , I can go anywhere , do anything . ", ' OK , Bond . ', " No , really . Look . It's got a double time zone setting . ", ' So you can always keep two times at once ? ', " Yep . I just can't decide what two cities to choose ... ", " The only two times you need are I'm late and I'm really late . "]
['Going to the cafeteria ? ', ' No , I am not eating there anymore . I have ordered my favorite food in the restaurant around the corner . The food served in the cafeteria is not my type . I am a total meat lover . But the cafeteria is doing its best to force me to be a vegetarian . They have been serving the Chinese cabbage and white gorse for three days . Haven ’ t you noticed that ? ', ' That ’ s fine with me . I don ’ t hate vegetables and I don ’ t eat much during lunch . ', ' Well , then the cafeteria suits you best . But anyway , if you like to have a lunch outside the company , feel free to join me anytime . ']
['I am going to give you an end-of-the-unit test this Friday . Please be prepared for it . ', ' Would you please tell us how to review our lessons ? ', ' Review all the lessons in this unit and see if you can understand the main idea of each lesson . ', ' Any other requirements ? ', ' Phrases and sentence patterns are also very important . You should know how to use them . ', ' Should we remember all the new words and expressions ? ', ' Certainly . ', " Sorry , I don't quite understand some difficult points in this unit . I wonder if you could help us to solve the problems . ", " Well . When you review your lessons , mark the places which you don't understand , then I will give you some coaching . ", ' When shall we have a coaching period ? ', ' How about tomorrow ? ', ' Ok . ']
['What do you think of smoking ? ', " It's harmful . Not only for yourself but for others . ", ' What in your opinion can be done to stop smoking ? ', ' Stop producing cigarettes . ', " But that'll affect the national economy . ", " That's right.But I don't think there are better ways . ", ' How about printing a warning on each cigarette packet ? ', ' Maybe it can take effect . ']
['Are you ready ? ', ' Yes . ', " Who can tell us something about the author's life ? Volunteer ? ", ' The author was a famous writer , and he was also a politician . He was born in 1911 and died in 1985 . ', " Very good . Sit down , please . Susan , what's the general idea of the text ? ", ' Can I answer it in Chinese ? ', " No , you can't . This is an English class , and you have to express yourself in English . ", ' Let me have a try . The author takes the characters peculiar to the British people as a topic to show that they are quite different from other nationalities . They are quiet , shy and reserved ... ', " Excellent . Class is over . Let's have a break . "]
["wow ! You're going to Tibet ? ", ' yes , my brothe and I are going . We just finished making our itinerary . ', " that's really cool ! I've always dreamed of going somewhere like Tibet , seeing something unique . ", ' great minds think alike . My brother and I have been thinking about going to Tibet for quite a long time . Do you have anything on your schedule ? ', ' nothing particular . ', " why don't you join us ? We are leaving next week ; you'll still have a week to prepare . ", " oh , Tibet sounds great , but I'm afraid it'll cost too much . Last time I traveled to India , and it cost me a fortune . ", " come on ! We're traveling on our own . It won't cost too much . ", ' ok , then count me in . where will we stay ? ', ' the youth hotels are comfortable and cheap . ', ' then make sure that you book me a room , too . ', " I'll take care of it . ", ' and check whether they accept credit cards . ', ' no problem . ']
['Excuse me , I ’ d like to apply for a library card . ', ' Certainly.Here ’ s an application form.Do you have proof of residence ? ', ' What sort of proof do you need ? ', ' A driver ’ s license or something showing that you live in this city . ', ' I ’ m a student from out of state , so I don ’ t have a local driver ’ s license . ', ' Do you have a current electricity or gas bill in your name ? ', ' The phone bill ’ s in my name . ', ' That ’ ll do.Bring the most recent one in with your completed application , and we ’ ll issue you a temporary library card right away . ', ' How long will it take to get the regular one ? ', ' It ’ ll be mailed to you within two weeks , but you can borrow books on the temporary card . ', ' Okay.Thanks for your help . ']
['See you later , alligator . ', ' In a while , crocodile . ']
['How did you meet your boyfriend , Cindy ? ', ' We were in the same science class last term . ', ' Who made the first move ? ', ' I did . ', ' Wow ! ', ' It was no big deal . ', ' What do your parents think of your dating a boy ? ', " They're glad that I finally got a boyfriend . ", " They're glad ? ! "]
['Hi , my name ’ s Karl . My wife and I are moving in next door . ', ' Hello , Karl . I ’ m Chuck Jones . We ’ re going to be neighbors . ', ' I ’ m happy to meet you . It seems everyone in town is so friendly . ', ' This is a small town , and we like to be neighborly . We know everyone who lives around here . ', ' Well , I ’ m from Chicago . There few people take the time to get to know their neighbors . ', ' So , tell me , Karl , hyoid you come all the way to Minnesota to live ? ', ' We wanted to live in a more peaceful community and have more space . Another reason is , we can afford to buy a home here , but we can ’ t in Chicago ! ']
['I hear that you are in love with Mike . ', ' You are kidding . ', " Don't you hit it off ? ", " Although we have many things in common , we'are not soul mates . "]
['Are you going to tell me about the stamp , or not ? ', " 120 British pounds . But there are still three days left in the auction . If you want it , you'll have to bid . Do you have the guts ? ", " I'm just asking . It's not like I'd actually make a bid . ", " Just don't come looking to me for help . ", " Don't worry . I won't . ", " I'm signing off . ", ' Have fun getting ripped off ! ']
['Have you met John ? ', ' Yeah , he came back from America last week . ', ' Have you noticed how fluently he speaks English ? He has only lived in America for less than three months . ', ' He must have a good ear . ']
['What courses are you going to take next year ? ', " Well , I am certainly going to take chemistry and physics , but I haven't decided on the other subjects yet . I ’ d like to take English . ", ' Why are you going to take English with chemistry and physics ? ', ' Because I want to study English literature . But I think chemistry is better for getting a job . ', ' Of course it depends on what you are going to do when you leave college . Have you decide what you are going to do when you graduated ? ', ' I am going to be a , well , I hope to be a research chemist . ']
['Does your wife work ? ', ' Yes , she does . She works at home . ', ' Oh , I understand . She cooks , cleans and takes care of children . Is that right ? ', ' Oh , no . Most of the time I do these things . She is a writer . ', ' You are really a hen-pecked husband . ']
['What kind of movies do you like , Sue ? ', ' I like all kinds of stuff . I admit I love romance . ', ' Just like my wife . So , what ’ s your favorite movie ? ', ' You mean my favorite movie of all time ? I guess I ’ d have to say pretty woman . ', ' Yeah , my wife likes that one , too . Personally , I prefer action movies . ']
['What are you thinking about ? ', ' About my boyfriend . ', ' Again ! ', ' You are really a wet blanket . ']
["Hello . Are you a friend of Helen's ? ", ' Actually , a friend of a friend . ', " My name is Phil . What's yours ? ", ' Alecia . ', ' Have you tried these little ditties ? They are really good . ', ' Thanks . They look delicious . ', ' Can I get you some punch ? I was just going to go get myself some . ', ' That would be great . I would love some . ']
['I usually bowl with an eight ball . I like the control of a light ball . I can spin it more , so that the ball hooks . ', " Well . I like them a little heavier . I don't have as much control , usually bowling straight , but the extra momentum compensates for that . ", " Well , let's see which technique is better . I think I'll go up first ... Yes ! I hit a strike . I knocked them all down on my first bowl . ", " Well done . You got them all . You get 10 points and your next two bowls are added to this frame's score . I'II dry my ball off and try to knock them all down as well . ", ' Good start . You knocked eight pins down . But you are left with a 7,10 split . Unless you can bowl a UFO-ball on this bowl , it is going to be impossible . ', ' I certainly can try ... No ! It went straight through the wickets . ']
['Mom , why do chinese people like to touch my head ? sometimes they even touch my cheeks . ', ' That is a part of chinese culture , if they think you are a lovely child , they touch your head and say , how cute you are . ', ' But i donor like it , not a bit , i am not a pet , i am a girl . ', ' Well , you get used to it , different countries have different manners . ', ' But i do not like anyone touch my head . ', ' They are just been in friendly , when you are in Roman , do as the Romans do , that means you need to adapt to your enviroment . ', ' What if everybody in the wheres goes crazy ? ', ' Then you might need to pretend to be a little crazy . ', ' Does this mean that if i might want those new European bitches , i am supposed to wonder run reget ? ', ' Do you think it is a ~ got give your brain , use it if you really cannot accept it people touch your head , keep distance from them , why not just wear your big flyby hat and ~ is anyone get close to you . ', ' That is my work , i will try it . ']
['can I use your laptop for a while ? ', ' sure , go ahead . ', " oh , isn't your computer Wi-Fi capable ? ", ' yes , it is . You want go online ? there are no wi-fi hotspots around . ', ' oh my , no internet access is killing me . ', " can't you wait till you get home ? then you can surf the internet using the broadband , wireless connection or whatever you like . ", " no , I'm not feeling myself . I just want to check my emails , visit my favorite websites and chat with my friends . ", ' now I see , you must be suffering from discomgoogolation . ', " what does that mean ? there's nothing wrong with me . ", ' well , the term " discomgoogolation " comes from " discombobulate " and " google " . Because floods of information are just a mouse click away , net users are very likely to become addicted to the web . ', " that's alright . I just can't bear losing track of all the latest information . It almost drives me crazy . ", " then , you're probably addicted . "]
["so , how's your course going ? Do you like it ? ", " i like my professors and the classes , but it's a lot of work . ", ' what are you specializing in ? ', " right now , I'm doing some research into the languages of different African tribes . ", ' that sounds really interesting . Can you speak Swahili ? ', ' yes , I learned how to speak it when I was little . ', ' really ? How did you do that ? ', ' well , I grew up in Africa , so I learned quite a few different languages . ', " that's amazing . Are you doing well in your classes ? ", " I don't know because I haven't received my test results yet . ", ' when did you take your exams ? ', ' about two weeks ago . ', ' how do you think you did ? ', " I left feeling pretty confident about my score , but I heard that my professors are very strict graders , so I'm a bit nervous . ", " I'm sure you'll do well . Did you study hard ? ", " You know me ; I'm always studying ! ", " don't worry . If you don't do well , no one can ! ", ' Thanks for the vote of confidence , Justin ! ']
['Ah ! No ! Damn it ! ', " It's a blackout . Now I can't see Seinfeld . ", " So what ? I just lost one hour's worth of work . ", " Really ? How could you do that ? Don't you save every couple minutes ? ", " No , I didn't save this time.Damn it ! And I'm sick of writing this paper . Now I have to write it all over again too . ", " I've had that problem too many times . So I learned to save.When I'm writing something , I save every three sentences or so . I don't want to lose anything . ", " I hate computers . Sometimes I think they cause more trouble than they're worth . ", ' What are we going to do now ? ', " I don't know . I feel like going out . ", ' I wonder how much of the city is down . ', " It doesn't matter . I still can go out and buy a beer . ", " Maybe . But if there's a blackout , probably the pubs are closed.And besides , I know you have a political science exam tomorrow . I thought you had a lot of reading to do . ", " Yes , that's true . Damn ! I just lost half my paper , and now I can't even do my homework.This is a bad time for this to happen . ", ' I have a flashlight in my closet . If you want to use that to read , you can . ']
['Mr . Brown , are your children always kicking up a row like this ? I cannot concentrate on my paper . ', ' Sorry , Mr . Black . I ’ m trying to make them quiet . ', ' I ’ m afraid if the noise goes on , I shall have no alternative but to leave . ', ' Sorry , sir . Believe me , everything will be all right . ']
["You mustn't touch the wet paint , Bill . ", " I'm sorry . I won't do it again . ", ' Try to be more careful in future . ', " I shall . I wasn't as careless as John Sampson . He walked across that wet cement over there . ", " The workmen oughtn't to leave it without a no tice . ", ' The headmaster asked them not to do so . ', " Then why isn't there a notice ? ", ' They went to their stores to get one . Here they come with it now ! ', " But look at them ! They've forgotten about the wet cement and they're walking across it to put up the notice ! "]
["you don't look too well . Maybe you should take the day off from work . ", " I couldn't do that . I have an important meeting to go to today . ", ' do you feel ok ? ', " not really . After a 12 - hour flight , I've got jetlag , and on top of that , I think I've also got the flu . ", " why don't you call your secretary and tell her to reschedule the meeting ? You should really get some seat or you'll end up feeling even worse than you do now . ", ' could you feel my forehead and check to see if I have a fever ? ', " you're really hot . Let me get you some Tylenol to bring the fever down . ", " ok . I'll stay home this morning and rest , but if I feel better in the afternoon , I'm going to the meeting . ", " Zach , what's that on your arm ? ", " I don't know . It looks a bit red , but I'm sure it's nothing . ", ' it looks like you have a red rash all over you ! Are you allergic to anything ? ', " just cats , but I don't think I was near any cats in the last couple of weeks . ", " I completely forgot about your cat allergy . I took care of a cat for my friend here a few days ago . Oh no . we'd better go to the doctor to get some medicine . Let's go . ", " shouldn't we make an appointment first ? ", " we would , but let's just go and see if there's an opening now before it gets worse . ", ' whatever you say . I just want to get to my meeting ! ']
['Craig , what do you do for work ? ', " I'm still a student . ", ' What school do you go to ? ', ' Boston University . ', " That's a good school . What do you study ? ", " I'm studying English , math , and history . My major is English . ", ' How long have you been studying English ? ', ' More than six years . ', " That's a long time . ", ' Yeah , I started to learn English when I was in high school . ', ' No wonder your English is so good . ', " Actually , it's not that good . I can read but I can't speak very well . I haven't had a lot of chance to practice . ", ' I see . Talking with other people is very important . ', " Yes , but I still don't have many friends here yet . ", " I'm having a party tonight at my apartment . You should come . ", " Oh thanks for inviting me . I'd love to come . "]
['Hello , Jason , there is going to be a screening of Final Destination 3 at our campus cinema tomorrow . I plan to go to see it . ', ' Is it a horror movie ? ', ' Yeah , I love horror movies . Would you like to go with me tomorrow ? ', ' No way . I will be scared out of my wits . ', " That's funny , I didn't know a big fellow like you could be so soft and timid on the inside . ", ' Hey , how would you like to taste my fist ? ', ' Alright , all joking aside , what kinds of moves do you like ? ', ' Um , let me see , romance , comedy . documentary , action , science fiction , animated and so on . ', ' That is to say , you like all genres except for horror movies . ', " Yeah . It seems like we don't speak the same language as far as movies are concerned . ", ' Not quite . I also greatly enjoy romance and comedy . ', ' The Notebook is this type of movie . ', " Really ? I haven't heard of it . ", " Well then , this could be a nice opportunity to enjoy it together . I bet you'd love it . ", " Ok . I can't wait to see it . Let's go ! "]
["Wow , there are so many lanterns to appreciate . Now , I can see why it's called the Lantern Festival . It deserves its name . ", ' Yeah . People always enjoy the lighted lanterns and the gala performances . ', ' What are they doing over there ? People keep on gathering there . ', ' Did you notice the characters on the lanterns ? ', " Sure . But you know that I can't read any Chinese characters . What do they say ? ", " They are puzzles . It's a tradition to solve the puzzles on the lanterns during the Lantern Festival . ", " Very interesting . But I'm afraid we'd better do something else . Hey , look ! There is a huge lantern there . Let's get close to it . ", " It's really eye-catching . It's the biggest dragon lantern I've ever seen in all my life . ", " Really ? Then I'm really lucky . Oh , it's spewing fireworks from its huge mouth . ", " Very impressive . It's made of glass which makes it even brighter . ", ' There are many Chinese characters on its body , too . What are they about ? Puzzles ? ', ' Let me have a look . Oh , no . They are Chinese poems which describe this happy scene . ']
['He is so kind . I couldn ’ t believe he murdered his wife . ', ' Of course not . I believe he ’ s innocent . ', ' I don ’ t understand . ', ' He nursed a viper in his bosom . His best friend Tony foamed him in . Tony first seduced his wife and then trapped him . ']
['You always stick to your PC recently . Are you still fascinated by chatting on line ? ', ' For me , the times of chatting online has gone . ', ' What the hell are you doing now ? ', " I opened my blog today . In order to have more visitors , I have to land on others ' blogs and leave my messages for their blogs . ", " What's new with you ? ", ' Do you still remember Justin ? ', ' Of course , he was our monitor in college . How is him now ? ', ' He seemed to be dumped by his girlfriend . I found his blogs were a little sad . ', ' Let me see . What a moving poem ! ']
['Will you be okay when you immigrate to America ? ', " Sure , I'm looking forward to it . ", ' What about your parents ? ', " I'll get used to not seeing my parents . "]
["So , how's your work ? ", ' Good . How about you ? ', ' I am going to resign . A few of the new staff have already left . Obviously , a lot of similar jobs pay much better salaries . ', " But your company is huge . Can't they afford to pay the staff decent wages . ", ' But we have a policy of paying according to seniority in the company , so new employees get quite low salary , no matter how excellent they have done . ', " That's shortsighted . By the time the workers are experienced and contributing . They are likely to go . ", " That's why I am going to leave . ", ' But you have already worked there for five years . ', " I am worried about my future . I can't believe that our company is as big as it is . The company can only continue to grow by taking care of its staff . ", " Well . The management doesn't seem to think that way . Anyways , you have to think twice before you act . ", ' Thank you . I will . ']
['I ’ m so excited , mother . Oh , a new baby ! ', ' My first grandchild . ', ' And my first nephew . He looks a lot like you , mum . He does . ', ' Do you think so ? Well , I guess . He does look a lot like me . Oh , he ’ s got Richard ’ s eyes though . ', ' Yes , he does have Richard ’ s eyes . The baby even looks like you than Richard does . ', ' Well , children usually resemble their parents . ', ' It ’ s true . Michelle is a lot like Henry in so many ways . And she is shy with new people just like he is . ', ' You often like comparing children with their parents . ', ' You ’ re right . ']
['Hello . ', ' Hello.May I speak to Mark , please ? ', " Sure , just a minute.Mark , you're wanted on the phone . ", ' Hello , this is Mark speaking . ', " Hi ! This is Jill.How come you didn't come in today ? ", ' Oh , we had a birthday party for David last night . As a matter of fact I woke up with a terrible hangover . ', " That's too bad.You ' ll have to be more careful nest time . ", ' Anything new at the office ? ', ' No , nothing special.Oh , yes , you know Bill , The guy with the moustache.His wife had a baby girl last night and he passed out cigars to everyone today , He said his wife and daughter are doing fine.The baby is their first child . ', " That's wonderful ! We've got to celebrate ! ", ' Yes , we have to.Do you think you can make it tomorrow ? ', ' Sure . I ought to be ready for some more drinks by then.Thank you for calling . ', " You're welcome.Bye . "]
['what kind of music do you like listening to ? ', ' I like music that has a fast beat and is lively , like dance music . You know , I go to a disco almost every week . Sometimes it ’ s too loud though . You prefer classical music , don ’ t you ? ', ' yes , I do . I find it very relaxing . I often listen to Mozart or Bach in the evening after a hard day at work . ', ' I must admit that I like several pieces of classical music . It ’ s certainly more sophisticated that modern dance music . ', ' classical music is supposed to be good for you brain . Research suggest that it makes your brain more active . Students who listen to classical music while studying perform better . ', ' really ? Perhaps I should listen to classical music often . I heard that listening to classical music is helpful in reducing stress . ', ' yes . That ’ s why I listen to it in the evenings . I usually play it as background music while I ’ m cooking or doing other housework . ', ' I ’ Ve got a few classical music CD ’ s . I should follow your lead and increase my brain power . ', ' you can find plenty of recording on the internet too . You can listen to samples and then buy them very cheaply if you like them . ', ' that ’ s a good idea . You should do the same with some music . You might find something you like . Classical music might make you clever , but dance might make you livelier and happier . ', ' that ’ s true . There ’ s clear evidence that people who listen to lively music are lively people . Music can influence a person ’ s feeling and character . ']
['Hi ! Wang Mei.Come and have a look at my new dress . ', ' Oh ! What a beautiful dress ! It fits you so well.You look so charming in the dress . ', ' Thank you for saying so . ', ' Where did you buy it ? ', ' I bought it in a store near my school . ', ' How much is it ? ', " It's only thirty yuan . ", " It's so cheap . I'll buy one , too . ", " I'll go together with you . "]
['Yeah , I ’ Ve just moved here , and I ’ d like to activate my cell phone , and I ’ m not sure if I should go with a prepaid plan , or a monthly rate plan . ', ' I see . Well , can I have a look at your phone ? Unfortunately , this phone can ’ t be used in the US , it ’ s not compatible with our 3G network . ', ' What ? Really ? I don ’ t really want to have to buy a new phone . ', ' Well , you ’ re in luck ! You see , if you sign up for our three-year plan , we ’ ll throw in a handset for free . ', ' Really ? What ’ s the catch ? ', ' There ’ s no catch ! You just choose a plan , sign a three-year contract and , that ’ s it ! Actually , we ’ re running a special promotion right now , and we ’ re giving away a Blackberry Curve with our special Mega Value forty dollar plan . ', ' So what does this plan include ? ', ' Well , you get nine hundred anytime minutes , and you can also enjoy free mobile to mobile calling to other Tel-Mobile clients , one thousand text messages per month , and unlimited evening and weekend minutes . Oh , and we also offer a rollover option . ', ' Wow , all this for forty dollars per month ? ', ' That ’ s right , plus the activation fee , the emergency services fee , the monthly service fee , oh , and any charges for extra minutes , and ... ']
['Excuse me , Professor , I have a problem and need to leave class early . ', ' Why do you have to leave early ? ', ' I am not feeling well . ', ' Could you make it up by attending my other section this week ? ', " Yes , it's all taken care of . ", ' Are you leaving right away or can you stay for a few more minutes ? ', ' I can stay a few more minutes . ', ' OK , but please make sure that you get all of your make-up work completed . ', " Thanks , Professor . I've got it covered ! ", " Go do what you have to do , but make sure it doesn't happen again . "]
['When he told me I had to work overtime , that was it . ', ' The last straw , huh ? ', " Yes , he's really pushed me too far . ", ' I know what you mean . ']
['Paul sends you his regards . ', ' How nice of him ! ']
['Do you think I still fashionable in this dress ? ', ' I think so . Blue is still very fashionable at the moment . ', ' This style came out last year , though . I like the dress , but I ’ m not sure whether last year ’ s fashions will be same this year . ', ' I think this kind of dress will stay in fashion for a few more years . People don ’ t change fashions every year . It would be too expensive . ', ' Yes . Only the top designer try to tell people to change fashion every year , but only rich people can do it . ', ' There are some real fashion victims who just have to keep totally up-to-date with expensive clothes . ', ' I wish I could be one of those people , but my budget simply doesn ’ t stretch that far . I have to limit the amount of money I spend on clothes otherwise I would go on a shopping frenzy . ', ' I know what you mean . The situation will be worse if we marry our boyfriends and have children . The we ’ ll have even less money to spend on fashionable clothes ! ']
['He has a girlfriend already . ', ' You are kidding ! He just broke up with Ann . ', ' His new girlfriend is a far cry from Ann . She is like a breath of fresh air . ', ' I hope I will meet her soon . ']
["Why , Tom ? It's five to six already and you are still writing here . ", ' So what ? Are we going anywhere ? ', " Yes , have you forgotten ? We have arranged to go to Mary's to watch some videos tonight . ", " Oh , I'm sorry I forgot all about it.Well , can I take a rain check ? ", " What's the matter with you ? You are the one that persuaded all of us to go there . ", " I'm terribly sorry , Rose.But I have to finish this paper by tomorrow or professor Martin will kill me . "]
['Oh ... I am really worried about the exam . I have no idea what will be on it . ', ' Why ? Just read your notes.You can see what the professor stressed in the lectures.Probably the exam will ask about things he stressed . ', " Yes , but my notes are all nonsense . I can't figure out what is important . ", ' Let me see them.Are these all the notes you have ? ', ' Yes . ', " But Laurie , how can you do well in school if you don't take more notes ? ", " What do you mean ? You think I don't write enough . ", " I'm sure you don't write enough.Look at this . Here you wrote , Russian Revolution . 1917 . Bolsheviks . Real revolution , or coup ? And that's all ? I remember he lectured for a half hour about that question.And you didn't write any of it ! ", ' I know , but I listened . ', ' Yes , but did you remember ? You need good notes to help you remember . ', " I suppose you're right . But what can I do ? I don't know what to write down . ", ' There are different things you can do.For one , the university offers a special free course on note-taking.You should go to the course . Also , I am pretty good at taking notes . I can help you on this exam . I will photocopy all my notes , and you can compare them to your notes.Then maybe you will see what kinds of things to write down . ', ' That would really help me , Sue . I appreciate it . All this makes me feel like an idiot . ', " Don't feel that way . I know you are very smart.Note - taking is a special skill . All students need to learn it.Some people are very smart , but they just haven't learned how to take notes yet . I'm lucky because I had a good English teacher in high school.She taught me how to take good notes . It's not hard . ", ' Alright . University and high school seem very different to me . I suppose I just need to learn how to manage lecture classes . Then I will do better . ']
['What are you grinning about ? ', ' Stephany said she would go out with me . ', ' I thought mom said no dating till you are 16 . ', ' That ’ s in one month , and besides , this is a group date with all of our friends . ', ' All of your friends , what are you planning to do ? ', ' We ’ re going fishing . ', ' What a party ! I hope you don ’ t expect the girls to fish . ', ' These girls are different , they are not wimpy . ']
['This is my friend Jenny . ', " What's her last name ? ", " It's Snow . ", ' What color are her eyes ? ', " They're blue . ", ' What color is her hair ? ', " It's brown . ", ' How old is she ? ', " She's 42 . "]
['Are you ok ? You seem a bit anxious . ', " Yeah , I'm OK , I have been having a lot of mood swings lately . I think it has to do with the pills my doctor prescribed that are causing chaos on my hormones . ", ' So you mean you feel ecstatic one minute and then blue the next ? ', " Yeah , it's weird . For example just this morning I was feeling detached and lonely , even though there was really no reason to feel that way . ", ' Well , maybe your mood will swing positively and you will feel confident , brave and hopeful ! ', ' I hope you are right . ']
['Look ! This picture of Mom in her cap and gown . ', " Isn't it lovely ! That's when she got her Master's Degree from Miami University . ", ' Yes , we are very proud of her . ', " Oh , that's a nice one of all of you together . Do you have the negative ? May I have a copy ? ", " Surely , I'll have one made for you . You want a print ? ", " No . I'd like a slide , I have a new projector . ", " I'd like to see that myself . ", ' Have a wallet size print made for me , too . ', ' Certainly . ']
["Michael Jackson's coming to town . ", " I Couldn't care less . "]
['What do you like to do with your free time ? ', ' Study English . ', ' You mean you like to study English ? Why ? ', ' It gives me great satisfaction . ', " Studying English wouldn't give me any satisfaction . It's hard work . ", " I don't mind the work . I think it's worthwhile . "]
['David , would you like something to eat ? ', " No , I'm full . ", ' Do you want something to drink ? ', " Yes , I'd like some coffee . ", " Sorry , I don't have any coffee . ", " That's OK . I'll have a glass of water . ", ' A small glass , or a big one ? ', ' Small please . ', ' Here you are . ', ' Thanks . ', " You're welcome . "]
['How long have you been in this company ? ', ' I came two years ago after I graduated from college . This is my first job . ', ' You must have found much difference between working in company and studying in college . ', ' Of course ! Everyday , there is a deadline to meet . Bosses watching and testing me all the time , not liking in college , handed in paper months later and tested on schedule . It is so busy . But anyway , I have trying my best to be a good employee . ', ' Well , you ’ Ve adapted yourself very well . Everyone in our office thinks you ’ Ve made a great progress in the past two years . What is your secret ? ', ' It is so encouraging to hear this remark . The secret is to make plans . Write down your goals , short-term and long-term and make detail plans for a week or a month . Then just work hard . ']
['Are you there , Mary ? ', " I'm back . My bid on the Buddha is still the highest ! ", ' How much is my stamp ? ', " Don't you want to hear more about my statue ? ", " Don't get ahead of yourself . Fat boy isn't yours yet . ", ' His name is not fat boy ! You can be so rude sometimes . ']
['What did you say ? ', ' I said he was nothing but a yeoman . ', ' Then he become angry with you ? ', ' Yes . ']
['Professor Wang looks so handsome today . He is wearing a light brown suit and a pink tie . ', ' He always wears an extremely becoming suit with tie . ', ' He ’ s quite particular about what he wears , especially about his ties . He gets different tie each day . ', ' A light brown suit and a pink tie today , and a light blue shirt and a blue tie yesterday . A perfect match ! ', ' The tie is necessary for man . It makes you look so attractive in a super tie . ', ' Match is important ; well , the way of tying is also important . ', ' My father dose not know how to tie a tie , for he often wears a cravat . ', ' My father wears a tie every day , but he can ’ t do it himself . My mother helps him with his tie every morning . ', ' You mother is not only a patient mother but also a gentle wife . ']
['There is a tornado warning on . My mother just told me she heard it on the radio . ', ' What is a tornado warning ? ', ' It means that a tornado has been seen somewhere in the area . ', ' Really ? In New Berlin ? ', ' No . Not necessarily in town . But in southern Wisconsin somewhere . A tornado has been spotted . They have two stages here.This is what is called a " tornado watch . " That means that the weather conditions are perfect for a tornado . ', ' I understand . They think a tornado might come . ', ' Yes . People should look out , because maybe there will be tornadoes coming.So it\'s called a " watch . " ', ' And the second stage is called a " tornado warning " . ', ' Yes . If a tornado has been spotted , they announce a " tornado warning " . So if there\'s a tornado warning on , it means a tornado is out there somewhere . ', " It's scary . ", " Well . Tornadoes can be dangerous , it's true.If we hear something like a loud train coming , then we have to go in the basement . ", ' What do you mean " a loud train " ? ', " That is what tornadoes sound like . They sound like trains . They're very loud . ", " But if you hear them coming , isn't it already too late ? ", " Maybe . It depends on the tornado.Some can move across the ground at 200 miles an hour.That is very fast . Others aren't so fast . ", ' Have you seen a lot of them ? ', " I've only seen one in my life . I was looking out the window . It was around two miles away . It was very interesting to watch.But it was heading toward my friend's house . So I quickly called them on the phone . ", ' Did it hit their house ? ', " No , it didn't . But they are glad I called them . ", ' What were they doing when you called ? ', ' They were all sitting in the living room watching TV.They had no idea a tornado was coming toward their house.If it had hit them , they could have all been killed . ', " That's terrible . Do many people die in tornadoes ? ", ' Not so many really . But a lot of houses are destroyed sometimes . ']
['Actually the general manager is regarded as a baby doll . He has much sympathy . ', " That's right . And his wife is a baby doll , too . She used to have many followers . ", ' Were you one of them ? ', " Nothing of the sort . I can't hold a candle to her . "]
["You know that this afternoon's meeting is cancelled , right ? ", ' Why am I always the last to know these things ? ', " I sent out a notice . You've stopped checking your e-mail ? ", ' No , but Bean did send me like a hundred forwards today . My mailbox must have been overflowing . ', ' How obnoxious ! I heard he was sending you dirty jokes . ', " He not only sent me nasty e-mail , but he's so bored , he even asked me to search the Net for even more forwards for him ! "]
['Stop running around in front of the TV , will you ? Why don ’ t you just sit and watch ? ', " I've tried , but I can't stand the bald man talking so loudly in the program . ", " Then stay away . Nobody's keeping you from doing that . ", " Don't be so irritable . I just don't understand the program , that's all . ", ' All right , I will explain it to you later on . Now scram . ', " Ok . I will wait until you have had your fun , if that's what you want . ", " That's exactly what I want , thank you . "]
['How did your interview go ? ', " Pretty well . I don't know if I'll get the promotion or not , but I feel good about it . ", ' If you get the promotion , what will your new title be ? ', ' If I get the promotion , I will be a senior engineer instead of an assistant engineer . ', ' Will you get a pay-raise , too ? ', ' Whenever you are given added responsibilities , you should get a promotion . ', ' That makes sense . Who interviewed you ? ', ' My boss . ', ' What kinds of questions did she ask you ? ', ' She asked me about my ability to work in a team and what I thought a good boss should be . ', ' The second one sounds rather difficult to answer . What did you tell her ? ', " I told her that I'm an excellent team player and that a good boss should treat male and female employees equally . ", ' Those are good answers . How did she react ? ', " She told me that even when I become a senior engineer , I'll have to work with the assistant engineers as a team . ", ' What do you think about her as a boss ? ', " She's pretty easy to get along with . She listens to her employees and treats everyone equally . ", " You're lucky . Not everyone has such a great boss ! ", " That's true . She's highly esteemed among everyone at my company . ", ' When you find out you get the promotion or not , let me know . ', ' I will do . ']
["What's this then ? ", " It's my geography , sir . The Map of Africa you set us . ", ' But this should have been handed in last Thursday . ', " Yes , I know , sir . I'm sorry . ", " Well , what's your excuse then ? ", " My mother's been ill and I had to stay at home . ", ' Oh , Yes ? ', " It's true , sir . "]
['Our unit is participating in a fundraiser this weekend and would like to borrow the van , if possible . ', ' I would need to check on that . Where is the fundraiser ? ', ' It will be at the beach by the pier . ', ' What day will you need it for ? ', ' We will only be needing it for Sunday . ', ' Maybe that could work . I need to know who will be driving it . ', ' The only two drivers will be Mary and I . ', ' If I give you the keys to the garage , could you bring it back on Sunday evening ? ', ' Sure . We also would like to use the chairs from the lunchroom . Would that be OK ? ', ' OK , but make sure that everything is back by Sunday night at the latest . ']
['Hi , what ’ re you reading ? ', ' Oh , it ’ s Death on the Nile . Have you read it ? ', ' No , not that one . But I saw the movie . Could I borrow it when you finished . ', ' Sure . I didn ’ t know you liked mysteries . ', ' Oh , I ’ m crazy about them . ']
['Who are those guys ? ', ' Kobi Bryant and Shaquille O ’ Neal , they are the Los Angeles Lakers ’ star players . ', ' Oh . ', ' Wait a second . He shoots , he scores ! ', ' All right ! ', ' Here comes Jordan , though . ', ' Wow , Michael Jordan ’ s slam-dunks are beautiful things to watch . ', ' Yeah . He ’ s older , so he doesn ’ t slam , as much as he did when he was younger , but when he does , it ’ s still amazing . ', ' Which team do you think will win ? ', ' The Lakers . Jordan is the only good player Washington has . ']
['How are your parents these days ? ', " Oh , they're fine , still very active and enjoying their retirement . ", " Oh , good . That's nice to hear . Please give my best regards to them when you're home . ", ' Sure , thank you . ']
['Those are the headlines for today , and now for the international weather report with Mike Sanderson . ', ' Thank you , Bob ! This past week has been the beginning of Armageddon for many , a series of unprecedented meteorological events occurred around the world . In Switzerland , a major avalanche was reported in the Alps . Fortunately , no one was injured . Due to to the extreme cold this winter , a blizzard has struck the US Midwest , causing classes in schools and universities to be temporarily canceled . Moving to to Latin American , Ecuador has suffered a six month drought that has not only affected farming , but has also forced the closure of the hydroelectric power plant that provides electricity for the entire country . In Chile , a major earthquake that registered seven point five on the Richter scale struck the southern region . Losses are reported to be in the billions . Authorities have not yet released an official statement . ', ' Not a great week for the world ! Any good news ? ', ' I ’ m afraid not , Bob . One of the major volcanoes in Mexico has erupted , causing major floods and landslides in the region . Meanwhile , Mexico ’ s coast has been hit by hurricane Liliana and officials say that all the seismic activity leads them to believe that a tsunami may hit Central America , affecting Honduras , Guatemala and Panama . That ’ s all the news we have for today , but stay tuned for updates on the six o ’ clock news . Back to you Bob . ']
['Happy Anniversary , honey . ', ' I thought you had forgotten . ', ' After the trouble I got into last year , no way . ', ' Thank you honey , it means a lot to me . ']
['I am fed up with Jack . He is so weak in dealing with other people and always eats dirt . ', ' So he is . But , why not try to help him to become stronger ? ', ' How do you know that I didn ’ t try ? I just couldn ’ t manage it . ']
['My friend Jane is very beautiful . ', " What's her figure ? ", ' Perfect . And I like her charming eyes , too . ', " What's the color of her eyes ? ", ' Dark blue . ', ' how old is she ? ', ' Twenty . ']
['Excuse me . Is anyone in that seat next to you ? ', " No , I don't think so . ", ' Do you mind if I put my jacket there ? ', " No . It's no problem.Are you American ? ", ' Yes . And you ? ', " No . I'm from Taiwan . Can't you see ? ", ' Well , there are many Chinese Americans , you know.And your English is very good . You sound like an American . ', " I don't think so . You are flattering me . ", ' No , really . I can only hear a little accent . ', ' Are you flying home ? ', " Well , yes . Actually , I'm going back to visit . ", ' You were visiting Taiwan ? ', " No , I'm going back to America to visit . I'm from America , but I don't live there now . I live in Taichung . ", ' Really ! You live in Taiwan ! ', ' Yes . Why not ? ', ' May I ask what your job is in Taiwan ? ', ' Sure . I teach history in a university . Have you heard of Dong-Hai University ? ', " Of course . It's a good school . How long have you lived in Taichung ? ", ' I have lived in Taichung for two years now.So this is the second time I am going back to states . I go back once a year to visit my family . ', ' It must be strange for you to live in Taiwan . ', " No , it isn't strange at all.Many people from Taiwan move to America too , you know.Do you think it is strange for them ? ", " No . Well , I don't know.But Taiwan is so crowded . Don't you miss life in America ? "]
['Are you new here ? ', ' This is my first day here . ', ' Are you a freshman in college ? ', ' I started school somewhere else . ', ' What school did you transfer from ? ', ' I started at PCC . ', ' What made you transfer ? ', ' My grades weren ’ t good enough to go here . ', ' Did you like PCC ? ', ' I loved PCC . ', ' Good luck here . ', ' I ’ m excited to be here . ']
['The band is pretty good . How do you like the music ? ', " It's very nice . I haven't heard live music in a while . This is fun . ", ' Well , then , may I invite you for the next dance ? ', " Of course . But I'm afraid I'm not much of a dancer ... ", " Don't worry . I'm not much of a dancer myself . ", " You're dancing so well . ", ' You dance beautifully too . ', ' When did you learn to dance ? ', " In college . But I don't dance very often . What's your favourite dance ? ", " It's hard to say . It depends . But I love the waltz . "]
['Li Lei , can you tell me what the origin of Easter is ? ', ' The Bible says that Jesus Christ was resurrected three days after he was crucified . People commemorate that at a festival called Easter . ', ' Oh , then when do you celebrate Easter ? ', ' We celebrate it on the first Sunday after a full moon on or after the 21st of March . ', ' How do you celebrate it ? ', " We make a lot of Easter eggs and then paint some designs on them . We'll also go to church and pray . ", ' That sounds interesting . ']
['Morning , Bob . Fancy meeting you here ! ', " Morning , Jenny . Haven't seen you for ages ! ", " Well , I thought I'd come to see you , so here I am . ", ' You did give me a surprise . How have you been ? ', ' Fine , just fine . And you ? ', " Not so well . I've come down with the flu . ", " I'm sorry to hear that . Take care of yourself . ", " It's really great to see you again . How about a drink tonight ? ", ' Sounds wonderful . When shall we make it ? ', ' How about seven ? ', ' OK . ', " I'll pick you up . ", ' Thank you . ']
['My son came home from three years in the navy . ', ' It was a real red letter day for you . ', ' Yeah . We rolled out the red carpet to welcome him home . ']
['What are your hobbies ? ', ' Sports . ', ' Like what ? ', ' Basketball and swimming . ']
["it's a lovely day , isn't it ? ", " yeah , and most excitingly , I met the girl living under me today . She's really nice . ", ' is she American ? ', " yeah , and most importantly , she's single ! Man , I could tell from the moment I saw her , she's the girl of my dreams ! ", " so I take it you two are hitting it off ? I know it's very convenient to be in a relationship with your neighbor , but what if you break up ? ", " I don't know . I am not really worried about that . I don't wanna lose before even starting . Besides I think the other two American guys have also fallen for her . ", " sounds like you've got some competition . You made a move already ? ", ' not yet . But I am thinking of inviting her to dinner sometime . I know some good restaurants nearby . ', " that's nice . Having been here a little while surely gives you the advantage , eh ? ", " you bet . Now that you mentioned it , I think I'll call her now and see if she is available tonight . ", ' good luck ! ', ' thanks ! ']
["Hi ! I'm Hong lei . What's your name ? ", " Hello , Hong Lei . My name's Ricky . ", ' Hi Ricky . Are you a new student here ? ', ' Yes , I had my first lesson this morning . Are you a new student too ? ', " No , I've been here for six months . ", " Six months . That's a long time . ", " It's not so long really . What class are you in ? Intermediate or ... ? ", ' Intermediate Three . And what about you ? ', " I'm in Advanced One . Who's your teacher ? ", " I can't remember her name , but she's got curly red hair . ", ' Ah ! Does she wear glasses ? ', ' Yes , I think so . ', " That's probably Anne Wallis . ", " Yes that's right . Do you know her ? Is she your teacher too ? ", ' No . But she taught me last term . How long have you been here ? ', ' Only a week . ', ' Wow , not long . Where do you live ? With a family ? ', " Well , I'm staying at the YMCA at the moment . I'm looking for somewhere more permanent . Do you know of any good places ? ", " Yes . Actually my friend has a spare room in here apartment and she's looking for a flatmate . Would you like her phone number ? ", ' That would be great ! Thanks for your help . Can I buy you coffee ? ']
["Guess what ? I've got great news ! ", ' What is it ? ', " Well , you know how I've been working at the Economist as a proof-reader , right ? ", ' Yes . ', ' Well , the editor-in-chief heard that I had experience as an editor at another magadize and asked me if I was interested in becoming an assistant editor for him . ', " Really ? That's fantastic ! Will you get a chance to do any writing ? ", ' She said that the columnist for the literary criticism column would be going on pregnancy leave soon and that I could be in charge of the column until she came back . ', " Wow ! That's really great news . How often does the magazine come out ? ", " It's a monthly magazine , but my column will be shared with another columnist so my articles will be due fortnightly . ", ' Are you looking forward to doing more editing work ? ', " Yes , but I'm even more excited about getting my thoughts published again ! ", ' Do you have any order forms here so that I can get a subscription to the magazine ? ', " I don't have any with me , but I think I could manage to bring a free copy home for you . ", " I'm really looking forward to reading your column . ", ' Me , too . Do you want to go out to celebrate my good news ? ', ' Sure , where would you like to go ? ', " Perhaps we could go to the library festival that's going on at the local bookshop . "]
["I don't think the teacher had a right to say that.The teacher was wrong to have accused her in front of the whole class . ", " You've got to be joking ! It's the teacher's right to say anything wants , and if she saw Myra cheating , she certainly had the right to say so . ", ' I agree she had the right to say something , but I feel she should have done it privately . ', " You're right.If I were the teacher , I wouldn't have done that . "]
['Welcome ! Sophia told us you were coming ! ', " Um ... It's wonderful to be here . Uh ... this place looks really cozy . ", ' Thank you ! Your cheeks are as red as a tomato ! Are you shy ? ', ' Maybe ... ', ' Some of my grappa will cure your shyness . ', ' Is that a kind of alcohol ? ', " It's a clear spirit we drink any time of the day . You will love it ! ", ' Great . My face will turn even redder ! ']
['Who wants to go first ? Allen ? ', " Uh ... I mostly just like to listen . You're the groom . Why don't you go first ? ", ' OK . Put on something by the Backstreet Boys ! ', " How about As long as You Love Me ! You can pretend you're singing it to your fiancee Brooke ! ", " I'd better not . Brooke hates the Backstreet Boys ! "]
['Are you free tonight ? ', " Yes , I am . What's wrong ? ", ' Would you please go to a dancing party with me ? ', ' OK . No problem . ', " As a matter of fact , I haven't danced for a long time . ", " But it's said that you dance wonderfully well . ", ' Thanks for flattering me . I think you dance a lot , right ? ', ' No . Just occasionally . ', ' What are your favourite dances ? ', ' I love rumba and waltz . ', ' How about samba ? ', " To tell the truth , I don't like it . It's too fast . ", " Then I'll see you at six . Is that all right ? ", ' OK . See you then . ', ' See you then . ']
['I would like to watch the Oscars on Tv tonight . How about you ? ', " Yes , I'd love to . It ’ s interesting to see who is considered the best in their field and which film are thought to be particularly good . ", ' I like watching it for the fashion . I like to see what the ladies are wearing . Of course , the men nearly always just wear the traditional tuxedo . ', ' Sometimes the men wear flamboyant colours . Which films do you think will win awards this year ? ', " I'm really not sure . Usually just one or two films look set to sweep the awards ceremony , but this year there are several contenders . ", ' You ’ re right . This year should be much more exciting than usual . What ’ s you favourite award category ? ', ' You might think this strange , but I like the category for “ best foreign language film " . ', ' It ’ s nice to see foreign language films making a little impact on Hollywood . I like the “ best actor and actress ” . ']
['You won ’ t believe who ’ s been elected to do overtime on the Baker account ! Me ! I ’ Ve already logged in 20 hours of overtime ! ', ' Wow ! Why so much ? I thought they were getting you an assistant . ', ' They were supposed to , but so far nobody ’ s turned up , and I ’ m left on my own to do the work . This is the first break I ’ Ve had all day . ', ' They ’ re really running you into the ground . Why don ’ t you ask for some time off ? You could take a long weekend and go away somewhere . ', ' You won ’ t believe who ’ s been elected to do overtime on the Baker account ! Me ! I ’ Ve already logged in 20 hours of overtime ! ', ' Wow ! Why so much ? I thought they were getting you an assistant . ', ' They were supposed to , but so far nobody ’ s turned up , and I ’ m left on my own to do the work . This is the first break I ’ Ve had all day . ', ' They ’ re really running you into the ground . Why don ’ t you ask for some time off ? You could take a long weekend and go away somewhere . ', ' You won ’ t believe who ’ s been elected to do overtime on the Baker account ! Me ! I ’ Ve already logged in 20 hours of overtime ! ', ' Wow ! Why so much ? I thought they were getting you an assistant . ', ' They were supposed to , but so far nobody ’ s turned up , and I ’ m left on my own to do the work . This is the first break I ’ Ve had all day . ', ' They ’ re really running you into the ground . Why don ’ t you ask for some time off ? You could take a long weekend and go away somewhere . ']
['Jimmy , I ’ d like to wear this robe for tonight cocktail party . What do you think of it ? ', ' Don ’ t dress like that . You ’ ll make fool yourself . You look stupid in that robe . ', ' What ? But it is my favorite piece of clothing . ', ' Maybe it is . But it ’ s out of fashion . ', ' What am I going to do ? ', ' Let ’ s go downtown and pick up some fashionable clothes for you . ']
['Would you like to come out with me tonight ? ', ' Sorry , I can ’ t . ', ' Tomorrow night , then ? ', ' I ’ d like to . But I ’ m afraid I can ’ t . ', ' I was wondering if you like to go to the theatre then . ', ' That sounds great . ', ' Ok . How about give me a ring , then ? ', ' No . I ’ d better not . ', ' Why not ? ', ' Because I don ’ t think my husband would like it . Thank you for inviting me anyway . ']
["I don't know what to do , if I can't find the money . ", " Don't worry yourself too much . ", " It's a large sum of money . I can't afford to lose it . "]
['Too ... your face is really oily ... perfect ! ', ' Why ? Are you planning to stir-fry my face ? ', " Nope . I'm going to tell your fortune . So ... the oilier , the better . ", " You've gone bonkers , Jen . ", " It's facial paper , and it fits into the rings of my binder ! It's magical . ", " OK . Let's see . Give me a sheet . "]
['Have you finished your work ? ', ' Not because I ’ m keeping an eye on the baby . ', ' Where is the baby ’ s mother ? ', ' She is at the supermarket downstairs . She said she would be back in about half an hour . ']
['Bob , how about joining the boxing club this summer vacation ? ', ' What a good idea ! ', " So let's get registered tomorrow . ", ' OK . ']
["I'm sure he was off-side . ", " But the ref didn't whistle . ", ' I think he favors the host team . ', ' Anyway , the host team seems to fight for the gold . ']
['What do you think of the former champ ? ', ' There were some bad misses in his defence , so he lost it . ', ' No champion can remain at the top for ever . ', " I suppose he's not in top form . "]
['I want to say goodbye to everyone . ', ' You ’ re leaving so soon . When are you off ? ', ' I ’ m catching the 9 fifteen train tomorrow morning . ', ' How about I come and see you off ? ', ' You really don ’ t need to . ', ' Ok . I ’ ll miss you . I hope we can see each other again soon . ', ' I hope so , too . Thank you , Lily . Thank you for everything . ', ' You ’ re welcome . ', ' Please say goodbye to the rest of the family for me . ', ' Ok . Take care . I hope you have a good journey . ', ' Thank you . Remember to look me up if you ’ re ever in Washington . ', ' Of course . I will . ', ' Goodbye , then . Thanks again for everything . ']
['How ’ s your father ? ', ' He ’ s fine . He retired last week . It ’ s turning point in his life . Now he can relax and enjoy his retirement . ', ' He can spend more time with his grandchildren . ', ' Oh , I don ’ t think he wants to . He wants to travel to several different countries around the world . ', ' So , he wants to have a more active retirement . Good idea ! ', ' How do you want to spend your old age ? ', ' In the same way , probably . ']
["You're not looking happy.What ' s the matter ? ", " Oh , nothing special . I'm just a bit tired . ", ' With the job ? ', ' With everything , with everybody , with all this ! ', ' A good suggestion for you.You need a holiday . ', " It wasn't always like this , you know . ", ' What do you mean ? ', " Well , I mean.We always do the same thing.There ' s no variety in our lives . ", " You need a holiday.That ' s what's the matter . ", ' Certainly , perhaps . ']
['Delicious ! Did you make this chocolate cake yourself , Fred ? ', ' Yes . I did . ', " It's really good . "]
["Let's take a coffee break . ", ' Why not ? ']
['The Canada Day is on the 1st of July . ', ' What is its national anthem ? ', " The national anthem of Canada is ' O Canada ' . ", ' Can you sing the song ? ', ' Yes , I could sing it when I was very young . ']
["Beautiful day , isn't it ? ", " Yes , it's not like what the radio said at all . ", ' I wish it would stay this way for the weekend . ', " As long as it doesn't snow ! "]
['You must be pretty excited about your trip to Europe . When is it that you are leaving ? ', ' In just three weeks , and I am excited . But there are still a few things I need to do before I go . ', ' Like what ? ', " Like renewing my passport , going to the travel agency to buy my plane ticket and figuring out what to do with my apartment while I'm gone . ", ' You are not going to give it up , are you ? ', " No way . I'll never find another apartment around here . But I don't like the idea of paying three months ' rent on an empty apartment , either . ", " I don't blame you . Perhaps you could sublet it . ", ' Yes , but whom to ? ', ' Mmm ... let me think . Oh , I know just a person . An old colleague of mine , Jim Thomas , is coming here to do some research this summer , from June to August . ', " That's exactly when I'll be away . It sounds ideal , as long as the landlord agrees . ", " Tell you what , I'll be calling Jim late this week anyway , so I'll mention it to him then . ", ' Well , thanks , Bill . Let me know what happens . That extra money will really come in handy . ']
['How is your new car ? ', " Perfect . Couldn't be better . ", ' Why do you say so ? Can I see your new car ? ', ' Of course you can . ( Lead Carl to his garage . ) ', ' Wow , this new car is dynamite ! It is a shiny , beautiful car . ', ' My car is simply a daisy . It drives smoothly . ', ' The car has very sleek lines . I love it . ', " I am glad to hear that . I'm really pleased with it . ", ' You made a good choice . ']
['Could you tell me the right time , please ? ', " Well , my watch says five past two , but it's no use relying on it , because it has been gaining and losing these last few days . ", " You'll have to get it fixed . ", ' Yes , I will . ']
["How's your business ? ", " Everything seems to be getting worse . I don't know what to do with it . ", ' Things are tough all over . You should never give up ! ', ' But how can I prevent a deficit ? ', ' I think you should make a thorough market investigation now . ', ' OK , OK . I ’ ll do my best . ', ' I always consider you are such a guy who never gives up . ', ' I know life is not all roses , and I believe I will pull this through . ', ' Yeah , you can make it . ']
['How are you , Sue ? ', ' Pretty good . I ’ Ve just had my new poems published . ', ' Congratulations on your success . ', ' Thank you . ', ' And how ’ s your brother ? ', ' He is fine . ', ' He ’ s going to be sent to Britain to study , really ? ', ' Yes . He ’ s already got the passport and visa . ', ' Fantastic ! Please send him my congratulations . ', ' Thank you . He ’ s very lucky indeed . ']
["Mike , I can't catch up with our Chinese teacher very well . ", ' I advise you to take an additional course in some Chinese schools . ', ' What is that ? ', ' This kind of school is good at helping people to improve their Chinese . ', ' Will they recommend me the class that suits me ? ', ' Sure . You can review the lessons you have learned at school and learn something new there . ', " That's great . I'll tell my mother about it . "]
["It's raining outside , Catherine , it's too bad.What ' s the weather like in your hometown ? ", " It's very hot , the temperature is often over 40C . ", ' Do you like the weather in Seattle ? ', " Not really.But I like it in spring and fall . I don't like it in winter . ", ' Why ? ', " The winter is very rainy , I don't like the rainy day . ", ' What about the weather in Boston ? ', " I lived there for three years . I like summer but I don't like winter . ", ' Is it very cold in winter ? ', " Yes , it is.But it's nice in spring and fall . "]
['God , I didn ’ t realize . I didn ’ t , I didn ’ t know ... ', ' ... Who you were with ? I didn ’ t know whom you were with . ', ' Excuse me ? ', ' Sorry , it ’ s from the Godfather . It ’ s when the , when the movie producer realizes Tom Higgins had emissary of Vito Corleone , it ’ s just before the horse ’ s head ends up in the bed with all the bloody sheets , you know , wakes up , and AAAL ! Never mind . ', ' You were spying on me , weren ’ t you ? You probably rented those children . ', ' Why would I spy on you ? ', ' Because I am your competition which you know perfectly well , or you would not put up that sign just around the corner . ', ' The entrance to our store is around the corner . And there ’ s no other way of saying that . It ’ s not the name of our store . It ’ s where it is . And you do not own the phrase around the corner . ', ' What is that ? What are you doing ? You ’ re taking all the caviar ! That caviar is a garnish ? ', ' Look , the reason I came into your store is because I was spending the day with Annabell and matt . And I was buying them presents . I ’ m the type of guy who likes to buy his way into the hearts of children who are his relative . And there ’ s only one place to find a children ’ s book in the neighborhood . That will not always be the case . And it was yours . And it is a charming little bookstore . You probably sell what 350,000 worth of books in a year . ']
['Hi , do you know what ’ s for dinner ? I ’ m starving . ', ' We ’ re on our own tonight , dad ’ s taking mom out . ', ' Out ? What do you mean out ? ', ' You know on a date , they are going to dinner . ', ' Dad and mom ? ', ' Yeah , they said they ’ re reviving the old tradition . ', ' You mean this is going to be a regular thing ? ', ' That ’ s right , once a week . Do you want to order some pizza ? ']
['Have you been in America long , Hellen ? ', ' No . Only for a couple of weeks . ', ' Where are you going to study ? ', ' I am going to register at Harvard next month . ', ' What are you going to major in ? ', ' I am going to major in tourism . What about you ? How long have you been here ? ', ' For nearly four years . ', ' Well . You should be able to give me some advice on where to stay . At the moment , I am staying in a hotel which is far away from the school . ']
["That's right . And I'm going to be Vice President of Marketing . ", " Way to go , Mary . A lot has happened during the last few months , hasn't it ? ", ' You can say that again ! ', " What's up with Vince and Elvin ? ", ' They work for Zina now . ', " And they're happy with that ? ", " They're in awe of her . After they saw how she crushed WebTracker ... but I guess you know all about that . "]
["Why don't you have dinner with me tonight ? ", " I'd love to . ", " Let's say about 6:00 ? ", " That's OK with me . "]
['Did everyone fill out their entry permits ? ', ' Yes . The videographer has already started filming my parents trying to speak English with the flight attendants . ', ' Speaking of flight attendants , they keep smiling at me . I wonder why ... ', " It'll be the year 2000 ! The flight attendants are coming over here . They're carrying bottles of champagne ! ", " That's because it's time . ", ' Time for what ? ', " It's time to make our wedding wish come true ... ", ' You mean get married now ? On the plane ? ', " Why not ? I've got the rings ready . ", " I don't know what to say , Jack ! ", ' Hopefully , you\'ll say " yes " ... ']
['May I help you ? ', ' I would like to return this book . ', ' May I do anything else for you ? ', ' I would also like to check out these books . ', ' Will that be all ? ', ' That ’ s it . ', ' Do you have your library card ? ', ' Oh , yeah . Here you go . ', ' Will that be all for today ? ', ' That ’ ll be all . ', ' These books are due back in two weeks . ', ' Thanks . Have a good one . ']
['Suit wrote me a letter . ', ' What did she say ? ', ' She got a master degree , and now she is going for her doctor . ', " Really ? I can't believe it . ", " It's not a surprise , is it ? She has always been a hard working student . ", ' But I think a master degree is good enough for a girl . ']
['I am sorry . I ’ Ve left my disk at home . ', ' Thank you all the same . ']
['Let ’ s go to the seashore on Saturday . ', ' Yes ! Let ’ s go sailing and water skiing . That ’ s so exciting . ', ' It ’ s expensive , too . Let ’ s just sit in the sun and go swimming instead . ', ' Yes . Let ’ s sleep on the sand . That ’ s most exciting ! ']
['Dou you think I should join a basketball team , Mary ? ', ' Why not . If I were you , I certainly would . ', " But I'm afraid it will take too much of my time . ", ' As the saying goes , work value work , play value play . All work and no play make a jucky-dull boy , you know . ', ' Em , you ’ re right . ']
['Titanic made a hit ! It was so touching . ', ' But I see things rather differently.The heroin is not attractive and her acting is just so-so . ', ' The heroin may not be attractive . I like the story , though . ']
["Congratulations ! You've just won a car ! ", " It's too good to be true . "]
['How are your wedding plans going ? ', ' Very well . We started organizing everything early to avoid a last minute rush to get things done . ', ' When will your wedding take place ? ', " At ten o'clock on the morning of next Sunday . We have invited all our relatives to the wedding . ", ' It will be a large church one . Is your wedding dress ready ? ', ' Yes , its design is very elaborate and the designer took many weeks to make it . ', ' You will be very beautiful on your wedding day . ', ' Thank you ! ', ' Which hotel will the reception be held at ? ', ' The Palace Hotel . ', " It's excellent . A friend of mine had her wedding reception there and said it was perfect , though very expensive . ", ' It will be expensive , but we think it will be worth . ', ' I think you made the right decision . ']
['Please come in ! ', ' Hi . Steven . I just drop in and want to have a chat with you . ', ' Oh , so nice of you to come here . Have a seat . Please make yourself at home . ', ' OK . ( Sit on the sofa ) Wow ! Your house was decorated so beautiful . ', ' Thank you . My wife would be very happy to hear this . ', ' She must have done a lot of work on it . ', ' You bet . ']
["Hey ! What's up ? ", " Hi , John ! I haven't seen you for ages . ", " Yeah , I've been out of town . ", ' So how have you been ? ', " Great ! Work is really busy now , but it's fun . "]
['We must set 1000 dollars aside each month . ', ' Why ? ', ' We are going to buy our own house . ', ' Really ? Congratulations . ']
["Hey , Jeff , where's your stereo ? ", ' I needed some money , so I hocked it last week . ', ' You must have been really hurting for cash to have done that . ', ' I had just enough money to make ends meet until payday . Then last Wednesday I received a phone bill to the tune of $ 195.00 . I hit the ceiling when I saw that . ', " It sounds like you weren't expecting that . ", " I'd forgotten that my brother had used my phone earlier this month to call his girlfriend . He forgot to mention that she happened to be in New York at the time 3000 miles away . ", ' Well , if you need some money to tide you over until payday , I can loan you some . ', " Thanks , but tomorrow's payday I can make until then . Thanks any-way . "]
['So what are you doing for Thanksgiving ? ', " Not much really . It's more of an American tradition , so back home we don't really celebrate it . In fact , I am not even sure of what exactly is being celebrated ! ", " Well you know , it's a time to get together with all your family and be thankful for everything ! ", ' Yeah but , how did this holiday come to be ? ', ' Well , the first settlers of Massachusetts arrived there because of religious persecution from England and King James . Once in the New World , they befriended an native named Squanto , who taught them how to harvest food from the area such as corn . ', ' And then what did happen ? ', ' Well , they had enough harvests for the next winter and celebration 。 They decided to have a big feast for the natives , giving thanks the land , and everyone for the foods , healthy and new lives . ', ' Interesting ! I am amazed how big and delicious thanksgiving dinners are ! ', ' Come to my house for Thanksgiving ! We are having turkey , pumpkin pie , mashed potatoes with gravy , and lots of stuffing ! ', ' Count me in ! ']
['Cheers ! To our first night in our new apartment . ', " It's so quiet . I'm not really used to it . ", ' All you hear is the crickets and the breeze . ', " It's a little eerie . I'm sure the silence will begin to grow on me . ", " Well , I think it's fabulous . And the neighbors don't even seem to exist . ", " That is a relief . It's a good thing we moved . "]
['Ms . : Do you have a question , Mary ? ', " No . That's not why I raised my hand . I need to go to the ladies ' room . ", ' Ms . : Let me give you a hall pass for it . ', " What's a hall pass ? ", " Ms . : With a hall pass , you can go to the ladies ' room or wherever you need to go during class time . ", ' I see . ', ' Ms . : If a teacher stops you in the hallway , just show him or her the pass . ', " Or else I'll get into trouble . ", " Ms . : That's right . "]
['What do you think of the speech the man delivered just now ? ', " Don't believe him . He's a liar . ", ' We cannot expect politics to be true anyway . ', ' Exactly . ']
['So , you friend ’ s getting married on Saturday . What have you bought her as a wedding gift . I find is so hard to choose the right gift . ', ' My friend and her fiance had a really good idea . They have cut out pictures from catalogues and pasted them in a notebook . The picture are of things they want . People sign their name by the item they will buy . ', ' That ’ s clever ! Then everyone knows that they are buying something the couple really want and there ’ s no chance of two people buying the same gift . What things were in the notebook ? ', ' Most of the things were household appliance . You know , everything from an iron through a vacuum cleaner to a cooker . I think it ’ s an excellent way for everyone who knows the couple to help them set up home . ', ' So , what did you get them ? ', ' I bought a sewing machine . I know that my friend likes making her own clothes , but her current sewing machine is quite old and has some problems . ', ' What ’ s wrong with it ? ', ' She says that after several years of use , it ’ s not working properly . When she uses it , it makes a funny noise . ', ' Household appliance don ’ t seem to last for a long time nowadays . ', ' I think it ’ s because the manufactures are constantly bringing out new models . Because they know that we will buy the new models , the appliances don ’ t need to last more than five or ten years at most . ']
["hey , Jimmy , you've been sitting in front of the TV all day . Anything interesting on TV ? ", ' not really . Quite boring right now , actually . Mostly infomercials and public service announcements . ', " why don't you turn off the TV and get outside ? You need to get some fresh air . ", " I know , I know.But my favorite show is on in a couple of minutes . It's the series finals , and I wouldn't miss it for the world ! ", " Really ? What's the series about ? ", " well , it's about how an immigrant girl achieve her dream in America . It's a sitcom but really quite smart and really funny . I think you'd like it . ", " it sounds interesting , but I am not a big fan of TV shows . They're time consuming and don't have much depth . ", ' I believe some shows are quite informative and interesting . Take this show for example , it examines American xenophobia and how it might conflict with the American dream , with hilarious results . ', " really ? that's interesting ! ", " yeah.Oh , here it comes ! why don't we watch it together ? they are going to have a court debate in this episode . It should be good . ", " OK , I'll give it a go . "]
['I ’ Ve had it ! I ’ m done working for a company that is taking me nowhere ! ', ' So what are you gonna do ? Just quit ? ', ' That ’ s exactly what I am going to do ! I ’ Ve decided to create my own company ! I ’ m going to write up a business plan , get some investors and start working for myself ! ', ' Have you ever written up a business plan before ? ', ' Well , no.it can ’ t be that hard ! I mean , all you have to do is explain your business , how you are going to do things and that ’ s it , right ? ', ' You couldn ’ t be more wrong ! A well written business plan will include an executive summary which highlights the idea of the business in two pages or less . Then you need to describe your company with information such as what type of legal structure it has , history , etc . ', ' Well , that seems easy enough . ', ' Wait , there ’ s more ! Then you need to introduce and describe your goods or services . What they are and how they are different from competitors ’ ? Then comes the hard part , a market analysis . You need to investigate and analyze hundreds of variables ! You need to take into consideration socioeconomic factors from GDP per capita to how many children on average the population has ! All this information is useful so that you can move on to your strategy and implementation stage , where you will describe in detail how you will actually execute your idea . ', ' Geez . Is that all ? ', ' Almost , the most important piece of information for your investors will be the financial analysis . Here you will calculate and estimate sales , cash flow and profits . After all , people will want to know when they will begin to see a return on their investment ! ', ' Umm . I think I ’ ll just stick to my old job and save myself all the hassle of trying to start up a business ! ']
['Are you a blogger ? ', " Sure I am . I've been writing a blog for almost three years . ", " Oh , it seems that I'm the only one who never blogs . When did you get started ? ", ' I began blogging when I first went to the US for my graduate strides . ', ' What do you usually write about ? ', " At first , I'll write about my life there . Like interesting things on the campus , travel stories , special English words that I come across . Sometimes , I'll post my pictures on my blog so my friends and family can get to know how everything's going . ", " That's interesting . How often do you write a blog ? ", " It's random . If there happen to be a lot of things going on , I may add several new entries in a week , and if I've got nothing to share , I may leave my blog untouched for weeks . ", ' Got it . Are you still updating your blog ? ', " Sure , since I came back from the US , I've been keeping the habit of blogging , simply to share my personal insights on any topic I like . ", ' Good for you . I know many people just leave their blogs alone after the first few months . ']
['What are you doing this Saturday ? ', ' Not much . ', ' Do you want to go see a movie ? ', ' That sounds good . ', " What's playing at the Century Fox ? ", ' Candlelight in the Window ', ' Should we go see it ? ', " I'd rather not . I don't like horror movies . ", ' How about ‘ Run of the Mill ? ’ ', " No . I heard that's really boring . ", " Why don't we go to a concert instead ? ", ' Great idea ! ']
['Hello , My name is Candy Brown . May I have your name ? ', ' Hello , Candy . My name is Jim White . Nice to meet you . ', ' Nice to meet you , too . Where are you from ? ', " I'm from New Orleans . What about you ? ", ' I was born here . ', ' Really ? This is a beautiful town . ', " It's nice talking to you . But I have to go . ", ' OK . Can I have your phone number ? ', " OK . It's 15066688866 . Call me ! Bye-bye , then . ", ' I will . Bye . ']
["It's a lovely day , isn't it ? ", ' Yes , the weather sure is nice today . ', " I love it when the weather is like this.Why don't we sit down outside and have our lunch ? ", " That sounds like a good idea.The sky is clear , the sun is shining and there's a nice cool breeze , so it is not too hot . ", ' I really miss the change of seasons like we have in Colorado ; but I must admit , this sure is a nice spring day . ', ' Hey , this spot in the shade looks really comfortable . ', ' Okay.Hey , is that a dark cloud over there ? Do you think it will rain after all ? ', " I don't think so . I say the weather report last night , and it said the weather should be fine all day . ", " If the weather stays nice perhaps we can go to the beach this weekend.It ' s been a while since I've not really gotten some sun . "]
['I hear that you have been promoted . Congratulations on your promotion ! ', ' Thank you , but I hate having to leave here and working abroad . ', ' When are you going ? ', ' Sometime next month . ']
['I need your help , Bob . ', " What's the matter ? ", " I'm really confused by these annoying abbreviations . ", " Just relax . That's because you're new to chat . Let me take a look . ", ' A / S / L , IGP , H & K , and ZZZ . What the hell do they mean ? ', " ZZZ means'sleepy or tired or bored ' , A / S / L is tricky , which is often used at first encounter . It's a three-word question , ' age , / sex / location ? ' ", ' Interesting . Then what does H & K refer to ? The city of Hong Kong ? ', " Wrong . lt's not a place name , but a passionate act . ", ' Really ? What kind ? A girl left this word to me , and I thought she was in Hong Kong . ', " Ahahah ... you miss her point for sure . H & K actually is an acronym for ' hug and kiss ' . ", " Hug and kiss ? ! How is it possible ? Oh , it's really bad to Miun - Verstand her meaning . ", ' Yeah , seems that you have a lot to learn and memorize . ']
['why are you in such a good mood today ? ', ' well , yesterday , I decided to face my fear of heights . ', " I didn't know you were scared of heights ! Was it really bad ? ", " let me put it this way . I've never seen a professional sorts game in a stadium because I could never get myself to walk to the top of the stairs to sit down . ", ' so what did you do about it yesterday ? ', ' I went sky-diving ! ', " you're kidding me ! that sounds really scary ! ", ' It was scary , but it felt great , too . ', " weren't you scared ? ", ' of course I was scared . But I had an instructor that went with me and that helped . ', ' so have you cured your fear of heights ? ', ' I think so . After I jumped out of the plane , I realized that I should just enjoy life . Worrying about it or not doing things out of fear is just plain silly . ', " I'm impressed . ", ' are you scared of anything ? ', " well , sometimes I get scared when I'm in my apartment all by myself . ", ' what do you think is going to happen ? ', ' I always worry that the door is unlocked or that a window is open and that a stranger will come in and steal my things . ', ' it sounds like you just need to be more careful . ']
['Look out ! ', " What's it ? ", ' You must have rolled over something just now . ', ' What you said gives me the creeps ! ']
['Mr . Green , I ’ d like to introduce you to Mr . Brown . ', ' How do you do , Mr . Brown ? It ’ s a pleasure to get to know you . ', ' My pleasure , Mr . Green . I look forward to an excellent relationship with your company . ', ' I propose a toast to the health of everyone here and to the success of our negotiation . ', ' Okay , let ’ s make a toast . ']
["So who does he think he is , anyway , I can't believe the way that my boss has been ordering everyone around lately , I mean , it's now like he is the CEO , or anything . ", " Um ... Actually I am guessing you didn't get the MEMO . Your boss was selected to fill the vacancy in the CEO slot . He actually is the CEO now , or will be , as soon as the official press releases and hoopla is done with . ", " Yikes ! you are joking , right ? I can't believe it . No wonder he is so stressed and bossy lately . I thought he was just being ostentatious by giving orders to people and all the different departments . What big shoes to fill ! ", ' No kidding ! When the last CEO left , we were worried about the future of the company . ', ' What does a CEO do anyway ? I know the CEO makes the most money in the company , but what does he actually do ? ', ' He is responsible to the board of directors for everything that happens in the company . He or she must give leadership to all company officers , as CEO is also responsible for providing the guidance of philosophy of the company , and acting as official representative , or face of the company . ', ' Must be one smart guy . ']
['Okay , can I ask you something direct ? ', " Ha ! It's not like you've ever been one to beat around the bush . ", ' Fair enough . Give it to me straight . Did she bully you into this ? ', ' No , seriously . . . I really want this . ', " I tell ya , when I got the invite , it really threw me for a loop . You've done a complete 180 . ", " I know . But things have changed . I guess I've settled down . ", ' I guess so . ']
['Have you ever been in an earthquake ? ', ' Yes , I experienced one when I was in Tokyo once . The tremors only lasted a few seconds though and then it was over . ', ' Do you know where it measured on the Richter scale ? ', " I don't remember , but it wasn't very serious . Have you ever been in an earthquake ? ", ' No , but I was in quite a few tornados when I was younger . ', ' Where are you from ? ', " I'm from the plains of the Midwest . It's a prime location for tornadoes . ", ' Did your house ever get damaged from the winds ? ', ' Most of the time we were lucky , but once a tree from our front yard was ripped out by its roots and ended up in our living room . ', ' Wow , that must have really been scary . ', ' Actually , some of my fon best memories of my childhood were of spending time with my family in the basement waiting for the tornados to pass . ', ' Have you ever experiences a flood ? ', " No , but my father's car was destroyed in a flood once . It actually happened the day after he bought the car ! ", " That sure didn't last long ! "]
['There is a tornado warning on . My mother just told me she heard it on the radio . ', ' What is a tornado warning ? ', ' It means that a tornado has been seen somewhere in the area . ', ' Really ? In New Berlin ? ', ' No . Not necessarily in town . But in southern Wisconsin somewhere . A tornado has been spotted . They have two stages here.This is what is called a tornado watch . That means that the weather conditions are perfect for a tornado . ', ' I understand . They think a tornado might come . ', " Yes . People should look out , because maybe there will be tornadoes coming.So it's called a watch . ", ' And the second stage is called a tornado warning . ', " Yes . If a tornado has been spotted , they announce a tornado warning.So if there's a tornado warning on , it means a tornado is out there somewhere . ", " It's scary . ", " Well . Tornadoes can be dangerous , it's true.If we hear something like a loud train coming , then we have to go in the basement . ", ' What do you mean a loud train ? ', " That is what tornadoes sound like . They sound like trains . They're very loud . ", " But if you hear them coming , isn't it already too late ? ", " Maybe . It depends on the tornado.Some can move across the ground at 200 miles an hour.That is very fast . Others aren't so fast . ", ' Have you seen a lot of them ? ', " I've only seen one in my life . I was looking out the window . It was around two miles away . It was very interesting to watch.But it was heading toward my friend's house . So I quickly called them on the phone . ", ' Did it hit their house ? ', " No , it didn't . But they are glad I called them . ", ' What were they doing when you called ? ', ' They were all sitting in the living room watching TV.They had no idea a tornado was coming toward their house.If it had hit them , they could have all been killed . ', " That's terrible . Do many people die in tornadoes ? ", ' Not so many really . But a lot of houses are destroyed sometimes . ']
['Is this your brother-in-law ? ', ' Yes , he married my sister ten years ago . ', " From his looks , I'd say he's a man of character . ", ' Yes , my sister loves his personality . ']
['What about you , Ernie ? How did you get into pop music ? ', ' Well I always hear it on the radio , so I started to get into it . ', ' Yeah , if something is on the radio it must be really good . ', ' I totally agree ! ']
['Hello , Mary . Why are you standing here in the cold wind ? ', ' I ’ m waiting for a bus and going for a walk in the park . ', ' Going for a walk in such a cold weather ? ', ' I always like to go for a walk before a supper . ', ' I see . ']
['Can you tell Bob from Tom ? ', " How can I ? They're as alike as two peas in a pod . ", " Don't you notice that Bob has a mole on his face , but Tom does not . ", ' You really have keen eyes . ']
['I have a problem . ', " What's the problem ? ", ' My mattress was supposed to be delivered today . ', ' Is there a problem ? ', ' The delivery people showed up four hours late . ', ' I apologize for their tardiness . ', ' I was late for work because of them . ', ' Again , I do apologize for the inconvenience . ', ' I want my money back for the delivery . ', " Seeing as they were late , that won't be a problem . ", " It shouldn't be a problem . ", " I'm going to refund your money right now . "]
["Hi , my name is Pete . You are Ann . Isn't that right ? ", ' Hi Pete , how do you know my name ? ', ' Do you see that girl in the red top ? She told me who you were . ', ' Oh Andrea , the Spanish girl ? ', " Yes , that's her . ", ' I met her last week at a party . Anyway , you must be from the United States ? ', ' Actually I live in London , but my family lives in Seattle . ', ' Oh , I am from London as well . ', ' Where in London do you live ? ', ' In Wimbledon - quite close to the tennis courts actually . Which is very nice because I love tennis . ', ' I play tennis there every week . Shall we have a game one day ? ', " That would be lovely . But now let's go and get a drink . "]
['Every year , the South has the floods . It is an act of God . ', ' Do you really think so ? ', ' Yeah , you have some other ideas ? ', ' Think , in some way it is an act of God , but in another way , it just is caused by us . ', ' For example ? ', " We didn't pay attention to the environment , cut down trees and polluted the air . ", ' Oh , I see . Fortunately government has taken some action to prevent such things . ']
['John got a heart attack last night . ', ' Oh really ? Is he all right ? ', ' Not so good , though his nephew took him to hospital in time . ', ' Poor old John ! I am ever so sorry . ']
["Watch out ! You're too close to the fire place . ", " Don't worry , but my clothes are made of leathers . ", " Really ? That's wonderful ! ", ' Thank you for your warning . ', ' Not at all . ', ' Be careful of yourself . ']
["You talked like the Terminator for two months ? Wow , I think you liked that movie even more than I liked ' Titanic . ' Why did you like ' Terminator ' so much ? ", " Well , ' Terminator ' is a really great action movie , and I like action movies because they're exciting . ", " Isn't ' Terminator ' really violent ? I usually don't like gory movies because they gross me out . ", " It is pretty violent , but since it's just robots fighting one another , it isn't very bloody and so it won't gross you out . ", " Hmm ... I don't know . Even though it may not be gory , I think it would still totally freak me out . "]
['So do you believe in palmistry ? ', ' Palmistry ? What is that ? ', " It's when someone takes a look at another person's palm 4 to tell the future . ", " Oh , you mean palm reading 5 . I've seen that before , but I don't believe in it . ", " Are you sure ? I've read a lot about palmistry and I've been able to tell a lot of accurate things about a person from his palm . Do you want me to take a look at your hand ? ", " Really ? You've read books about it ? Ok , then . But only if you want to . ", " Ok , let's see , well , you've got a long life line , which is good , and the love line is strong ... ", ' What else do you see ? Will I be successful ? Will I make a lot of money ? ', ' Hmm , hard to say , wait , yes , it looks like you will do well in business , and your ambition will help you a lot , but ... ', " What ? What is it ? What's the matter ? ", " You seem to have a large gullibility line . You believe everything that you're told . ", ' Hey ! ']
['I heard through the grapevine that Michael probably become the new sales manager . ', ' How did you get wind of the rumor ? ', ' I am not a rumor monger . ', ' Let ’ s stop gossiping and get back to work . ']
['Melissa ? I ’ d like to invite you to my wife ’ s birthday party . ', ' Thanks , Frank . I ’ d love to come . When is it ? ', ' Her birthday is on the 9th . We ’ re going to have dinner at a Mexican restaurant , and then maybe go out dancing . ', ' Sounds like fun . You can count me in ! Just give me directions to the restaurant . ']
['Hello , Janet . ', ' Good morning , Pete . ', ' And what is this ? ', " Ah , this is my daughter's birthday present . Her birthday is next week . ", " And when is your son's birthday ? ", ' That is not for a while . His birthday is only in August . ', " But Mark's birthday is in April so I need to think about his present soon . ", ' And when is your birthday ? ', ' Oh , my birthday is in December just before Xmas so of course nobody remembers . ', ' My birthday is in June , when we are always on holiday . So my family often forgets my birthday too . ']
['Thank you very much for everything you have done for me during my stay in China . ', ' And I must thank you again for your generous help . ', " The help is mutual . I must thank you to see me off . My wife and I will be looking forward to seeing you . You will come to see us , won't you ? ", ' I promise I will take the first chance to call on you . Please send your wife with my best regards . ']
['How do you usually spend your leisure time ? I mean , do you have any special interests out of your job ? ', ' Of course . You see , almost everyone has some kind of hobby ', ' Yeah , you ’ re quite right and what ’ s your hobby ? ', ' I like taking photos out of door . ', ' Oh , photography , It ’ s really a good hobby . ', ' Yes , I usually develop and print all my own photos . ', ' You yourself have a photo studio ? ', ' Yes , simple as it is . t does work . ']
['Can I help you ? ', ' Yes , can I return this article , please ? ', ' May I know the reason , madam ? ', " You see , I bought it for my husband , but he doesn't like it . ", ' When did you buy it ? ', ' Last Saturday . ', ' Can I see the receipt ? ', ' Yes , here you are . ', ' Well , if there is no damage , you can return it . ']
['hey , Lily , what are you doing ? ', ' waiting for someone . ', ' you mean the boy you met on MSN ? ', " you're right . He is so funny and I think I'm in love with him . ", " you must be joking . You can't fall in love with someone you've never met ! ", " I know , but I keep thinking of him every day . And I get really depressed when he's not online . ", " I think it's just a crush . You can't be serious . ", " well , this might be silly . But I just can't get him off my mind . And I can't help missing him . ", ' did you tell him ? ', " yes . He said I'm his dream girl . ", " you shouldn't take it too seriously . It might be a lie . ", " I know . I can't tell whether he's serious or not so I need your advice . ", ' I think you should enlarge your circle of real life friends , and then the right person will come along . ']
["hi , Natasha , how's life ? ", ' great . My family came to visit me . ', ' oh , you must be very happy . How many people are there in your family ? ', " my immediate family is very large . It's my mother , my father , my two older brothers , my younger sister and me . ", ' I have a small family . They are my parents , my younger brother and me . ', " I thought you were the only child in the family . Didn't China practice the only-child policy in the early 1980s ? ", " yes , it did . But my parents are ethnic minority people . It's a preferential policy for an ethnic minority family to have two children . ", ' interesting . What do you think about families with only one child ? ', ' the child must feel very longly . My younger brother is 10 years younger than me . Before he was born , I used to be the only child and always dreamed that I would have a younger sister or brother one da ', ' do you get along well with each other ? ', ' yes , we are very close . He is 12 years old and very smart . He always makes us laugh a lot . ', ' you are very lucky to have such a nice family . ', ' thank you . ']
["Is there a city where it's always warm ? ", " Yes , there are many cities where it's almost always warm.San Diego , for example . ", " Are there any other cities where it's always hot ? ", ' Many.Most of the cities in the southern part of the United States are hot all year . ', ' But why do so many people live there ? ', ' Most people grow accustomed to the climate , but there are many others who complain about it all the time . ', ' Are there any cities where it rains a lot ? ', ' Several.Two good examples are Seattle , in the state of Washington , and Portland , Oregon . ', ' Tell us about some cold cities . ', ' In the north there are many cities which are very cold in the winter.Boston and Chicago are two of them . ', ' Is it always cold in Chicago and Boston ? ', ' Oh , no.On the contrary , there are many beautiful days , especially in the spring and fall . ']
['Did you read this ? It says that the number one new years resolution make is to spend more time with friends and family . ', ' Why would that be funny ? ', ' Well , think about it . We are a society that is always on the go , not because we have to , but because we want to . ', ' Why ? ', ' We work hard and spend less time at home because we are trying to provide for our family with goods and services that are usually unnecessary . ', ' I don ’ t agree , but anyways , I think you should start thinking of a new year ’ s resolution yourself . ', ' What ’ s the point ? We always make a new year ’ s resolution and by February we will have forgotten about it . It ’ s pointless . ', ' Well then maybe you should resolve to sticking to your goals and objectives . ', ' What about you ? Your gym bag is gathering dust and you still have brand new running shoes that are yet to be jogged in . ', ' Well , I would go if you kept your promise of going to the gym with me everyday ! ', ' Yeah , yeah , whatever . ']
['You don ’ t look like enjoying this workout . ', ' I ’ m not crazy about it at all . ', ' You don ’ t like this sort of exercise ? ', ' I ’ m not interested in it . Are you keen on it ? ', ' Yes , that ’ s funny . I thought you liked it . ', ' I hate it . ', ' Never mind . It ’ ll be over in 10 minutes . ', ' It ’ s the worst thing I ’ Ve ever tried . ']
['Bye . Take care . ', ' You too . ']
["I'm afraid I've had a terrible row with my boss . What shall I do ? ", " I think you'd better apologize . ", " Oh , but I can't . It wasn't my fault . ", ' Maybe not , but I advice you to say it was your fault . ']
['Jack , what are you doing ? ', ' I am reading . ', ' I can see that . But why are you reading advertisements for houses for sale ? Are you buying a house ? ', ' No , not yet . But I like to see what is available . ', ' Can I have a look as well ? ', ' Of course , have a seat . ', ' Oh , this one looks really good . And look at the garden . So beautiful . ', ' Yes , nice . But I prefer this wooden house with a garden fence and a sloping roof . ', ' Yes , but my house has large windows and so gets lots of sun . And it has a small balcony at the top . ', " Well , you can't compare a small balcony to this large veranda . This is perfect for having a barbecue in summer . ", " Talking about a barbecue , didn't you say you are organizing one next week ? ", ' Yes , next Saturday . I hope you can make it . ']
['John , do you mind helping me prepare for the picnic ? ', ' Sure . Have you checked the weather report ? ', ' Yes . It says it will be sunny all day . No sign of rain at all . ', " I'd like some toast and chicken wings . ", ' Okay . Please take some fruit salad and crackers for me . ', " Done . Oh , don't forget to take napkins , disposable plates , cups and picnic blanket . ", " That's great . We can also take the dragon kite with us . After the picnic , we can fly it . ", ' Cool , we can take shuttlecock and badminton racket . ', ' Okay , it sounds good . ']
['How ’ s your trip going ? ', ' Oh I ’ m enjoying myself but it ’ s so hot here ', ' Isn ’ t London hot in the summer ? ', ' Well it can be but Shanghai is much warmer than London . ', ' I see . What about transport ? How does Shanghai compare to London ? ', ' Actually I think the buses and trains here are more modern . ', ' And what about the number of people on the streets ? ', ' Oh , I think Shanghai is much more crowded than London . ']
['Mom , can you talk about the philosophy of life with me ? ', ' You got me on that one . ']
['Do you like the Harry potter books and movies ? ', ' Not really ! ', ' Why not ? They are very fun and exiting . ', ' Maybe , but I think they are just for kids . ', ' No , that ’ s not true . Many adults like the Harry potter books too . ', ' Maybe they don ’ t agree with my taste . ']
['Hi , Anna . I haven ’ t seen you for ages . Where have you been ? ', ' I ’ Ve been away on holidays for sometime . ', ' No wonder I haven ’ t seen you recently . Where did you spend your holidays ? ', ' I went with my husband . Our first stop was Bangkok . We stayed there for 5 days . Then we flew to Hong Kong , stopover for 3 days . Our last stop was China . We visited the Great Wall . ', ' You must have a wonderful time . ', ' Yes . We enjoyed ourselves very much . Have you traveled much , Luke ? ', ' No , my wife doesn ’ t like traveling . We haven ’ t been traveling for more than ten years . The first time we traveled together was in 1978 when we just got married . We spent our honeymoon in the Alps . ', ' Oh , I see . Yeah . Some people like traveling , some don ’ t . My husband didn ’ t like traveling at first , either . He said what ’ s the use of traveling ? A waste of money and a waste of time.At last I got him on the move . After all , he loved me . We went to Bali , Indonesia , one of the most beautiful places in the world . That trip left a very deep impression on him . Since then whenever we have holidays and money , we ’ d like to patronize the travel agency . Isn ’ t it a bit dull to shut yourself at one place all your life ? ']
["Hey , the pool's open now ! ", ' As of today it is . Memorial Day marks the end of the school year and the beginning of summer . ', " So it's time for the kids to get outdoors ... ", ' ... and for us to get tans in our new bikinis . ', " Not this Taiwanese girl . We don't like to get suntans . ", " That's smart these days with all the news on skin cancer . Hey , there's everybody ! We made it ! "]
['Donna , you really shocked everyone at the party last night ! ', ' You mean with my performance ? ', ' Yes ! We have all assumed that you were the quiet , shy type . ', ' I guess everyone has a few secrets up their sleeve . ', ' Where did you learn to sing like that ? ', ' I was part of a band in school . ', " You ? Wow . And why don't you ever dress like that at work ? ", " Come on ! This is work . Don't you think that would be a little weird ? "]
['Would you like to join the drama club ? ', ' Sure . ', ' Why do you want to join it ? ', " It's very exciting . I think . "]
['Hey man ! How ’ s it hanging ? ', ' Hey man ! Everything is just groovy baby ! ', ' Did you go to the roller rink on Saturday ? I heard it was far out , man ! ', ' I wanted to , but I ran into this foxy lady that just moved to my block ! I was chatting her up a bit and then we mellowed out at her place . ', ' Right on , right on ! Well , Jim went to the rink with Sherry and he said it was dy-no-mite ! He was low on bread , but Sherry paid for everything . ', ' Gravy ! Jim is such a jive turkey man . He is always hitting me up for cash . Anyway , you wanna book and go grab some grub ? ', ' Yeah man , I ’ m starving ! ']
['Did you do anything fun over the weekend ? ', " I didn't want to go out last weekend , so I decided to stay at home and watch a movie . ", " Why didn't you want to go out ? ", " I was very tired after working all week . Sometimes on the weekend I don't have enough energy to go out to a movie theater . ", ' Did you download a movie or rent it at the store ? ', " I downloaded it so that I didn't have to remember to return it . "]
["I'm not a VIP . ", " You're too humble . "]
['Is there a lot of crime in your city ? ', ' There ’ s some , but I don ’ t think it ’ s a big problem . A lot of it is petty crime , burglary and car theft . There ’ s very little major crime . ', ' It ’ s the same in my city . We also have a lot of drug addicts . A lot of the crime is committed by drug addicts who need money for drugs . ', ' That happens in many places . In my city , there is a very good drug rehabilitation program . The police and courts are also tough on people who commit crimes , but I don ’ t know if that ’ s the reason for our relatively low crime rate . ', ' Some people believe that a tough approach is better . Other prefer a more lenient approach . ', ' I think that the best way to reduce crime is to spread wealth more evenly . If most people have similar amounts of money , they will not think of stealing from others . ', ' That ’ s possible , but I ’ m not sure it would really happen like that . ']
['I really should be on my way . ', ' Oh , don ’ t go yet . Let ’ s at least have one more . ', ' No , thank you . I can ’ t . ', ' It ’ s too bad that you have to leave so early . ', ' Thank you very much . I had a really good time . ', ' Thanks for coming ! We should meet again sometime soon . ', ' That would be great ! Actually , can I get your phone number , Ella ? That ’ s assuming you don ’ t mind if I call you sometime . ', ' Anytime . You can reach me 5558929 . ', ' ok , got it . I ’ ll call you sometime next week . ', ' Fine . ', ' It ’ s time to go and I hope we can get together again soon . ', ' I hope so , too . Bye ! Ben . ']
['He said he will get married by the end of this month . ', ' Big talk , I ’ d say . He does not have a girlfriend yet . ', ' Who knows . After all , he is handsome and rich . ']
['My son closed his ear to what I said . I don ’ t know what I should do . ', ' You can twist his arm in order to have a control of him . ', ' I cannot have the heart to do that . ']
['I got a raise . ', " I'm glad to hear that . "]
['I would love to be famous and have thousands of adoring fans . ', ' Really ? I ’ m not sure that I would like all the attention . There have been numerous cases of paparazzi interfering with star ’ s private live in recent years . ', ' I love being photographed ! If I were famous , I ’ d do interviews for all the top magazines , like cosmo and elle . ', ' I wouldn ’ t mind having my photo taken a few times or being interviewed once or twice , but it would get tedious after a while . Imagine the things the gossip columnists would write about you . ', ' no-one really believes gossip columnists . ', ' I think you ’ ll find that many people believe what they read in gossip columns . You ’ d also have to be very careful about every word you said . If you appeared on a chat show and said something silly , it would be reported in all the newspapers and magazines . ', ' I think you ’ re right about that . I ’ d need a good manager to be my spokesperson . I could do a lot of charity work , which would help a lot of people . ', ' That ’ s a great idea . Which charities would you support ? ', ' I love children , as you know , so probably a children ’ s charity . ', ' You ’ d have to remember that anything you said or did might reflect on the charity , so you ’ d really need to be very careful . Anyway , I ’ d be the first to buy your posters and I ’ d attend your first book-singing when you wrote your autobiography . ', ' Thanks , but actually I was hoping I could ask you to write my biography . ']
['Have you ever thought about Tom ’ s attitude ? ', ' I ’ Ve cut it upland come to the conclusion that hi is actually sick of Jenny ’ s brother . But he likes Jenny . She is a big apple in his eye . ', ' Love me , love my dog . He ’ s a sensible kind man . ', ' That ’ s why many people look up to him . ']
["What do you think of the new television channel ? Aren't the programs awful ? ", ' I quite agree with you . They are terrible . They are complete waste of time , but my wife disagrees with me . ', ' Actually , what bothers me is the violence . There are far too many detective and police shows . ', " I couldn't agree with you more . There aren't enough educational programs , and even the news shows are not well done . ", " You are absolutely right . They are too brief . They don't tell you anything . "]
['do you mind if I sit here ? ', ' no , of course not . Go ahead . ', " don't I know you ? ", ' yes , now that you mention it , I think we had a chemistry class together in high school . ', " you're right ! How are you ? It's been a long time ! ", ' What did you do after high school ? ', ' I went straight to university afterwards . What about you ? ', ' I took a year off to go travelling . ', ' that sounds exciting . Where did you go ? ', ' I went all over the world . It was the best year of my life . Where did you go to school ? ', ' I went to a small school in Connecticut . It has a very good reputation for its languages department . ', ' Oh , did you study a foreign language ? ', ' yes , I got a grant to study Chinese . ', " that's a very difficult language to learn , isn't it ? ", " it is , but it's very rewarding . ", ' so you can speak Chinese ? ', " I can , but not as well as I'd like to . I'll be studying Chinese until the day I die ! ", ' I think most languages take a lifetime to learn well . ']
["Hi , Mary , I didn't see you at work this morning . Are you all right ? ", " Oh , I feel miserable . I've got a bad cold , My head is dizzy and my nose is running . ", " Oh , I'm so sorry to hear that . Have you seen a doctor or taken any medicines ? ", " As a matter of fact I have , The doctor said it'll go away after a day or two.He ' s prescribed me some tablets . ", ' Are you feeling better ? ', ' Yes , it helps me but I just have to wait and let my system do the work . ', ' Do you need anything , grocery ? ', " Oh , no , I'm fine.My refrigerator is piled up with food.But if it's not too much trouble for you . I'd like something to read . ", " Sure , I'll get it for you.Books or magazines ? ", " I'd like both . "]
['Sally , I ’ m tired of this Western food . I really miss my mother ’ s Sichuan cooking . ', ' I ’ m sure you do miss that type of cooking . But can ’ t you try to get used to Western food ? ', ' I have tried . But Americans like butter , bread , sugar , and cream too much . ', ' I suppose you ’ re right , Lee . Maybe that ’ s why so many Westerners are overweight . ', ' It ’ s interesting that Americans work very hard at their jobs , do not take naps during the day , and yet they can be so heavy . ', ' You see , because we are often busy working , we eat too much fast food , and that food is very fattening . ']
['I was thinking about applying for the new position . ', ' Do you think that is a good idea ? ', ' It seems like a good idea but I am not really sure . ', ' What are your main concerns ? ', ' Well , it would give me a chance to grow , but I am wondering if I would like the job . ', " I know what you mean , I've thought about that myself . ", ' I am also thinking about the pay . ', ' Could you take a slight pay decrease for a chance to move forward ? ', ' Yes , it might be worth it . I am not certain . ', " I think I'm convinced that trying for this position is the best choice for you . "]
['The murderer was sentenced to life imprisonment . ', ' It ’ s severe punishment , I think . ', ' Yeah , because he just killed a man in cold blood . ', ' No wonder . ']
['David , what have you been up to lately ? ', ' I went on a trip with my family last week . ', ' Really ? Where did you go ? ', ' We went to Europe . ', ' What cities did you go to ? ', ' London , Paris and a few other cities . ', ' Did you go to Berlin ? ', " No , We didn't go there . I'd like to go there next time . ", " I think this summer is a good time to visit Berlin . It's a beautiful place and the people there are very nice . ", " That's what I've heard . ", ' I went there last year . If you want , I can give you some information I have about the city . ', ' Thanks . ']
['Look at this survey conducted by a website . A quarter of the employees will spend an average of 10 minutes everyday online doing personal things . Hi , Francis , what about you ? ', ' Well , I just spend 15 minutes as so checking my stock bonds and booking an air ticket for my mother . Anyway , I have done all my work and it is about the time to leave . ', ' Though our company doesn ’ t have a return policy , limiting the personal use of internet , I don ’ t think the boss will like us to do that . ', ' Certainly , work always comes first . ', ' But it is lucky for us . The company computers don ’ t have software keeping tracks of websites we visit . I have shopped too often online these days . ', ' Well , keep a low profile . ']
['Have you started your report yet ? ', " I'm having a hard time getting the information . ", " It's easy . You only have to search the internet in order to get the information you're looking for . ", " Oh , I didn't think of that . "]
['The principal just announced that Dr . Smith is going to take over as dean of our department . ', ' Oh . ', ' Why are you so calm ? Are you not surprised to hear this ? ', ' No , I knew it all along . He was the obvious choice . ', ' Do you think he can do well ? ', ' A new broom sweeps clean anyway . ']
['Where are you from , Laura ? ', " Well , my whole family is in the United States now , but we're from Costa Rica originally . ", " Oh , so you're from South America . ", " Actually , Costa Rica isn't in South America . It's in Central America . ", " Oh , right . My geography isn't very good ! "]
['Flight BE407 to Rome is delayed . Will passengers please wait in the lounge . ', ' Oh , How annoying ! ', ' The time of departure will be announced as soon as possible . ', ' It ’ s infuriating . I have to be in Rome by five . ']
['After you . ', ' No , after you . Ladies first . ', " That's very kind of you . "]
["Hi , Tina , I've got good news . I have successfully passed the first two rounds of interview with ABC Company . They informed me to go to the final round next Monday . It looks very promising . ", ' That is awesome . Congratulations ! I know you can make it . ', " Thanks . Let's go for a celebration this evening . Are you free ? ", ' Yes . Wait for me at the cafe down my office building . Say 5 PM , ok ? ', ' No problem . See you ! ', ' See you ! ']
['Are you going to leave school at the end of the term ? ', ' Yes , I am . ', ' What are you going to do ? ', " I'm going to be a clerk . ", ' What does a clerk do ? ', ' He works in an office . He writes letters and reports , and he types . ', ' I want to be a vet . ', ' A-what ? ', ' A vet-a veterinary surgeon . ', " Good gracious ! What's that ? ", " A vet's a man who takes care of sick animals . He's an animal doctor . ", ' I once read a story about a person who talked to animals . It was very interesting . ']
['Hello Michael . ', ' Hello Todd . ', " We're going to talk about Australia . Or your going to talk about Australia . So first of all how any people live in Australia ? ", " Australia ? Oh , there's about twenty million people in Australia right now . A little bit under , but close to twenty . ", ' OK . What are the biggest cities ? ', " The biggest city ? The biggest city is Sydney , then it's followed by Melbourne and then Brisbane and then I think it's Perth . But most of the big cities are on the East Coast of Australia . And Perth is on the west coast , but sort of of out there by itself . ", ' OK . Um , if you had to live in one place where would you live ? ', ' I like Brisbane . I had my teenage years in Brisbane , growing up in Brisbane , um or maybe Sidney because it is a big city , but Brisbane has got the gold coast and the sunshine . ', ' Oh , nice . Actually , what is the capital city of Australia ? ', " Ah , Canberra is the capital city . But is not the biggest city . Sydney is the biggest city . Canberra was made sort of by the politicians so Sydney wouldn't get to crowded . It's a separate territory . "]
['Jim was late again . ', " It's not like him to be late . "]
['Can you tell me what the date and time of our field trip is ? ', ' We are leaving on our science field trip at 8 a . m . next Monday . Do you have something to write that down on ? ', ' Yes , I can write that on my calendar . ', ' That will be on the second of December . Be there half an hour early to get your bags on the bus . Do you understand ? ', ' Yes , I understand . ', ' The bus will bring you back 6 days later on December 8th . Is someone coming to get you ? ', " No , I don't have a ride yet . ", ' We will be leaving the campground at 5 in the evening and arrive at our campus at 8 p.m.Any more questions . ', ' How much will the trip cost ? ', " I put all of that information in the packet . I'll give you another copy if you need one . See you on Monday ! "]
["I've just been a little depressed lately . ", " What's wrong ? ", ' Nothing really . ', ' Then just keep your chin up . ']
['You know , Mary , I feel we meet somewhere before . Where were you born ? ', ' I was born in Beijing , but I spent most of my childhood in London . ', ' What was your childhood like ? ', ' I had a pretty strict upbringing , and my parents taught at an university so they have extremely high expectations for me . ', ' Where did you go to university ? ', ' My parents wanted me to stay in Beijing , but I decided to go back to England . I graduated from University of Newcastle upon Tyne with a degree in Cross Culture Communication . ', ' What is your current occupation ? ', ' I am a journalist . I write for China Daily . ']
['Hi Amy , you look very happy . ', " Yes , I'm very pleased . I've just got two tickets to see the Olympic opening ceremony . ", ' Wow . You must be very excited . ', ' I certainly am . I would have been very disappointed if I hadn ’ t got them . ', ' Shall we go to a restaurant to celebrate ? ', " What a good idea . I'm quite hungry . ", ' Me too . I feel very thirsty as well . ', ' Let ’ s go then . ']
["I don't think the lecture is very interesting . ", ' The lecturer is dull , too . ', " I feel he's like a talking machine . ", ' I feel the same way . ']
['Steven , I need badly your help . ', " What's the matter ? ", ' My wife has found that I have an affair with my secretary , and now she is going to divorce me . ', ' How could you cheat on your wife ? You have been married for ten years . ', " Yes , I know I'm wrong . But I swear that the affair lasts only for two months . And I still love my wife . I couldn't live without her . ", ' I will try my best to persuade her to reconsider the divorce . But are you sure that from now on you will be faithful to her forever ? ', ' Yes , I swear . ']
['Mary has really gotten under my skin . ', ' I know what love it . When I was young , I felt the same way . ', ' I think I ’ m crazy about her . ', ' You are , why not ask for a date ? ']
["finally we're on board ! ", " yes . It was so crowded . I'm worn-out . Let's find our seats . ", ' are they window seats or aisle seats ? ', ' let me see ... yes , one window seat and one aisle seat . ', " ok . But can I trade my seat with you ? I prefer the one near the window . I'm a terrible flyer . I always get airsick and can never relax until after I've landed . ", " that's fine . I'd like to be on the aisle anyway . It's easier to get in and out . ", ' thanks . Where shall we put our luggage ? ', ' I think the smaller carry-on bag can go in the overhead compartment , and the others can go under the seat . ', ' good idea . ', " don't forget to keep the seat belt on . ", " ok . Hope it's a pleasant trip . ", ' yes ! ', ' and no hijackers . ', ' oh , you have too wild of an imagination . ']
['I want to have a complete relaxation this weekend . ', ' You mean you want to stay at home ? ', ' Yes , exactly . ', ' I thought maybe you were interested in an outing . ']
['I like football best of all . ', ' Do you ? ', " It's a very good game . ", ' Do you watch it or do you still play it ? ', ' I only watch now . ']
["hi , my name's Abby . What's your name ? ", " I'm colin . It's nice to meet you . What do you do ? ", " I'm a freelance English teacher . How about you ? ", " I'm in between jobs at the moment . ", ' what kind of job are you looking for ? ', " I'd like to find a job with flexible hours in the IT field . ", ' have you ever thought about becoming a freelance IT consultant ? ', ' no . Is it difficult to find such a job ? ', ' not if you are good at net-working . Do you like to meet new people ? ', " yes . I'm pretty out-going and friendly . ", ' do you have experience in the IT field ? ', ' I have some . I worked in the IT department at a language school for four years in Spain . ', ' do you speak Spanish ? ', ' yes , but not fluently . ', " that's OK . Have you sent your CV out to anyone yet ? ", " I've sent my CV to dozens of companies but nobody has got back to me . ", ' did you write a clear objective in your resume ? ', " no , because I didn't know what I wanted to do . ", " I think you need to update your CV . Bring it over to my office tomorrow and I'll help you with it . ", " thanks , I will . I'll see you tomorrow then ! "]
["Who's that over here ? ", " That's the new teacher . ", ' What do you think of the teacher ? ', " She's very nice . ", ' What does she teach ? ', ' English , of course . ', ' Is she your teacher ? ', ' Yes.She teaches our class three times a week . ', ' Can she speak Chinese to her students ? ', ' Not very much . ', " It's a good thing you can speak English ! "]
['The Phoenix team overpowered its counterpart 86 to 50 . ', " They're absolutely right to get a replacement for 21 . ", ' If the Phoenix beats the Rocket , it will enter the final . ', ' No way , if it still has 21 . ']
['Julie , is that you ? ', " Yes . And you're Paul , right ? Paul Hill ? ", " Yes , it's me . And you're Julie Ashley . How are you ? ", " I'm fine . After ten years , you still look great ! ", ' So do you ! How are you doing ? ', " Not bad . Let's find a table and sit down . We have a lot to talk about . ", " Okay , let's sit over there . "]
['Marquet , do you think I should enroll in the science course ? ', " Yes , I think so , If you want to graduated this year , you've got to take a science course . ", ' Right , I figure since you are doing premedical , you know about the very courses . ', ' Well , I have to take biology , chemistry , maps and physics . What you need is a good introductory course for non-science majors . ', ' Yes , I really weak in maps , I did poorly in high school . ', " That's a problem . "]
['Do you like traveling ? ', ' Yes . I ’ Ve just come back from Scotland . ', ' Where did you visit ? ', ' I only had time to visit Edinburgh . ', ' How did you like it ? ', ' It ’ s fantastic . ', ' Where did you go there . ', ' I went to there on business . ', ' And do you have friend there ? ', ' Yes , a lot of friends . ', ' You must enjoy yourself . ', ' Yes . And I took many pictures . ']
['Hello , Chandler ! How are you ? ', ' Fine . And you ? ', ' Just so so . I am too tired . My company has been holding too many training sessions lately . ', " That's good . Not Evey company provides employees with training opportunity . It seems that your company wants to further develop their employees and encouragelifelong learning . ", ' Good ? ! For them but not to me . ', " So , what's the problem ? ", ' We have to participate in training after a busy day and during the weekend . You know , after work all you want to do is throw yourself onto your bed . And during the Weekend , you just want to stay at home and enjoy a family dinner . ', ' Yes , you are right . But one should keep learning daily to maintain our keen mental power expand our intellectual capacity . Constant learning drive us to Sharp our power of reasoning , analysis and judgement . ', " Yes , I agree with you on the point but couldn't the training be held during the working day instead of weekend ? ", ' Yes , you are right . I think weekend is the time for family gathering and rest Maybe you could make that suggestion to your boss . ']
['The company is selecting three employees to attend the marketing seminar next month . Did you put your name in for it ? ', " No , I don't really care too much for seminars ... I find them to be either boring ot useless . I mean , how much can you really learn in one afternoon ? ", " It's not just about the things that you learn , you know ... seminars are a really great opportunity to mingle and network with professionals in our industry from all over the nation . You can learn a few things , but more importantly , you rub shoulders with the business leaders and make contacts that could lead to potential sales or partnerships in the future . The social mixers are always more important than the seminars anyway . ", " I'm still not too jazzed about going ... I feel kind of awkward in those cocktail party situations . ", ' Well , what if I told you the seminar is going to be held in Hawaii ? Does that perk your interest ? ', " Now you're talking . "]
["I think I'll write a book . ", ' What about ? ', ' All of the time tested healthy habits from around the world . ', " You have done a lot of traveling . I'll bet you've learned quite a bit . ", " The interesting thing is to see what really works and what's just hype . ", ' Because you can see the results with the general public ? ', " That's right . I think we all have much we can learn from each other . ", ' I would buy that kind of book ! ']
['I heard that you went to the concert the day before ? How did you like it ? ', ' It was terrific.The concert was really a hit.The symphony orchestra was so good that I was completely absorbed in their performance . ', ' Who was the conductor ? ', ' Oh , speaking of the conductor , he is indeed a genius.He did a perfect job.His name is Menuhin , a descendent of Russian American immigrants . ', ' Oh , I learned that he is also a legendary violinist . ', " Absolutely right.He gave a performance of Felix Mendelssohn's violin concerto.That caused a sensation.The audience were stunned by his pure tone . ", ' Obviously you did enjoy the concert . ', ' Yes , I did . ']
['Hi , Daniel , how are you holding up ? I am greatly sorry for your loss . ', ' Thank you , I ’ m doing much better . I ’ Ve begun organizing everything for the funeral . ', ' How ’ s that going ? ', ' It ’ s a lot harder than I imagined . There are many things that you have to to arrange . I booked a time and date with the funeral home , but I still have a lot of things to do . ', ' Have you bought a burial plot and a casket ? ', ' No . Wendy is being cremated . She always talked about how she didn ’ t want to be buried . I already chose a cremation urn and we plan to spread the ashes in the ocean . ', ' I see , that sounds like something she would have really liked . I am sure the memorial service will be tasteful . You are doing a great job . ', ' Thanks , it hasn ’ t been easy , but luckily we have life insurance and Wendy left behind a detailed will that will sort out any other legal matters . ']
['Hey , guys ! ', ' Hi ! Nicole ! ', " How's business ? ", " Great . We can't keep up with the demand . ", " Wow ! I'm impressed ! ", ' How about you ? ', ' I quit my job as a food critic . ', ' Then let me take you out to dinner to celebrate . ']
["You can't beat me at tennis . ", ' Do you want to bet ? ']
['Song , I hate to say goodbye , but I have to . ', ' Nice meeting you , Kevin . I hope to see you again . ', " Let's keep in touch . ", " Sure , let's . Goodbye , then . "]
['Shakespeare was born in 1867 . ', ' No , it sounds wrong . He was born in the 16th century . ', ' Are you sure ? Can you make it more exact ? ', ' 1564 . ']
['How is he ? ', ' Not very well . He was white about the gills . ', ' Did he see the doctor ? ', ' Yeah , but he refused to take the medicine . ', ' Why ? ', " I don't know the reason . "]
['When will our party be held ? ', ' Next Wednesday . ', ' Have you sent out invitations by our party ? ', ' Yes , I have . ', ' When ? ', ' Ten days ago . ', ' Could Dr.Cole like to attend the party ? ', ' Yes , he will . ', " That's fine . "]
["What's the score ? ", ' The Ukraine team took the lead by 3 to 1 at the end of the first half . ', ' The Russian team needs to tie the Ukraine to get the pass for the final . ', " It doesn't seem to be so easy . "]
['what are you looking for ? ', ' I want to buy a new camcorder for my trip this summer . ', ' do you know what camcorder options are available ? ', " not really . I thought I'd just have a look today . ", ' would you like to look at the new digital camcorders that have just come in ? ', " sure . I'd like to see the smallest camcorder that you have first . ", " ok . This Sony model is their newest and our most popular camcorder . Why don't you see if you like the way it feel ? ", " it's very light . That would be good . How is the battery life ? ", " it's got an above-average battery life . It lasts up tp 12 hours and can be charged in 30 minutes . ", ' can you also take still photos with this ? ', ' yes , that is an option . ', ' how about night vision ? Can you use it in the dark ? ', ' yes . I can show you examples of some footages that was taken with this camera in the dark . ', " that's not bad at all . How's the microphone ? Does it pick up much sound ? ", " It can record any sound that's within about 8 feet of the camera . ", ' how does that compare with other models ? ', " there are models that can pick up more sound than this one , but they're much bigger and heavier than this one . ", " I guess you can't have everything , can you ? "]
['Do you think what I did to Elvin was out of line ? ', ' You could have tried to explain to him about the new programmers . ', " Elvin doesn't want any programming help . He wants all the glory for himself . ", ' You might be right . He does think pretty highly of himself . ', ' Did you hear the names he was calling me ? ', ' I heard . But did you have to tear out his nose ring ? ']
['Are things still going badly with your house guest ? ', ' It ’ s getting worse . Now he ’ s eating me out of house and home . I ’ Ve tried talking to him but it all goes in one ear and out the other . He makes himself at home , which is fine . But what really gets me is that yesterday he walked into the living room in the raw and I had company over ! That was the last straw . ', ' leo , I really think you ’ re beating around the bush with this guy . I know he used to be your best friend in college , but I really think it ’ s time to lay down the law . ', ' You ’ re right . Everything is probably going to come to a head tonight . I ’ ll keep you informed . ']
["Why don't you come round for a meal one evening next week ? ", " I'd love to . ", ' Which day would suit you ? ', ' Any day except Tuesday . ', ' How about Thursday ? ', ' Yes , Thursday would be fine . What time shall I come ? ', ' Oh , about 6:00 . Will that be OK ? ', ' Yes , of course . Thank you very much . ', ' See you on Thursday , then . ']
["Bob , I'm really upset with you . ", " I'm sorry , I didn't mean to forget our wedding anniversary . ", ' You forgot it last year as well . ', " I know , I'm sorry . "]
['Belinda , I ’ m going to a party tonight . What shall I wear ? ', ' Is it formal or informal ? ', ' I guess it ’ s formal . ', ' Then , you should dress well . ', ' That ’ s right . ', ' I think a white shirt with a blue tie looks nice on you . ', ' You are smart . ', ' Of course , the sports shoes don ’ t go with the formal occasions . ', ' You are right . What kind of shoes should I wear ? ', ' The brown leather shoes go well with your trousers . ', ' Good idea . Oh , by the way , would you please pick me up after the party , honey ? ', ' It ’ ll be too late ; you ’ d better take a taxi . ', ' OK . ']
["What's his job ? ", ' He used to be a policeman . ', ' But Mrs.Smith hired him to find her lost son . ', " Yeah . He's a private eye now . "]
["Let ' s got out tomorrow night . We can go to a bar and try to find you a girlfriend . ", " I don ' t think that ' s a good idea . I am just not good with approaching someone and starting up a conversation . ", ' Maybe you just need a few pick-up lines , you know , break the ice . ', " Pick-up lines don ' t work ! ", " Come on ! You can just walk up to a girl and say “ If you were a booger I \\ ' d pick you first . ” ", ' What ? Come on ! That ’ s just lame ! No girl would fall for that ! ', " Fine , then you can say , “ So there you are ! I ' Ve been looking all over for YOU , the woman of my dreams ! ” ", " That ' s a good one ! I think that ' s pretty funny . ", ' Yeah , so you make her laugh , you make a fool of yourself a little bit and then you buy her a drink . ', ' Ok , how does this sound , “ I was so enchanted by your beauty that I ran into that wall over there . So I am going to need your name and number for insurance purposes . ” ', " Nice ! Let ' s go ! "]
["At their last meeting , the stockholders voted unanimously to block the merger of our company with Blycore . All the executive committee was in favor of the merger ... I don't understand how the stockholders could have so much power to throw a wrench in the plans ... ", " If they all unite on a certain issue , it's the stockholders who have the final say . You'd think it might be our CEO or the workers , but in fact , the stockholders control the money so they have the most power . ", " Is it really that simple ? It doesn't seem very efficient to run things that way ... ", ' It might not be the most efficient , but if you think about it , it makes pretty good sense . The stockholders are our investors . They own the capital in our company , so they should have say about what is done with the company . ', " I guess I'd buy that ... "]
['Did you go to the concert last weekend ? ', " No , I didn't . And you ? Was it good ? ", ' Yes , I did . I enjoyed it a lot.There was a folk singer , a violinist and a pianist . ', ' How much was the ticket ? ', ' I only paid two dollars for mine . ']
['Great ! I landed on Classic Movies . ', " I didn't know you liked old movies . ", ' I love them , especially the all-time greats like Gone With the Wind . ', " You're so right ! Today's movies are just too commercial ! ", ' Sometimes I think Oscars are only awarded to movies that make a lot of money . ']
['Why are you asking me about my boyfriend ? ', ' Well , Brad from school asked me out just today . ', ' Brad Bush ? Good for you ! ', " But I don't know what to do . ", " You mean you've never had a boyfriend ? ", " My mom says no boyfriend until I'm in college . ", ' Until college ? ', " Actually , that's what a lot of parents in Taiwan say to their kids . "]
['Now that it ’ s the new year , I ’ Ve decided to turn over a new leaf . ', ' Yeah ? You finally decided to wipe the slate clean ? ', ' You got it ! I have a new job , I ’ m living in a new city , with new friends ! This is my opportunity to make some small changes in the way I live my life . ', ' So what are you going to do ? Take up an art class or something ? ', ' Well , first of all , I ’ Ve decided to stop smoking . It ’ s not that I ’ m pinching pennies or anything , it ’ s just that I ’ Ve been smoking since I was sixteen , and I think it ’ s time to stop . ', ' I ’ m with you on that one . Anything else you ’ re planning on doing ? ', ' One last thing , I ’ Ve decided to come out of the closet . ', ' It ’ s about time ! ']
['Why are you in such a hurry ? ', ' I should finish it as soon as possible . ', " Don't worry , do it step by step ", ' Why can I learn it ? ', " Don't worry , do it step by step . ", ' I feel I really stupid . ']
['Hey , Frank , there is that Janet chick . ', ' Wow , what a great burd ! ', ' She sure knows how to strut her stuff . ', " She's a real turn-on , alright ? ", " And look out she's dressed . ", ' Yeah , I noticed . She must be really loaded . ', ' No way . Her old man is rich . He buys her anything she wants . ', ' Lucky her . Anyway , I think that is just as beautiful . ', " I think you've lost it . ", " Well , that's my opinion . ", ' I admit that she is much prettier than Kate . ', ' Oh , there is no comparison . Now we are talking but ugly . ', " At least we agree on that . Let's go and get a drink . "]
['Do you like swimming ? ', ' Yes . Swimming is one of my most favorite sports , indoors or out-doors . ', ' Me too . Swimming is a very good exercise for health . It combines water , bath , sunbath , and air bath together . It promotes the growth and haleness of muscles , bone , viscera and nerve systems . ', " I have never thought that swimming can bring us so many benefits . I only know that swimming in great waves and deep running water can train people's spirits , and enable people to be fearless of the hardships , dangers and difficulties and become brave and staunch . ", ' Have you ever swum in a river or a lake ? ', " Yes , but not always . However , I won't let it go if I have a chance . "]
['You should have seen the T . V . show that was on last night , the topic it covered was really interesting , animal rights . ', ' Do you really believe in that ? If they are going to focus on something , they should do it on civil rights . ', ' Yes , but we can ’ t deny that animals are vulnerable , defenseless , and are completely at the mercy of human beings . ', ' I understand your point , but we continue to have transgressions against human rights . If so much attention weren ’ t devoted to the topic of animals , we would then concentrate more on saving a human being instead of protecting a koala . ', ' You can ’ t compare apples and oranges . I believe that both topics are important and that we can ’ t ignore them , the mistreatment of animals can cause a great environmental imbalance . I believe that governments should prohibit activities like poaching . ', ' Well , you are right on that point . This is the reason that I don ’ t buy leather and I try to buy synthetic products . ', ' At least you ’ re doing your part . My contribution is to have a pet in the house that I treat like a member of the family . ', ' As long as you don ’ t treat it better than your wife , it ’ s fine . ']
['So it looks like we start selling in the U . S . next year . ', ' Did Mr . Lin put you in charge of marketing ? ', " He's still not sure whether he wants to put me in charge , or whether he wants to hire an American.But even if he hires an American , I'll probably be transferred to our American office . ", ' Where will it be ? ', " We aren't sure yet . Maybe L . A . I think L . A . would be the best idea . ", ' Is it because of trade negotiations that we can start selling in the U . S . ? ', " Yes , the recent agreements between the two governments have changed everything.Now we have the right to sell in America at a much lower tariff.It ' s going to be good . We can compete more directly with them . ", ' Great . ', ' Our computers have a high level of quality now.We can demonstrate it . And our prices will be good.So I think it will really be worthwhile . ', ' You seem excited about it . ', " Well , you know I studied marketing in America.So maybe the thought of going back there to promote our brand is kind of exciting to me . I'd love to be part of the team . ", ' Do you honestly think we can compete though ? All the computer giants are there . ', ' Yes , I do . I think we can compete . I think we can make a name for ourselves.It will be hard at first . But if we develop a good advertising campaign , I think we can break into the market . ', " The company will have to choose a good advertising firm.And then there's the problem of quality.How do we convince American buyers that our quality is good ? ", " It takes some time.Because even if the quality is high , people won't accept a high tech product unless they recognize the name.Name recognition is crucial . ", " Well , I hope it all works out , John . I think if you're part of the team , things will go well.But you know we'd all miss you here . So I won't say I'm happy to think that you're leaving . ", " That's very nice of you to say.But if we set up an office there in the States , maybe you could try to become part of it . ", " Me ? No way . I'm dedicated to the company , but I'm not going to leave Taiwan . I'm happy here . "]
['How are the children doing at sport ? ', ' I ’ m very pleased with their performances . Timmy can cover the 100 meters in 12 seconds . That ’ s very fast for a kid his age . ', ' He ’ s not very good at the long jump though , is he ? ', ' He ’ s not bad . He can jump a distance of over four meters . I think he just prefers running to jumping . Jimmy ’ s very good at the high jump . He can jump over two meters . Again , that ’ s fine for someone hi ', ' Two meters ? That means that the high jump bar is above his head ! Are any of them good at long-distance running ? ', ' The longest race we run is the 1500 meters . A few of the boys and one girls can do it in less than five minutes . ', ' How are they at swimming ? ', ' They ’ re ok . I ask them to swim 500 meters each day . That ’ s 20 lengths of the swimming pool . They ’ re not very fast , but that ’ s ok . I just want them to build their strength up and keep in shape . ', ' Kate is very good at diving from a height of 10 meters . ', ' I ’ d be afraid to jump from that height ! ', ' I think that these kinds haven ’ t learnt to be afraid yet . She started diving from a lower height , but she soon wanted to go higher . ', ' It seems that they really enjoy to go faster , higher and further . ']
['How many people are there in your family ? ', ' Five . Besides my parents and me , there are my brother and sister . ', ' That is a big family . How old is your sister ? ', ' 15 . ', ' What about your brother ? ', ' He ’ s not quite 25 . ', ' Do you miss your family ? ', ' Yes . ', ' Do you often go home ? ', ' No . But I write to them often . ', ' How often do you write to them ? ', ' Once a month . ']
['Wow , American football is more exciting than I thought . ', ' You ’ re in America now , my British friend . We just call it football . ', ' Oh , right . So , I can ’ t quite follow what ’ s going on ... who ’ s winning ? ', ' The Giants are up by three points because of the field goal they kicked , but the Redskins have the ball and there pretty close to the end zone . ', ' Wow ! What a hit ! ', ' Yeah , he tackled him so hard his helmet came off . ', ' Is he ok ? ', ' It looks like it , he ’ s getting up . ', ' I guess he hit him too hard ; the referee just called a penalty on the home team . ', ' The Giants ? ', ' Yeah . ', ' Well , here we go again . ', ' What happened ? Why did everyone get so quiet ? ', ' The Redskin ’ s quarterback just threw a touchdown pass for seven points . We ’ re losing again . ']
['Who stands out in your mind as a man or woman of sound character ? ', ' If I think of famous people , I think of Abraham Lincoln . ', " He's the US president , who walked five miles just to give a lady her change , isn't he ? ", " That's the one . He also was famous for never giving up on his goals . ", " That's right . He ran for office quite a few times before he was finally elected . ", ' And I also admire him for his courage in fighting for equal rights . ', " He had great vision , didn't he ? ", ' And humility . I would have liked to meet him personally . ']
['What ’ s your working day like ? ', ' I have a typical 9 to 5 job . Actually , I work a little longer than 9 to 5 most days . ', ' Do you get paid onetime ? ', ' No , I don ’ t . I get a bonus each month , depending on the value of the contracts I sign with clients . ', ' Do you have any breaks ? ', ' We have an hour-long lunch break from 12 to 1 . we can take coffee breaks during the day . My boss doesn ’ t mind , as long as we get out work done on time . ', ' My boss gets annoyed if we take coffee breaks . I suppose your job involves a lot paperwork , doesn ’ t it ? ', ' There ’ s some paperwork , but most of the time we put any information onto computers . Then we can send information to each other by email or across the network . Do you work in a cubicle ? ', ' Yes , I do . I don ’ t like it very much . ', ' I work in a cubicle too , but I I don ’ t mind it . ']
['Freeze ! ', " Don't shoot . I give up . "]
['You know that ? Dan got a divorce . ', ' Really ? I thought he loved his wife very much . ', ' Yeah . But his relation with Sallycome to a sticky end and was found by his wife . ', ' He deserved it . ']
['Hello , is Jack there ? ', ' Speaking . ', ' Jack ! It ’ s Rose here . ', ' Hi , Rose . How ’ s everything ? ', ' Fine , thanks . I ’ m having several friends over for dinner this Saturday . And I was wondering if you have the time to join us . ', ' Sounds good . What time do you want me to come ? ', ' Is six o ’ clock okay ? ']
['Joanne , let ’ s not make this divorce any more acrimonious than it already is , okay ? Let ’ s just get down to business and start dividing this stuff up fairly , so we can go our separate ways , alright ? ', ' Fine with me . I just want to get this over with . It ’ s important we make a clean break . I should have signed a pre-nup . ', ' What was that ? ', ' Nothing ! Anyway , you ’ re right , there ’ s no reason this has to be nasty . My lawyer tells me you ’ Ve accepted our alimony proposal and the division of property , as well as the custody agreement-I keep the cat and you get the dog . So that ’ s done ... finally . ', ' Let ’ s not go there , Joanne ! Ok , so let ’ s start with the record collection , I ’ ll take the albums I contributed and you can have your cheesy disco albums back . ', ' Fine , but I ’ m keeping the antique gramophone as my grandfather gave it to me . ', ' I believe that was a wedding present to both of us , Joanne . And you hardly ever use it ! ', ' He ’ s my grandfather , and he never really liked you anyway ! ', ' Whatever ! Alright , I ’ ll concede the silly gramophone , if you ’ ll agree that I get the silver tea set . ', ' How typical , when are you ever going to use a silver tea set ? Fine ! I don ’ t want to drag this out any longer than necessary . What ’ s next ? What about these old photographs ? ', ' Which ones ? Let me have a look . Wow , look at that ! That brings back memories ... That ? ', ' Our trip to Italy ! I remember that day . We were going to visit the Trev fountain , and we got caught in the rain ... ', ' ... and you looked so adorable with your hair all wet . I had to take a picture of you standing there in that little alley , smiling and laughing in the rain ... ', ' Oh , we really did have fun back then , didn ’ t we ? ', ' Oh , Joanne , are we making a big mistake ? I know our relationship has been on the rocks for sometime but are you sure we can ’ t reconcile and try again ? I still love you . ', ' Oh Jeff ! I love you too ! I ’ m so glad we didn ’ t have to decide who keeps the motorcycle . ', ' The motorcycle ? But that ’ s mine ! ']
["What's the time now ? ", " Sorry , I don't know , there's something wrong with my watch . ", " You've simply forgotten to wind it up , have you ? When do you usually wind it up ? ", ' In the coming , before going to work . ', ' You got up so late today . You have , I think . Turn on the TV and set your watch by it . ', " OK . I'll turn it on . ", " All right . It's just four o'clock . ", " Well , I'm setting my watch at four . Thank you . ", ' You are welcome . ']
['Going to the gym tonight , Mary ? ', ' Yes , Sally . I want to do some sit-ups and perhaps get in a game of singsong . ', ' That sounds like fun.Would you mind some company ? ', " I'd love it.Working out is more fun with a friend . ", " I'll get my things and meet you there . ", ' Good.If you happen to see Jim and Bob on the way see if they would like a game of singsong . ']
['Whose part do you think is best played ? ', ' That of the old man . ', " You're absolutely right ! That's the very figure I like best . ", ' Some of the scenes moved me into tears . ']
["We're having a tailgate party I before the game . Would you like to join us ? ", ' Okay . But what is a tailgate party ? ', ' Someone brings a truck to the game and we have a barbecue right there in the parking lot out of the back of the truck ! ', ' How fun ! Can I bring something ? ', " Don't worry about it ! Just come at five . ", ' I make a mean potato salad ! ', ' Well , if you insist , you are welcome to bring a potato salad ! ', " Then I'll see you in the parking lot at five ! Thank you ! "]
['What may I do for you ? ', ' I need to get a passport . ', ' You will need to apply for one . ', ' When will I be able to do that ? ', ' You can do it right now , if you ’ d like . ', ' That ’ s fine . ', ' Please fill out this application . ', ' Then what do I do ? ', ' I just need to take your picture . ', ' How long will it take for my passport to be ready ? ', ' You will get it in a few weeks . ', ' That ’ s perfect . ']
['I ’ Ve got this really neat idea , you can hire a car and drive straight there . ', ' Are you nuts ? What would my friends think if they see me in a hired car ? ', ' But that ’ s the quickest way to make your plans work . ', ' Oh this is hard ! Well , I ’ ll see what I can do . ']
['Would you please put that cigarette out ? I get sick on it . ', ' You do ? OK , fine with me . ', ' Thank you SO much . ', ' But I also want ya to do me a favor . ', ' What ? ', ' You gotta have some better deodorant . ', ' I ’ m sorry ? ! ']
["I really hate to say this , but don't go away mad , just go away . ", ' I knew this would happen some day . ', " Then , why didn't you try to prevent it in the beginning ? ", " Well . It's not all my fault , Anna . You are responsible , too . ", " I don't want to argue anymore . Please get out of my life ! ", ' I think we can still talk . ', " No way ! Please don't follow me around . ", " Talk it easy , Anna . You really don't hate me . do you ? ", ' Yes , I do . Leave me alone ! ']
["It's a fine day today , isn't it ? ", " Yes , it is.It ' s wonderful after the downpour . ", ' How nice seeing the sun back again ! The air is so fresh . ', ' I hope it stays nice like this for a long period of time . ', ' Well , the weather is so unpredictable this time of year . ', " You're right.We don't know what is going to be like tomorrow . ", ' Look ! It looks as if it is going to rain . ', ' The weatherman predicts a fine day today . ', ' The weather is often quite different from the weather forecast . ']
['When can we expect you and your daughter for dinner ? Next Saturday ? ', ' Next Saturday ? I ’ m sorry . I ’ Ve promised to go to a Chinese Opera with my daughter . ', ' How about Sunday then ? ', ' Yes , Sunday sounds fine . What time ? ', ' Does 6 thirty suit you ? ', ' It suits us fine . We ’ ll see you then . ', ' Thanks , goodbye . ']
['Hey , look ! They ’ re playing reruns of the 1996 Olympics . ', ' Isn ’ t that Michael Johnson ? I think he set a world record in this race . ', ' He completed the first 200 / 400 double in Olympic history ! ', ' Are you sure ? What about Carl Lewis ? He won four golds , didn ’ t he ? ', ' Carl won the gold in the 100 , 200 , long jump , and 4x100 relay in 1984 . ', ' I like the way Carl runs . He looks more graceful . ']
['Will you have time this Saturday evening to go to the cinema with me ? ', ' Saturday ? Oh , I have a previous engagement . ', ' What a pity ! Then how about Sunday ? ', " I've already got plans , too . ", ' Then when do you think we could go out together ? ', ' How about Friday ? Only in that day can I arrange it . ', ' OK . Any time on Friday will be OK with me . ', " That's settled then . I'll contact you later . "]
["Come on , fellows.Let ' s enjoy my wife's cooking ! ", " Em , it's delicious ! ", ' Thank you ! My wife likes cooking very much . ', " You're lucky . "]
['Guess what ! ', ' What ? ', ' I am going to the mountains with my family this weekend . ', ' That sounds like fun . ']
["Does Mr . Schmidt know he's going to become a father ? ", " No , and I have no way of getting ahold of him ! There's no phone where he's at ! ", " Well , he has a surprise waiting for him when he gets back , doesn't he ! ", ' My older sister Judy will be here soon to help . She already has a boy and a girl of her own ... ', ' I just saw a red van pulling into the driveway . Is that her ? ']
["B , what's in your hand ? ", ' Sunday papers . I usually read them after coming back home from our company . ', ' Why do you read them ? ', ' As you know , I am a sports fan . And these papers are famous for their sports section . So I will feel relaxed after grasping some information I am interested in . ', ' I got your meaning . Reading is your own solution to solve pressure from busy tasks . ', ' Correct ! What about you , Fred ? ', ' I often go to the bar near our dorm when I am overtired . I am crazy for drinking wines with special taste . ', " Don't overdo it . ", ' Shall we have a drink someday ? ', ' I get drunk easily . ']
["What a lovely day , isn't it ? ", " Yes , it's nice and bright . ", ' I hope it stays like this . ', ' I hope so too . ', ' Is the weather usually like this here ? ', " It's usually a bit hotter than today . ", " What's the weather like in winter ? ", " It's pretty cold and it often snows . ", ' I wonder what it ’ s going to be like tomorrow . ', " Let's hear the weather report later . What's the weather like in your hometown ? ", ' Neither too cold , nor too hot . ', " That's quite a lovely weather . ", ' Yes , especially in spring . ', ' Have you ever seen a hurricane ? ', ' Once , when I was a child . ', ' Do they often happen in your country ? ', ' Now and then . ', " Oh , it's time for the weather reporter . Let's turn on the TV . "]
['Are you travelling in America ? ', ' No , I am on business . I will spend half a month for the business . ', ' What do you do ? ', ' I am currently working in a foreign company as a salesman . ', ' I know all the tricks of the trade . It is quite tiring and difficult to be promoted . ', ' Maybe . But it provides much wider space for me to improve the skills and increase the experience . What about you ? ', ' I am a reporter at a TV station . ', ' Do you like your job ? ', ' Yes , I have good working conditions and I would require a salary at least 15 , 000 $ a year . ', ' Which kind of news do you catch ? ', ' I report the social news which means I always interview the citizens of various professions and trades . ', ' Are you feel tired ? ', " Sometimes . News happened out of expectation . Sometimes I have to get up in the early morning while I can't sleep for editing and interviewing . ", ' You have to experience this if you want to be an extraordinary reporter . ', " That's right . I am still wet behind the ears . "]
["What a charming room ! It faces south , and there's such a lovely view of the city . ", " I'm glad you like it.The bell is on the bedside.Just ring if you want anything.The room attendant speaks a little English.So I don't think you'll have any trouble . ", " No , I shouldn't think so.By the way , is there a socket for my razor ? ", " I think so.Here it is.It ' s by the basin . ", ' Is it a two-pin socket ? ', ' Yes , it is . ', " Good , I ' Ve get a two-pin plug . "]
["You're my hero . ", " Aw , shucks , ma'am . "]
["That's brilliant ! We can name the grades of motor oil by where they come from . ", " Mr . Mechanic , I'd like a nice Venezuelan blend this morning . ", ' I think the Saudi Arabian will hit the spot today . ', ' But really , maybe this can work . Everyone loves coffee , and everyone needs motor oil . ', ' A match made in heaven . ']
['What ’ s your city like ? ', ' It ’ s quite an interesting place to live . The best thing to do in my city is go shopping . There are several indoor and outdoor markets , department stores and shopping malls . ', ' Is the traffic bad in the city centre ? ', ' Not really . Cars are not permitted in several parts of city centre , especially in the main shopping areas . The public transport system is pretty good . ', ' What about restaurants and entertainment ? ', ' There are restaurants with food from all over the world . We have a small china-town near the city centre . There are many Indian , thai , and Italian restaurants all over the city centre . There are many s ', ' Is there a lot of nightlife in your city ? ', ' There are several good clubs near the city centre . Many people in my city prefer something more cultural , so we several theatres and venues for classical music concerts and operas . ', ' It sounds like a really exciting city to live in . ', ' It is . I hope you ’ ll have time to come for a visit soon . You really should come during the summer , when the weather is better and there ’ s more happening outdoors . ']
['Bob ! Your eyes look bloodshot . Did you not sleep well ? ', ' I had a drop too much last night . I attended a banquet given by a Chinese colleague of mine . And it was startling for me to find that people are forced to drink against their will on a Chinese table . ', ' you have it right . Alcohol is a medium for communicating emotion in China . Drinking with business partners or would-be friends is a way of solidifying friendship , especially in Northern China . ', " I just felt embarrassed if I refused to drink when people toasted to me . But if I keep gulping down one cup after another , I'm afraid I would feel unfit or sick . ", ' you lose face by refusing to drink , and the host might think you refuse to give him face . The right thing to do seems to be drinking yourself into incoherence until you throw up . This will endear you ', ' a few guys even threw a drunken fit last night , crying hoarsely and bawling whole heaps of nonsense that I never understood . ', ' then he must be opening his heart to the friends . In a word , as long as you demonstrate a readiness to drink more in spite of already suffering extreme discomfort , no one will jeer at you . ', " I got you . Next time . I'll preface a toast with a statement like ' I can't drink any more ' and then drink anyway . "]
['When ’ re you getting married ? ', ' We planned our wedding for next May . ', ' Why so late ? Didn ’ t she want to get married this October ? ', ' Yeah , I did . But my fiancee has an important project . ', ' That ’ s really a shame . By the way , who will be the bridesmaid ? ', ' Julie ’ s friend , Mary . And John will be the best man . ', ' Wow ! I ’ m very excited about your ceremony . ']
["Good afternoon , Mrs . Brown . I've come to see Mr . Brown . ", ' Good afternoon , Mr . Green . ', ' Is he in ? ', " I'm sorry , but he's not in , he's gone out on business . ", ' Oh ! I just drop in on him for a chat . ', ' Please come in for a cup of coffee . ', ' No , thank you . Please tell him to phone me when he comes back . ']
['I heard the film was after the novel The Godfather . ', ' Who wrote it ? ', ' Mario Puku . ', " Who're the producer , the director , the stars , heroine and the hero ? ", " I'm always interested in how , but seldom pay much attention to who . "]
['Going to the gym tonight , Mary ? ', ' Yes , Sally . I want to do some sit-ups and perhaps get in a game of singsong . ', ' That sounds like fun . Would you mind some company ? ', " I'd love it . Working out is more fun with a friend . ", " I'll get my things and meet you there . ", ' Good . If you happen to see Jim and Bob on the way see if they would like a game of singsong . ']
["You didn't show up to my performance last night ! Some kind of friend you are ! ", ' Give me a chance to explain . I was no my way and I had an accident . ', " Sure . You look like you're all black and blue . ", " I am fine . In fact , I don't have a scratch on me or my vehicle . But the other guy is in critical condition . ", " You're serious ? ", " Yes , I'm serious . I'm really sorry about missing your concert . ", ' I guess I misjudged you . I hope you can forgive me . ', ' Of course I forgive you . What are friends for ? Now , what am I going to do for that other guy ? ']
['The whether in Beijing is just beautiful . ', ' Autumn is the best season in Beijing you know ? ', ' Yes . I can see . The summer heat is over . And the winter cold is still far away . ', ' What is the whether like in Washington at this time of this year ? ', ' Autumn is also very nice In Washington . ', ' Is it very cold in winter there ? ', ' No . it isn ’ t . But sometimes it slows a lot in winter . ', ' Does it rain a lot in summer there ? ', ' Oh . Yes . Sometimes it rains very heavily ', ' How about here in Beijing ? ', ' There ’ s a lot of rain in summer . But it seldom rains in autumn ', ' I feel it ’ s rather dry here ', ' That ’ s true . many people from the south don ’ t like the whether here . ', ' Are you from south ? ', ' No . I ’ m from the north . I was born in Beijing actually . ', ' I see . So this is your hometown ? ']
['Tom set the whole country by the ears with his discovery . ', ' He is really terrific ! ', ' He was very clever when he was a boy . ']
['My friend Jane is very beautiful . ', " What's her figure ? ", ' Perfect . And I like her charming eyes , too . ', " What's the color of her eyes ? ", ' Dark blue . ', ' how old is she ? ', ' Twenty . ']
["Nice day , isn't it ? ", " Sure it is . Why don't we go to a park ? ", ' Good idea ! ']
['Look how fast that car can accelerate ! ', " I've never seen anything like it . "]
['Hi , how are you doing ? ', " I'm fine . How about yourself ? ", " I'm pretty good . Thanks for asking . ", ' No problem . So how have you been ? ', " I've been great . What about you ? ", " I've been good . I'm in school right now . ", ' What school do you go to ? ', ' I go to PCC . ', ' Do you like it there ? ', " It's okay . It's a really big campus . ", ' Good luck with school . ', ' Thank you very much . ']
['My brother joined the army last year . ', ' Oh , what does he look like ? Is he tall ? ', " He's tall and strong . ", ' I can tell it from your build . ']
['You seemed to be fed up with Mary . ', ' Yeah . I get sick of her . She always bends my ear about what she thinks . ', ' She is a barking dog . But she means well . ', ' But I don ’ t like anyone who would drive me crazy by telling me what to do . ', ' You are unfair to her . She is a very nice girl . ']
['I have lots of friends . ', ' Really ? How many do you have ? ', " I don't know , maybe one hundred . ", ' That is a lot of friends . Do you have a best friend ? ', ' Of course . I have lots of best friends . ', ' How many best friends do you have ? ', ' I think about twenty-five . ', ' Hmm . I have only one best friend . ', ' I feel sorry for you . ', ' I have only a few friends . ', ' You must be lonely . I will share my friends with you . ', " That's very nice of you . "]
['I have talked a lot about your restaurant business and your friends with my friends . One of my friends seems to be on good terms with Sue . ', ' Is he beating Mark ’ s time ? ', ' She is indeed well . But she would not give anyone a tumble , you bet . ']
["Give me your hand . ( takes Rose's hand ) Close your eyes . Go on . ( Rose closes her eyes ) Step up . Now hold on to the rail . Keep your eyes closed ; don't peek . ", " I'm not . ", ' Step up onto the rail . Hold on . Keep your eyes closed . Trust me ? ', ' I trust you . ', ' All right , open your eyes . ( Rose opens her eyes . She stretches her arms , and Jack stands behind her , arms around her . ) ', " I'm fling , Jack . ( singing ) Come , Josephine , in my flying machine . Up she goes , and up she goes ... "]
['My uncle passed away last night . ', ' My condolences . ']
['Man , they take a lot of our paycheck . ', " Yeah , the government really takes a bit , doesn't it ? ", " Seriously . The only tax I don't mind them taking is social security . It's only a few dollars every paycheck . ", " Yeah , I don't mind it either . We ’ ll both end up rich slobs and not need it , but what if we do , you know ? ", " Yeah . It won't be much , but at least we ’ ll have a monthly check when we get old . ", ' Yeah , my grandmother gets by on social security and the money my grandfather invested when he was alive . ', " Let's just hope the politicians don't figure out a way to spend it . ", " Really ? No , they couldn't . None of them would have jobs if they did . "]
['Nick ! How ’ s it going ? ', ' Oh , hey ... ', ' What are you doing in this neighbourhood ? Do you live around here ? ', ' Actually , my office is right around the corner . ', ' It was great to meet you last week at the conference . I really enjoyed our conversation about foreign investment . ', " Yeah , yeah , it was really interesting . You know , I'm in a bit of a hurry , but here ’ s my card . We should definitely meet up again and continue our discussion . ", ' Sure , you still have my contact details , right ? ', ' You know what , this is really embarrassing , but your name has just slipped my mind . Can you remind me ? ', ' Sure , my name is Ana Ferris . Don ’ t worry about it , it happens to me all the time . I ’ m terrible with names too . ']
['Can I borrow one of your pens , Amy ? ', ' Take your pick , Julie . ']
["Hey , Sandy , what's new ? Interested in a movie tonight ? ", " I wish I could , but I'm busy . I'm going to work at a soup kitchen tonight . ", ' Soup kitchen ? Is that a new restaurant or something ? ', " Nah , it's a place where homelesspeople go to eat . ", ' How did you get involved in something like that ? ', " Well , the minister at my church told us about it , and it seemed interesting . I thought I'd try it once , and if I didn't like it I'd stop . ", ' So what do you do there ? ', " It's simple . All we do is prepare some food , usually sandwiches and some fruit , and give it out to them at the soup kitchen . ", ' Yeah , it sounds easy . How long does it take ? ', " Only about two hours , for a couple of days a month . Why don't you give it a try ? ", " I don't know . I mean , I like helping the community and all that , but I don't know if I have the time ... ", " Come on , it's easy , and it'll make you feel good . Why don't you come with me tonight ? "]
["Wang , I'd like you to meet my friend . Dou , this is Wang . ", " Hello Wang . I'm Dou . Pleased to meet you . ", ' Pleased meet you , too , Mr . Dou . ', ' Just call me Miao Dou , Please . ']
['And we got a 50 thousand dollar ticket for construction workers peeing off the roof . ', ' That ’ s great . Is the electrician here today ? ', ' See , I just told you he hit a deer . Man , I knew you weren ’ t listening to me . ', ' You ’ re right . I wasn ’ t . I hear nothing . ', ' Nothing ? ', ' Not a sound on the city streets , just the beat of my own heart , I think that ’ s how it goes , something like that . ', ' You and Patricia got engaged , didn ’ t you ? You can tell me . ', ' Engaged ? ', ' Come on . ', ' Are you crazy ? ', ' What ? I thought you liked Patricia . ']
["I'll come see you tomorrow . ", ' Promise ? ']
['Have you got any plans for the coming holiday ? ', ' Yes , I have a very special one . I will be doing volunteer work in a zoo for two weeks . A friend of mine working there told me the other day that they were in need of some volunteer keepers . I was very interested . So I asked him to get me the application form . Lucky , my application was approved by the manager very soon . ', ' Volunteer in a zoo ? What specific things will you do ? ', ' I will help to prepare food , feed animals and clean up . I ’ m very excited about it now . ', ' It must be a unique experience . I ’ m looking forward to share your story when you come back . ', ' Ok , I will bring you photos as many as possible . ']
["Oh , honey . You came . I'm so glad ! Why are you wearing a bonnet ? ", ' Uh , just for fun . Happy Easter , Mom . We got you these Easter lilies . ', " They're beautiful . Taylor , you're so pale and skinny ! ", " Of course I'm pale . It's just now the beginning of spring . I don't have my summer tan yet . ", " I guess . Are you sure you're taking care of yourself ? ", " I'm fine , Mom . Remember Holly ? This is her roommate , Yi-jun .. "]
['Is everything ready for Billy ’ s birthday party ? ', ' Yes . I ’ Ve finished making the birthday cake and I ’ Ve put all the things on the table . Did you find the party hats ? ', ' Yes , I did . I ’ Ve put one on the table for each child . I put up the big “ happy birthday ” sign too . ', ' Thanks . Do you think we have enough for the kids to eat and drink ? ', ' I ’ m sure of that . There ’ s enough food here to feed an army ! ', ' That birthday cake looks wonderful , but you haven ’ t put any candles on it yet . ', ' Thanks for reminding me . I ’ Ve prepared some party games for the children too . ', ' I ’ Ve brought a tape with lots of children ’ s songs on it . ', ' Hopefully , that will keep everyone happy . ']
['Are you doing anything tonight ? ', ' No , nothing . Why ? ', ' Do you like western music ? ', ' Yes , I do , very much . ', ' There ’ s a concert tonight . Would you like to go and listen to it ? ', ' Oh , yes . I ’ d love to . ']
['Mum , can I finish my homework later ? ', ' Sorry . You know the rules . ', ' But I want to watch TV now . ', ' That ’ s out of the question . ', ' Please . ', ' Not a chance . ', ' Not even for an hour ? ', ' Sorry , it ’ s impossible . ']
['Table-tennis is our national game . ', " Yes , I like ping-pong very much , but I can't play well . ", " I can't , either . I like watching . "]
['Listen to this . Mary got married . ', ' Is she really ? I can ’ t believe it ! ', ' Yes . Yesterday . ', ' Good gracious . That ’ s incredible ! ', ' She married Jerrod . ', ' You ’ re kidding . ', ' She ’ s going to live in Paris . ', ' Really ? I ’ m surprised . ']
['It was great meeting you . ', ' Me too . ', ' Maybe we can meet again sometime ? ', " Of course , but I'll have to go now . "]
["What's your favorite hobby ? ", " I'd like reading books best . ", ' What kinds of books do you like to read ? ', ' Literature and economy . ', ' By the way , would you like to see movies ? ', " That's OK . ", ' What do you do in your spare time ? ', ' I like to play golf , play badminton or crack jokes . ', ' I just like to sleep like a lazy cat . ', " That's a bad habit . "]
['Are you sure you heard right ? ', ' Yes , he is running for class president . ', " I don't believe you . ", ' Take my word for it . ']
['There is a new restaurant opening up in town next month . ', ' What kind of food will they be serving ? ', " My favorite , Mexican . And I've heard that the head chef is from San Paulo . ", ' It sounds like this is going to be authentic Mexican food . ', ' I can hardly wait ! ', ' Do you know the day they plan to open ? ', " I'll double check the announcement . ", ' Maybe we can make reservations ahead of time ? ']
['I am thinking about inviting you to a dinner . When would you have time ? And what kind of food do you fancy ? ', ' That would be great . I am really in the mood for a spicy hotpot . Any special reason for the invitation ? ', ' To thank you for helping me at work last week . If you would not have been so kind , I would not have been able to pick my parents from the airport . You really did me a big favor . Thank you so much . ', ' It was my pleasure . How about this evening ? I feel very hungry now . ', ' Fine , I know a good hotpot place in the downtown area , food there is pretty spicy too . Shall we try that one ? ', ' Ok with me . You are the boss . I will meet you downstairs after work . ']
['Charlotte , have you had your supper ? ', ' No , I don ’ t want to eat anything . ', " Why ? Don't you feel well ? ", ' I ’ m down in spirits . ', " What's up ? ", ' My manager jumped on me for my mistake today . ', ' You must not feel depressed about such a trivial thing . ', " I think I'm too clumsy . I can do nothing well . ", " You'd better shape up if you want to get the job done . ", ' But I doubt myself . ', " Cheer up ! Don't let me down . We all make mistakes , and that is life . "]
["I'm afraid I can't go to the pictures with you tomorrow . ", ' Busy with your work again ? ', " Not really . I'm expected to attend a meeting . ", " I'm not at all convinced . Tomorrow is Saturday ! "]
['Mum , I have something for you today . ', ' What for ? ', " Don't you remember ? Today is March 8th . It's Women's Day . ", " Oh . I've really forgotten it . ", ' Now , close your eyes . ( Mum closes her eyes and Steven puts the present in her hand . ) ', ' A silk scarf . I love it . Thank you very much . My lovely son . ', " Happy Women's Day . I love you forever , Mum . "]
['What do you think of your teacher ? ', " He's very strict with us . ", ' And I hear he gives very good lectures . ', " Indeed.He ' s strict with himself , too.We can see every lecture of his is well-prepared . "]
["I'm so glad to meet you . ", ' How is everything going on ? ', ' Fine . ', ' You look prettier than before . ', ' Really ? Thank you . ']
['You must be annoyed about your boyfriend ’ s leaving you , huh ? ', ' Don ’ t ever mention him . I ’ m getting over it . ', ' It ’ s a sad thing . I ’ m ever so sorry ... ', ' Are you done ? ']
['Hello , Rebecca , fancy meeting you here ! ', " Hi , Paul . I haven't seen you for a long time . ", ' How have you been ? ', ' Fine , thank you , and you ? ', ' Pretty good . What brings you here ? ', ' I came to see my uncle . He lives in the next block . ']
['What courses are you going to take next year ? ', " Well , I am certainly going to take chemistry and physics , but I haven't decided on the other subjects yet . I'd like to take English . ", ' Why are you going to take english with chemistry and physics ? ', ' Because I want to study english literature . but I think chemistry is better for getting a job . ', ' Of course it depends on what you are going to do when you leave college . Have you beside what you are going to do when you graduated ? ', ' I am going to be a , well , I hope to be a research chemist . ']
['Hi , chary , are you busy this evening ? ', " sorry , I'm afraid that I've got plans tonight . ", ' what are you doing ? ', " I'm going to my parents ' house for my father's birthday . ", ' how old is he today ? ', " it's his 50th birthday . ", ' well , wish him a happy birthday for me . ', ' sure thing . What are your plans for the evening ? ', ' I was just thinking of going to a movie tonight . ', " well , if you can wait until tomorrow night , I'll go with you then . ", " sorry , I've got people coming over tomorrow night . ", " sounds like this weekend just isn't going to work out for us . ", ' sounds that way . Maybe some other time then ? ', " sure.Hey , I'm sorry , but I've got to get going . ", " yeah , me , too . It's about time I made a move . ", ' say hello to your friends for me . ', ' likewise . See you later . ', ' Bye ! ']
['Good afternoon ! ', ' Hi , how are you doing ? ', ' Fine , thanks . I am Wang Lin . ', ' Glad to meet you , Wang Lin . I am Mary . ', ' Is this your first time in Beijing ? ', ' Yes . My company has an office here , and I have just been transferred . ', ' Here is my phone number . If you need anyone to show you around , call me . ', ' Great . I would like that . ']
["Hey Michelle , jump in quick . It's pouring out there ! ", ' Oh , hi Melissa . Are you going to the conference too ? I was planning to pick up Mr . Campbell . ', ' Yes , he told me . We need to pick him up at his hotel and then go to the conference . ', ' Oh I see , okay . So I heard you got married . Congratulations ! ', " Ah thank you ! I'm very excited . We were going to get married next year , but then we decided to get married on holiday instead . It was wonderful . ", " That sounds so romantic ! Jack and I were hoping to get married in Europe next year , but we had to postpone our plans . We just don't have the money ! ", " I know what you mean . I think Shanghai is getting more and more expensive , don't you ? ", " I sure do . In my opinion , it's actually becoming more expensive than back home . ", " Definitely . Oh , there's Mr . Campbell . Driver , can you stop here please ? "]
["What's that , a new video game ? ", " Nope ! It's the latest generation of PAD ! You won't believe what it can do . ", ' For instance ? ', ' It has a built-in camera unit that takes digital color stills . It also plays MP3 files , which I can save on media cards and then transfer to the hard drive of my computer . ', ' Wow ! Anything else ? ', ' This one comes with its own folding keyboard . It has a pre-installed handwriting recognition program . I can use the stylus to write on the screen . ', ' What if I want to use CD-ROMs or floppies ? ', " Just plug in a peripheral CD or floppy drive and you're ready to go ! "]
["Hey , what's up ? ", ' Oh , nothing . ', ' What were you writing ? ', ' ( Laugh ) All right . You caught me in the act . I finally worked up the nerve to ask Diana out . I was just writing a note to put on her desk . ', " You mean you're going to ask her out in a note ? You big chicken ! ", " I admit it . I'm a wuss . I just can't do it in person . ", ' But , you work with her everyday . ', " That's different . When I'm working , I'm in a different frame of mind . But , when I even think about asking her out , I get tongue-tied . At least in a note , I can get the words out without turning beet red . ", " You've dated a lot . What's so different about Diana ? ", " Well , for one thing , she's gorgeous . She's so upbeat and sweet . Who doesn't like her ? Oh , I don't know . All I do know is that I think we have great chemistry together . But , what if I'm wrong . Maybe she's just been nice to me out of courtesy and doesn't think of me that way . Oh ... forget it . This was a bad idea . ", " Well , I guess you don't want this note , then . ", ' What note ? ', ' I was looking for you to deliver this note from Diana . She wants to know if you want to go to the office party with her tomorrow night . ', " You're kidding ! I can't believe you've been standing this entire time and didn't say anything . ", ' Sorry . What can I say ? Now , do you want the note or what ? ', ' Yeah , I want the note . ', ' Have a great time tomorrow night . ', ' Thanks . I plan on it . ']
['So , what happened ? ', ' He never came . ', ' He stood you up . ', ' I wouldn ’ t exactly characterize it in that way . I think something happened . Something terrible and unexpected that made it impossible for him to ... what if he showed up , took one look at me and left ? ', ' Not possible . ', ' Maybe , there was a subway accident . ', ' Absolutely . ', ' A train got trapped underground with him inside . ', ' And no phone . ', ' And you know , how those express trains create suction . ']
['Mary , how was your date with john ? ', " It's OK . It seems we have a lot in common . ", ' Oh , really ? That is great news . What does he look like ? ', ' He is tall and slim , fair-haired . ', ' Sounds like he is pretty cute . What do you think of him ? ', ' He is a nice guy and very considerate . I am impressed with how smart he is and he has a great sense of humor . ', " Oh , it's love at first sight . When will you see each other again ? ", " He didn't say , but he said he would call me . ", ' Maybe he is busy with his work . Just wait and try not to think about it too much ! ', " Oh , David . Stop it ! I am a bit nervous ! What should I do if he doesn't call me ? ", " Come on , Mary , you're a total catch . I bet he will call you . Don't worry . ", " Thank you , David . You're always so encouraging . ", " That's what friends are for . "]
["I feel terrible , but I've just broken your ashtray . ", " It's nothing to get upset about . ", " I don't know what to say . I'd like to replace it . ", " No . It's out of the question . "]
["I'm so angry at Bob for buying a new bike . ", " What's the big deal ? "]
['The hotel is full tonight . we will need to find a new place to stay . ', " Maybe it's just a blessing in disguise . I've been wanting to try a new place anyway . "]
['Do you know much about computers ? ', ' Not a great deal . ', " I've just been reading an article about them.they ' ll be used for all sorts of things now . ", ' For accounting system and things like that , you mean ? ', ' Yes , but they are used for other things , too.Do you remember when we went to buy a ticket for the flight to Paris . ', ' Yes ? ', ' The man asked where we want to go , then he type out the information on the form and waited for a reply . A few moment later , he gave us two tickets . ', ' Of course , his machine must have been connected to a computer . ', " That's right . "]
['How happy you are ! Next Monday is your wedding day . Congratulations ! ', ' Thank you ! ', ' Fred is really a good guy . And he loves you so much . ', " Yeah . I'm lucky to be his wife . ", " He's after your own heart , it is important . ", ' So he will make a perfect husband . Make sure you will be here next Monday . ', ' I promise ! ']
['Many happy returns of the day , darling ? ', ' Thank you very much . ', ' And here is your birthday present . ', ' A gold watch ! ', ' Do you like it ? ', ' I love it ! Darling , you ’ re kind . ']
["I didn't expect to see you at this hour . You must have goofed off again . ", " Goofed off ? Maybe , but I'm not a clock-watcher . I finished doing what I should do and then knock off an hour earlier . ", " You'll be sorry if the boss finds it out . He may probably give you the bag . ", " I'm sure of what I'm doing . "]
['Hi Jane , you look great . ', ' You too . Have you lost some weight ? ', ' Yes , I took off 4 kilos . I am glad you notice it . ', ' Not some crazy diet fat I hope . ', ' No no , I just changed my eating habits . I eat a balance meal . and I eat less than before . ', ' Good for you , keep it up . ']
['On balance , dress designing appeals to me most . ', " Yes , it's to my liking , too . ", ' Say , how would you like to be a dress designer ? ', " It's my dream . "]
["Hi , Sue . What's up ? ", " Hey , Andrew . How's everything with work ? ", ' Ok , I guess . My boss has been on my back recently . ', " Really ? What's he been doing ? ", " You know , just giving me lots to do . I'm really busy right now . ", ' Are you ? What are you busy with ? ', ' Oh , lots of things . Mostly training new people . ']
['OK , that ’ s fine . Bye . ', ' What happened ? ', ' That ’ s it , my lease is up . I have to move . ', ' What ? Why ? Can ’ t you renew it ? ', ' The owner apparently is selling this place to make way for the construction of a parking lot ', ' Well , I can help you pack . We should start looking for a new place for you ASAP . ', ' I think I might move in with my parents for a couple of months until I can find something . You know how hard it is to find a decent place around here . I ’ m gonna have to put most of my stuff in storage for a while . ', ' Well , let me know if there ’ s anything I can do to help out . ', ' Actually , would you mind looking after my pet tarantula and snake for a couple of weeks ? ', ' Hehe .. sure ']
['Which social problem do you think the government needs to concentrate on most ? ', ' I think housing is a big problem . There are thousands of homeless people on the streets . ', ' How would you solve the problem ? ', ' I have a good idea to solve it . The government could provide some money for homeless people to build their own homes . ', ' It would probably be very expensive . ', ' I think the government can afford it . Besides , there are many advantages . Homeless people would find it easier to get jobs if they had an address . They would learn some useful skill for finding jobs in the construction industry or home improvement . ', ' It ’ s not a bad idea . I think education is the biggest problem at the moment . Schools don ’ t seem to have enough money to educate kids properly . ', ' If we are to invest more money to education , we will need to raise taxes . That wouldn ’ t be popular with voters . ', ' Most voters what everything bout ways . They want the government to pay for lots of things , but without increasing taxes . ', ' The government should show that it is using money efficiently . Sometimes you hear about how the government has wasted money on a project . ', ' Yes . The government has limited funds and must show that it is using the money responsibly . ']
['The sun is shining . ', " But there're some mare's tails . ", " That's the sign of wind . ", ' Oh , really , I thought it was a sign of rain . ']
['Hello , Joanna . You are looking very charming in the new dress . ', ' Thanks . Does it suit me ? ', ' Yes , it suits you very well . It certainly is unique . I don ’ t think I ’ Ve seen anything like it before . ', ' I know . That ’ s why I bought it . I hate wearing the same styles like everybody else is wearing . ', ' And the necklace , it matches your dress marvelously . ', ' It ’ s very nice of you to say so . I should say you are glamorous yourself , as a matter of fact . ', ' Thank you for saying so . ']
['Welcome back ! How was your vacation ? ', " It was fantastic , but I'm glad to be back ! Being a tourist is really tiring ! ", ' Where did you end up going ? ', " Because it's off-season , we got a really good package deal to Paris , so we went there . ", " I've always wanted to go to Paris . The Eiffel Tower is one of the most famous tourist attractions in the world ! Did you go to the top ? ", ' That was the first thing we did . I have a few pictures . Do you want to see them ? ', " Sure . What's this one a picture of ? ", " Oh , that's a picture of me on our fourth day of travelling . I'm standing next to a famous foundation in the centre of the city . ", " You don't look very happy in that picture . ", ' No , by that time , I was sick of sightseeing . I had had enough of art galleries , cathedrals , fountains , statues , and palaces ! ', ' So what did you do ? ', ' We spent that afternoon walking around a flea market . We had a few coffees , watched a movie , and went for a swim in the pool at the hotel . ', ' My travel agent always reminds me to plan a day of relaxing for every 3 days of sightseeing . Did you go to the Louvre ? ', " Of course ! You can't go to Paris without going to their famous art gallery ! I was surprised by how small the Mona Lisa was though . ", " That's what everyone says ! I can't wait to see it for myself some day . "]
['Your ring is very beautiful . ', ' Thank you . It has been handed down in my family for three generations . ', ' Oh , it is precious . ', ' It surely is . ']
['Our major is from a bigger city . ', ' He ’ s doing fine . A new broom sweeps clean . ', ' He brings with him some talented people from his former city . ', ' I think we ’ ll benefit a lot . ']
["Hey , where's Cindy ? ", " She told me that she's got tennis practice today . ", " You're Mary , right ? ", ' How did you know ? ', ' Cindy told me about you in our gym class . ', ' I see . Do you live in this neighborhood , too ? ', ' My house is next door to yours . ', " Oh , Cindy did mention you before . You're Alexander Newman . ", ' Just call me Alex . Alex and Alexander are the same thing . ']
["What's the score ? ", ' The Ukraine team took the lead by 3 to 1 at the end of the first half . ', ' The Russian team needs to tie the Ukraine to get the pass for the final . ', " It doesn't seem to be so easy . "]
['I hear that there is a festival called Duanwu in China . ', ' Yes . It is also called Dragon Boat Festival . ', ' Why are you celebrating this festival ? ', ' We celebrate it to commemorate a great patriotic poet of China — Qu Yuan . ', ' What do you do on that day ? ', " We'll have rice dumplings . What's more , there are also dragon boat matches in some places of southern China . ", ' I see . ']
["Hey , there's Leo . I wonder why he's walking arm in arm with that young woman . ", " It's as plain as the nose on your face . They're dating each other . ", " You're pulling my leg ! She must be thirty years younger than Leo . Talk about robbing the cradle ! ", " Well , you can bet this relationship's going to be a flash in the pan . ", " It must have been love at first sight because I know he didn't have a girlfriend last week . ", ' I think you are absolutely right . Actually , my father proposed to my mother after knowing her only two weeks . They got married a month later . ']
['How many credits are you taking this semester ? ', ' I have to have at least eighteen to keep my scholarships and grant . But so far , I only have fifteen . ', " What's the matter , are the classes you want full ? ", " Yes . And now I'm down to either taking a class I'm not going to need or considering a double major . ", ' If you were to take on a double major , what would be your first choice ? ', ' I think with International Business a language would be appropriate . ', ' Have you even thought that far ahead ? I mean what country would you like to do business with ? ', ' As a matter of fact , I would like to work in South America . So some Latin language like Spanish or Portuguese would work . ']
['What part did you get in the play this time ? ', ' I got a character part — some old lady who shows up in a few scenes . ', ' I wish I had a character part . Those are my favorite . ', ' Are you kidding ? You got the leading role . ', " I know , but I've done that so Ay times . It's getting old . The leading guy is always the same macho A . ", " I would trade you if I could but I don't think I'd be a very convincing macho A . ", " Next time . You are going to love your part . I've seen the script . ", " I do a good old lady . I wouldn't mind being the damsel in distress once in a while . "]
['Are you free on Friday evening because we were wondering if you would like to come round for dinner ? ', ' Oh , thank you very much . I ’ d like to come , but I ’ m afraid I ’ m busy that evening . ', ' That ’ s a pity ! Then when would it be a good time for you ? ', ' Well , I ’ m not too sure , actually . I ’ Ve got a lot going on the next couple of weeks . Why don ’ t I call you later ? ', ' Okay , that ’ s fine . ']
['Which season do you like best ? ', ' I like spring best . It is neither too cold nor too hot . Freezing days make me lazy and stuffy days make me lazier . How about you ? ', ' I prefer summer , especially the summer evenings . When the sun comes down , it is so nice to take a walk and breathe . After a rain shower , the smell of the air is refreshing . It is also a best reason for ice-cream . ', ' How do you get through the stuffy daytime ? ', ' Well , I have to hide in the air-conditioned rooms . Anyway , it is all worth , just think about the cool evening time . ']
["Great party , isn't it ? ", ' Yeah , really , jane and ted always have great parties . ', ' This is my first , I only met jane last week . she and I teach at the same school . ', " Oh , so you're a teacher . ", ' Yeah , history , what about you ? ', " I'm in the car business . ", ' Salesman ? ', " Yes , that's right . ", " Oh , I see , by the way , my name's Mary . ", " Nice to meet you , I'm jim taylor . "]
['Remember that old man who used to beg for money on the street across from our house ? ', ' Yeah . Whatever became of him ? ', ' He got a job and now he owns a small grocery in town . ', " That's great . We should visit him some time . "]
["Sorry . I've got to run . ", ' OK . See you . ']
['Hello , this is the International Student Office . My name is Leah . How may I help you ? ', " I'd like to speak to the Ms . Collins , please . ", ' Ok . Can I ask who is calling , please ? ', ' This is Nathaniel Brown . ', ' And what is your call regarding ? ', " I'd like to talk to her about my accommodation situation . ", " Ok , I'll try and put you through . Please hold . ", ' Ok . ', ' ... Sorry , her line is busy at the moment . Can I take a message ? ', ' Sure . Can you have her call me back on my cell phone number ? ', " Ok . What's your number ? ", " It's 0-7- 7-8- 7-3- 6-7- 6-8- 8 . ", " Let me repeat that back to you . That's zero , double seven , eight , seven , three , six , seven , double six , double eight . ", " No , there's no double six at the end of the number . It's just zero , double seven , eight , seven , three , six , seven , six , double eight . ", ' I got it . When should I have her call you back ? ', ' Anytime before 6 pm tonight . ', " Ok , Nathaniel . I'll have Ms . Collins call you back sometime tonight before 6 pm . ", ' Thank you ! ', ' Bye ! ', ' bye ! ']
['Dan , Dan , dude . You have to come over to my house right now ! ', ' Is everything OK ? ', ' Just get over here ! ', ' Come in ! Quickly ! ', ' So , since when is your house a bank ? ', ' What do you mean ? ', ' I mean , what ’ s up with the locks and iron bars on your windows . ', ' Security , Dan , security ! You can never be too safe you know ! A lot of sickos out there . Just the other day they caught that peeping tom red handed ! Had a high power telescope and binoculars by his window . ', ' What ’ s the matter with you ? Why are you acting all paranoid ? ', ' Paranoid ? I ’ m not paranoid ! I ’ m cautious ! You see Dan , we have to be on guard at all time ! People just invade your privacy as if they knew you ! Telemarketers , solicitors , even your bank ! They have way too much information ! I like to keep everything on a need to know basis . ', ' OK , well , what did you want to see me about ? ', ' You are being watched ! Be careful Dan ! Be careful ! ']
["You didn't ring me last night.You said you would . ", " I'm sorry to have made you disappointed . ", " That's all right . But why were you so rude to me at lunch . ", " Was I ? Sorry , I didn'y mean to be . I do apologize . ", ' And why are you yarning now ? Are you bored ? ', " Forgive me darling . I'm very tired . "]
["Hey ! What's up ? ", " Hi , John ! I haven't seen you for ages . ", " Yeah , I've been out of town . ", ' So how have you been ? ', " Great ! Work is really busy now , but it's fun . "]
["Hey , let's go to the night market after work tonight . ", " That's a good idea . I haven't been in a while and I need to get a new backpack . The old one is hanging on by a thread ! ", ' That reminds me I should buy some new socks to go hiking this weekend . ']
['Reciting texts really bores me to death . ', ' Do you have to remember every text ? ', ' Yes , the teacher says recitation is real good . ']
['Good Lord ! Look at that man . ', ' Yes ? ', " He's swimming in the cold sea . He must be very strong . ", ' Sure he is . Winter swimming does good to health , I hear . ']
['How about a movie tonight ? ', " It doesn't matter to me . ", " Does 7 o'clock suit you ? ", " Either way . I don't care . ", ' How about a snack after work ? ', " I couldn't careless . ", ' Would you rather stay home ? ', ' Whatever you say . ', ' Are you really interested in doing something ? ', " I don't mind if you want to . "]
['Have you bought another handset ', ' No , it is the original one . ', ' This is silver gray , while I remember your handset was black . ', ' I have changed a case for it . ', ' Can a handset case be changed ? ', " Of course . That's why I bought this type . I can change its case frequently , so it is novel to use it . ", ' How many cases are accessible ? ', ' There are two more , one is orange and the other is pink . I have bought them all . ', " It's really going to be fresh all the time . "]
['Would you mind going to dinner with me tonight ? ', " I'd love to go out with you , but I'm sorry I'm busy tonight , but I'd like a rain check . ", ' OK . ']
['I want to change my job . ', ' Why ? ', ' Well , I want to earn more . ', ' I see . ', ' Not only that . The job I ’ m doing now is the most boring job you can imagine . ']
["It's very cold tonight ! ", ' Can I get you another blanket ? ', ' 0h , that would be nice of you . ', " I'll turn the heat up . ", ' Yes , please do that . ']
['Do bullfights interest you much ? ', ' Absolutely ! Everything that ’ s thrilling turns me on . ', ' So I ’ Ve got two tickets to the latest show but I need a little favor from you . ', ' What is it ? ']
["There is a wonderful opera today . I'd like to see it . ", " I do not like the play with complicated plot . What's on today ? ", " ' The sound of music ' . This music is known by everybody and is suitable for all ages . It is about a happy family without sex , violence or bad language . ", ' I know that . I have seen the film as the same title . Andrews gives a performance to be remembered for a lifetime from Maria to a cheerful governess . ', ' Yes , you are right . I like the song in the movie , edelweiss , do you remember it ? ', ' Of course , it is a nice song that can make audience calm and pleasant . ', ' Those young actors play the roles perfectly . ', ' I hope the opera will be more stupendous than the movie . Have you bought the tickets ? ', ' No , I am asking you whether you will go to see it . ', " Let's go . We'd better buy the tickets earlier and have dinner in restaurant . "]
['Would you like to come out with me tonight ? ', ' Sorry , I can ’ t . ', ' Tomorrow night , then ? ', ' I ’ d like to . But I ’ m afraid I can ’ t . ', ' I ’ m wondering if you like to go to the theatre then . ', ' That ’ s sounds great . ', ' Ok . How about give me a ring , then ? ', ' No . I ’ d better not . ', ' Why not ? ', ' Because I don ’ t think my husband would like it . Thank you for inviting me anyway . ']
['You look like a basket case . ', " I'm not surprised . ", " What's the problem ? ", ' My brother in-law just dropped in from the states . ', ' Yeah , and ? ', " I decided to put him up while he's here , big mistake ! ", ' Why ? ', " He's lazy . I tried being a good host , but if you give him an inch , he'll take a mile . ", ' I guess you think twice next time he comes . ', ' You can say that again . ', ' So how long has he here for ? ', " Two weeks . If he thinks I'll put up with his attitude that long he's got another thing coming . ", ' Well , I know you do the right thing . ']
['Hi , Mrs . Henderson . ', ' Hi , Steven . Do you have time and chat with me ? ', " Of course I have plenty of time . What's new ? ", ' The new couple next door divorced . Have you heard about it ? ', ' No . The Hills ? Who filed for divorce first ? ', " I guess it Is Mrs Hill . She sued for divorce on the grounds of her husband's misconduct with his secretary . ", " Oh , maybe not . It's just your guess . Do not give currency to idle gossip . ", ' OK . I close my mouth . ']
["What's up , buddy ? You look so upset . ", " I just broke up with a girl . Why didn't she understand that I loved her ? ", " I'm sorry to hear that . What's your conflict ? ", " I don't know . She always said I didn't love her , but I did . ", ' Did you think about talking to her again ? Maybe she is waiting for your call . ', ' I have asked for a talk again , but she refused and said she wanted to be quiet . ', " Come on , guy . Maybe she isn't your right person . "]
['I like your sweater . It suits you very well . ', " Thank you for saying that . It's a present from my girlfriend . ", ' She certainly has the taste . ']
["Mr . : There are two things that you'll need to know . ", ' What are they ? ', ' Mr . : The school has three lunch periods , and the kids are divided into three groups to go to lunch . ', ' Wow ! ', ' Mr . : Furthermore , when you are dismissed in the afternoon , you will be divided into two waves . ', ' Two waves ? ', " Mr . : The school parking lot is not big enough for all the school buses to come in at one time . So only half the buses come in first to pick up the first wave's students . ", ' And the other half come in later to pick up the second wave . ']
["Oh , my God ! I've been cheated ! ", ' What ? What did you buy ? ', " It's a brick ! I can't believe how stupid I was . Damn it ! ", ' What is it ? Why did you buy a brick ? ', ' There was a guy on the sidewalk.He had three new boxes , Panasonic video camera boxes.He said he had to get rid of them quick . ', ' And ? ', " So he said he'd sell me one for twenty dollars . A four-hundred-dollar camera for twenty bucks . ", " And it's a brick ? ", ' Yes . ', " I can't believe how stupid you are . Why didn't you open the box ? ", " I wanted to . But he said , no , the box is still in its plastic wrap from the store.If it's opened , other people won't believe it's new . ", ' So he had the boxes wrapped in plastic . ', ' Yes , it was the kind of perfect plastic wrap that comes with new products.Look , it even had a bar-code price sticker on it ! It looked brand new . ', ' But why would a guy be selling new video cameras for twenty dollars ? ', ' He said he had to get rid of them . They were stolen . ', ' Aha ! Now I understand.You were trying to buy stolen goods on the sidewalk.So , what I think is , you deserve to get cheated ! ', " C'mon , don't blame me ! I thought it was a new camera . We could use it.We were even thinking about buying a camera . I don't understand how he could have such a perfect-looking box . ", " That's no problem.He just has a friend who works in a shop that can do plastic wrap . That's easy.And probably it's the same shop he got the boxes from.Maybe his friend works in an electronics store . They sell video cameras there . Probably they had a couple video camera boxes lying around.So they get the idea of wrapping bricks to sell to fools like you.Twenty dollars a brick . That's a good profit if they can sell enough bricks . ", " You're right , Sarah . I was a fool . I can't believe it . How could I fall for such a trick ? "]
["I'm sorry for being late . ", " You're supposed to stand here quietly until the flag - raising ceremony is over . ", ' About what time can I go to my own class ? ', ' When everything is over . ', ' Now that it is all over . can I go now ? ', ' Not yet . You should stand still for another few minutes . Late-comers must be recorded . ', " That's too bad ! "]
['Are you looking forward to seeing that big concert next week ? ', " You bet . I'm really excited . "]
['Hey Joanne . What are you up to ? ', " I'm just watching some television . ", " I'm so bored . I don't know what I'm going to do today and it is only ten in the morning . ", ' Me too . Do you think we are boring people ? ', " I don't think we are boring . It's just that we don't have any hobbies . ", " That's right . What do you think we should do as a hobby ? ", " That all depends on what you like to do . For example , I like to doodle on the notepad , so I'm thinking about doing some real drawings . ", ' I like to play the piano for fun . ', ' Yeah . That can be a good hobby . ', " Hobbies are great . I'm going to make a list of all the things I like to do . ", " That's a great idea . I'm going to do the same . "]
['Have you had any kind of punishment in your college ? ', ' Yes , but it was many years ago . ', ' What was it for ? ', ' I was a naughty boy and I played hooky . So the school gave me a punishment to clear the classroom for a week . ']
['How do you like my new sports car ? ', " It's cool . "]
["If I won the Pools , I'd go round the world . ", " Would you ? I wouldn't . ", ' What would you do ? ', " Oh , I don't know . I'd buy a big house with a garden for my wife and kids , I suppose . But it's difficult to imagine having a lot of money . ", " One thing's certain . If I had a lot of money , I wouldn't work any more . ", " Wouldn't you ? What would you do with all that spare time ? ", " As I said , I'd go round the world . ", ' What would you do after that ? ', " Oh , I don't know . It'd take me a long time to go round the world . ", " It doesn't sound very exciting . ", " Anyway , we haven't won the Pools , and we're not likely to win them . So there isn't much point in talking about it , is there ? ", " I'd be happy if I got a rise . ", ' And my wife would be happy if I bought her a mink coat . ', " Well , I'm not likely to get a rise and you haven't the money for a mink coat , so let's come down to earth and have another drink . ", " What'll you have ? ", " I'll have a pint of the best . ", " I'd have a Scotch if I were you . We deserve it . ", ' All right . Make it a double , will you ? ']
['do you like animals ? I really like dogs . ', ' so do i . I don ’ t like cats . ', ' why ? I think cats are ok . ', ' I can ’ t bear being near cats . They don ’ t seem to like me either . ', ' I like wild animals . I don ’ t like spiders and snakes . I think spiders and snakes are disgusting . ', ' I ’ m fond of snakes . I think they ’ re great . I agree with you about spiders though . I think spiders are horrible . I think it ’ s because they have so many legs . ', ' I think bears are wonderful . Pandas are fantastic . I low the people who kill them for their fur . ', ' I agree . I ’ m carry about mice . I think they ’ re so cute ! ', ' really ? I don ’ t see the attraction . I ’ m afraid of mice . ']
['I hear your sister has had an accident , is it true ? ', ' Yeah , it happened a week ago . ', " That's a crying shame . It really is ! ", " Fortunately , she's not seriously injured . "]
["Good evening , I'm so happy you could come . ", ' Thank you for inviting me . ', ' What would you like to drink ? ', ' A glass of white wine would be fine , thank you . ']
['My son is alway complaining that I dump on him . He was very rude and told me to mind my own business . I cannot put up with that . ', ' What does his dad say ? ', ' John is a peacemaker.He simply doesn ’ t bother.He says he should give him a free hand . ']
['Do you think children watch too much Tv ? ', ' I only allow my child to watch up to an hour a day . I don ’ t think that tv is bad for kids . I think that kids should be active and not become couch potatoes . ', ' Perhaps I should impose a limit on how much Tv my kids can watch . They don ’ t do much else in their free time . At least they always do their homework first . ', ' If you decide to put a limit on the amount of tv they can watch , remember to have something else for them to do . If you don ’ t , they ’ ll get bored and misbehave . ', ' They could go out and play with their friends . ', ' Sure . You could talk to other parents in your neighbourhood and plan it so that all the kids are free at the same time . ', ' Perhaps I could ask my husband to teach them foot ball or some thing . He watches too much Tv too . ', ' That ’ s a good idea . Remember that if the parents watch too much Tv , the kids will probably follow suit . ']
['Did you meet the new girl in our sales department . She is taking the place of Maggie during her alternative leave . ', " Did they finally fill that post , how come I haven't seen her ? She must have not been inducted yet . ", " I guess not , They haven't officially introduced her to the whole staff yet , she barely started yesterday . ", ' Is she just working temporarily ? What are they going to do when Maggie comes back from leave . ', ' If the new girl is competent , maybe they will promote her when that time comes . ']
["what's up ? ", " not much . I'm just trying to hook up to the internet . I'm having a few problems though . ", " what's wrong ? ", " I've got all the cords plugged in , but it appears that I'm offline . ", ' Are you using dial-up or broadband ? ', " actually , I've got a wireless connection . ", ' In that case , you need to turn on your airport . ', " I hook up to the Internet every day . I can't believe I didn't do that . ", ' do you like ever chat online ? ', " No , but I'd like to . Do you have to pay to do instant messaging ? ", ' Oh , no . You can register for free . Just go to the yahoo website and it will tell you how to do it . ', " what do you do if people want to talk to you online but you don't want to talk to them ? ", " well , you can always block them . When I don't feel like talking to certain people online , that's what I do . ", " what's your email address ? I'll add you to my contacts list . ", " it's aubreyinchina@yahoo.com . ", ' cool . We can meet up in a chat room sometime or just chat online using messenger.thanks for your help . ', " don't mention it . "]
['I ran into a glass door yesterday . ', ' What a bone head ! Be careful next time . ']
['You have been here for how long ? Four months now ? ', ' Yeah , about . ', ' Do you know Chinese better now ? ', ' Oh , definitely . I remember , when I first arrived in Guangzhou , my girlfriend was haggling with a sales clerk over the price of a mobile phone . ', ' Oh , yeah . Many Chinese like to bargain . It happens almost everywhere . ', ' I mean , I understand that . But the speed of the conversation got faster and faster , until it seemed to me that they would fight . My perception of the tone was that it was a violent shouting match . The truth was that it was a perfectly normal conversation . ', ' A shouting match ? You ’ re so funny . You must be exaggerating . I don ’ t believe it . ', ' I am not exaggerating at all . I ’ m telling you the truth . That was how I felt at that time . ', ' Yes , perhaps . Chinese usually don ’ t notice that sort of thing . Maybe it ’ s quite natural to us . ', ' Yes , absolutely true . ']
["That guy's manner really turns me off . ", ' Yeah.He never stops asking questions . ', " Maybe he's abnormal . "]
['Do you like our new history teacher ? ', " I'm fed up with his endless talking . ", " You can't say that ! He's a very knowledgeable person . ", " I can't see it . "]
['Have you seen Harry ? ', ' No . As far as I can remember he was supposed to be on a business trip to Lisbon . ', ' Yes , but he was supposed to be back by now . ', " Maybe you'll call his home . "]
['You spoken English is pretty good . Please tell me your experience in learning English . ', " Uh , I don't know what to say . What do you want to know ? ", " What's your method of learning ? ", ' Let me think a minute . I think I always try to take every chance to practice . ', " What if there is no chance ? I mean what if you don't have a partner , what will you do ? ", ' Well , I talk to myself . That is , I play one role first , than the other . ', " That's a good idea . You are really creative . "]
["How's your new car ? ", " Perfect.Couldn ' t be better ! ", ' You made a good choice , then ? ', " It's just what I wanted . ", ' No regrets ? ', " I'm really pleased with it.Thanks . ", " I'm glad you're so happy . ", " It's super . "]
["Now that you'recommending such enormous fees , producers , directors , movie-makers must see you in a completely different light . ", ' Yeah . ', ' Then the standard that you set yourself originally must have changed . ', " Well , if that's the case , I don't mind breaking the image that they might have or the standards that they have . I can only do what I know , and live how I've lived all my life , because I'm a fairly stubborn person . ", " It seems to me that now you're famous . You've got to go out and be seen at the right places and go to the right parties . ", " I don't go to parties . The parties I go to are the barbecues I have in my house . Being seen in the right places is something that I don't believe in . I don't believe in going to events just for the sake I of being seen . ", " Then fans don't see you much in public places . ", " Yes . I have a very low-key life ; I have a great life . I love what I do and I love how I spend my time , which isn't in a public place . ", " A lot of people compare you to Julia Roberts . I wondered if there was anyone that you compare yourself to in Hollywood , that you've watched and thought , ' Well , they've got something I could use a little bit or could learn a little bit about . ' ", " I've never had one person that I'd idolized . The comparisons to Jul-ia Roberts are incredibly flattering . I don't really know who I would compare myself to . I'd like to be a combination of a lot of people . A little bit of everything , really . I haven't quite figured out where my strengths are yet , and I've definitely found my weaknesses . "]
['When do children start school in your country ? ', ' Normally at six . Before that , they spend several years in the kindergarten or pre-school education center . ', ' But thats only in the cities , isnt it ? ', ' Right . In the countryside , things are more complicated . ', ' Can kids in the countryside get equally good benefits and education like those in the cities ? ', " It depends . In some poor , underdeveloped areas , children's education is a problem . Many kids cannot afford to go to school . "]
['The baby is crying again . ', ' Leave him alone , he ’ ll soon stop . ', ' How can you do so ? Perhaps something is wrong with him . Let ’ s go and see him . ', ' OK . Nothing serious . He just wants us to be with him . ']
['Oh that ’ s a lovely necklace . ', ' Thank you . My husband gave it to me . ', ' Oh I didn ’ t know you were married . ', ' Yes I am . I got married five years ago . ', ' Oh I see . That ’ s nice . Did you meet your husband at work ? ', ' No , we met at university . ']
['Hi ! Is that the new laptop you brought last week ? It looks very nice . ', ' Yes , it is . Thanks . I ’ m just surfing on the internet . ', ' Here ? In this cafe ? How can you do that ? ', ' This cafe offers a wireless internet connection . That means I can get on the net for free while I ’ m here . Of course , I have to buy a cup of coffee ! ', ' That ’ s great . Can you do it anywhere ? ', ' No . you can only do it when the cafe offers a wireless connection . There are only about 10 or 12 places that offer it in this city . ', ' So , what programs do you have on your laptop ? ', ' I ’ Ve got all the usual ones for word processing and then I have a few for creating and editing photographs . ', ' I know you are keen on photography . It ’ s very useful for you to be able to download photos from your digital camera . Then you attach the picture files to emails and send them to anyone , anywhere , at anytime ! ', ' It ’ s wonderful , isn ’ t it ? Would you like to see some photos that I look recently ? ']
['Nice and warm again , isn ’ t it ? ', ' Oh , it ’ s lovely . Think of the nasty weather we had last week . ', ' How are you these days ? ', ' Fine , thank you . And you ? ', ' Fine today , though a bit under the weather last week . ']
["What's happening in your life ? ", " Can you believe I'm going to America ? ", ' That sounds great . ', " Yes , I'm really excited . "]
['My wife is really a chatter box . It ’ s so boring . ', ' I have an idea . ', ' What is it ? ', ' You just turn a deaf ear when she talks . ']
['You ’ re a wonderful person , Kathleen . ', ' So are you . ', ' And I ’ m so honored that you would want to be with me because you would never be with anyone who wasn ’ t truly worthy . ', ' I feel exactly the same way as you . ', ' Don ’ t , don ’ t , don ’ t , don ’ t say that . That , that makes it worse . ', ' What ? You don ’ t love me ? Me , either . ', ' You don ’ t love me ? ', ' No . ', ' But we ’ re so right for each other . ', ' I know , I know . Well , is there some , is there someone else ? Oh , that woman on television , Sydney Ann . ']
['My elder aunt feels like vomiting , she is pregnant . ', " She'd better drink plenty of hot water and lie in bed . ", ' But she feels like having no appetite at all if she stays at home all day . ', " Don't worry . She will be all right . "]
['Is this your umbrella , miss ? ', ' Oh , yes , it is . Thank you . I was looking for it just now . ', ' You look a bit familiar to me . I wonder if I have seen you somewhere before . ', ' Have you ? ', ' May I ask where you live ? ', ' Just two blocks away , in that tall building . ', ' That ’ s it . I live there , too . I live on the sixth floor . ', ' My family move in just two weeks ago . We live on the fourth floor . ', ' It ’ s a small world ! May I know your name , miss ? ', ' I ’ m Chen Ming . ', ' How do you do , Miss Chen ? I ’ m Song Mei . ', ' I ’ m glad to meet you , Mr . Song . ', ' Are you going to your office now , Miss Chen ? ', ' No , I ’ m going to the airport to meet some friends from Beijing . ']
["It's very thoughtful of you to invite me to your wedding . ", ' How can I forget my old friend ? ', ' My best wishes to you and the bride ! ', ' Thank you very much . ']
['I have a sweet tooth . I can not help but think about having something sweet between meals . ', ' A new candy shop just opened around the corner last week . They have a variety of candies and it is always full of people . ', " That sounds really attractive . Let's go to that candy shop now . ", ' Are you serious ? It is always crowded with many people . ', ' why not ? I would like to buy some candies . Since there are so many people , I think they must have delicious candy . ', ' Look at the candy bar over there . It is so colorful and tasty . ', ' They have lollypops , chocolate drops , fruit candy , mints , pearbrittles and toffee . They are in different colors and flavors . ', ' I want to get a big bag and buy a little of everything . ', ' Me too . I finally understand why a small shop like this can always befilmed with dozens of people . ', " To be honest , I care only about whether I can have some delicious candy eat . I couldn't care less about whether the shop is popular or not . ", " You are a candy terminator . Be careful or you'll get a lot of cavities . ", " That is true . Speaking of cavities , I am starting to feel something is wrong with my teeth now . Let's get more strawberry chocolate drops before we go home . ", " You really can't live without candy . "]
['Who do you think will win the championship ? ', " I really can't say . Both teams this year seem really good . ", " There's a game on tonight . You want to watch it with me ? ", ' That sounds great ! ']
['Good morning miss . Wang ', ' Good morning Mr . Li ', ' It ’ s a beautiful morning isn ’ t it ? ', ' Oh . It ’ s a nice day indeed ', ' I hope it won ’ t be too hot , I can ’ t stand the heat ', ' Really . For me too . ']
['You are very late , but I was on pins and needles the whole time . ', ' Oh , I ’ m sorry . ']
['Look at these newlyweds . They seem as if they are on top of the world . ', " Yes , they do . It's great for them to tie the knot and get married . ", ' People who have just got married feel that the world is right before them . ', ' Nothing seems to be happier for them . ']
['What would you say if I told you I was going to quit school ? ', ' I ’ d say , think twice about it . Well , you are not going to quit school , are you ? ', " I don't know . I failed my exam . ", ' What did you get ? ', ' A B plus . ', " That's not bad . ", " But I should have aced it . I mean I finished the paper so quickly , thinking it's a piece of cake . But when I knew my result , I was like what ? That can't be true ! ", ' Listen , John . I understand that you are such an excellent student and I know you must have lots of stress , but you really want to give up ? ', " No , I don't . I just don't know how to handle this . This is my first time , you know . ", " I know . Don't worry . Do you know what you should do ? ", ' What ? ', ' You need to blow off some steam . The world is not on your shoulder . ', ' How ? ', ' Forget about school and exams . Come over to my house and have fun . I have some really good DVDs . ', " Thanks . But I really don't feel like watching movies tonight . I have to get an early start in the morning . ", ' Then go to bed and have a good sleep . ', " I guess that's what I need . Thanks . You're being a really good friend . ", ' Of course I am . Well , pleasant dreams ! ', ' Thanks , bye . ']
['You are too picky . ', " No , I'm not.Hey , look at that guy over there . ", ' Which guy ? ', ' The guy in the blue shirt at the table by the window . ', " I can't see him . Where ? ", ' Right there . ', " Oh , I see him now . Wait ! That's ... ", " Yes , it's Mel Gibson . ", " Oh , wow ! It's really him ! Who is that woman he's with ? ", " I don't know . Why don't you go ask for his autograph ? ", " I can't do that . ", ' Why not ? ']
['Do you have a family tradition at Christmas time ? ', ' We have so Ay ! But my favorite happens at Christmas Eve . ', ' What is it ? ', ' Well , all the brothers and sisters get together and fill the Christmas stockings for the litt 1e kids . ', " That's it ? That's the tradition ? ", " Well , in fact it's fun for us to just be together that night and do this one thing . ", ' I guess the spirit of it is what really makes any tradition fun . ', ' You should be there some Christmas Eve . ']
["Karen , do you have a minute ? I'd like to ask you about something . ", ' Sure . What is it ? ', ' I think you can give me some advice.You have worked here longer , and I just want to know what you think . ', " I'm glad to help you . But what is it you want to ask about ? ", ' I am worried about the meeting this morning . ', ' Why ? I think the meeting went well . ', ' Really ? ', ' Yes . But what are you worried about ? ', " I'm afraid I was too rude . ", " Rude ? You weren't rude at all , Annie . Why do you think you were rude ? ", " Well , I maybe talked to Mr . Drummond too directly . I thought I maybe said too much . I don't want him to be angry . ", " I understand . But really you weren't rude at all.You said what you thought . I think he appreciates that . ", ' Really ? ', ' Yes . ', " But I am new here , and I'm not sure he is used to that . ", ' You mean because you are a woman ? ', ' Yes . And he is the president of the company . ', " Listen , Annie . You shouldn't worry about Mr . Drummond.He is a very good man to work for . He is not sexist at all.He appreciates people for their ideas.And he is willing to take suggestions from men or women . ", " I am very happy to hear that , Karen.It ' s good to know I'm working in such a company . ", " I agree with you on that , Annie . I've worked for Derek Drummond for nine years now . I feel he appreciates his employees for their work , not their gender . I would never change jobs . ", ' Good . Thank you for telling me this . ', " Any time . If you have a good idea , don't be afraid to speak up.This is a company that appreciates initiative . "]
['I really admire you , Diana . ', ' why , Jerry ? Your words just came out of the blue . ', ' you are really happy and able to achieve high scores at school . ', " I work very hard and that's it , you know , practice makes perfect . ", " isn't there anything else ? ", ' I have no idea . ', ' you must have a high IQ score . ', ' well , Jerry , let me tell you a secret . ', ' go ahead . ', ' my IQ score is slightly above average . ', ' seriously ? But you are such a genius . ', " maybe I've got a higher EQ . I'm not sure . ", " well , perhaps you're right . Sometimes EQ matters more than IQ . ", " you can say that again , Jerry . And I'm sure you're high in both of them . With a little more time cracking the books , you can also get high marks . ", " oh , thank you . I'm going to the library , are you coming ? ", " let's go ! "]
['Hey Sarah . Why are you limping ? ', ' Oh . Hi Matt . I went snowboarding yesterday and my whole body aches . ', ' Was it your first time ? ', ' Yeah . And I never want to go again . ', " I remember the first time I went . My back was sore , I couldn't sit down because it hurt my butt , and my legs would cramp if I walked too fast . ", " That's exactly how I feel now . ", " It's only like that the first couple of times . ", " Ha . There won't be a next time . ", " You gotta give it a chance . It's fun after awhile . ", " I'll think about it after I start feeling better . Right now , I don't even want to hear the word snowboarding . "]
['Hi Mark . ', ' Oh , hi Stacy . ', ' How was your summer vacation ? ', ' I worked over the summer at a restaurant . Have to make tuition money , right ? What did you do ? ', ' I took summer school . I withdrew from two of my classes last year so I wanted to make them up . ', ' So are you officially a junior now ? ', ' Yeah . And I have 5 credits to spare . I only needed to take 10 credits over the summer , but I took 15 because the price was the same . ', ' That makes sense . So where is Nicole ? ', ' She dropped out of school completely . ', ' Really ? Why ? ', ' She worked at a startup company as an intern and since the business did well , they asked her if she wanted to work full time . ', " Wow . She's so lucky . She doesn't have a degree and she already has a job . ", " It sounds good now , but I'm traditional . I want the degree , so I wouldn't have accepted the offer . ", ' Do you know how much they are paying her ? ', " I don't know . But I bet it must have been a good offer , or she wouldn't have accepted it . "]
['What is up ? ', ' Look at the dishes ! I have told you three times to put away these dishes . But now ... ', ' Oh , don ’ t be angry . I just thought you might need them sometime . ', ' I have told you that I don ’ t need them any more . The thing that really annoys me is that you played dumb with me . ']
['Are you a smoker ? ', ' Yes , I ’ m afraid I am . My husband is a smoker too . ', ' Would you describe yourself as being a heavy smoker ? ', ' No . But my husband smokes 20 or more a day . ', ' When did you begin to smoke ? ', ' I had my first cigarette when I was 17 . ', ' Might I ask if you have tried to give up smoking ? ', ' Yes . Twice . ']
['Hey , look at my new shirt . What do you think about it ? ', ' Just so-so . Where did you get it ? ', ' I bought it on a street market . A real bargain ! ', " I'd much rather buy expensive but good quality clothing , because it is not only nice but lasts a long time . "]
["Jenny , you look terrible . What's eating you ? ", " Don't brother me ! ", " Hey , chill out , I'm just trying to help . ", " Sorry , Sally , it's not your fault . ", " So , what's the problem ? ", ' I drew a blank on the algebra test . ', " No kidding ! Didn't you study for it ? ", ' Yeah , but nothing was clear during the test . ', " That's too bad , anyway , I'm sure things will turn around next semester . ", " I'm thinking of dropping out . ", " You can't do that , Jenny ! ", " I'm dead serious about this , Sally . ", " Come on , let's talk about it . "]
["Lisa , I'm home . ", ' How was your day ? ', " Pretty good . I've made a few friends already . ", ' Anybody I know ? ', ' Well , Pam Franklin lives next door to us . By the way , can I go to her house this Saturday ? ', " Of course . You didn't have to ask me . ", " That's what Pam said . ", " Just don't stay out too late . "]
["It's nice and bright today , isn't it ? ", ' Yeah . The autumn is marvelous here . ', ' How about winter ? ', " That's a hard time . The air is cold and damp , and the road is often icy . ", " It's boring , right ? ", ' Sure . ', ' Do you get much rain during the summer ? ', ' Plenty . We never worry about lack of rainwater in our area . ', ' So you should bring an umbrella often . ', " That's right . "]
['Thank you for coming to see me off . ', ' Not at all . ', " If have time , I'll come again . ", " You're welcome at any time . ", " Thank you for your hospitality . I hope I didn't cause you too much trouble during my stay . ", " You're most welcome . ", " I'm afraid I have to go now . The plane will take off soon . ", ' Call us as soon as you get home . ']
['May I invite you to dance with me ? ', " Sorry , I can't dance . ", ' Never mind , I can teach you . ', ' Is it difficult to learn ? ', ' No , it is easy . ', ' How should I do ? ', ' You just follow me . ', ' All right . By the way , do you often dance ? ', ' Yup , because dance can relax myself . ', ' It seems a good way . ']
['Hmm , what should I wear today ? ', ' Come on , you think about what to wear almost every day . There are thousands of clothes in your wardrobe . ', " Well , haven't you ever heard people say that there is always one piece of clothes missing from a woman's wardrobe ? ", ' I have and I can prove that is 100 % true for you . ', " Loving to look beautiful is women's nature . In fact , I am thinking about going to my favorite clothing shop today . ", ' No kidding ! Again ? ! You just went shopping yesterday . You really are a shopaholic . ', ' Well , I need to change the shoes I bought from Nasi . They are too small . I want to ask them whether they come in a larger size . ', ' OK . Do you have the receipt with you ? I think they will ask you to show them the receipt first . ']
["I'm feeling hungry . ", " Isn't it time for dinner ? ", " Yes , let's get something to eat . ", " How about Mac Donald's ? "]
['What do you think of the way people use and treat animals ? ', ' I think most people treat animals well , but we are often cruel to animals . When we raise animals for food , the conditions they live in are often poor . ', ' Perhaps people should stop eating animals . We could grow more crops . ', ' What would you do with all the animals ? You couldn ’ t just let them go . Besides , some people would still hunt them . Meat has become an integral part of our diet . ', ' We could provide them with better conditions anyway . We should certainly try to improve the conditions at zoos . We should try to recreate the natural conditions as much as possible . ', ' That ’ s true . I think zoo are a good idea , because they allow people to get close to animals . I think it ’ s good for kids to see wild animals . ', ' I agree . I ’ m an adult and I love going to the zoo . I don ’ t like animals experiments though . I believe that we can do tests in other ways . ', ' I read that the number of animals being used in experiments is falling dramatically as new techniques are being introduced . ', ' That ’ s good news . The good thing is that most people treat their pets well . ', ' Sometimes you read about people who have been cruel to pets or other animals , but those stories are rare . ', ' Have you every given money to any of the charities that take care of animals . ', ' Yes , I have . They do an excellent job . ']
["I'll be seeing you around . ", ' OK.Take care . ']
['Did Bean send these dirty jokes to you , too ? Look ! ', ' What a creep ! Phony good luck e-mails are one thing , but sexual harassment is crossing the line . ', ' No wonder he asked for my address first-he just wants to harass me ! ', " You could try using a spam filter to reject stuff that's obviously pornographic or anything else you don't want . "]
['Do you object to drinking black tea , Mr.Zhang ? ', ' Yes , that is why I never drink it . ', ' Do you drink green tea , then ? ', " Very seldom , because tea has tannin which may be harmful to one's health . ", ' But if the tea is good and well prepared , it will do much good . ', ' What good is it for ? ', " Not only can it appease one's thirst , but it can also refresh one when tired . ", " That's true , but it must not be allowed to stand long . ", ' Why is it so ? ', ' Because if you drink a kind of tea which has been prepared for some time before , it will do you harm . ']
['I just heard your boy had taken the first place in the history test . He is super cool . ', ' You flatter me . ']
['Jennifer , would you like to have dinner with me ? ', ' Yes . That would be nice . When do you want to go ? ', ' Is today OK ? ', " Sorry , I can't go today . ", ' How about tomorrow night ? ', ' Ok . What time ? ', ' Is 9:00 PM all right ? ', " I think that's too late . ", ' Is 6:00 PM OK ? ', " Yes , that's good . Where would you like to go ? ", ' The Italian restaurant on 5th street . ', " Oh , I don't like that Restaurant . I don't want to go there . ", ' How about the Korean restaurant next to it ? ', ' OK , I like that place . ']
['Hi , long time no see . How have you been ? ', " Oh , I've been fine , but I'm having some trouble with my son . ", ' Tell me all about it . ', " Oh , he's 14 and in the past few months , he's become quieter and a bit secretive . He locks himself in his room and I think he's running around with the wrong crowd . ", ' Oh , I see . What makes you think that ? ', " Well , he's become friends with a couple of older boys who are in a band . And one night last weekend , he came home really late , way past his curfew . ", ' Really ? What happened ? ', " He told me that his friend's car broke down and they had to walk home . ", " I see what you mean . I understand why you're concerned . Have you tried talking to your son about it ? ", " I haven't yet . I just keep hoping it's just a phase he's going through . ", " You may be right , but it doesn't hurt to find out more about what's going on in his life . ", " You're right . I should talk to him . Sometimes , it's not easy being a parent . Thanks . It helps to get it off my chest . You're always so easy to talk to . ", " I don't know about that , but my door is always open . Stop by anytime . "]
['Hello , Tom ! Do you have plans for this evening ? ', ' Nothing special . ', ' How about having dinner with me ? ', " That's great . I would love to . And when ? ", " Let ’ s fix it at seven o'clock , OK ? ", ' No problem . However , maybe I should come early to help you prepare the dinner . ', ' Don ’ t worry . I will arrange everything . ', ' All right , see you tonight . ', ' See you . ']
['Hello Mei , How about going for a meal this evening ? ', ' Good idea ! I finish work at five . Why don ’ t we meet at six ? ', ' Ok that sounds good . Where shall I meet you ? ', ' Let ’ s meet in front of the train station . ', ' Ok great , I ’ ll see you at six . ', ' Ok , see you tonight ! Don ’ t be late ! ']
["I'd like to meet you again sometime . ", " That would be great . Actually , can I get your phone number , Ella ? That's assuming you don't mind if I call you sometime . ", ' Anytime . You can reach me at 5558929 . ', ' Ok , got it . I will call you sometime next week . ', ' Fine . ', " It's time to go . Bye , Ella . Hope to see you soon ", ' Bye , Jason . ']
["Lisa , I'm so glad to see you . How are you doing ? ", ' Fine . I miss you so much , uncle Benjamin . ', " Me too . We haven't seen each other for years . ", " It's been 3 years now . ", ' How time flies ! Now you are a college student out of a little girl . ', ' How is aunty Shirley ? ', " Couldn't be better . ", ' How has May been ? ', " She's been good . She is in grade one in Joy Chain high school . And she dreams to be a volunteer in 2008 . "]
['When she told me that she would marry no man but Dick , my heart was almost in my mouth . ', ' You were scared , too ? I dared not tell you my feeling when I heard that . I almost got fainted . ', ' I could not and can ’ t make out the reason why she would set her heart on a man like Dick . He plays the field with many girls . ', ' But Sarah says she does not care , so long as he loves her . ']
['Excuse me . May I take a picture of you and your little boy ? ', ' What ’ s it for ? ', ' It ’ s for a book . ', ' Oh , that ’ s a nice idea . Well , it ’ s fine if you take our picture . ', ' Thank you . I appreciate your help . ']
["Hey , That's a really nice outfit you have on . ", " Why , thank you . I wasn't sure if it looked okay or not . I can't believe all the words the salesgirl said . ", ' Oh , you look stunning . Your dress really goes well with your shoes . ', " I'm glad that you think so . I thought it might be a bit too revealing . ", ' No , not at all . It looks really classy on you . Where did you pick that up ? ', ' I got it on sale down at the department store . ', ' When did you go there ? ', ' I was just there a couple of days ago . You know , you should go down there too . They have a lot of stylish clothes on sale . ', ' I might just do that . What style of clothes do they have ? ', ' Anything you want . They have both casual and formal styles . ', ' I was hoping to get a few new ties for my collection . ', " That's a good idea . Some of your ties are pretty outdated . ", " Well , I spent a lot of money on getting my shirts tailor-made , so I couldn't afford to buy any new ties . ", ' Anyways , are you going to the party tonight ? ', ' Yes , I am . Say , are you going to wear that outfit to the party ? ', " I don't think so . It is a little too formal . I'm probably going to wear something more laid back . ", ' Me too . I will probably go dressed in a T-shirt and jeans . ', ' I guess that you will really be dressing down . ', " That's my style when I'm not in the office . ", ' Good point . I suppose that we all have our own individual styles . ']
['Hello , John . How are you ? ', " I'm fine , thanks . And you ? ", " Very well , thanks . Nice to see you again . I haven't seen you for a long time . What have you been doing lately ? ", ' Oh , nothing much really . And how is everything with you ? ', " Fine , thanks . I've been busy lately . ", ' What have you been doing ? ', " I've been studying for my exams . My school exams will begin next month . ", ' Really ? Good luck for them . ', ' Thanks . And how are your parents ? ', " They're both very well , thanks . ", ' Where are you going now ? ', " I'm going to do some shopping.Why don't you come with me ? ", " I can't . I have to meet someone . ", " It's been nice talking to you . ", ' Good-bye . See you again sometime . ']
['Mom , look , that cake looks delicious . My mouth is watering . ', ' OK , boy . I will buy it for you . ']
['What a pin-up she is ! ', " Can you imagine she's over forty ? ", " That's incredible ! She has such a sharp figure . ", " Absolutely . She's a teacher of aerobics . "]
["What's the date today Mr.Brown ? I don't have a calendar . ", ' Today is Tuesday , 25th September , 2001 . ', ' 25th Sep ? Oh , I have an appointment tonight . ', ' What time is your appointment ? ', " It is at 8 o'clock . ", ' What time is now ? Do you have the correct time ? ', " I don't know what time it is . ", " It must be about 6 o'clock . ", " I have to go now . I don't want to be late . ", " You won't be late . It's still early . "]
['Hi , Michelle . Do you need to use the photocopier ? ', ' Oh , hi Jeremy . No please , go ahead . So how are you , Jeremy ? I was talking to Linda about you only last week . ', " Oh , I'm fine , thanks . I'm super busy with work actually . Did you hear about the Lawson contract ? ", ' No , tell me more . ', ' Well , I was discussing the contract with Bill and he said that they met the head of Lawsons last week . ', ' And . ', ' And hopefully they are going to confirm the deal on Wednesday , fingers crossed . ', " That's great news , Jeremy . Congratulations ! Anyway , I must get back , but give my regards to your wife Monica . ", ' I will , Michelle . Speak to you soon . ']
["What's your favorite kind of music ? Do you like pop music ? ", ' I like almost all kinds of music . But I like country music best . ', ' There was a concert country music last week . ', ' I wish I had been there ! ', ' I like it , too . But sometimes I enjoy jazz and classical music . ', ' You have good taste in music . ']
['What can I do for you ? ', ' I am returning these books . ', ' What did you do to this book ? ', ' I accidentally ripped the cover . ', ' You will need to pay for the damage . ', ' How much do I need to pay ? ', ' I ’ m going to need $ 5.00 . ', ' That ’ s not too expensive . ', ' It isn ’ t . ', ' Here ’ s the $ 5.00 . ', ' Thank you . ', ' No problem . Have a good one . ']
['Hello ? ', ' Hi , Randy . What are you going to do this weekend ? ', ' I ’ Ve no idea . Nothing really . ', ' How about going hunting with me ? ', ' Wonderful . ', ' Okay . I ’ ll pick you up around 6 ', ' I ’ ll be ready . ']
['How is your business on the Internet , Steven ? ', " Don't mention it . I lost a bunch of money on it this year . I think it is on the brink of bankruptcy . ", ' I am sorry to hear that . It shows that you should buy companies , not ideas . ', ' I changed my strategy around too . I am investing in good companies now . ', ' Yes , I agree with you . I am going to find a good company and invest in it soon . ', " It's a good idea . But please be careful when you invest this time . ", ' Yes , I will . I should learn more from you . After all I am green hand on it . ', ' If you have any question , you can ask me . ', ' OK . My wife sent me a message and asked me to go home just now . I am leaving . ', " All right . Let's chat next time . Bye-bye . ", ' Bye . ']
['Where do you have to go . ', ' To New York . ', ' When do you have to be there . ', ' Tomorrow morning . ', ' How long do you have to be there ? ', ' Three days . ', ' When will you be back ? ', ' On Friday . ']
['I ’ Ve got a new boss . ', ' Oh , what ’ s he like ? ', ' Well , he ’ s got dark hair and brown eyes . ', ' Yes . ', ' And a white sports car . ', ' Um , that ’ s good . ', ' Yes , but he ’ s got a wife and 3 children as well . ']
["Now I understand . But I don't smoke or drink.So what am I supposed to buy in here ? ", ' You can buy some of these nice butterflies . ', " No , I'm sorry . I don't think it is nice to have butterflies mounted in boxes.It is kind of disgusting . ", ' What ? You feel sorry for the butterflies ? ', ' Yes . I think they should just let them fly free , and not try to sell them to foreigners . It is a kind of destruction of nature . ', " Well , I agree with you . I'd rather think that the butterflies are flying around in the mountains . I just wonder if they really catch so many that it affects the butterfly population . ", ' Who knows ? Hey , I like these jade bears here . ', ' How much are they ? ', ' This one is 2300 dollars.Maybe I should buy it for my mother . What do you think ? ', " If you want . Didn't you buy her a small vase already ? ", ' Yes , but she would like this a lot . She likes to collect little things like this . ', " Alright . Buy it then . I won't buy anything . Well , maybe I'll buy some Cognac . ", ' Maybe I could buy some Cognac for my brother . He always drinks it . ', " Let's go ask about it . "]
["What's new ? ", ' Nothing much . ']
['Hi , Monica , I got big news . ', ' You got a raise ? ', ' Not really , just take a wild guess . ', ' You got promoted ? ', ' Well , it is not going to happen so soon , I guess . ', ' You won a lottery ? Don ’ t beat around the bush , just tell me , please . ', ' Ok , I lost 5 pounds . ']
["I'm frustrated . ", " What's the problem ? ", " I can't work out this problem . ", ' Let me take a look . Maybe I can figure it out . ', ' Thanks . I really appreciate it . ']
['You ’ re a big fan of Andy Lau , aren ’ t you ? ', ' Yes , I ’ Ve been got all his albums and most of his films on DVD . I adore him . He ’ s my idol . ', ' How come you don ’ t have all of his films on DVD ? ', ' Some of his early films are hard to find nowadays , especially the ones where he only played a bit part . ', ' I see . I ’ m sure you ’ ll find them one day . I see you also have several poster of him . ', ' Yes . These posters are new . I bought them last week and put them up on my bedroom walls yesterday . ', ' Are you a member of his fan club ? ', ' I was , but then I discovered you can find out everything for free on the internet , so I ’ m not a member now . ', ' Did you see the interview with Andy Lau in cosmopolitan magazine last month ? ', ' Of course ! I bought two copies . ', ' Two copies ? One to keep and one to cut the pictures out of , right ? ']
['What would you like to have in your breakfast , bread , egg or sandwiches ? ', ' Bread . ', ' And milk or orange juice ? ', ' Orange juice . ', ' What would you like for lunch , pork , mutton or beef ? ', ' I think mutton is best . ', ' What kind of drink do you like most , red wine , beer or champagne ? ', ' I like champagne . ', ' And among apples , oranges and bananas , which is your favorite ? ', ' Banana of course . ', ' Do you always have meals outside or in your house ? ', ' I always have meals outside , because I ’ m not good at cooking . ']
['The art critic from the daily chronicle doesn ’ t think much of the max oreo exhibition . He says that the artwork is uninspiring and old fashioned . ', ' Really ? I thought the exhibition showed that he had real talent . What did you think of it ? ', ' I liked it . I didn ’ t think his works were masterpieces , but the certainly weren ’ t uninspiring , in my opinion . ', ' I don ’ t think I ’ Ve ever read a good review of an exhibition by that critic . He doesn ’ t seem to like anything . Which kinds of paintings do you prefer ? ', ' I like landscapes and still life . You prefer abstract paintings , don ’ t you ? ', ' Yes , I do . I like painters who use will rather than watercolors . The colors appear richer . What do you think ? ', ' I agree . I prefer oils too . I collect landscapes , but I only have a small collection . You have a small collection of abstract art , don ’ t you ? ', ' Yes . Good artwork is very expensive nowadays . When I was in china , I bought some calligraphy by famous artists . You should come and see it sometime . ', ' That would be nice . Can you read the characters ? ', ' I know what the characters on the paintings mean . I think Chinese characters look very artistic . It ’ s said that the way they are written can give insight into the artist ’ s character . ', ' I think that ’ s true with any of the fine arts . ']
['Jenny , are you having fun here ? ', ' Yes , of course . This is really a nice party with wonderful people and lovely wines . ', ' I ’ m glad you ’ re enjoying it . ', ' Thank you for the invitation . ', ' It ’ s my pleasure . Would you like another glass of champagne ? ', ' Yes , please . Thank you for everything . ']
['What do you think of the play showed last night ? ', " I think there's too much violence and it did no good to my little boy . ", ' Yes , I turned it off when the fight got heated in it . ', " It's really hard to avoid such bad influence anyway . "]
['Hey , Tom , I want to learn how to play golf . ', " You're really sporty ! ", ' I want to do everything I can . ', ' Do you have clubs ? ', ' No . Can I rent clubs ? ', " There are clubs for beginners . It's cheaper to buy those rather than rent them a few times . ", ' What kinds of clubs ? ', " Like the seven-piece set . It's only $ 120 . ", " I'll buy a set . But you have to teach me . ", ' Okay . ']
["You are married to a foreigner , aren't you ? So what's it like ? ", ' Well , in the first year of our marriage , we had great difficulties in getting along . The things that are important to me are not important to him . We had a lot of conflicts . ', ' Yeah , I know what you mean . The first year of any marriage is difficult for all couples , not to mention two people from different cultures . ', " Now we have a two-year-old boy . We're very happy that he's healthy and smart . ", " Oh , so he's half Chinese and half American . That's unusual . What languages does he speak , then ? ", ' Right now he speaks mostly English , and he can say a few Chinese words . But he will learn in the future . ', ' What does he look like ? Can people tell ? ', " Yes , people surely can . He's whiter than the Chinese kids , and his hair is a little blonde . My husband says his eyes are very Chinese though . "]
["What do you mean his grandmothers are already dead ? Wait a minute , you don't think he's avoiding me , do you ? ", ' Well you know , claiming that your grandmother is sick is the classic excuse used to get out of doing something . ', ' Oh man , I hate rejection . It really makes you feel terrible , especially when you really liked the person . ', " Is there anything I can do to help ? Just remember that I'm there for you if you want to talk about it . "]
["How do you do , Mr.Smith ? This is Lili . I'm calling to thank you for the wonderful dinner we had yesterday . I enjoyed it very much . ", " You're welcome . I'd like you to join us for dinner again sometime . ", " Thank you , Mr.Smith . I'm returning to China today . ", ' Today ? ', " Yes . I appreciate all help and in particular , all the time that you've spent on my account during my stay here . ", " Don't mention it . I am pleased to help you . ", " If there's anything that I can help you in the future , please let me know . ", " I'll do that.Thank you.Have a safe trip home . "]
['Do you buy that newspaper every day ? ', ' Yes , I do . I find it very informative.It always has plenty of articles from correspondents all over the world and the business section is very useful too . ', ' Is there a Sunday edition of that newspaper ? ', ' Yes . There is . it has several sections , so it ’ s quite a read ! It usually takes me a few hours to read it on Sunday morning . ', ' What section does it have ? ', ' Let me see . There ’ s the news section , the entertainment section , sports , business , and world affairs . ', ' What ’ s in that section ? ', ' World affairs ? They look at the most important stories in more detail . I find it fascinating . Do you buy a daily paper ? ', ' I buy a national newspaper sometimes , buy I nearly always buy a local evening newspaper . I find the local news more interesting than national or international news . ']
['You must like negotiating a lot . People are saying , you are a super negotiator . ', ' Ha , I am flattered . Actually , when it comes to negotiate , you don ’ t need to like it . You just need to understand how it works . ', ' I am not good at it by any means . Give me some advice . ', ' Well , generally speaking , if you want to change someone ’ s mind or understand his position , you have to put yourself in his shoes . Understand his need and the cost for his need . And then you work together to find a solution . ', ' Sounds easy . But how can I apply to practice ? I am thinking about applying for more reimbursement for my mobile bill . But I am afraid our boss will turn me down . ', ' Ok , as John after Kennedy put it , let us never negotiate out of fear , but let us never fear to negotiate . ']
['Hey , Shirley . The party has been wonderful . My husband and my children have enjoyed it very much , and me too . ', " I've said you will enjoy your life here ! ", ' I surely will . By the way , is the party like this held every weekend in our neighborhood ? ', " Oh , I've forgotten to tell you . The party is held every other week . And every family gives their own performance each time . ", ' My children would like that ; they like dancing very much . ', " That's good ! ", ' Look ! Who is that guy on the stage ? ', " Oh , my God ! That's my husband , Benjamin . ", ' Really ? ', " He likes American Idol very much , and he always imitates the contestant at home . I can't believe he got on the stage himself . ", ' He performs very well . He is so funny ! ', " OK , just ignore him . I've noticed there are lots of exercise facilities in our community . After dinner you can go there for a walk with your family ! ", " OK , that's perfect ! By the way , is there any playground in our neighborhood ? ", ' Yes , there is one behind our building . And you can play tennis there . But if you want to play tennis there , they will change you 30 Yuan per hour . ', ' OK , got it ! Thank you so much . You have helped me a lot ! ', ' You are welcome ! We are neighbors ! ']
['You look pale , you must have poor health . ', ' Yeah . You said it . ', ' Why not go to see the doctor ? ', ' I ’ Ve done that . The doctor advised me to cut out smoking and drinking . ']
['How is Tom now ? ', " He's out of the hospital and up and about again at last . ", " Let's congratulate him on Sunday . "]
['You said you like classical music very much . Then who is your favorite opera star ? ', ' There are three of them , the Three Tenors . ', ' Oh , you mean Pavarotti , Domingo and Carreras . Have you been to their live shows ? ', " Yeah , it's really a unique experience . It's a solo concert by Pavarotti . He put on the performance in the Forbidden City in Beijing . ", " I've heard of that one . It was also his swan song . ", " Besides , speaking of classical music , we should never forget about the New Year's Concert . ", ' Of course not . People all over the world watch it on TV , or listen to it on the radio . ', " Sure . It's undoubtedly one of the biggest classical music events . Have you ever been to the live show ? ", " Yes , I went to the New Year's Concert in 2005 . ", ' Wow , you are so lucky . I saw that one on TV . But it must be so different to be there in the concert hall . ', " That's for sure . You know , it's really amazing to be in the best concert hall , listening to the performance by the best orchestra . I had the greatest time ever . ", ' Who was the conductor at that event ? ', ' Lorin Maazel . He did an amazing job . Moreover , he just celebrated his 75th birthday . ', " So cool . I wish I can go to the live New Year's Concert someday in the future . ", ' The right opportunity for you would come along soon . You know , music is transnational . ', " I believe in that . Well , the performance is about to begin . Let's be quiet . "]
['I really need to find a parking spot . ', ' Are you looking for a space on or off campus ? ', ' Do you know any spaces on campus ? ', ' You can park in the student parking structure . ', ' Where is it located ? ', " You'll find the parking structure on the west side of the campus . ", ' Do you have any idea if the parking structure has any spaces left ? ', ' Last time I checked , it was pretty empty . ', ' What time was it when you went up there ? ', ' That was earlier this morning . ', " It wouldn't be full right now , would it ? ", ' I have no idea . ']
['Ok . Let ’ s look at our short presentation on China . What do we need to include ? ', ' We need to talk about the size of the country and its population . ', ' Ok . China is about the same size as Canada and the united states and it has a population of about 1.3 billion , making it the latest country in the world by population . ', ' It says here that most of the people are han Chinese , but there are 55 minorities that make up almost 10 % of the population . ', ' We need to say something about the geography and climate of china . Is there any way to divide the country into sections ? ', ' We could divide into five parts . There ’ s the northeast , which is mild in summer and very cold in winter . Then there is the northwest , which is largely desert . Tillet is famous for its mountainous climate . The rest of the country can be roughly divided into two parts . One is temperate-mild in winter and warm in summer . Then , in the south it is hot most of the year . ', ' That sounds very general . ', ' It is , buy remember that we only have a few minutes to make our presentation . We can select cities from each part and give data for each one . ', ' One from each part ? Lhasa , Urumqi , Harbin , shanghai , and hongkong . The capital city is Beijing , right ? ', ' Yes . The other large cities are Chengdu , Dalian , Wuhan , tianjin , shenyang , Chongqing . Hongkong and Guangzhou . ', ' We should take a large map and highlight those cities . What is each of them famous for ? ']
['I learned of the railway accident only this morning . ', ' A really dreadful accident and many people were killed . ', ' Is that true ? ', ' Yeah , well , I fill you in one the details later . ', ' Thanks . ']
['Who is responsible for the accident ? Is it Tony ’ s fault ? ', ' No . I don ’ t suppose he ’ s to blame . The man in the other car made a big mistake . ', ' You mean Tony is the victim ? No , I don ’ t think so . He ’ s equally responsible because he tried to overtake you . ', ' Yeah . I think everyone should go easy on driving . ']
['Did you hear who won the English speech contest ? ', ' No , who won ? ', " It's George . ", " Really ? I'm surprised . I didn't know his English was that good . "]
["He's honest , hardworking and responsible . I simply can't find any shortcoming of his as an employee . ", " I rather doubt it.You ' re cheated by his appearance , I think . ", " Don't be so jealous . He never speaks ill of you before me . "]
["Paul , let's go and see Grandpa this afternoon . ", ' But Grandpa will be working . ', " It's Saturday . ", ' I almost forget . ']
['I have made up my mind . I am getting a tattoo . ', ' Really ? Are you sure ? ', ' Yeah ! Why not ? They are trendy and look great ! I want to get a dragon on my arm or maybe a tiger on my back . ', ' Yeah but , it is something that you will have forever ! They use indelible ink that can only be removed with laser treatment . On top of all that , I have heard it hurts a lot ! ', ' Really ? ', ' Of course ! They use this machine with a needle that pokes your skin and inserts the ink . ', ' Oh , I didn ’ t know that ! I thought they just paint it on your skin or something . ', ' I think you should reconsider and do some more research about tattoos . Also , find out where the nearest tattoo parlor is and make sure they used sterilized needles , and that the place is hygienic . ', ' Maybe I should just get a tongue piercing ! ']
['our company is going to do some cutbacks soon . ', ' really ? Where did you hear that ? ', " I met with the supervisor just this morning . I don't know , but I am a little worried . Who do you think will get sacked ? ", " I'm not sure ... well , first , it couldn't be George . He is such a kiss-ass . He'd wash the boss's dog if he asked . ", " no , it's not going to be George . I don't think it's Andy either . He is involved with the boss's sister in-law . And you know how whipped our boss is . ", " that's true . What about Lisa ? I bet there's nobody who could do a worse job than her . ", " Lisa ? No way . I've heard a rumor that she and the boss were having an affair . You know rumors can't come out from nowhere . ", " well , okay . Then there is still Michael . But he's pet after having the best sales record for three months in a row . It definitely won't be Michael . ", " no , that would be crazy . But then who will it be ? Oh dear , it must be me . I should have known it ! Why else would he have talked to me alone about the downsizing . What should I do ? I've got a family t ", ' well , it could be me too . But I am not too worried . This place is suffocating me with this boss being such a hard-ass and colleagues who barely know how to get dressed in the morning . It would almost b ']
['Do you often surf the Internet ? ', ' Yeah . I do it once a week . ', ' Is it very interesting ? ', ' Sure . I get a lot of information and make many friends . ', " Oh , I'll have a try . "]
['I want to say ... ', ' Say it ! What is it ? ', " That I can't go on any longer without you . ", " You know you shouldn't say that at a time like this . ", ' Nancy , I made up my mind you were the only woman for me at the first sight . ', " Too sudden ! I'm not ready for it . ", ' Forgive me for startling you with the impetuosity of my sentiments . ', ' Stop it . No more of that talk . ', ' I really love you . ', ' No , I shall faint . ', ' And I hope so . This is what you were meant for . Say you love me , say yes , say yes . ', ' Yes . ']
['Do you think Tom will be elected president ? ', ' No , I think Harry will get it . ', " Let's make a bet on who gets it . ", ' OK , loser buys pizza tomorrow night . ']
['Your knowledge of English is really surprising . ', " Oh , it's nothing to speak of . ", ' No , seriously . I am impressed . ', ' Thank you . I appreciate the compliment . ', ' Your knowledge of English is really surprising . ', " Oh , it's nothing to speak of . ", ' No , seriously . I am impressed . ', ' Thank you . I appreciate the compliment . ']
['Have you noticed the Mexican restaurant on the other side of this street ? ', ' You mean the one with the yellow bricks ? But last time I saw it , it wasn ’ t really in business yet . I saw some people inside furnishing the rooms . Is it open now ? ', ' Yes , someone give me a pamphlet introducing the restaurant and its business hours when I passed by this morning.So , let ’ s have a try . My treat . ', ' Great , I like the idea of trying some new food . ', ' Good for you . Today we have more chances to try some new food because there are now many new form restaurants in our city coming from places all over the world . ', ' Also some traditional Chinese food , like noodles and dumpling are marketed in modern ways with improved food quality . I heard this year , the government has imposed very stringent inspection on the hygiene conditions restaurants and suppliers of food are also under tighter control . ', ' For sure all the customers will benefit from this . ']
["You were right . It's raining again . ", ' I told you so . ']
["Hi . What's up ? ", " Nothing much . What's new with you ? ", " Not too much . I've been pretty busy . ", ' Me too . Seems like all I do is eat and sleep . ', ' Gotta go . Call me tonight . ', ' Okay . Check you later . ']
["What's all this noise about ? ", " They're discussing whether they should replace Miss Smith , the Music teacher . ", ' Why ? ', " Because she's not responsible enough . "]
['How many people are there in your family ? ', ' My immediate family is quite small . It ’ s just my older step-brother , my mom , my step-dad and me . how about you ? ', ' I have a large family . I have three older sisters , my twin sister , a younger brother , and parents . ', ' I didn ’ t know you were a twin ! Are you identical or fraternal ? ', ' We ’ re identical . I mean , we look exactly the same , but we are complete opposites when it comes to everything else . ', ' Interesting . It must be great having a twin sister . Are you best friends , too ? ', ' We used to be really close , but that all changed once she moved to Shanghai . How about your family ? You didn ’ t mention to your biological father . ', ' I don ’ t know much about him . He died when I was just a baby . Even though I don ’ t have a blood relationship with my step-father and step-brother , I consider them to be my real family . ', ' What about your step-brother ’ s mother ? Does he keep in touch with her ? ', ' No , she also died when my step-brother was little . My mother and my step-father met each other shortly after my father died and became good friends . They ended up getting married a few years later . ', ' Sounds like it was meant to be . ']
["It's awfully quiet around here . ", " Yeah . There's nobody in sight . ", " I have a feeling that we're not supposed to be in here . ", " I think you're right . Let's go . "]
["Mike's going to have a self-driving traveling across the country . ", ' Really ? He is so great . ', " You don't want to join him ? ", " Surely I want . It's quite popular nowadays . ", ' Yes , and I want to have a try . ']
['Where are you going ? ', " I'm going to Bill's house . ", ' What are you going to do there ? ', " I'm going to help him . ", " What's he doing ? ", " He's fixing his roof . "]
['Are you going to the movie theater with me tonight ? ', ' Is there anything good playing ? ', " Titanic is playing tonight . It's a blockbuster . ", ' Really ? I want to go , too . ', " OK , let's meet at the movie theater entrance tonight . Don ’ t be late . ", ' No problem . ', ' ( After watching the movie . ) Are you crying ? ', ' I get a lump in my throat whenever I see a tragic movie . ', " Tragic movie ? I think it's a love story . ", ' But their love is touching ! ', " Ah , you're just too emotional . ", ' I am not ! ']
["Many people play sports in China , don't they ? ", ' Yes . Table tennis is probably the most popular . ', ' I expect all Chinese can play table tennis . ', ' Most anyway . ', ' Do you like playing table tennis ? ', " Yes , I like . But I can't play it well . ", ' Are indoor sports popular ? ', ' Basketball and swimming are very popular . ', ' Really ? I like playing basketball , too . ', ' We can play together if you are free . ', " That's great . "]
["I couldn't look at you , and say you aren't beautiful ! ", ' You are pretending ! ', " No , Miss Anna , you must let me say how lovely you are ! What's wrong with that ? ", " It's wrong because---it isn't true . ", " You know that everybody notices how beautiful you are , don't you ? ", " Well , no-that is , I've heard Linda say they do , but ... Thank you . But please don't speak to me again . ", " Oh , Miss Anna ! That's too hard ! I won't be here long . "]
['Both our countries are quite small . How would you describe the landscape in your country ? ', ' My country is well know for being very flat . There are some hills in the southeast of the country . ', ' Is it really completely flat ? ', ' Pretty much . The land rises and falls only a few meters . The southeast , the hills rise to a height of a few hundred meters . There are mountains over 1000 meters high in your country . ', ' Yes , there are . They are not very big compared with the mountains in other countries . ', ' The coast of your country is very varied . The coast of my country is just made up of sandy beaches . ', ' That doesn ’ t sound too bad . Great for sunbathing ! The coast of my country changes even within a few kilometers . There are cliffs , then sandy beaches . Then rocks . There are lots of caves in the cliffs . There are also many small islands off the coast , but few people lives on them . ', ' There are many lakes and rivers in your country too . We also have many rivers , but only a few lakes . ', ' We also have waterfalls in the mountains . They make the landscapes look very scenic . The landscape has been shapes by millions of years of erosion , especially by water . ']
['Do you speak only English in the class , or does your teacher explain everything to you in Spanish ? ', ' Oh , we never speak Spanish in class ! Miss.Parker speaks to us only in English . ', " I suppose she's right.Does she speak English very slowly ? ", " Not always.Sometimes we don't understand her.Then she has to repeat what she said . ", ' It must be interesting to study English . ', ' Mario and I are the best students in the class.Miss.Parker says that my pronunciation is very good . ', ' Is English pronunciation easy or difficult ? ', " Sometimes it's difficult.Some words look different from the way one pronounces them . "]
['We have a class outing today . ', ' Have fun . ']
["Excuse me , Professor . I have to talk to you about why my homework didn't get done . ", " What happened that you didn't get it done ? ", ' I had to watch a football game instead . ', " Well , you had more than one day ; couldn't you have fit it in on another day ? ", ' Yes , I think so . ', ' Either way , I only allow one missed assignment per semester . When will you be turning the make-up in ? ', " I'll make it up next week . ", ' Fine , but it cannot happen again if you want an “ A ” in the class . ', ' OK , I can do that . ', ' Remember that you are in college now , not high school . ']
['Will you be done doing my hair soon ? ', ' Give me a little while longer . ', ' How much time do you need ? ', ' There you go . How do you like it ? ', ' I think it looks gorgeous . ', ' You think it looks nice ? ', ' I honestly think it looks great . ', " Thanks . I'm glad that I did a good job . ", ' How much is it for my hair ? ', ' Just give me $ 55 . ', ' Thanks for doing such a good job . ', " No problem , girl friend . I'll see you next time . "]
['Why do you look so gloomy ? What are you looking for ? ', " My dissertation . I put it somewhere last night and I can't find it now . ", ' Did you finish typing yesterday ? ', ' Yes , I kept on typing it until midnight , but it is lost . ', " Don't worry about it . It must be somewhere in your room . Let's see where you put it . Have you searched your drawers and the desk ? ", ' Yes , but there is nothing inside the drawers or on the desk . ', ' How about the shelf ? ', " I've searched everywhere . Where on earth did I put it ? ", " Don't get upset over it . At least you have another week to go . ", " I have been working on it for a whole month and it's too late to write another . Just think of all my hard work that goes for nothing . How could I do such a thing ? ", " Cheer up ! What I meant was that you can find it sometime during a week . There is no need to write a new one . Oh , what's this ? Is this your dissertation ? ", " Let me see . Yes , that's it . Where did you find it ? ", ' You ’ Ve put it among these journals . ', ' My poor memory . Thank you very much . ']
["how come you're still up ? Shouldn't you be asleep by now ? ", " I've been having a hard time sleeping lately . ", ' as far as I know , insomnia is usually caused by stress . Are you stressed at all ? ', " well , I'm really worried about my grades . I didn't think this course would be so stressful . ", " you're a good student . I'm sure you can do well . What you need to do is to relax . ", " you're probably right . I just wish it were that simple . How can I stop feeling so anxious all the time ? ", ' taking a yoga class or learning some relaxation techniques can help you cope with your stress . ', " I don't really have time to learn anything new . I need to spend my time studying ! ", ' you need to take some breaks throughout the day . Studying all day isn ’ t very usually effective . ', ' you ’ re right . I usually end up starting at my computer or checking my email instead of doing my work for class . ', ' besides , it ’ s not difficult to learn yoga . In fact , I can teach you a move that ’ s supposed to help you fall asleep ! You just have to sit down like this , bend over and breath in deeply . ', ' that ’ s fantastic . I ’ m going to go try that out in my room now . good night ! ', ' good night , sleep tight ; don ’ t let the bed bugs bite ! ']
["Before we begin eating , I'd like to present everyone with a gift from Taiwan . ", ' What is it ? ', " It's a Taiwanese puppet doll . ", " It's huge ! ", " Yeah . They're usually this big . ", ' The craftsmanship is excellent . ', ' All the parts work . ', ' Thank you so much . ', " Don't mention it . "]
["Can I still get tickets for tonight's performance ? ", ' The balcony is still available . ', " Aren't there any other seats ? ", " No , I'm afraid that's it . "]
['It seems to me that you fall for good-looking guys . ', ' Yeah . ', " Why don't you date up a handsome guy and spend time together ? ", ' I have found myself a date mate . ', ' You must have a lot in common and a barrel of fun . ', " A barrel of fun , of course . He often says that I'm a date bait . "]
['Would you like some coffee , Tom ? ', ' Yes , thank you . ', " Here's some sugar . ", ' Thanks . ']
["Espresso is made with a machine that forces steam and boiling water through finely ground coffee . It's strong . ", ' OK , OK , this is good . Keep talking . What about cappuccino and all those other drinks ? ', ' Cappuccino is one-third espresso and two-thirds a mixture of steamed milk and froth . ', ' Froth ? ', ' If you want something manly , stick with the espresso . ', ' Thanks , Hugh . I owe you one . ']
['What do you think of the speech the man delivered just now ? ', " Don't believe him.He ' s a liar . ", ' We cannot expect politics to be true anyway . ']
['Another weekend is coming ! ', " And we're going to have summer vacation . ", ' Yes.What will you do this weekend ? ', " I'll plan for the vacation . "]
['Hello , Tom . How do you find the dinner of yesterday ? ', ' Very good . That may be the most delicious food I have ever eaten . ', " It's nice of you to say so . ", ' I really appreciate you for having invited me . ', " Don't mention it . You know , we ’ re old friends . ", ' Anyway , I owe you one . Are you free tonight ? ', ' Yes . Why ? ', ' I want to invite you to enjoy the food I cook . ', " That ’ s great . I'd love to . "]
['Thank you for your letter . ', ' Is your waist any better ? ', ' Yes , I ’ m feeling very well these days . ', ' I ’ m glad you are getting better . ', ' And I was glad to receive your letter . ', ' Then when will you be back again ? ', ' I will be back again next Wednesday . ', ' I hope to see you at that time again . Bye . ', ' Bye . ']
['When I was a little boy , I had a dream of becoming a lawyer . ', ' Your dream comes true now . ', ' Yes , I knew I would make it . ', ' You are really confident . ']
['This is my uncle , Charles . ', ' He looks strong.What does he do ? ', " He's a captain . ", ' He must be very brave . ', ' Exactly ! ']
["How's your brother doing ? ", " As a matter of fact , he hasn't been feeling too well . ", " I'm sorry to hear that . What's the matter ? ", " Tell him I hope he's better soon . ", " I'll tell him . Thanks for asking about him . "]
['Are you a soccer fan ? ', ' Yes , I am . I like to watch soccer games on TV , but I don ’ t play . I watched every game of the 2002 World Cup . ', ' Which team is your favorite ? ', ' Italian . They played very well , but they were not very lucky . ', ' I like the Brazilians . They are the real champions . ']
['What are you doing , awake ? ', " I can't sleep ... ", " But it's almost midnight ! ", " Exactly . I'm too excited for Christmas morning . Also , I thought I heard Santa . ", ' Really ? How do you know it was Santa ? ', " Well , I heard that naughty boys and girls get coal in their stockings , so I thought I'd be nice and make Santa cookies . I even left out some milk . I heard someone in the kitchen eating the cookies , so I came downstairs ! ", " Hmm ... well I know that Santa won't come down the chimney with you hiding behind the tree , spying on him ! ", ' Really ? ', " Really ! Let's go back upstairs and get back to bed . That way , we can let Santa do his job . Then when you wake up , it will be Christmas already ! ", ' O-K ... ', " Hey , honey ! Is that you ? Don't eat all the cookies — I want some , too ! "]
['Hey Eve , how are you ? ', ' I ’ m fine , Celia . And you ? ', ' I ’ m ok . I ’ m so busy ! ', ' Do you have a lot of homework ? ', ' Yes . Don ’ t you ? ', ' Of course I do ! ', ' Which class are you working on right now ? ', ' I ’ m studying for my chemistry exam tomorrow . ', ' Are you in Mrs Green ’ s class ? ', ' Yes . Are you ? ', ' Yes . We must have the same exam tomorrow ! ', ' Do you want to study together ? ', ' Sure . This library is too quiet though . ', ' Do you want to go to and empty classroom ? ', ' That sounds good . ', ' Ok . Let ’ s go ! ']
['Are you ready to go the concert ? ', " Yes . Should we go there by bus so we aren't late ? ", " Actually , why don't we go there by bike ? We could get stuck in traffic if we travel by bus in rush hour . ", " That's true . Cycling is good for our environment , too . Let me just get my helmet then . ", ' Is your helmet comfortable ? ', ' Not really , but I liked the design , so I got it . ', " Maybe you should think about getting a round helmet ; they're better . ", " I'll think about it . ", ' Is that your new bicycle ? ', ' Yes , my father gave it to me for my birthday . Do you like it ? ', " It's the newest 10 speed cycling mountain bike . These are really expensive ! ", ' Nothing but the best from my dad . I like everything about it except for the brakes . They are a bit sticky . ', ' I can fix those for you . Is there anything else wrong with it ? ', ' Well , my saddle is too low for me . Do you know how to change the height ? ', " That's easy . It's important to have the saddle high enough so that your legs can extend fully when you are on your bicycle . ", " Is that why my knees have felt sore after every time I've ridden my bike ? ", " It's possible . Give me a minute and I can fix these for you and then we can go . "]
['Oh , God . It ’ s late . I ’ m afraid I have to leave . ', ' But you just got here . Can ’ t you stay a little longer and have some tea ? ', ' That ’ s very kind of you . But if I don ’ t go now I ’ ll miss the last bus . ', ' That ’ s too bad . ', ' Thank you for your hospitality . ', ' Thanks for coming . ', ' How about next time we meet at my place ? And I ’ ll treat you to Chinese food . I know how much you like it . We can order in and watch video too . Anything you like , I promise . ', ' Great idea . I ’ m looking forward to it . See you then . ', ' Well . I really do have to go . ', ' Good night then . ', ' See you tomorrow . ']
["I'm going for a walk , Yi-jun . I need some time to myself . ", " Don't you want to go to the visiting hours ? This sheet says they are tonight . ", " I just can't right now . Everyone will be talking about Taylor and ... ", " ... and maybe that's what we both need . ", " I need to come to grips with his death first . And I also need to prepare a eulogy in case I'm asked to speak tomorrow . ", " OK , but don't forget I'm here for you , and I know how you feel . It's my loss , too . "]
["You're going to get into a lot of trouble if you do that . ", ' What makes you say that ? ', " I don't see anything wrong with what we're doing ! That's just the problem . In these kind of things , the trouble doesn't always appear at first . ", ' But everything has been so easy . ', ' Everything has gone as smooth as clockwork . Just like we planned ! That may be true , but if you were to do it , you would have trouble on the horizon . You always say that . ', ' Yeah , you never look at the positive side of things . ', " Okay . Have it your way , but don't say I didn't warn you . "]
['Write down your name here in ink . ', ' But I don ’ t have a pen with me . May I use a pencil ? ', ' I ’ m afraid a pencil won ’ t do . Wait a moment , I ’ ll find you one . ']
['this party rocks ! ', ' you said it . Good beer , good music , and on top of that , there are so many hot girls here ! ', " I'm with you on that . Check out that one over there . I think I'm in love ! ", " well , she's alright , but not really my cup of tea . What about the blond with the red dress ? ", " oh , that's Janice . She's just new in town . You have a thing for blonds , eh ? ", ' yeah ! She could do anything she wants to me ! ', " I bet . Why not go over and talk to her ? She's really nice . ", " I don't think so . I get so nervous talking to girls . I always put my foot in my mouth , scare her off , and end up looking like a real fool . Besides , she is way out of my league . ", " come on ! Man up ! You'll never know until you try . ", ' okay okay , just let me have another cup of beers to get my head in the game . ', ' all right . But I think you ought to move soon . ', ' why ? ', ' I can see five other guys eying her up . ', ' okay , here I go ! ', ' good luck ! ']
['Do you watch a lot of TV ? ', ' Not really . I could take it or leave it . ', ' Not me . I have to have my TV and watch whatever comes on . ', ' How can you do that ? ']
['I am certain I am going to fail my English test . ', ' Why are you so pessimistic ? ', " Because it's impossible to improve listening level within a week . ", ' Only for this reason ? ', ' Yes , I think my vocabulary and reading comprehension are not very bad . ', " Don't worry about it . Practice makes perfect . I will lend you some listening materials , so that you can practise more before the exam . I believe you can pass the exam with good preparation . ", " Oh , thank you . That's very nice of you . "]
['Hello ! So you are leaving today . ', " Hello . Thank you for seeing me off . You actually don't need to bother . ", ' It is my pleasure to see you off . ', ' Thanks a lot . I hope to see you again . ', ' I hope so , too . ', ' Thanks again for everything you have done for me . ', " You're welcome . Have a nice trip ! "]
["Did you see the way that Brian came to work yesterday ? Ever since he came back from that conference in Silicon Valley , he's been coming to work dressed in jeans and sweatshirts . It's like he's decided to make himself at home in his office . I don't know how long it'll take before the management talks to him about it . ", " He was really influenced by the way they do things on the west coast . I guess the working atmosphere is a lot more relaxed and casual in California . It comes from the information technology industry .. there isn't such a large division between home and office , so people want to work in the clothes they feel more relaxed in . ", ' Maybe so , but it seems kind of strange , which the rest of us in white shirts , dark suites , and ties . ', " It's not as bad as that ... We are allowed to wear more casual jackets and trousers . Besides , didn't you hear what Brian found on his desk this morning ? ", " What's that ? ", " Management decided to give him four brand new white shirts . That's their way of telling him that his new style of dressing down is not quite acceptable . "]
['I go to the fitness center every weekend . ', ' What for ? ', ' To lose some weight . ', ' Why , you look pretty all right . ']
["Uh-oh . I'm in trouble . ", " Why ? What's wrong ? ", " I just remembered that I've got to give a speech in class today and I forgot to prepare for it . ", " I guess you'll have to wing it . "]
['I heard you received a prize for you book . ', ' yes , I did . I won a prize for best local history book at the annual book awards . ', ' congratulations ! You must be very proud of your achievement . ', ' actually , I was happy just to get the book published . Winning the prize was an added bonus . ', ' what was the prize ? ', ' I won $ 200 to spend on any books of my choice . ', ' that ’ s a great prize for a person who writes books ! Have you ever won a prize before ? ', ' I shared a prize with some friends last week . We won a bottle of whisky at a pub quiz . ', ' I won $ 10 in the lottery last month . Perhaps next time , I ’ ll be luckier and win the jackpot ! ']
['To be frank , I find philosophy rather boring . ', " To tell you the truth , it's the most tedious course i have ever had . ", ' How could you manage to pass the exam ? ', ' It is still a mystery to me . ']
['What date is it today ? ', ' Why ? ', " Look at the girls in the street . They all have a bunch of flowers.Is it Valentine's Day ? ", ' Oh , yes ! I completely forgot about it . ', ' Did you have a fight with Jack ? ', " No , but now he'll be in trouble . What's a boyfriend for ? To forget about Valentine's Day ? ", ' Come on , dear ! You forgot it , too . ', ' You know , it\'s OK for a girl to forget these " big days " , but for a guy , to do that is unforgivable . ', ' Is that your phone ? ', " Oh , it's Jack . Excuse me . ", ' Wow ! Good timing . ', ' He asked me out to a dinner tonight . How about joining us ? ', " Come on ! Three's a crowd ! ", ' So what ? ', " Just go ! It's Valentine's Day ! "]
['I heard that your previous manager was very capable , he is a good manger . ', ' That ’ s a matter of opinion . ', ' What do you mean ? ', ' I worked with him for two years . That was the worst time in my career . ']
['And lots of " Dear Abby " sob stories ... ', ' Hey ! I learn a lot from the psychologists who give advice in those columns ! ', " No wonder you're such a wacko ... ", ' Whatever ... Smell ! Perfume samples ! ', ' Nice . Hey , I like the layout of this page ... ', ' You mean , you like the pictures of the beautiful models ... Hello ? ']
['How many cleaning ladies does your company hire ? ', ' We have two cleaning ladies . But both of them have received little education . ', ' Most cleaning ladies are illiterate . But some of them do a very nice job . ', ' But I actually dislike another lady . She is more capable and seems to have ideas of her own . But the trouble is she Isa backseat driver with some of us . She would tell you what to do and where to put things . ']
['I find that every employee here respects that manager very much . ', ' Yes . He carries a lot of weight . Everyone here is willing to follow his orders . ']
["What's your favorite book ? ", " It's Gone With the Wind . ", ' Why do you like it best ? ', ' I enjoy the various characters and the plot . ', ' Well . I like the Thom Birds best . ', ' Is it very interesting ? ', " Sure . I like the writer's language , too . ", " If I have a chance , I'll enjoy the book . ", ' Would you like to go to the bookshop with me ? ', " That's a good idea.Let ' s go ! "]
['It ’ s a beautiful day here in New Zealand at the Men ’ s Volleyball world championship . My name is Rick Fields and I ’ m joined by the man with the plan , Bob Copeland . ', ' Thank you , Rick . We ’ Ve got a very exciting encounter ahead of us today as two powerhouse teams , Brazil and China , face off against each other and try to qualify for the next round . Without a doubt , both teams are in top shape and this will prove to be a competitive match . ', ' The ref signals the start of the game and here we go . Ribero serves and China quickly receives the ball . Chen bumps it to the setter , and ... a very nice set by Chen ! ', ' Xu spikes it ! Wow , what a great hit ! The Brazilian blockers anticipated the play and tried to block him but he managed to get the ball in ! ', ' It ’ s China ’ s service now . What a superb jump serve by Li , oh , and we have a let serve . The ball was coming in fast and almost made it over the net . ', ' Brazil calls for a time out and we ’ ll be right back , after a short commercial break . ']
["Hello , Grace . That's a beautiful skirt you have on . Where are you going ? ", ' I am going to attend an interview . ', ' What kind of job are you applying for ? ', " My major is English . Of course I'll apply for an English teacher . ", " Oh . That dress doesn't exactly match the job . ", ' Why ? You said my skirt was beautiful just now . ', " Yes , your skirt is really beautiful , but you are applying for a teaching position . You see , your skirt is very short , and your make up is too thick . What's more , the color of your lipstick doesn't match your skin . As a teacher , you should be a little more sedate . ", ' Then what should I do ? ', " Some of my friends tell me that being a teacher , the most important is the beauty of mind . You shouldn't pay too much attention to your appearance . You should appear frugal and prudent . Your experience and knowledge will gain the appreciation of your interviewer . "]
["I don't know how John can put up with his son , who fools around without working . ", " He's out of John's hands . Nothing he can do about such a black sheep . ", ' If I were him , I would give him a good talking-to . I would insist on his stopping fooling around like that . ']
['London is such a historical city ! There ’ s history everywhere you look . There ’ s nelson ’ s column , built as a monument to one of the Britain ’ s great admirals and his important victory . He won the battle of Trafalgar in 1805 . ', ' I ’ m looking forward to seeing Westminster abbey , where many historical figures are buried , like Isaac Newton , the great mathematician and Winston Churchill , the great wartime leader . ', ' Nearby , on the banks of the thames , there ’ s the statue of Boadicea . She fought the Romans when they invaded Britain . ', ' Women have often played an important role in British history . Queen Elizabeth I built a navy strong enough to fight off the Spanish armada in 1588 . more recently , Margaret thatcher transformed british society in the 1980 ’ s . ', ' She was a very controversial leader . Are we going to visit the famous tower of London later ? ', ' There ’ s a lot to see there . Perhaps we should go tomorrow . ', ' I ’ m looking forward to seeing the famous castle and prison . Many historic figures were imprisoned there in the past . I really want to see the crown jewels too . ', ' I ’ Ve seen them before . They ’ re quite incredible . If you want to see historical figures in London , there ’ s one place you have to go . ', ' Where ’ s that ? Oh , I know ! Madame Tussaud ’ s the waxworks museum . ', ' There you can see british leaders , entertainers , criminals , and royalty . ', ' Sometimes , it ’ s hard to know who belongs in each section of the museum ! ']
['so , how should we go to the theatre ? ', " let's take the bus . ", ' I hate the bus system in London ! The bus drivers are rude , the buses are never on time , and there are few people around who can help you . ', " it's not that bad . You probably just had a bad experience once . ", " it wasn't just once . Every single time I take the bus , something bad happens to me or to someone else on the bus . ", " we could take the subway , but we'd have to go three stops along one line and then change trains twice . ", ' train fares are twice as expensive as the bus fare , too . ', " if we don't hurry up , we'll miss the show . Should we take the bus ? ", " we're already late , so I think we had better take a taxi . ", " I don't think we'll be able to find a taxi very easily during hush hours . Let's just take the bus . ", ' fine . Have a look at the timetable to find out when the next one arrives . ', ' it looks like it should be here in just a few minutes . ', " don't worry . Nothing bad will happen . I'll even buy your ticket for you . ", ' thanks , that was nice of you . ', ' see , now something good has happened to you on a bus trip ! ']
['Mary , please go to the door . I hear the bell . ', " It's the mailman , Mother . Here's a letter from Uncle George . ", " Give it to me ... How wonderful ! He's coming to visit us . ", " When's he coming ? ", " He's coming by car on the twenty-fourth . He's staying from thetwenty-fourth to the twenty-sixth . ", ' Let me look at the calendar . Good ! The twenty-fourth is a Saturday . Is he coming alone ? ', " No , he's coming with Aunt Cynthia and the girls . ", " Mother , I don't remember the girls . How old are they ? ", " Your cousin Fay is fifteen . Rosemary is older than Fay . She's seventeen . ", ' Are they going to stay here with us ? ', ' Of course . The girls can stay in your room with you . ', ' Mother , may we have a party ? ', ' If you like , but now we have to think about meals and many other things . ', ' Prepare the list , Mother . I can go shopping . I can go to the small stores.Everyone knows me there . ']
["What's your little caper ? Come home so late ! We are all worried about you . ", ' Oh , I am terribly sorry . But I was so captivated with the singer at the subway exit . So I forgot the time . ', ' Singing ? At the subway exit ? Oh , it sounds like someone needs some money . ', ' Oh , no , the guy was a musician who just sang . He played the guitar and sang so many cool pop songs . Many people were drawn to his music and there was no hat on the floor . He sang for appreciation , but not for money . ', ' It is just pop song , you could have sung there too if you want it . ', " Oh , no , it was a kind of pop art . I like it but I couldn't do it that well . ", ' Honey , just do it next time . Have you heard of the real art in the subway station in Russia ? ', ' No , but tell me some . I am interested . ', ' Many oil painting exhibitions are there . That is a kind of Museum Exhibition . ', ' Are there many people there ? Do you think people actually like them ? ', ' I am sure you will . There are some works , and some students who major in painting interpret the meaning for visitors . And people can enjoy the paintings while waiting for the train . ', ' But I still prefer the pop music in the subway . ', ' Both the pop music and the oil painting ate arts , but with different aesthetic values . ', ' Dad , you talk well , but can you appreciate that kind of art ? ', " Not well enough , but I'm learning . "]
["It's wonderful to be in the mountains after a hustle bustle week . ", ' Indeed . I love the smell of the grass and trees . They certainly refresh my mind . ', ' Can we stop here for a while ? My backpack is very heavy . ', ' Sure . Did you hear anything ? Look ! An eagle is hovering in the sky . ', " Let me see . It's not an eagle . I think it's a vulture . ", ' Yes . Will it hurt us ? ', " I don't think so . Let's walk by the stream . I am sure we can find the waterfall on the map . ", ' OK . I have a good pair of hiking boots . It should not be a big problem . ', ' I also brought a bottle of water and some provisions . If you are hungry , you can let me know . ', ' You are kind . Look there is a big tree over there , it looks like a thousand-year-old tree . ', ' Well , it is a birch tree.It is not as old as you think . ', ' How do you know ? ', ' Because its trunk is not thick enough to be like a thousand-year-old tree . ']
['Can we talk ? ', ' Sure , honey , we ’ re talking now , aren ’ t we ? ', ' You know what I mean . ', ' Yeah . I know . ', ' I want to know where this relationship is going . I ’ m in love with you and I need to know ... ', ' You know , I think you ’ re awesome . ', ' I ’ m awesome . Well , I guess that ’ s my answer , isn ’ t it . ', ' Honey ... ', ' Look , if you don ’ t love me , it ’ s not a thing , alright , we ’ Ve had our laughs , but I don ’ t appreciate ... maybe it ’ s just time we ... ', ' Baby , I love you so much . ', ' You do ? ', ' I love you . And I think you ’ re awesome . ', ' Oh , I love you too ! ', ' Come on . Put the gun down . ', ' Oh baby , I ’ m so sorry . ']
['Would you like to come over for dinner tonight ? ', " Sure , but I have to tell you that I've become a vegetarian . I don't eat any kind of meat . ", ' When did you decide to become a vegetarian ? ', " I saw a program a few months ago about how animals are raised for human consumption . I haven't been able to eat a single piece of meat since . ", " That's great . Do you find that you eat a lot more fruit and vegetables now ? ", " Definitely . I've also been buying organic fruit and vegetables , which is more expensive , but much better for you because they don't have any pesticides on them . ", " You've really turned into a health nut , haven't you ? ", " I guess you could say that . Eating fruit and vegetables helps keep you healthy . I've lost 5 pounds and I feel great ! ", ' How do you get enough protein in your diet ? ', ' Well , I eat a lot more tofu , beans , nuts and some fish . ', " Well , don't worry about dinner . I'll only make vegetarian dishes for you . Do you like sushi ? ", ' I prefer cooked fish to raw fish , but if you really like it , make it . ', ' How about a spicy tofu and vegetable stir-fry ? ', ' That sounds great . What time should I come over ? ', ' Dinner will be ready at about 7:30 pm , so you can come over at 7 p . m . ', ' Sounds good . See you there ! ']
['How old is Keith ? ', ' He ’ s 21 . how old is James ? ', ' He ’ s a year older than Keith , but he looks younger . ', ' How ’ s your father ? ', ' He ’ s fine . He retired last week . It ’ s turning going in his life . Now he can relax and enjoy his retirement . ', ' He can spend more time with his grandchildren . ', ' Oh , I don ’ t think he wants to . He wants to travel to several different countries around the world . ', ' So , he wants to have a more active retirement . Good idea ! ', ' How do you want to spend your old age ? ', ' In the same way , probably . ']
['Is this seat taken ? ', ' No . Please sit down . ', ' Thanks . ', ' Are you also going to Beijing ? ', ' Yes , on a business trip . How about Yuu ? ', " I'm taking a vacation to visit a friend there . Have you ever been there before ? ", ' Yes , I Went there once last summer . ', ' Really ? What did you think ? ', " I think it is amazing . You can enjoy both the traditional Chinese culture as well as the vitality of a modern cosmopolitan city . The only thing I didn't enjoy was the subway . ", ' Was it that crowded ? ', " Yes.These were always so many people.After taking the subway during the rush hour , you'll envy sardines in their cans . ", ' Oh , maybe I can take the bus or even rent a car . ', " That's a good idea . Wish you a great vacation ! ", ' Thank you very much ! ']
['I love ice cream . ', " Really ? Me , too . What's your favorite flavor ? ", ' I like both strawberry and coffee ice cream . ', ' Chocolate is mine . ']
['Would you like to go skiing with me ? I heard the new ski area is great . They have safe tracks , especially for the beginners and provide free training . I think it suits you best . ', ' Sounds not bad ! You know , the only thing I worried about is the safety . I ’ m not an active exerciser and my muscle may be not strong enough for such an intense sport . ', ' Well , Then you can go to the three-day-long training camp first . There ’ re some professional teachers and they can guide you to do certain necessary exercise . ', ' I will think about it . ', ' Come on ! It is really a fun game . ']
['Do you like watching the Winter Olympic Games ? ', " Of course . It's the tradition game in winter , and with good reason . Don't you like watching it ? ", ' Of course I do . I love it . All the games are exciting and the competitors are respectable . ', " That's true . For various reasons , it takes more to hold a fierce game for Winter Olympics than it does for Summer Olympics . You know , the low temperature may cause many problems . ", " Yeah . What's the difference between the Winter Olympics and the Summer Olympics ? ", ' When the Olympic Games started in modern times , only summer events were included . When it grew popular , there came the Winter Olympic Games , which includes a variety of winter sports . ', " I see . Then , what's your favorite winter sport ? ", ' Figure skating . In my eye , nothing beats it . ', ' Then you must know Shen Due and Hao Hongbo . ', " Oh , I didn't expect you to know them . But yes , I love them not only because of many medals they've won , but also because of their spirits . ", ' You should go to talk with May . She is a big fan of them too . ', ' Sure . What about you ? What do you like about the Olympics ? ', ' For me , the Olympics for the disabled always catches my heart . It makes me understand that perseverance makes the impossible possible . ', ' Hey , young man , you are so deep today . ', " I always am . You just didn't notice . "]
['It is difficult for old people to do away with old ideas . ', ' So the reform cannot be carried out well . ', ' Government is making efforts to change situation . ', ' Easier said than done . ']
['Does she make any sense to you ? ', " No . It's all Greek to me . ", " She's speaking French , not Greek . ", " I know that . I mean I couldn't understand her at all . ", ' Me neither . All I have to do is study French hard . ', ' I wish you the best of luck . ']
['How are you going all these days ? ', ' Fine , thanks . ', ' But you look depressed . ', ' I have some problem with my work . ', ' Is it serious ? ', ' I can solve it , thanks . ', ' How about your family ? ', ' Everything is Okay . And as soon as I see my son at home , all my worries vanish into the blue . ']
['So what do you feel like doing this evening ? How about going to the cinema ? ', " Ah , that's a good idea . But I heard the film club of our school would show a film for free . Maybe we don't need to go to the cinema . ", " That's good ! I've also heard there will be a party held by the Students ' Union tomorrow evening . Would you like to go with me tomorrow night ? ", " I'd like to , but I'm afraid I can't . ", ' Why ? Do you have to prepare for your examination ? Oh , come on , girl , relaxation is also very important . ', " That's not the reason . I have to go to the English Corner tomorrow evening . You know , I've been going there every week . ", " Oh , God , I've forgotten it . ", ' You said you wanted to improve your English , so how about coming with me tomorrow ? I can also introduce some friends to you . ', " Oh , no , I don't want to know any more geeks like you . ", ' They are not geeks . They are also interested in singing , dancing , and so on . They are excellent , and they can always help me a lot . ', ' Really ? Is there a foreign teacher for every class ? ', ' It depends . If they are not busy , they will come to join us , and talk with us . ', ' So you just talk all the time ? ', ' Of course not . The foreign teachers also teach us English songs , and play games with us . ', " That sounds interesting . I'll go with you tomorrow evening . ", " You won't be disappointed . "]
['You ’ re going to set up your own law office , aren ’ t you ? ', ' Yes . After so many years of hard work , I ’ d rather I had an office of my own . ', ' If you need help , don ’ t hesitate to ask me . ', ' I ’ ll be very glad if you would help . ', ' I ’ d like to wish you every success in your new venture . ', ' Thank you . I wish I would . ', ' Good luck to you . ']
['Wow , is that your sports car ? ', ' Yes , do you like it ? ', ' I love it ! I used to always want to drive a green jaguar . Is it in good condition ? ', ' Yt looks good on the outside , but the inside is a different story . It needs a lot of servicing before it can go out on the roads again . ', " What's wrong with it ? ", ' Well , first of all , it needs a new engine , which is extremely expensive . ', " When's the last time you had it serviced ? ", ' It must have been a few years ago now . ', ' I thought all cars needed regular servicing on a yearly basis . ', " They do . Once my son was born , there was no reason to drive this car anymore . It's only a two-seater , you know ! ", ' What else is wrong with it ? ', " The heating controls don't work anymore , so it always feels like it's about 100 degrees in the car — even in the summer ! ", ' Anything else ? ', " The brakes don't really work that well anymore either . ", " Why don't you get it all fixed ? ", ' It costs more than you think to run a car---especially when there are so many things wrong with it ! ', ' Well , let me know when you can get it fixed . I ’ d love to go for a ride in it ! ']
['Can you play baseball with me today ? ', " No , I can't . I'm sorry . I have to help my mother . We're going to move tomorrow . ", " Where's the new house ? Is it far from here ? ", " No , it's not far . It's near our old house . ", ' Can I help you pack ? ', ' Sure . Thanks . ']
['I think I need a new notebook . ', ' Why ? Is there some new , cool computer out on the market ? ', ' You bet there is . Feast your eyes on this puppy ! ', " That's a notebook ? ", ' Believe it ! ', ' It looks more like a toy , or a cool briefcase ! ']
['Dalian is a beautiful city . Do you agree ? ', ' I suppose I do . ', ' The climate here is pleasant . ', ' You said it . ', ' This city is really comfortable to live in . ', ' It sure is . ', " No other city can match it . It's heaven . ", ' Well , if you live in other cities as long as enough , you will love them just as much . ', ' Maybe . ', " That's for sure . "]
["Ah , Michelle , hi . I was hoping to see you . How have you been ? How's the family ? ", " Oh , hello , Mr . Campbell . I'm fine and Jack's doing well . How are you ? ", " I'm fine thanks . I got your report this morning . Thank's for that . Are you joining the conference today ? ", " Yes , I'm leaving at four pm . ", ' Good , well we can discuss this more then , but I think the figures are looking very good for this quarter . ', ' Yes , me too . ', " I'm planning to discuss the advertising budget at the conference . I don't think we should continue with the TV advertising . "]
['Have you read all these crazy things that are going on around the world ? ', ' What do you mean ? ', ' I was reading about how some people get tricked or drugged in their hotel rooms and have their organs removed ! Then they are sold on the black market . ', " Don't tell me you actually believe all that ? Don't be so gullible , they are just urban legends . They are just stories people make up to scare you . ", ' Well , I was also reading about how some popular songs have subliminal or even satanic messages if you play them backwards ! Can you believe that ? ', " You really think an artist or song writer is going to go through the trouble of putting subliminal or satanic messages in a song ? Don't be so naive ! ", ' Well maybe you are right , but how about the story of how KFC has rows of headless chickens which are super grown in order to get bigger chickens faster ! ', " Sounds a bit too far fetched to be true , don't you think ? "]
['Hi Bob , this is my friend Mary . ', ' I am very pleased to meet you . ', ' Bob is in advertising . ', ' That sounds an interesting job , Bob . ']
['Wow ! I can ’ t believe I ’ m standing here ! ', ' What are you so excited about ? ', ' I ’ m standing in front of an exquisite work of art ! ', ' What ’ s the big deal ? It ’ s just a picture of some woman . ', ' I ’ Ve seen it so many times in books , but I never imagined I ’ d get to see it in person . ', ' There are tons of other paintings that I think are better . ', ' Maybe so , but do you have any idea how much this one is worth ? ', ' No , how much is it worth ? ', ' About 80 million dollars . ', ' Whoa . ']
['Lady , you look unhappy . What ’ s the beef ? ', ' A man stepped on my feet when I was waiting for the taxi . ']
['When were you Bron may I ask ? ', ' On 20th May 1963 . ', ' Do you know what it was according to the lunar calendar ? ', ' 27th day of the fourth month . ', ' By the way , could you tell me when the film will begin ? ', ' It will begin at 5 thirty . ', " I am frigid I can't be there on time . ", ' You can see it tomorrow . ', " I don't want to miss it today . ", ' See you . ', ' See you . ']
['Did you see the 2005 Grammy Awards on TV last night . ', " Yeah . I was so happy , because my favorite singer , Ricky Martin won ' Best Latin Pop Performance ' . ", ' He seems to win awards everywhere . ', ' He is really great . He has sold millions of records worldwide . He is especially known for his rocking performance at the football World Cup song-the Cup of World . ', " I heard one observer even said ' It was a song sung in Spanish for international football , and he made it so popular that even the Americans loved it . ' ", " That's right . His voice ranges from the smooth sound of ballads to the highpowered rhythms of the Spanish Caribbean where he grew up . He has fan clubs across the world , from America to Russia , from England to Taiwan , from Norway to Australia . "]
['Ben cancelled his trip . ', ' How come ? ', ' Because General , his dog , got sick . ', " He's such a mother hen . "]
['Hi Jane , you look great . ', ' You too . Have you lost some weight ? ', ' Yes , I took off 4 kilos . I am glad you notice it . ', ' Not some crazy diet fat I hope . ', ' No no , I just changed my eating habits . I eat a balance meal . and I eat less than before . ', ' Good for you , keep it up . ']
['It may comfort you to know that many people attended his viewing . ', ' How did they hear ? No one called . ', ' In times of loss , it is often hard to pick up the phone . But his whole family was here . ', ' His mom and dad must be destroyed . He was their only son . ', ' And he was so young , with so much life to look forward to . ', ' Yes ... thank you for understanding . We have to go now . ', ' This sheet tells the visiting hours and funeral time and location . ']
["OK . Steven , you're looking at a picture . Please describe what you see ! ", " Uh , I can see a red double decker bus . It's the kind of bus you'll see very often in London . In fact I know this bus is from London because I can see the names , Chelsea , Sloan Square , Victoria , Herring Cross . These are all areas in London . Um , so obviously the bus is in London . ", ' OK . Have you ever been on a double decker bus ? ', ' Yeah , yeah , yeah . many times . Many times . When I was younger , you used to get double-decker all over England but now you only tend to see them in the big cities . ', ' Oh , really . Mm ! How much is the fare ? ', " Well , it depends on the journey . It's .. I guess it's not too expensive , but the minimum price you would pay is , for a short journey , is about a pound . ", ' Mm , yeah , who can you see on the bus ? Can you pick out anyone on the bus who looks interesting ? ', " Hmm , yeah , well this girl here at the back , that's leaning on the door , um , she looks really bored , actually . Maybe she is going to work or something and she doesn't want to go ! ", ' Is that how you feel on the bus ? ', " Uh , well , no , not really , because I haven't worked in England for a long time , so I haven't taken a bus for a long time . ", " So , so you're British , do you missing them ? ", ' Um , yes , sometimes . Sometimes . ']
['Is the view going to be ok ? ', ' Don ’ t worry , you did a good job and it should be fine . ', ' I ’ ll do my best . ', ' That ’ s the way to go . ']
['I got a promotion . Lunch is on me . ', ' It ’ s great . ']
['You can keep these books for only half a month . ', " May I renew them if I haven't finished reading them ? ", ' Of course , you can . ']
['Bob , you look pale . What happened ? ', " I didn't sleep a wink last night . ", ' Did you have something on your mind ? You look so concerned ! Maybe I can help you . ', " Well , I'm under a lot of pressure . My boss is very pushy . He assigned me two projects . Now the deadlines are near and I still haven't finish one of them . ", ' Is there anything I can do for you ? ', ' Well , I guess no one can help me but myself . For the moment , I just need someone to talk to so that I can relieve my stress . ', ' I know your feeling . Take it easy . ']
['Which team won ? ', ' The Spur . ', ' What was the score ? ', ' They managed a 99:80 victory . ']
['You know ... I did very poorly on that test . ', " Cheer up ! It's not the only chance in life to do well on a test . There'll be many more . ", " Well , you know how I am about exams . I'm a perfectionist . ", " Don't worry about it . All in all , you've done very well in school . "]
['What happened to Nancy ? She is all sweetness and light today . ', ' She is going to get married . ', ' No wonder ! Who is the bridegroom ? ', ' I don ’ t know . ']
['I think Bill Clinton is a good president . ', ' But he has the sex scandal . ', " Well . Maybe he isn't a good husband , but he is a successful president . ", ' I agree . He is also an excellent speaker . ', ' Yes , he is . Of course he makes mistakes , but who doesn ’ t . ', ' yeah , it ’ s fair to say so . ']
["What good sunshine ! Let's go and get a suntan on the balcony . ", " I've had enough of it while working under the sun in the day . I don't need any more sun-tan . ", " It's different in my case . I work in the office , so only rarely do I get the chance to get any sun . ", ' It might be good to you . But please keep in mind that too much tanning damages the skin rather than does any good to you . You might end up with skin cancer . ']
['Would you like to stretch your legs ? ', ' Why not ? ', " Let's get a soft drink . ", ' Do we have enough time ? ', ' Yes , we do . ', ' The performance is excellent . ', " It's a new concert hall and the acoustics are great . ", " I couldn't agree more . ", ' Is this your first time to come to a symphony concert ? ', ' Yes , it is . ', ' Do you have concert halls in your city ? ', " Yes , but it's much smaller . ", " Well , we'd better get back to our seats . It's about to start . ", ' OK . ']
['Wake up sleepyhead.The sun is beginning to shine . What a lovely summer day ! ', " Yeah , clearly blue sky.But it is a bit too hot for me . I don't like heat and humidity . ", " It's not that hot . It's cooler than yesterday . Let's go swimming ! ", " That's a thought . It's still early , and the beach isn't crowded at this time of the day . If we don't stay too long , we won't get sunburned . ", ' Yeah , sounds like fun . I can wear my new pink bikini . ', " There won't be anyone there to appreciate how cute you are . ", " Who cares ! Well , the smart guys get there early . That's the kind of guy I want to meet . Let's go ! ", ' If you are going to husband hunting in a bikini , then I want to wear one , too . ', ' Ok , you could borrow one of mine . ', ' Thanks , how about the green and black one ? ', ' No problem . Here it is . ']
["It's a beautiful day , isn't it ? ", " Yes , isn't it . ", ' Do you now the temperature today ? ', " It's beautiful 75 degrees . ", " How nice . I hope the weather will stay like this for the whole week . I'm going on the canoe trip this weekend . ", ' Not a good plan . The TV weather forecast says the hurricane is coming this weekend , and the temperature will also drop to 66 degrees . ', " What a nuisance ! Every time I plan to go canoeing or camping , a storm comes along . The sky gets dark , the wind starts to howl and the temperature drops.Well , I'd better stay home . ", ' I never make any definite weekend plan until Friday morning . Then after listening to the weather temperature , I make my plans . ', " That's smart . I'm going to start doing the same thing . "]
['are you ready to go the concert ? ', " yes . Should we go there by bus so we aren't late ? ", " actually , why don't we go there by bike ? We could get stuck in traffic if we travel by bus in such hour . ", " that's true . Cycling is good for our environment , too . Let me just get my helmet then . ", ' is your helmet comfortable ? ', ' not really , but I liked the design , so I got it . ', " maybe you should think about getting a round helmet ; they're better . ", " I'll think about it . ", ' is that your new bicycle ? ', ' yes , my father gave it to me for my birthday . Do you like it ? ', " it's the newest 10 speed cycling mountain bike . These are really expensive ! ", ' nothing but the best from my dad . I like everything about it except for the brakes . They are a bit sticky . ', ' I can fix those for you . Is there anything else wrong with it ? ', ' well , my saddle is too low for me . Do you know how to change the height ? ', " that's easy . It's important to have the saddle high enough so that your legs can extend fully when you are on your bicycle . ", " is that why my knees have felt sore after every time I've ridden my bike ? ", " it's possible . Give me a minute and I can fix these for you and then we can go . "]
['Next please ! Hello sir , may I see your passport please ? ', ' Yes , here you go . ', ' Will you be checking any bags today . ', ' Yes , I ’ d like to check three pieces . ', ' I ’ m sorry , sir . Airline policy allows only two pieces of checked luggage , at twenty kilograms each , plus one piece of carry-on luggage . I will have to charge you extra for the additional suitcase . ', ' What ? Why ! I am taking an intercontinental flight ! I ’ m flying sixteen thousand CMS ! How am I supposed to only take two , twenty kilo bags ? That ’ s absurd ! ', ' I am sorry , sir , there ’ s nothing I can do . You cannot board the flight with that large bag either.Carry - on bags must fit in the over-head compartment or under your seat . That bag is clearly too big . ', ' Now I see . You charge next to nothing for an international ticket , but when it comes to charging for any other small thing , you charge an arm and a leg ! So tell me , miss , how much will I have to pay for all of this . ', ' Let ’ s see ... six hundred and twenty-five US dollars . ', ' That ’ s more than my round-trip ticket ! ']
['Do you feel like going to see a movie tonight ? ', " I'd like that very much . ", ' How does 7:30 sound ? ', ' Fine . See you later . ']
['How are you ? ', ' Fine . ', ' I haven ’ t seen you for several days . ', ' Oh , I have been with my uncle for a week . ', ' What ’ s he doing ? ', ' He is an accountant . I have been helping him for a week . ', ' He must be happy . ', ' Yeah . How are you these days ? ', ' Fine too . ']
['So what kind of music turns you on ? ', " Rock ' n'Roll , I guess . ", ' You mean the kind of stuff like Nirvana ? ', ' Not really . That ’ s pretty heavy metal . ']
['Dick , I ’ Ve decided not to rent that house . ', ' But yesterday you said you would rent it . ', ' I ’ Ve changed my mind . ', ' Why is that ? ', ' Well , I think maybe I should find a house that is closer to where I work . ', ' Maybe you ’ re right . ']
['Hi ! How are you going ? ', ' Fine , thank you.How are you doing this morning ? ', " Not bad.How about you ? Haven't seen you for a long time . ", " Yes . I've been to New York . I got back only yesterday . ", ' Did you enjoy yourself ? ', ' Very much.New York is such a nice place.Shall I show you some photographs ? ', " Thanks , I like looking at photographs.How nice ! Oh , I'm afraid I must be going now . I've got an appointment . Have a good day . ", ' You too . I hope to see you soon.Goodbye . ', ' Goodbye . ']
['You ready ? ', ' Am I ready for what ? ', ' Are you ready to transfer to a new school tomorrow ? ', ' Oh . Yes , I ’ m ready to transfer . ', ' You ’ re not nervous , are you ? ', ' I ’ m very nervous . ', ' Why are you nervous ? ', ' I ’ m not going to know anybody there . ', ' That ’ s not a problem . ', ' That makes me nervous . ', ' It ’ s fun meeting new people . ', ' I didn ’ t think about it that way . ']
['Did you see Victor on Wednesday , Wendy ? ', ' Yes . We went for a walk in the woods near the highway . ', ' Wasn ’ t it cold on Wednesday ? ', ' Yes . It was very cold and windy . We wore heavy wool sweaters and walked quickly to keep warm . ', ' It ’ s so nice and quiet in the woods . ', ' Yes . Farther away from the highway it was very quiet and there were birds and squirrels everywhere . We counted over twenty squirrels . ', ' It sounds wonderful . Did you take lunch with you ? ', ' Yes , we bought veal sandwiches . We stopped around twelve , and we ate and watched the squirrels , but it was too windy to sit long . It was a very nice walk , anyway . ']
['Wow ! That ’ s a pretty dress , but it ’ s too expensive . ', ' Yeah , it is ! Why is it so expensive ? ', ' It ’ s because of good quality and the fine design . ', ' I don ’ t think it ’ s worth that money . ', ' Anyhow , this dress is really elegant . ']
['How is your business going ? ', " Business couldn't be better . ", ' Really ? Maybe I should work for you . ', ' Welcome . I could use the help . ']
["Hey , what's the matter ? ", " It doesn't matter . I just feel a little dizzy . ", ' Are you sure that this has nothing to do with sleep ? ', " I don't know . "]
["I've been told that you are a very successful businessman abroad . I wonder how you managed to achieve such success ? ", ' Oh , through a lot of hard work , of course . ', " I suppose that in a foreign country it was difficult at first , wasn't it ? ", ' Surely it was , especially when you only knew few people and little English . ', ' You mean you didn ’ t know much English then ? ', ' Right . I only knew a few English sentences . ', " That's incredible . Could you tell me what you did to make a start ? ", ' First , I worked as a servant . ', ' Really ? I wish you could tell me more about your experience . ', " I'd like to , but I must run to a meeting . "]
["What's the news on our website ? How effective do you think it is from a marketing standpoint ? ", " We've been able to survey and track some of the information of our website users through some cookie technology , and it's surprising to see the results . ", " What kinds of hits are we getting on our company's website ? ", ' From the numbers , it seems nearly half of the visitors who stumble onto our page pick up the link not from network browsers or search engines , but from our circular insert . That means our consumers are purposefully and actively seeking information about our products and services through the web format . Based on these findings , I am completely convinced the internet is the marketing power of the future ! ', ' You really think that many people turn to the internet to find product information.What about the old standbys of word mouth and print media ? ', " Well , these mediums are still important ... they aren't a thing of the past ... But I think they might be less important now than in the past . The technology age has arrived ! "]
['What do you know about Julia Roberts ? ', ' Her acting is OK . ', ' I mean her personality . ', " I'm afraid I know less than you do.Tell me more about her , will you ? "]
["I've never seen a machine like this before and need some help . ", ' Sure , no problem . What are you trying to get ? ', ' I want to buy a drink . ', ' OK . This machine needs you to use that change machine first to get correct change . ', " I've got the correct change already . ", ' First you put your money in the dollar slot or the coin slot . The dollars have to be smooth . ', ' OK , what next ? ', " Just know that sometimes the money doesn't go in perfectly the first time and you have to try again . ", ' OK , next ? ', ' Choose what you want and push the button . Sometimes it takes a couple of tries . ', ' I agree with you . ', ' Hope that works for you ! ']
["Honey , wait ! I've sprained my ankle . ", ' Oh , my god , are you OK ? ', ' Of course not ! ', ' Come on , sit down , and let me have a look . ', ' The pain is killing me . ', " I told you to wear running shoes . But you don't listen . ", ' I thought leather shoes will do just as well . ', " Hold on , don't move , I will take care of that . ", ' What are you going to do ? ', ' I will get some ice , and put it on your ankle.How does that feel ? ', " God ! It's freezing ! ", " Be brave . Don't worry . You will be able to walk soon . "]
["So Chris , I've heard that you're from a big family . How many people ? ", ' Nine total . Seven children and my parents . ', " Seven children ? That's a lot . Why did your parents have so many ? ", " Well , my mother came from a big family , and wanted to have one of her own . My father was an only child , and didn't really care about having a large family , but my mother talked him into it . ", ' Jeez , seven children . That must have a lot of problems . We have four children in my family and my grandparents can never get our names right . ', ' It can be hard , and there are certain sacrifices you have to make . ', " Like what ? I assume that there's no privacy . ", " That's one . Another is the lack of personal property . Everything you have , from toys to clothes , is used by your brothers and sisters . Especially clothes . Three quarters of my wardrobe are hand-me-downs . ", " And the age gap is also annoying . There's a ten-year difference between my younger brother and me . We have nothing in common . ", " Same problem here . There's an 18 - year gap between the oldest and youngest child in my family . The last child was born just as the oldest was going to college . ", " Well , at least going to college won't be too bad . Since both of your parents are college professors , they must give you reduced tuition at the college . ", " They do , but it doesn't help too much . Having seven children means that the money situation in my home is always pretty tight . "]
['That was a nice funeral . ', ' Yes , dad , it was . ', ' The son gave a nice speech about his father . ', ' It was long , too . ', ' I think it was about 45 minutes long . ', ' But it went by fast . It was interesting . ', ' I liked it . ', " I'll give you a speech like that , too . ", ' Do you think anyone will come to my funeral ? ', ' Of course . ', ' I think only the family will be there . ', ' You have lots of friends . They will be there , too ! ']
['Hello ? ', ' Hi , Randy . What are you doing right now ? ', ' Nothing . Just watching TV . ', ' I ’ Ve got two tickets for a newly released film . Would you like to see it with me ? ', ' Sure . What time ? ', ' The film will start at 2 ', ' Sounds good . Where and when will we meet ? ', ' In my parking lot , at 2pm . ', ' All right . See you then . ']
["How do you think TaiWan's economy is doing ? ", ' Not too good actually , people are not spending as much as before ! ', ' Do you know why that is ? ', ' Lots of reasons I guess , unemployment is pretty high these days . ']
['Does your child still believe in Santa Claus ? ', ' Yes . She believes everything about him . ', ' How sweet . ', " Yes . If she doesn't believe it , Christmas won't be so exciting to her . ", " When are you going to tell her that Santa Claus doesn't exist ? ", " I'm not going to tell her . She will find out and understand when she grows older . "]
['I am kind of nervous . ', ' Nervous ? Why ? ', " I don't know . I never went to a church before . I was not raised as a Christian , so I don't know what to do . ", " Don't worry . You don't have to do anything.All you have to do is listen . You will enjoy it . ", " Maybe . I know I agreed to go with you , but now I don't feel right about it . ", " Listen , Ryan.Catholics welcome people who aren't Catholics to visit the church.You don't have to pretend to be Catholic . It's okay if you just come to listen . ", ' Really ? ', ' Yes . We are kind and welcoming people.It is not a secret society or something like that . ', ' Alright . But will we sing ? ', " Yes , but you don't even have to sing . If you want to sing along , you can . ", " I don't know the words . ", ' There is a songbook . All the words are in the songbook.Many people have to read the words . ', ' And will I go up to the front to have the bread and wine ? ', " No . That is something only true Catholics do.So if you come to the church as a visitor , you only listen to the service.But you shouldn't go up to the altar for the bread and wine.Only after someone joins the church , then they go up for the Eucharist . ", ' Eu-char-ist ? What is that ? ', ' That is the special word for the ritual of the bread and wine.The Catholics call it the Eucharist . ', " It doesn't sound like an English word . ", " It's not . It's an ancient Greek word . It means gratitude . ", ' Alright . Well , I feel more comfortable now.Now I understand I am welcome as a visitor . ', " Of course you are . I wouldn't ask you otherwise . "]
['Hey Jack . How were your classes this semester ? ', ' They were not too bad . I really liked my poli-sci class . ', ' Would you consider it your favorite class ? ', " I don't know if I would call it my favorite , but it ranks up there . ", ' What class was your favorite then ? ', ' I took a business communication class last year and it was terrific . ', ' I never took that yet . If that was your favorite , I think I will check it out . ']
['What are you reading ? ', ' It ’ s an article about language . It talks about the idea of having a single global language . ', ' It seems that English already is the main global language . Does the article suggest that there should be an artificial language like Esperanto as the world language . ', ' Actually , it suggest English . The main argument is that English is already being studied as a second language in most countries-china , India , mexico , Nigeria , Pakistan , and japan . So beginning again with a language like Esperanto would be wasteful . The second argument is that English is used in modern technology far more that any other language . Most emails are sent in English and the vast majority of website use English . ', ' Does the article say anything about other language ? How will they survive in an English-speaking world ? ', ' The article points out that many languages have been lost and will be lost , but others will continue to be used for generation , even if English continues to be the dominant language . ', ' Right . All the people who speak Chinese . Hindi , French and Spanish aren ’ t suddenly going to stop using those languages . ', ' Exactly . The article suggests that those languages will be used , but that they will only rarely be used in international communication between non-native speakers . ', ' In that case , I shall continue to learning a few basic phrases in other languages . ']
['Are you have a hand in locking into the case ? ', ' Yes . ', ' How do you feel about it ? ', ' It is really a hard nut to crack . The problem is that the crime was done without leaving any trace . ']
['Ahh ... What a fine day ! I do feel like an outdoor exercise . ', ' How about taking a walk in the park ? ', " OK.It ' s delightful to have a walk in the park with the air so fresh . ", " Oh , it's so quiet here.We have the park to ourselves , only you and me ! ", " Don't you see many people over there ? Just on your left . ", ' Oh , I see them.Some are doing Taijiquan , some are performing swordplay , some are practising the Chinese Wushu . ', ' A growing keep-fit fever is sweeping over China . ']
['Another glass of beer , will you ? ', " Thanks , I'm enough . ", ' At least one for your trip . ', " I'll have it if you insist . "]
['Have you seen that house ? ', ' Yes , it looks interesting . ', " You're right . I love it very much . ", ' It must be old . ', ' At least more than 100 years old . ', " Let's enter it ! ", " I can't open the door . ", ' It must be locked . ', ' Let me ask the old woman in that reception office . ', " She can't answer you . ", ' She must be deaf . ', ' It must be a haunted house.Are you frightened ? ', ' Frightened ? You must be joking . ']
['Good morning . Phyllis Seymour speaking . ', ' Hi , Ms . Seymour ? It ’ s Allan Parker . I ’ Ve been waiting to call you and thank you for all your help last week . ', ' Thank you very much , Mr . Parker . But , that is my job . ', ' Well , I want to let your boss know that she ’ d better hold on to you ! You ’ re a hard worker ! ']
["It's raining outside , Catherine , it's too bad.What ' s the weather like in your hometown ? ", " It's very hot , the temperature is often over 40 ° C . ", ' Do you like the weather in Seattle ? ', " Not really.But I like it in spring and fall . I don't like it in winter . ", ' Why ? ', " The winter is very rainy , I don't like the rainy day . ", ' What about the weather in Boston ? ', " I lived there for three years . I like summer but I don't like winter . ", ' Is it very cold in winter ? ', " Yes , it is.But it's nice in spring and fall . "]
['Wei , you look really tired . ', ' Yes , I didn ’ t finish work until 9:00 pm . ', ' 9:00 ! ', ' Yes , I have too much work to do at the moment . ', ' Why ’ s that ? ', ' Because too many people in the office are on holiday . ']
["I've heard you're going to America tomorrow . I want to see you off at the airport . ", ' Oh , thanks a lot . ', ' What time are you leaving ? ', " 1:30 P . m . But I've got to check in at 12:30 P . m . ", ' What airline and what flight ? ', ' Pan American Airlines . Flight 282 . ', " I'll see you at the airport at 12:30 P . m . ", ' Ok . See you tomorrow . ']
['He was hauled up last week for the second time . ', ' You mean he had been put in prison before . ', ' Of course , he is a man with a history . ', ' Oh , he had fooled me . ']
['Hello . Can I sit here ? ', ' Yes . ', " By the way , I'm Robin . ", ' Hi . My name is Jessica . ', ' Nice to meet you . ', ' Pleased to meet you too . And where are you from , Robin ? ', " I'm from Kathmandu . What about you ? ", " I'm from New York . Oh , this is my stop . Bye , Robin . ", ' Bye . See you . ']
["Well , I've never downloaded music before . How does it work ? ", " You haven't ? If you've never tried it I can show you how . ", ' Alright . But why is downloading music better than buying Cds at the store ? ', ' Downloading music is really fast and convenient , and you can preview all the songs before you buy them . ']
['Hi ! How are you doing ? ', ' Good , thanks . How about you ? ', ' Pretty good . Say , where are you living this semester ? ', " In No . 4 Dorm . I like dorm life . You will meet a lot of people and you don't have to cook . What about you ? ", ' Oh , I am looking for an apartment . I prefer living off campus . I can study better . ', " I hope you will find a place . Listen , I'd better go . I am going to be late for class . ", ' Okay , see you around . ', ' Take care . ']
['I think modern painting means nothing . ', " I think so too . It's just pointless . ", ' Then why are so many crazy about it ', " I don't know.Maybe they are really crazy . ", ' Maybe . ']
['I heard you are going to move . ', ' Yes , I found a better house near my office . I ’ m very satisfied with it . But I ’ m worrying . ', ' What are you worried about ? ', ' I ’ m worrying about how to move all of my household stuff . You know , I have a lot of stuff . ', ' You can call a mover . ', ' How much dose that cost ? ', ' Around 200 RIB for a truck . ', ' I think it ’ s a little expensive . ', ' But think about it , you just need to pack your stuff and leave everything for the movers , how much trouble you will save . ', ' That ’ s right . ', ' I know a mover which has a very good reputation for their service . I ’ ll leave you their phone number . ', ' Wonderful . ', ' It ’ s 8357688 8 . ', ' Okay , thanks a lot . You did me a great favor just now . ', ' You ’ re welcome . ']
['I saw your car outside , so I stooped by . ', ' Yeah , I come here every now and then . ']
["I just meant that she's got different taste . ", ' What kind of girl is she ? ', " She's pretty conservative . ", ' Is her fiance Taiwanese ? ', ' Yes . ', ' How old is he ? ', " About 30 . He's really outgoing . But why do you ask ? "]
['How have you been ? ', ' Fine , thank you . ', " And how's everyone in your family ? ", " Very well , thank you . I'm meeting my wife and daughter for lunch at twelve.Would you care to join us ? ", " I'd love to , but I'm afraid I can't . "]
['That girl looks very attractive , doesn ’ t she ? ', ' Do you think so ? I don ’ t like girls who look like that . I like girls who aren ’ t too slim . If you like her , go and talk to her . ', ' I ’ d like to , but there ’ s her boyfriend . He ’ s very broad-shouldered . ', ' He ’ s huge ! He must go to the gym to have a well-built body like that . ', ' Do you prefer tall girls or short ones ? ', ' I don ’ t mind , but I like girls with long hair . ', ' We have different tastes . I like girls with short hair . I like tall girls - probably because I ’ m so tall myself . ', ' Have you ever dated a girl taller than you ? ', ' No , never . I don ’ t think I ’ Ve ever met a girl taller than me ! Have you gained weight recently ? ', ' Yes , I have . Perhaps I should go to the gym , like that girl ’ s boyfriend . ', " I'm getting a bit plump myself . Perhaps I ’ ll go with you . "]
['Good morning , Linda . How have you been ? ', ' Pretty bad . I ’ Ve had a bad cold for three days and still can ’ t get rid of it . ', ' I ’ m sorry to hear that . Is there anything else I can do ? ', ' No , thanks . ', ' Well , I hope you ’ ll feel better soon . ', ' Thank you for your concern . ']
["Do you have a copy of our service contract with Telecoms ? I'm not happy with their response time and I'd like to check the terms and conditions of the contract . ", " Sure . I've got a copy here . It's due for renewal at the end of next month . We've still got time to look for another supplier if you're not happy . "]
['Um , which of them is the better typist ? ', ' Well , Mary types faster than Jones . But I think Jones types more carefully . ', ' Is there any difference in their short hand ? ', ' Jones can certainly take down letter more quickly , but Mary ’ s short hand is the best in her class . ', ' How about languages ? ', ' Both of them speak excellent French . But I think Mary speaks German more fluently than Jones does . ', ' Um . That doesn ’ t really matter . Because we have more French visitors than German . ']
['Today is your birthday . First of all , happy birthday to you ! ', ' Thank you for coming . We will have dinner outside . Eat up ! ']
['Excuse me . Is anyone sitting here ? ', ' No , nobody . ', ' You don ’ t mind if I smoke , do you ? ', ' Well , to be frank , yes , I do . ', ' Oh , I ’ m sorry . But this isn ’ t a no-smoker , isn ’ t it ? I mean would you mind if I smoke here ? ', ' Actually it is . Perhaps you haven ’ t noticed the sign . ', ' Sign ? What ’ s sign ? ', ' There , on the window . ', ' Oh , sorry . I didn ’ t notice it . Sorry . ', ' That ’ s all right . ']
["I don't know whether or not to believe him . ", ' You can trust him . He always tells the truth . ', " But it's really too important to me . ", ' I said you can trust him . You just have to believe it . ']
['I feel pity for the old man . ', ' I feel the same way . ', ' It must be dreadful to grow old . ', ' It sure is.He has no one to turn to , very miserable indeed . ']
['Excuse me , sir . Could you spare a minute ? ', ' Uh , yes . ', ' Do you go to work by train every day . ', ' Yes . I commute five days a week by train . ', ' And would you mind telling us what you think of the rail service ? ', ' It ’ s really very good . ', ' Why do you say that ? ', ' Well , trains are frequent and come on time . ', ' Which train do you catch in the evening ? ', ' I usually take the five thirty home . ', ' And can you get a seat ? ', ' No , I usually have to stand . ', ' Would you agree that the service is fast ? ', ' Yes , it ’ s reasonably fast but it certainly isn ’ t cheap . Fares have gone up 25 present . ']
["So , how'd everyone do ? ", " Well , there's this clock I was ... MY vintage clock ! How do you have my clock ? ? ", ' Your vintage clock ? ! I just paid sixty-five dollars for it . ', " Sixty-five ? What the ... ? How did you bargain him down , Wei ? You've never even been to a flea market before ! ", ' It must be my special touch . I think bargaining is in my blood ! ', ' Never underestimate a woman when it comes to bargaining ! ']
['You are studying here , aren ’ t you ? ', ' Yes . I have been here for three years . ', ' Do you like this campus ? ', ' Well . I ’ m rather disappointed with it . ', ' How come ? ', ' It ’ s too old . And it isn ’ t as specious as I expected . ', ' Oh . It ’ s awful , but it can ’ t be helped . ', ' I ’ ll just have to put up with it . ']
['Would you mind if I smoked ? ', " I'd rather you didn't . "]
['How do you feel about the TV series ? ', " Oh , to be frank , I think it's sheer waste of time to watch it . ", ' Yes , I agree , but still a lot of people watch it . ', " But I don't think much of it . "]
["I've brought some potato chips . Would you like some , Jack ? ", " Yes . I'd like to swap some of my peanuts for your chips . ", " That'll be fine . Thanks . ", ' Do you have any ketchup ? ', " I forgot to bring it , but maybe Mary has some . Let's go and ask her . "]
['Harry is a hen-pecked husband . ', ' No , he isn ’ t . ', ' Then why does he let himself be lead by the nose ? ', ' He is afraid of his father-in-law . ']
['Have you ever found yourself in a situation when you have to lie to people who trust you ? ', ' Do you mean lying to people for their good ? ', ' Yes . Is it wrong to lie to them even if it is for their good ? ', " It's hard to say . I mean , how can you judge what's good for them ? Maybe it is best to tell them the truth no matter what it is . ", ' But sometimes it is so hard to tell the truth . ', " I know . If you're sure the truth will do harm , maybe you can choose not to tell it . "]
["Hi , Julie . I was in your neighborhood and I'd like to drop by . ", ' Come on in . Would you care for a drink ? ', ' That sounds refreshing . Thanks ! ']
['May , is the university a terrible place ? ', ' Surely not . Life in the university is fun . Why did you ask ? ', ' Because you study day in and day out for the entrance exam . So I figure you would study even harder after you ’ Ve got in . ', " Studying in the university is not easy , but it's not as arduous as you think . ", " How do you know that ? You haven't got in yet . ", " Of course I know . I once attended Lisa's class , sitting quietly at the back of the classroom . ", ' Oh , really ? Were you not caught ? ', " Of course not . You are allowed to attend any lecture , only if there are empty seats for you and you don't disturb the class . In universities , you study in a free and creative environment . ", ' What do you want to study in the university ? Have you thought about it ? ', ' This question has really been bothering me . I like Chinese literature , you know . But economics is really hot now , and it has a very good career prospect . ', " I will choose what I like . You don't know what a torture it is for me to study English , because I don't like English . ", " Though I like Chinese literature very much , I'm also interested in economics . It's a tough choice to make . ", ' You can decide later . You will have choices before you submit your university application form . ', ' Right . I have lots of time to think carefully before I make my final decision . ']
['Who is your favorite NBA star ? ', ' Kobe Bryant , of course . ', ' Kobe ? I know him , the key guy of the Lakers , a heck of a NBA player . He is on fire when he breaks through enemy defense . ', ' He is competent both in driving the lane and shooting jumpers , but what really makes him formidable is his ability to switch up and dribble with his left hand . ', ' Maybe he is not good at rebounding ? ', ' Indeed , no man can be perfect . He is just so-so in crashing the boards . Usually he plays shooting guard . Rebounding might not be his strong suit . ', " Kobe came to Beijing during this summer's Olympics . Did you go to the match between China and USA ? ", " Who wouldn't ! My friend Lee went so far as to get an autograph from him . ", ' Well then , what are your spoils ? ', ' Well , nothing more than a jumble of photographs . ']
['May I help you ? ', ' I would like to find this book . ', ' Is there a problem ? ', ' I don ’ t think you guys have it . ', ' You should look it up on our computer . ', ' I did that . ', ' What came up ? ', ' It should be on the shelf , but I didn ’ t see it . ', ' I can try to get the book from a different library . ', ' I didn ’ t know you could do that . ', ' I will call you when I find it . ', ' I appreciate your help . ']
['What happened ? ', ' It was just a misunderstanding . ']
['I hear little Bob has recovered . ', " That's a great relief . I was worried about him . ", ' The operation was very successful . ', ' His parents must feel very happy . ']
['Are you in favor of having a trip during the spring break ? ', ' This is just what I have in mind.Where are you planning to go ? ', ' How about the Yellow Mountains ? ', ' Good idea ! ']
['Did you go to the movie yesterday ? ', ' Yes , I did . ', ' What did you think of it ? ', " I don't think much of the film . ", ' I think it is the worst one I have ever seen . ', " Oh , I'm not sure I agree with you . It was not a good one , but it was not the worst one . Actually , it wasn't too bad . ", " I can't think the same . ", " What's more , some scenes were good , much fit for the children . ", " I couldn't agree with you . "]
['Thanks for offering to give me a lift . I ’ m looking forward to this party , but I didn ’ t want to go alone . ', ' Don ’ t mention it . It ’ s my pleasure . Have you been to one of these large , sit-down dinner parties since you got to New Haven ? ', ' No , this is my first.Last week I went to a cookout for new professors at Dean Barksdale ’ s home . I took a taxi because I didn ’ t want to be late.But I was the first one ', ' Cookouts often start slowly . A two o ’ clock start means you arrive any time after two . ', ' Thanks for telling me this . ', ' I was late getting back from the mall , but I ’ m hurrying . ', ' Why are you in such a hurry ? They said , Dinner at eight , and it ’ s only seven-fifteen . I don ’ t want to be the first one there again . ', ' Don ’ t worry . We won ’ t be the first . ']
['How did you do in the last quiz ? ', ' I doubt if I can pass it . ', " Don't be so worried , You know Professor Robert is not too strict . ", " But I often skip his classes , and he doesn't like me . ", " I hope you'll do better in the final . ", ' I must , if I want to pass the course . ']
['I am so bored all day . ', ' Why ? ', ' Jack borrowed a large sum of money from me and didn ’ t pay me back . ', ' Don ’ t make a mountain out of molehill . I am sure he will do that on his payday . ']
['Mike has changed much after marriage . ', ' Yeah . He ’ s almost become a slave , his wife is leading him by the nose . ', ' It ’ s unbelievable . He used to be such a rough guy . ']
['Say , Anna , what are you doing tonight ? Would you like to go out ? ', " Oh , sorry , I can't . I'm going to work late tonight . I have to finish this report . ", ' Well , how about tomorrow night ? Are you doing anything then ? ', " No , I'm not . What are you planning to do ? ", " I'm going to see a musical . Would you like to come ? ", " Sure , I'd love to ! But let me pay for the tickets this time . It's my turn . ", ' All right ! Thanks ! ']
["Sorry , I overslept . My alarm clock didn't go off this morning . ", ' Again ? ', " That's right , even though I did set the alarm last night . ", ' Your clock never works . Perhaps you should buy a new one . ', " Well . If it breaks down again tomorrow , I'll definitely buy a new one . ", ' Maybe by then it will be too late . ', ' What do you mean too late ? ', ' By that time , you will be fired . ']
['Do you often go to watch sports games ? ', " I go occasionally when there's a game on near home , but usually I watch it on TV . ", ' Can you recall the games ? ', " Sometimes . But I'll never forget the game in which our Chinese Women's Volleyball Team won the World Cup . It is the most thrilling and exciting game I have ever seen . "]
['How do you like your work ? ', " The work is rather hard , but it's interesting . ", ' What do you do ? ', ' I work in a publishing house . How about you ? ', " Mine isn't hard , but it's not interesting . ", ' What do you do then ? ', " I'm a clerk in a shop . "]
['May I help you ? ', ' I can ’ t find the book I want . ', ' Why don ’ t you try looking at the database ? ', ' I checked it already . ', ' Do we have it available ? ', ' It wasn ’ t there . ', ' I guess it is lost . ', ' Will you be getting another copy ? ', ' Yes , we will . ', ' Could you reserve a copy for me ? ', ' I can do that . ', ' That ’ s great . Thanks a lot . ']
['Can you help me figure out how to use this vending machine ? ', ' Yes , I would be happy to help . What do you want to buy ? ', ' I want to buy that candy . ', ' OK . So this machine will make change if you need it . Do you have your dollars ready ? ', ' Yeah , so far , so good . ', ' Next , you feed your dollars into the machine in the slot . Make sure they are smooth . ', ' Yeah , I already knew that . ', " I'm sure you know that if the dollar gets stuck , you might have to re-feed it . ", " OK , let's move on ! ", ' Now you just make your selection and pray . If nothing comes out , try again or call the number on the side of the machine . ', ' I hope it works ! ', ' Well , good luck ! ']
['What was your wedding ceremony like , Abigail ? ', ' My husband and I got married in a registry office with just two friends there as witnesses . But then we had three parties to celebrate . ', " Three parties ? That's quite a lot . That must have been expensive ! ", " Well , since my husband and I are from two different countries , and we live in a third country , we decided to have one in each country . It wasn't actually that expensive . ", " Were your parents upset that they weren't there to see you get married ? ", " I would have liked them to be there , but they couldn ’ t afford to fly out to see us , and we couldn't afford to fly out to see them , so they understood . ", " Did your husband's family get to meet your family ? ", " My husband's parents flew out to meet my family when we got married in my hometown , so that was great . Some people spend ridiculous amounts of money on extravagant wedding receptions , but we agreed that the wedding party should be less about money and more about family . ", ' That makes sense . Did you go on a honeymoon ? ', ' We waited until our one-year anniversary to go on our honeymoon to Africa . ', " You really didn't have a very traditional wedding , did you ? ", ' Not at all , but we don ’ t have a very traditional marriage either , so it suited us perfectly ! ']
['Did you read this ? It says that the number one new years resolution make is to spend more time with friends and family . ', ' Why would that be funny ? ', ' Well , think about it . We are a society that is always on the go , not because we have to , but because we want to . ', ' Why ? ', ' We work hard and spend less time at home because we are trying to provide for our family with goods and services that are usually unnecessary . ', ' I don ’ t agree , but anyways , I think you should start thinking of a new year ’ s resolution yourself . ', ' What ’ s the point ? We always make a new year ’ s resolution and by February we will have forgotten about it . It ’ s pointless . ', ' Well then maybe you should resolve to sticking to your goals and objectives . ', ' What about you ? Your gym bag is gathering dust and you still have brand new running shoes that are yet to be jogged in . ', ' Well , I would go if you kept your promise of going to the gym with me everyday ! ', ' Yeah , yeah , whatever . ']
['How did your vacation go ? ', ' I traveled the Three Gorges . ', ' What about the trip ? Do you enjoy yourself ? ', ' Yes , we had a good time . The trip was terrific . We toured the Three Gorges by boat . Its realty exciting ! ', ' Did your boat float down the river ? ', ' Yes . There are many places where the gorge is very narrow , with steep cliffs on both sides . ', ' Sounds dangerous . ', ' Yes , but we have life jackets . And we got a real kick out of that . ', ' What a thrilling trip ! ']
['What do you think of his behaviour yesterday ? ', " He's a sad dog . He came to the wedding in jeans ! ", " I don't think so . He only had no common sense . "]
['They promised us a sea view . ', ' Well , you can just see the sea . Between the factory chimneys . ', " Isn't it awful ? I can't bear to look at it . I don't think I can stand this place for two weeks . ", " Well , it can't be helped . We'll just have to put up with it . "]
["Hello , Mike , long time no see . How's everything going ? ", ' Not bad . Thank you . You look great today . And how is your husband ? ', ' He caught a cold yesterday , but he feels much better now . ', " Well , I'm glad to hear that . Please give my regards to him . ", ' I sure will . Thanks . ']
['Hello ! How are you . ', ' Not too well ! I ’ m just to the doctor . I haven ’ t been feeling too well over the last few days . ', ' What have you got ? A cough ? A cold ? ', ' That ’ s the funny thing . I don ’ t what ’ s wrong with me . I just feel exhausted . ', ' Perhaps you ’ Ve been working too hard . You do have a high-pressure job . ', ' Maybe . I haven ’ t been able to keep my food down either . That ’ s unusual . ', ' Well . I ’ m sure the doctor will be able to prescribe something to make you well again . Dr . Jameson is very good . ', ' Yes , he is . I ’ Ve make an appointment for 10 o ’ clock , so I ’ d better move along . ', ' OK . Hope you feel better soon . You should take it easy . I ’ m sure the doctor will prescribe rest , you know . ']
['If you go out recently you will find some people riding scooters in high streets and back lanes . ', ' Yes . The German engineer would never dreamed that the hand - supported scooter he invented several years ago to solve his traffic problems would become so fashionable in the Occident within a few years and even spread to Japan and China . ', " Looking at the ' five sense organs ' of a scooter , it can be said as delicate and agile . To pull the T-shaped pole and make it vertical with the flat board and then pull it vertically , adjust its height suitable to you and you may use it . ", ' Small and exquisite in size , easy to operate , foldable and easy to carry are its charms . ', ' Your two hands hold the pole , stand on the board , the other foot steps back against the ground and controls well the balance of the body , then you can ride in the air . It has a feeling of surfing . You need not let other people teach you . Your fear will disappear quickly . ']
['Hi , dear , do you know what the important day is today ? ', ' I don ’ t know . ', ' Please think it over . ', ' Oh , I see . ', ' Come on , dear . I know you mustn ’ t forget it . ', ' It ’ s Saturday , a great weekend . ', ' Ur , you really let me down . ', ' Don ’ t be angry with me . I have a bad memory . ', ' No , you haven ’ t . You just don ’ t care about me . You ’ re an indifferent husband . ', ' What day is it on earth ? ', ' It ’ s an anniversary of our weeding . ']
['Hi , dear , do you know what the important day is today ? ', ' I don ’ t know . ', ' Please think it over . ', ' Oh , I see . ', ' Come on , dear . I know you mustn ’ t forget it . ', ' It ’ s Saturday , a great weekend . ', ' Ur , you really let me down . ', ' Don ’ t be angry with me . I have a bad memory . ', ' No , you haven ’ t . You just don ’ t care about me . You ’ re an indifferent husband . ', ' What day is it on earth ? ', ' It ’ s the anniversary of our weeding . ']
['Let ’ s call it a day . ', ' It ’ s nice to go home earlier once in a while . But it ’ s the evening rush . ', ' It ’ s hard to commute a long way . ', ' Sure it is . I really hate to get caught in a traffic jam . ']
['How was your trip to America ? ', ' We had a fantastic time . ', ' Did you go to the Magic Kingdom ? ', ' No , but we went to the Kennedy Center . ']
['How do you like these dishes ? ', ' Fine , they are colorful and tasty . ', ' Did you enjoy your dinner ? ', ' Yes , I did . I have never tasted anything like this . ', ' Would you like some more rice ? ', " No , thanks . I'm full . ", ' Another piece of meat pie ? ', " No , thanks . I'm on diet . ", ' How about the dessert ? ', ' Ice cream , please . ']
['What was the movie you saw last night ? ', " It was a foreign film called ' Gone with the wind ' . ", " Really ? I've seen that movie , too . ", ' How did you like the movie ? ', ' I thought it was pretty good . ', " I can't say I agree . ", " You're kidding . The storyline and acting were outstanding . ", ' I guess I expected too much from the movie , so I was a bit disappointed . ', ' It might be . ']
['Tom , aren ’ t you a little too old to be trick-or - treating ? ', ' What are you talking about ? Where is your Halloween spirit ? Didn ’ t you ever dress up in a costume and go around the neighborhood trick-or-treating with your friends ? ', ' Of course , I did , but when I was ten ! Trick - or-treating is for kids , plus , I ’ m sure people will think you ’ re a kidnapper or something , running around with kids NCP at night . ', ' Whatever , I ’ m going next door I heard Mrs . Robinson is giving out big bags of M & Ms ! ']
['I hear Yolanda has been studying every night this week for the exam . ', " That's good , but I think it's too late . She hasn't studied all semester , and I doubt she can catch up in one week . "]
["Hello . I'm Jason . ", ' Hi . My name is Dolma . ', ' Nice to meet you , Dolma . ', ' Good to meet you too . ']
['When and where were you born ? ', ' I was born in Beijing in 1965 . ', ' You look so young . ', ' Really ? Thank you . ']
['How about the hiking ? It was freezing yesterday , are you all ok ? ', ' Can ’ t be better , it was wonderful . We had a lot of fun there . There was so much joy and walk and breathe the winter air . We arrived at the park at 9 o ’ clock in the morning and didn ’ t leave till 3 o ’ clock in the afternoon . ', ' You had been walking for 6 hours , isn ’ t that boring ? ', ' Of course not ! We built a snowman , some snow dogs and one big snow fort . We went sliding on the nice hill . It was a real work out . At noon , we had the most special winter picnic outside . Fortunately , we got it all on a video tape . You must come with us next time . I bet you will love it . ', ' Well . You know I hate walking , but I can ’ t wait to see your guys ’ video . ']
['Do you believe in horoscope fortune-telling ? ', " I used to be an atheist . But in recent months , I couldn't but form a more favorable opinion of horoscope . ", ' That sounds interesting . Have you been involved in any mystery ? ', ' Not exactly , except that I find horoscope predictions increasingly accurate . I came upon a website which sends me an up-dated message by e-mail each day forecasting my experience in detail . It is amazing to find these forecasts largely in line with my daily life . ', ' What did it say about you then ? ', ' For example , the message for the day before yesterday notified me that I , as a Leo guy , was to have some " unusual experience in food and drink . And as it turned out , the reality matched this prediction well . Lasi night , I was treated to a dinner party by Mr . Lee . ', " But it must have been only a coincidence . That's the only way superstition wins over science . ", ' Oh , no . You can never tell whether such-and-such is science or sheer fraud.If horoscope is really something deceptive , how come quite a size of proportion of young people think highly of it . ', ' For fun . It serves as a shared topic to them.While they claim to consult the predictions constantly and marvel at their " accuracy \' . they do not necessarily take them seriously . When it that these predictions are matched by their real-life experiences , they delight in spreading the thrill with friends . But if there isn\'t any correlation between reality and predictions , they just grin , forget about them , and go on living as usual . ']
["Don't have some relation with him . You know , he is not a kind man . ", ' Yeah . Sometimes I just cannot accept his behavior . ', ' If you attack him , be sure you ’ ll get a Roland for an Oliver . ', ' OK , it ’ s better to be far away from him . ']
["It's nice and bright today , isn't it ? ", ' Yeah.The autumn is marvelous here . ', ' How about winter ? ', " That's a hard time.The air is cold and damp , and the road is often icy . ", " It's boring , right ? ", ' Sure . ', ' Do you get much rain during the summer ? ', ' Plenty.We never worry about lack of rainwater in our area . ', ' So you should bring an umbrella often . ', " That's right . "]
['You don ’ t look like enjoying this workout . ', ' I ’ m not crazy about it at all . ', ' You don ’ t like this sort of exercise ? ', ' I ’ m not interested in it . Are you keen on it ? ', ' Yes , that ’ s funny . I thought you liked it . ', ' I hate it . ', ' Never mind . It ’ ll be over in 10 minutes . ', ' It ’ s the worst thing I ’ Ve ever tried . ']
['Hi , Jenny . Are you going to school now ? ', ' Yup . I have English at 9 in the morning . ', ' Got any plans after the class ? ', ' Not really . What about you ? ', ' We will have our midterm exams next month . I plan to look for some important books and study at the library . Do you want to join me ? ', ' Sure . I need to return some books . They are due today . Besides , I can also read some weekly publications , magazines and newspapers . ', ' Great . We can go to the swimming pool in the gymnasium after that . ', ' That sounds like a good idea . We can chill out a little in such a hot summer . Are you good at swimming ? ', " Well , that's a good question . I haven't swum for almost two years . I think I need more practice . ", " Oh , it's almost 9 . I need to hurry . I am running late now . See you after class in front of the library then . Bye ! ", ' See you then . ']
['Linda , would you care for some candies or cookies ? ', " No , don't try to tempt me . I'm becoming chubby , and I have to slender down . ", ' You are not really chubby . You are actually thin enough . ', " I don't think so . I know I've put on weight this winter . ", " So you are watching your weight , aren't you ? ", ' Yes , to tell you the truth . I am on the diet . ']
['Did you listen to the weather forecast ? ', ' No . Why ? ', " There's a typhoon coming . ", ' No way ! ', ' Yep , it should be here by tomorrow night . ']
['... I knew it . I always knew you were a lesbian ! ', " She's my roommate , not my date . The D-man , as in dork . ", " Haha . Still got that great sense of humor , I see . Here's my card . I sell used cars . A car from us is a car you can trust ! ", " Alrighty then . Didn't you use to date Sheryl ? ", " Sweet little lassie . Yep , broke her heart when the D-man told her he couldn't be a one-woman guy . ", " Oh ? I heard she dumped you . Anyway , she's right over there . Oh , Sheryl ! "]
['Which team do you think will emerge with the last laugh in this World Cup ? ', ' I wish it could be Germany . But it seems they are not in a very good conditions . ', " No , they aren't . They had a hard time in the group stage and only sealed a sit in the eighth-finals with Wallack ' s header in the final three minutes . Just think , group A consists of Austria , China , and Saudi Arabia , all of which are minnows . ", " It seems they've been out of luck since the beginning of the event . Their shots hit the woodwork as many as six times . Oh . my goodness ! I'm afraid the team is under a spell . ", ' Well , at least the Germans have demonstrated a very good ability to control the midfield . They recorded a total of 62 tackles in the match against Austria . And they to be endowed with perfect positional sense . I think that will give rise to scoring chances sooner or later . ', ' I agree . Eeven though German attackers are not good at dribbling past opposing defenders , they breach the defensive line through quick movements to the right attacking positions and through accurate , well-timed passes . ', " That's why I still have very high hopes for the team . Now that the tournament has proceeded into the knock-out stage , the Germans will probably make it through to the finals . ", ' Yes . They have a good reputation for their tenacity and discipline , especially in vital , decisive encounters . ']
['The woman was beaten again . Why didn ’ t she call the police . ', ' Because it was her husband who beat her . ', ' It is incredible . ', ' She said that she didn ’ t want to foul her own nest . ']
['Are you feeling better today , Bill ? ', " Well , it's hard to say . I cough a lot in the evening . ", " You'd better give up smoking . It's bad for your health . ", " You're right , but you know , it's hard to give up an old habit . ", ' But you should make up your mind first . ', ' You know , I often have to work till late at night . I need something to keep me awake . ', " Why don't you go to bed and get up early ? You'll have the same time for work . ", " Thank you for your advice ! I'll try it . "]
["I don't know why people are just mad about David Peckham . Is there really anything so fascinating with him ? ", ' He appeals to the fans thanks to two things ', ' you mean he plays well ? Yeah , he often scores by free kicks in crucial games . But a football match is by no means merely a show of taking free kicks . ', " Certainly not . What really counts is to play as a team , passing the ball amongst each other , dodging defenders . Free kicks are a result of all the teammates ' collective efforts . However , a few free k ", ' In the case , maybe facial charm should be his leading card . After all , the majority of his fans are girls . ', ' yes , his face looks are manly , with a straight nose and infinite eyes . As a man of medium height in the West , he keeps a powerful but elegant figure , looking neither lanky nor stout . ', ' and he is English ! He makes a model gentleman when he puts on a black suit and speaks with a typical British accent . ']
["What are you reading ? You've had your nose buried in that book since last night . ", " This book is so good . I just can't put it down ! It's called ' The Power of One ' . ", " I haven't read a book like that for as long as I can remember . ", ' Me either . From the very first page , this author just pulled me right in ! ', " Can I read it when you're finished ? ", " Yes . I'm in the last chapter now and it is just gripping . ", " Don't tell me anything about it . I want to read it for myself . ", ' Okay . But be prepared for an all-nighter ! I doubt you will want to put it down either . ']
['Did you have a part-time job when you were still in school ? ', ' No . I was way too busy studying all the time . How about you ? ', ' Yeah . I worked about 20 hours a week in a pizza restaurant . ', ' What was that like ? ', ' It was always very busy there . ', ' What did you do ? ', ' I stood behind the register and took pizza orders . ', ' Did you get any perks on the job ? ', ' Yeah . I got to eat as much pizza as I could for free . ']
['May I introduce myself ? I am steven smith . ', ' Glad to meet you mr smith my name is jenny . ']
['Don ’ t be worried . Please sit down and take it easy . ', ' How could I feel easy ? I ’ m really pissed . ', ' But you should avoid finger-pointing when you haven ’ t got the real facts . ', ' Ok . I ’ ll try my best to calm down first . ']
['That looks like an interesting book . ', ' It is . It ’ s got pictures of interesting building from all over the world , with brief descriptions of how they were build , their purpose , and so on . ', ' There are the pyramids . It ’ s easy to see how they got that name ! they don ’ t have smooth sides though . ', ' They don ’ t now , but most of them did originally . There ’ s picture of the pentagon in the united states . It ’ s very distinctive with its five sides . ', ' Look at that cylindrical office building . I ’ Ve never been seen one that shape before . ', ' Yes . Usually only TV towers are cylindrical in shape . ', ' TV towers are usually thicker at the bottom than at the top . They ’ re not perfectly cylindrical . ', ' This is the world ’ s largest sports stadium . It ’ s a massive oval . ', ' What sports do they play there ? ', ' It says here that it ’ s m mainly used for big football matches and athletics meetings . ', ' Is that building a perfect cube ? ', ' According to the book , it is . I ’ Ve never seen a building that is a perfect cube . Look at the building . From the air , it looks like a square with a semi-circle attached to each of its four sides . What ', ' Is says here that it ’ s a war memorial . Now , there ’ s a distinctive structure-the stomium in Brussels . See ? It consists of several connected by cylinders . I believe you can go up and down inside it . ']
["Hey Bobby . What's going on ? ", ' Just taking a smoke break . ', ' I forgot my cigarette today . Do you have another one ? ', ' Sure . Here you go . ', ' Thanks . ', " I didn't know you smoked . ", " Really ? I've been smoking for over a year now . ", " Oh . You're new to smoking still . I've been smoking for 7 years . ", ' You ever tried to quit ? ', " Many times . I'm really addicted . It's harder to stop than you think . ", " Yeah . I tried to quit last month , and I thought it was going to be easy , but it turns out that I'm still smoking . ", ' I highly recommend you quit soon . The longer you smoke , the harder it becomes to quit . ', " I think you're right . Aright . Gotta go to class . Thanks for the cigarette . I'll talk to you later . ", " No problem . I'll talk to you later . "]
['Do you know who ’ s just got married ? Old Mc Donald . ', ' Never ! He ’ s over 80 , isn ’ t he ? ', ' He ’ s nearly 90 . ', ' Good gracious ! Are you sure ? ', ' I am . Whatsmore , his wife is 84 . ', ' Is she really ? ', ' Yes , she is . And guess what , he is her sixth husband . ', ' Really ? Quite a woman , isn ’ t she ? ']
['What did you do last night ? ', ' I just stayed at home and watched TV . ', ' Did you watch the Barcelona versus Madrid game ? ', ' Yes , it was a very evenly matched game . ', ' What were the results of the game ? ', ' It ended in a tie . ', ' What was the actual score ? ', ' It was three all . ', ' Really ? I thought Barcelona was going to win . They are a much better team than Madrid . ', ' If Barcelona had played as they normally do , they should have won . ', ' What happened ? ', ' Their goalkeepers got injured after the first goal , but he kept on playing anyway . ', ' That explains it . ', ' How many more games are left this season ? ', ' That was the last game before the playoffs . ', ' When do the playoffs start ? ', ' In a few weeks . Are you planning on watching them ? ', ' Of course ! I really love watching football games on TV . ', " Me , too ! Do you want to come over and watch the next game at my place ? I'm planning on having a few people over to watch it together . ", ' Sure , that would be great . ', " Ok , it's a date then ! "]
['The acting of this film is marvelous.In spite of the thin plot , the acting , the music and the scene have won the Academy Award of this year . ', " I'm sorry for hero . I dont think there's any excuse for his acting in some parts . ", " Don't be too critical.We can't expect it to be perfect . "]
["Last weekend I didn't want to go out either , so I stayed at home and played video games by myself . It was really fun ! ", ' Oh yeah , that sounds pretty cool , I guess ... ', " Yeah , I'm really into video games . In fact , all my friends are on the Internet . I've never met any of them in the real world . ", " Oh really ... well you must be very popular on the Internet . But it's true that it's nice to do some things in the comfort of your own home . "]
['Hello , Pam . ', " I'm glad that you can make it . ", ' It looks like there are a lot of people inside . ', " Yeah . I've invited a lot of friends besides you . ", ' Should I take my shoes off ? ', ' We all keep our shoes on indoors . ', ' Where are your parents ? ', " They've gone out so that we could have the house to ourselves . ", " That's great ! "]
['Will you go with us this Sunday ? ', ' What for ? ', " Let's go and play volleyball . ", " Sorry , I don't feel like playing . I have too much homework . "]
["I think it's about time that we had to go . ", " What ? Won't you have more drinks ? ", " I'd love to , but I have to get up early tomorrow and get to the office on time . ", " Oh ! I'm sorry , but I wish you could stay . ", ' Thank you for a very enjoyable evening and your hospitality . ', " Don't mention it . You can come whenever You are free . "]
['Wow , Is winter always this cold in Taiwan ? ', " Not really . It's much warmer usually . Your are not used to cold weather ? ", ' No , I am from south California . This is my first real winter . ', " Well , You'd better get some more warm clothes . ", " What's the temperature today anyway ? ", " I would say it's about 5 degree Celsius . "]
['When is your birthday ? ', ' August 1st . ', ' Do you usually have a birthday party ? ', ' Yes , we do.My parents prepare dinner for me . ', ' What would you do at the party ? ', ' We sing " Happy Birthday " at the party and have birthday cakes . ', ' Do you know when people began to sing the song " Happy Birthday " ? ', " Well , I don't know . ", ' Let me tell you the story.In 1892 , Patty Smith Hill and Mildred Hill wrote a song called " Good Morning to you " . But later someone added the words " Happy Birthday " to their tune . ', ' So the " Happy Birthday " song has been popular since then ? ', ' Yes , actually , the song has been sung since its publication in 1932.People all over the world have sung it in many different languages . ']
['What do you think of your teacher ? ', " He's very strict with us . ", ' And I hear he gives very good lectures . ', " Indeed . He's strict with himself , too . We can see every lecture of his is well-prepared . "]
['I ’ Ve got a new boss . ', ' Oh , what ’ s he like ? ', ' Well , he ’ s got dark hair and brown eyes . ', ' Yes . ', ' And a white sports car . ', ' Um , that ’ s good . ', ' Yes , but he ’ s got a wife and 3 children as well . ']
["I'm very grateful for what you have done to my son , doctor . ", " That's all tight , Mr.Smith.That ' s my job . I'm very glad he recovered so soon . ", ' I know he has brought great trouble to you . A million thanks . ', " No trouble at all . He's very cute and brave . By the way , do remember to keep him away from sea food for at least two weeks . ", " I will . It's most thoughtful of you . "]
['Would you like to have dinner with me tonight ? ', ' Oh , that sounds great ! ', ' I ’ ll pick you up at ... say , seven thirty ? ', ' Yes , that would be perfect . ', ' See you tonight then . ', ' Yes . Thank you for inviting me . ']
['Excuse me , could you tell me where you have got that music book ? ', " Certainly . Let me see . Oh , it's on that self . ", " It's too high . I can't reach it . Could you help me ? ", ' Of course . Here you are . ', ' Thank you very much . ']
["Thank you so much . I can't take this . ", " She will insist . It's a rosary . She has millions of them . Take it . ", ' What did she mean just now about raising pigs ? ', ' Oh ! My grandmother used to say “ raising pigs , raising kids ... at least you can eat the pigs . ” ', " Ha-ha . I get it . That's funny . Your cousin's a real sarcastic lady . ", ' She likes to complain about her macho husband and her “ bambinos ” , but she loves them all dearly . ']
['I ’ m hungry , let ’ s grab a bite to eat . ', ' Sure ! How about we go home and prepare a couple of sandwiches ? ', ' Nah ! Let ’ s go get a burger and fries . ', ' All you ever do is have unhealthy fast food Pizza , fries , burgers and hot dogs ! You have to start eating better ! ', ' What are you talking about ? I have salads some times . ', ' Yeah right ! I ’ m serious ! You should also cut down on your sugar intake as well . You drink carbonated drinks that are high in fructose syrup ! It ’ s really not healthy ! ', ' Fine ! I ’ ll start drinking and having home cooked meals that are low in fat . Are you happy now ? ', ' It ’ s a start , but I ’ ll be happy when I see you stick to your promise ! ']
['I hear you and James are engaged at last . ', ' Yes , we are . ', ' When are you getting married ? ', ' In the spring . ', " Oh , lovely . Where's the wedding going to be ? ", " Well .. we're not sure yet , probably in St.Albans . ", " Oh , yes , your parents live there , don't they ? ", " Yes , that's right . ", " Where are you going to live after you're married ? ", " We're going to buy a flat or a small house somewhere in South London . ", ' Are you going to give up your job ? ', " Yes , probably but I may look for another one when we're settled in . "]
['Daddy , I want to buy a ten-speed-sportsman . ', ' How much is it ? Is three hundred dollars enough ? ', " No , I'm not asking for money . I'm asking for your advice . ", " Oh , you've already grown up , son . "]
['I feel pity for the old man . ', ' I feel the same way . ', ' It must be dreadful to grow old . ', ' Yeah . He has no one to count on . ']
['What a nice photo you ’ Ve taken ! ', ' I ’ m flattered , but really anyone else could do it . ', ' You have a real talent , Ellen ! ', ' I ’ m thinking of making an album , you know . ']
['I don ’ t dare to look after the children now . ', ' Why ? ', ' The children always make themselves in danger . I always have my heart in my mouth with them . ', ' It is because your children have grown up , and you haven ’ t lived with a child for a long time . ']
['Is there anything I can do for you ? ', ' Yes , the fried chicken is too hard to eat . I suggest you bring me another one free of charge . ', ' Well , I think you should go for our manger . I will call him here . ', ' OK . I will talk to him direcly . ']
['Why did Tom quit the job ? ', ' He said his present job seemed to be a blind alley . ', " If he doesn't change his attitude toward his work , I don't think a new job can make any difference . "]
['I want to buy a gift for my father . Will you go with me to choose one for him ? ', " Sure . Is it your father's birthday ? ", " Don't you know ? Tomorrow is Father's Day . ", ' Oh ! How could I forget such an important holiday ? ', ' You also need to choose a gift for your father , right ? ', " Yes , let's go . "]
['Jane is going to quit her job in the bank . ', ' You must be joking . The job is nice and she is well paid . ', " It's true , but she says she is tired of counting others ' money . "]
['How long have you been in China ? ', ' A few months . ', ' How do you think of living here ? ', " Great ! I'm having a great time . "]
["Let's go see pandas ! The news said that two pandas arrived at the zoo last week . ", ' Great ! I would like to see cute pandas , too . ', ' How can we get there ? ', ' We can take the MET and get off at the Zoo Station . ', " OK ! Let's go . ", ' ( At the zoo ) Wow ! This zoo is really huge . ', ' Yes , you can find hundreds of various animals here . It is the biggest zoo in Taiwan . ', ' Look at the map . It has different areas , such as marine lives , mammals , polar animals and insects . ', ' Where can find the pandas ? I think we are here to see the pandas . ', ' We have to go to the mammal area . We are at the gate right now . We need to go straight from here and turn left and go along to the end and make anotherleft turn . ', ' It should take at least 20 minutes to get there . Are there any shuttle buses running place to place around the whole zoo ? ']
['Finding an excuse is obviously down your alley . And trying to avoid taking care of the children is what you are good at . ', " Listen , Nancy . If I don't work hard , I will be laid off . ", " You are passing the buck . I'll be hanged if I ask you to go to the park with us . ", ' Come on , Nancy . Play it cool . I go with you and burn the middle night oil tonight . ']
['Thank you for showing me your offices , Mr . Becker . I can see why Washington bureaucrats enjoy their jobs . ', ' Why do you say that ? ', ' The city is beautiful , the off ... , the offices are modern and comfortable , and the work is so interesting . ', ' Many people work for the federal government their entire adult lives . Government service can be a rewarding and secure career . ', ' Do you mean financially rewarding ? ', ' Well , many positions pay salaries that are comparable to those in private industries . ', " I've always thought that most bureaucrats are lazy . ", " Sometimes that's true , but not usually . Most feds are honest , hard-working professionals . It ’ s hard to keep highly trained people , so the pay and working conditions have to be attractive . ", ' How much do you make ? ', " I'm a GS - 15 . That's high on the scale of workers , but even a GS - 1 is paid a living wage . "]
['I just got fired . ', ' You asked for it . ']
['Hello ? ', ' Hi , Kathy . Have you had lunch ? ', ' Not yet . And I ’ m really hungry now . ', ' I ’ m starving , too . There is a new Chinese restaurant close by . Do you want to go there for lunch ? ', ' Why not ? ', ' It ’ s my treat this time . ', ' Thanks . I could eat a cow . ']
['Would you like to see our new shirts ? ', ' Sorry , but I ’ m not really interested in those things . ', ' But they ’ re very nice , you know . ', ' Really . ', ' And not expensive either . ', ' Oh , I don ’ t care about that . ', ' Everybody is buying them . ', ' Are they ? ', ' Yes , they ’ re very fashionable , you see . ', ' I ’ m afraid I ’ m not interested in fashion . ', ' I see . ', ' But thank you very much all the same . ', ' Sorry , I couldn ’ t help you . ']
["Hi . What's up ? ", " Nothing much . What's new with you ? ", " Not too much . I've been pretty busy . ", ' Me too . Seems like all I do is eat and sleep . ', ' Gotta go . Call me tonight . ', ' Okay . Check you later . ']
['Hey , what sort of drinks do you want ? Gatorade or water ? ', ' Gatorade . It ’ s rich in Vitamin and it gives us energy and vitality . ', ' Yes , that ’ s the exact thing we need . One for each . ', ' What should we do , now with Jack out of the game ? ', ' We should choose from the backups . ', ' That ’ s right . Spraining the ankle and breaking the leg are the common things during the match . ', ' That ’ s why we should learn to protect ourselves . Otherwise , the game is not worth the candle . ', ' That ’ s for sure . During the back court , we should change the position we played . ', ' Yes , I played shooting guard , I like shooting and you ’ ll play inside , OK ? ', ' I agree with you . I think we ’ ll play much better than before . ', ' Wow , the cheer-section is coming . The music is so fantastic . ', ' Yeah , look how passionate they are ! Are they professional ? ', ' Well , you should ask your friend . You know I ’ m not the boss . Just kidding . ', ' Oops ! I almost forget about it . Do you see the girl in the middle of the first line ? ', ' Yeah , what ’ s up ? ', ' Don ’ t you think she looks like your daughter ? ', ' I also have a doubt . Oh , kill me softly , she is May . ']
['Welcome to my birthday party , I am so happy you can come . ', ' Thanks for inviting me . Here is the gift for you . Happy birthday , Francis ! Many more happy and healthy years for you ! ', ' Thank you , shall I open it now ? ', ' Yes , please do . ', ' Wow , a remote car model and my favorite brand . I really like it . That is so nice of you . ', ' Yeah , I was really struggling whether I should give you this nice little car . It was the last one they had and I really like it so much myself . ', ' Typical you , always wanting to keep the best things for yourself . The more I appreciate the gift now . ']
['Hi , Mark ! Long time no see ! ', ' Hi , Alex ! ', ' Where have you been ? ', ' I just got back from London . ', ' How was your flight ? ', ' It was OK . There was a lot of turbulence , though . ', ' That ’ s too bad . How long was the flight ? ', ' It was 10 hours . ', ' Did you have a layover ? ', ' Yes , in Paris , France . ', ' Did you buy anything in the duty-free stores ? ', ' Yes . I bought two boxed of chocolate – one for me and one for you ! ', ' Oh , you didn ’ t have to ... ', ' It was nothing . ']
['I wish our competition will quit poaching our people , when Susan resigned last week to work for the Sunburst , she was our fourth employee to leave us for them . ', " Have you ever considered that perhaps we have a morale problem among our employees ? If everyone is discontent with their work , of course they won't stick arround . ", " Well , those do leave will soon find out the grass isn't as green on the other side of sense as they thought it was , I know Sunburst is suffering from inbreeding . ", ' Inbreeding is a big drawback from snitching most of their employers from one or two companies . ', ' With Susan leaving , we should probably look to someone new on board . ', " Our human resource department is working on it , it's not easy to recruit new employees every few month , it's hard to find qualified people . ", ' Maybe we should start shopping around the competitors people . ']
['Do you have a bf ? ', ' Yes , I had a bf before . ', ' Why you say bf before ? ', ' We parted from each other last month . ', ' Have you got a new one ? ', ' Mmmm , no . How about you ? ', ' I am single , I have no real of , only an E-gf , that is you . ', ' Haha , so you are my E-bf . ', ' I like you . Do you agree to be my of ? ', " Mmmm . .. OK , let's try to be . ", ' Wow ! Blablablabla . . . ', ' Hey ! What is it ? ', ' I am flying like a bird . ', ' LL ', ' I am so happy . I want to drink a cup of champagne . ', ' I have no champagne right now . How about this ? ', " It's OK , so I send you this . ", ' Is it made of chocolate ? ', " It's my heart ; it's made of what you like . ", ' Oh , I will have a sweet dream . ', ' Are you sleepy ? ', " A little bit . I have to go to sleep though I don't want to . ", ' Yes , I do not want to see ur sleeping in the office . ', ' Thx.Bye for now . Kisssssssssss . ', ' C U here , honey . ']
['Hello , Kevin . ', ' Oh , hi , Lee . You look great . ', ' Thanks . You too . ']
["What's the weather forecast for today ? ", ' Cloudy in the morning , overcast in the afternoon . ', ' Any rain ? ', " No , but I wouldn't be surprised if it rained tomorrow . ", " I wouldn't either . It's been looking like rain for several days . "]
['Which do you like better , orange or lemon ? ', ' I like orange better . ', ' Why ? ', ' Because orange is much more to my taste . ']
["You hurt Ben's feelings . ", ' So ? ']
["have you ever seen Bill Gate's home on the internet ? ", " no . what's it like ? ", " it's got its own library , theatre , swimming pool , and a guest house . The house itself has about ten different rooms that are all hooked up to computers so you can get things done in each room through ", ' would you want to live there ? ', " I think his house is fantastic , but I wouldn't want to live there . You would have to hire one or two people to clean all the rooms in the house , plus a few people to take care of the gardens , and pro ", " what's your dreamhole like then ? ", ' my dream home is actually just a small cottage in a quite village in England . ', ' would you want to buy an old cottage or build a new one yourself ? ', " old homes are great because they've got character . I think that's important . ", " it that why you wear second-hand cloths as well ? Because they've got character ? ", " no , that's just because I don't have enough money to buy new cloths all the time ! ", ' I see . If you lived in an old house , would it be decorated in a modern way ? ', " no , I'd definitely try to restore it to its original state . I love to imagine what it'd be like to live in another time in history and living in a house decorated like it would have been 200 years a "]
["When I quarrel with my husband . He didn't even try to cool me out . ", ' It takes two to make a quarrel and it takes two to mend fences . ', ' I was so angry that I could not keep cool . What I need is just an apology . ']
["You're just left school , haven't you , Emily ? ", ' Yes , I finished last Friday . ', ' You sound relieved . ', " Well , yes . I don't mind admitting that I am . I enjoyed school , but I did object to having to go in every day once we've done all our exams . ", ' Well , what are you going to do now ? Have you made any plans ? ', " Yes , I intend to go to university.That ' ll be in September.But it all depends on my A level results . ", ' You mean getting into university actually depends on your passing your A level subjects ? ', ' Oh , yes . ']
["That was a great dinner . I didn't know that you knew how yo cook . ", " I'm glad you liked it . Are you ready for dessert ? ", " I don't know . I'm pretty full . What are we having ? ", ' I made strawberry shortcake . ', " Ooh , that's my favorite . Maybe I'll have a small slice . ", ' Great . Would you like coffee or tea with that ? ', " I'll have a cup of tea . ", ' Do you take cream or sugar with your tea ? ', ' Actually , could I have some milk with that ? ', ' Definitely . Would you like skim or whole milk ? ', " Skim , please . That'd be very nice . Thanks ... oh no . Janna , I'm so sorry , but I've got to go . ", ' What happened ? ', " I just got a message from my sister saying that she's been in a car accident . I need to go pick her up . ", " I'll go with you . Where is she ? ", " She's on the M40 , near Reading . ", ' Is she alright ? ', " I don't know , she didn't say . I'm so sorry about this . ", " Don't worry . Family comes first . Come on , let's go . ", " Actually , I've only got a two-seater . I'll have to go on my own . ", ' Ok . Just call me if you need anything then . ', ' I will . Thanks a lot . ']
['You look upset , is there anything wrong ? ', ' Yes , to tell you the truth , there is . ', ' What is it ? ', " Well , I've lost my wallet and my ID card . ", " Oh , that's too bad ! I am sorry to hear that ! ", ' Forget it , there is no use crying over the spilled milk . ']
['Diana , do you like the perfume I gave you ? ', ' It ’ s good . But to tell you the truth , I don ’ t wear perfume . ', ' I ’ m sorry . I didn ’ t know that . ', ' That ’ s all right . Thank you all the same . ']
['Are there any interesting stories in the newspaper today ? ', ' There are a few stories about natural disasters . There is a massive forest fire in Australia . It covers several square kilometers of land has destroyed many more square kilometers . ', ' Was it caused accidentally or naturally ? Sometimes it gets so hot that fires begin naturally in Australia and Africa . ', ' Nobody knows at the moment , but it has been very hot there recently . The drought in Africa is causing starvation . Millions of people have migrated to try and find food . ', ' What is the international community doing to help ? ', ' The European union has sent several plants with relief supplies . Several countries have sent soldiers to distribute food and medical supplies . Refugee camps have been set up across the region . ', ' How many countries have been affected ? ', ' Six have been seriously affected , but the refugees are also migrating to several surrounding countries . ', ' I saw on the tv yesterday that there has been another earthquake in Iran . ', ' Yes . There have been a few there recently . They say that this one was not a big quake . The Iranians are dealing with it on their own . They have purchased some special equipment to find people buried under rubble . ', ' Does the newspaper say anything about casualties ? ', ' So far , less than 20 people have died , but over 100 are in hospital . ']
['Where are you going for your trip ? ', ' I think Hebes is a good place . ', ' But I heard the north of China are experiencing severe sandstorms ! ', ' Really ? ', " Yes , it's said that Hebes was experiencing six degree strong winds . ", ' How do these storms affect the people who live in these areas ? ', " The report said the number of people with respiratory tract infections tended to rise after sandstorms . The sand gets into people's noses and throats and creates irritation . ", ' It sounds that sandstorms are trouble for everybody ! ', ' You are quite right . ']
['hi , how are you doing ? ', " everything's great . And you ? ", ' same here . Have you seen any new films recently ? ', " no , I haven't had a chance to . But I've been watching a Chinese TV series called Chinese-Style Divorce . ", " oh , really ? I saw it two years ago . It's worth seeing and it's thought-provoking . ", ' yeah . I found it is so close to our life . ', ' it reflects some of our difficulties in this ever-changing world . ', ' you said it . You know , the divorce rate has been on the rise in recent years . ', " well , it's said that a lot of young people favor getting married quickly which tend end quickly too . ", ' I know a couple who divorced a week after getting married . ', " oh , that's too short-lived . ", " that's true . It's said the short-lived marriage is typical of the post - 80s generation . ", " I can't agree more . The only-child generation in China tends to know little about marriage . ", " definitely . They don't take relationships and marriages very seriously . ", ' in their mind , love is nothing but passion and marriage is over once the passion is gone . ', ' I think , as the saying goes as the saying goes haste makes waste , it is the same thing with marriage . ']
["We should keep Frank at arm's length . ", " Yeah . He's known as a sly dog . He's done many people in . ", ' He hits below the belt . ', ' And he may cash in on people whenever chances are provided . ']
['Did you read the letter in the paper about smoking ? The person who wrote that must be crazy . ', " I don't think so . I think the government should do everything it can to discourage people from smoking . ", ' Maybe so . But a law banning cigarettes would do no good . ', " No.You can't suddenly make smoking illegal . But the government could prohibit smoking in public places like cinemas and theaters . "]
['So Beth , what kind of music do you listen to ? ', ' I listen to a lot of hip hop . What about you ? ', ' I mostly listen to pop music , but I like a lot of different stuff . ', ' Yes , me too . I mostly listen to hip hop , but there are many genres of music I like . ']
["Tomorrow's Carl's birthday ? ", " Yes.Let ' s hold a birthday party for him , shall we ? ", " Good idea ! Let's make ready , then . "]
["I know I'm a blabbermouth , but what do you think she should do , John ? ", " Honey , we're in the museum now . We're not here to discuss your coworker's love life . We're here to enjoy the great paintings by Picasso ! ", " I know ! But it's really important to her ! Her whole life could be ruined by this man ! ", " You're making a federal case out of it . One unhealthy love affair can't ruin anything . It could even make your life more interesting . ", ' Are you serious , John ? ', " All I'm trying to say is that life is ... like ... er ... this painting . "]
['Don ’ t you think it would be an idea to name the ship Dolphin ? ', ' All right , if that would make you happy . ', ' So you ’ Ve got something on your mind , I guess . ', ' Well , nothing really serious . ']
['Have you decided what you are going to take next semester ? ', " Well , I'm an English major , you know.So I came here to make sure I'm taking the right things . ", " Good . I think it's a good idea . Our department should require meetings like this . ", " I want to finish my degree in four years.So I don't want to forget to take classes I need . I have a friend who has to stay in college another year.She didn't know until recently . There were some classes she needed to take to graduate.She didn't know about them . ", ' Yes , that happens . ', ' I brought my transcript from my first year.Here . And here is the list of courses I plan to take in the fall . ', " Alright . Good . I see you've already taken six credits of your breadth requirements.You have one botany class and one chemistry class . And political science.So that's nine credits . Did you take English Composition 201 ? ", " No , I don't need to . I took Advanced Placement English in high school.So I'm not required to take composition . ", " Excellent . I see you have the 18th century poetry class for next semester.And the modern novel class . You haven't taken a Shakespeare class yet . ", ' No , I thought I would take it later . ', ' Actually , I recommend you take Shakespeare sooner rather than later . ', ' Well , I suppose I could cross out the 18th century poetry class . I have to see when the Shakespeare class meets . ', ' Let me look at the timetable.Shakespeare meets Monday , Wednesday and Friday at 11 ', ' I can take it then . I have that time slot free . ', ' Good . I recommend it . Shakespeare is of course enormously important.We want our students to take the class as soon as they can.And Professor Friedman is an excellent teacher . ', " I'll take it then . ", ' Tell me , Lisa , what made you decide to be an English major ? ', ' I want to be an English professor in the future . I love studying literature , and I want to teach it . ', " Really ? That's great to know . ", " That's the reason I want to finish my B . A . in four years.Because I know I will be in school a long time . I want to start the M . A . and Ph . D . program as soon as possible . "]
['hey , Lucas , how was your trip to Paris ? ', ' it was wonderful , but I was so tired . ', ' did you go to the top of the Eiffel Tower ? ', ' yes , that was the first thing we did . We went all the way to the top . There were visitors from all over the world taking photos there . ', ' what else did you see ? ', " art galleries , cathedrals , statues , fountains , palaces , bistros , there's really too much to say . ", ' you must have had a great time . ', ' yes , at the beginning we were all excited and had lots of fun . However , on the third day of traveling in the city , I felt sick . I think I had something bad to eat , but it passed by the evening . ', " yes , you need to be careful with what you eat when you're abroad . Sometimes new food might disagree with you . ", ' on the fouth day , we went to taste the French cuisine . That was really fantastic ! And no stomach problems . ', ' that is great . Everyone says French food is wonderful . ', " you'll have to try for yourself some day . "]
['Excuse me . ', ' Yes , Miss , what can I do for you ? ', " I ordered my dish about a half an hour ago , but it hasn't arrived yet . ", " I'm sorry for that , I'm going to check with the chef right now . Miss , I just checked with the kitchen , and they said your order will be coming right up next . Oh , here comes . ", ' Thank you . ', " Miss , I'm very sorry for the delay , please enjoy this . Free a glass of wine for inconvenience . Again I'm terribly sorry to make you wait so long . ", " It doesn't matter . "]
['How do you like this waltz ? ', " It's very nice , I like it very much . ", ' Well , then , may I invite you for the first dance ? ', " My pleasure . But I'm afraid I'm not much of a dancer , and I suppose you dance often . ", ' Me ? Oh , no . In fact , I took up dancing quite recently . ', " Oh , really ? But you're doing the waltz wonderfully well . ", " I'm glad you say so , you dance beautifully too . It's lucky that I got a partner . ", " Thank you for your compliments.It ' s just that you are a good leader . Do you like the fox-trot and tango ? ", ' Yes . And what dances do you do best ? ', " Disco is my favorite . I like it better than any other dances because it can release one's pent-up feelings , and is a healthy exercise . But I don't do the rock and roll and the break dance . ", ' Oh , well , the music has stopped . Thank you for the dance . ', " My pleasure . Let's go and have a drink . ", ' Fine . ']
["What's the Mountaineering Club doing this weekend ? ", ' We are going to climb a cliff on the Yangtze River . ', ' How hard is the climb ? ', ' It is a very difficult climb , because there are not many places to put your hands and feet . ', ' What did you do last week ? ', " We rappelled down the side of a 300 - foot cliff . It's very exciting . ", ' Wow . That sounds like a lot of fun . I am sorry I missed it . ', ' Well , you should come this weekend . I think you could do the climb . ', ' Yeah , I will . See you then ! ', ' Ok , see you . ']
['How many people are there in your family ? ', ' There are 15 people in my family . ', ' What did you say ? How many ? ', ' 15 people . ', ' Wow . That is a very big family . Do you all live together ? ', " Of course we do ! My father's parents , Mum , Dad , three unmarried aunts , two uncles , my two brothers , my three sisters and me . ", " But you don't live at home anymore . ", " Right , but that's where my heart is . But you're right , now there are only 14 living at home . ", ' My goodness ! Your family must live in a huge house . ', ' Yes . My family lives in rural Korea , near Pusan . We have a huge house.The first floor of the house is a part-time private school.In the afternoon , students come for special tutoring in biology , Englis ', ' Wow ! you grew up in a school ! No wonder your English is excellent ! ', ' My aunts and uncles are all teachers . ', ' You are so lucky ! ', ' I guess so . While growing up , I read hundreds of interesting English storybooks every year . ', " That's what i did in America . I was reading all the time . I was never a big TV watcher . TV wastes time . ", ' I agree . Reading for fun is why all the English students at our family school have excellent English . All the students read 800 easy storybooks during their second year of studying English . ', " 800 books ? I'm impressed ! ", " My aunts studied in the American universities.They say that extensive reading for fun is the most effective way to improve your English.That ' s what they learn here in America . "]
['... Now that we have been over the gory details of our disastrous first quarter , Ed ! Give us some good news . How are things looking for us in terms sales this month ? ', ' Uh well ... would you like the bad news first or the really bad news ? ', ' What ? Ed , don ’ t tell me you only have bad news ! ', ' Well sir , our sales have dropped , no plunged , fifty percent in the past month alone . We are currently overstocked and overstaffed and our profits refalling fast . The market is in recession and we have no way of moving our inventory , or getting rid of our staff . If we consider redundancies , it would cost us a fortune because of the new regulations governing compensation packages . It ’ s a real mess . ', ' For crying out loud ... How fast are we losing money ? ', ' Um ... how can I put this ? Let ’ s just say that at this pace , we will be filing for Chapter eleven in less than three months . ', ' What ! Geez ! How could this have happened ? So what ’ s the bad news ? ', ' Oh , that ’ s the really bad news . Our supplier suffered QC problems and , well , half of our production is faulty . We ’ re going to have to recall all itemssold in the last quarter . And the worst part ? We ’ re going to have to shoulder this cost . ', ' Are you joking ? Get the supplier on the line now ! They have to assume the costs of this mess ! ', ' We tried that , sir . The factory has gone under and the owner apparently has fled the country . ', ' We ’ re doomed ! ', ' There is some really good news though ! ', ' Really ? What ! ', ' I got offered a new job ! ']
['So Vicky , how long have you held your present position ? ', ' I ’ Ve been a secretary for two years , before that I was at university . ', ' And how do you like working for IBM ? ', ' It ’ s challenging , I feel I have learned a lot . ', ' What ’ s strength do you bring to the job ? ', ' I get along well with people , and I enjoy working with others . ', ' That ’ s good . We always need team players here . ']
["I'm exhausted . My new exercise class is so hard , ", ' I think it is easy . I could work in your class with no problem . ', ' You thing so ? ', ' Oh , without a doubt . When is the next class ? ', ' Tomorrow morning . Try it . ', ' No problem . ', ' Are you going to this class this morning ? ', ' Of course , easy . No sweat . ', " You're no able to move after this class . ", " Are you kidding me ? It's going to be up a piece of cake . ", ' You want to bet ? ', " Yeah , what't the bet ? ", ' I bet I can go one hour in your class this morning and not feel a thing . ']
["Johnny , you did badly on the test . I think you haven't been studying enough . Am I right ? ", ' Yes , Ms . Jones . ', " Well , you'd better start studying harder if you want to pass this class . "]
["Professor , where's Canada ? ", ' Canada is north of here . ', ' Can you show me on the map ? ', ' Sure . Look here . Canada is north of the United States . ', " Oh , I see . Where's Mexico ? ", ' Mexico is south of the United States . ', " How about Connecticut ? Where's that ? ", ' Connecticut is east of New York . ', ' What state is west of Pennsylvania ? ', ' Ohio . ', " OK , Where's Los Angeles ? ", " Los Angeles is in California . It's southeast of San Francisco . ", " Where's Boston . ", ' Boston is in the northeast part of the country . ', ' Where is Las Vegas ? ', ' Las Vegas is in the southwest . ']
['What kind of books do you like ? ', ' I like reading novels about early America . ', ' Really ? Me too . ', ' Which one do you like best ? ', ' I prefer the novels by Hemingway , such as The Old Man and the Sea . I like the simple words in his novels . ', ' Yup . Though the words he used are simple , but the spirit he has conveyed is great . ', ' Absolutely ! ']
["Doesn't she have any friends ? ", ' If she has , they must be fair-weather friends . ', ' Such friends are even worse than enemies . ', " She'd better keep away from them . "]
['Is that true ? ', " I guess so . Now Anna's got four kids and another on the way . ", " Wow . She looks good for having had that many kids . She's pregnant and wearing Prada ! ", " That's Anna for you . She keeps up the image of the stylish Italian woman . Here she comes . ", " She's glowing . It must be the pregnancy . ", ' Yeah , or the expensive Italian facial treatments . ']
['Hi , Jenny . Are still working ? ', " Hi , Nancy . Come in please . I'm just putting away on my books . ", " So , you are leaving , aren't you ? ", ' Yes , I ’ m going to take a holiday tomorrow . ', " How nice ! I can see you are busying packing . I'm sorry to interrupt you . ", " That's all right . I'm almost finished . Do you need my help ? ", ' Yes , could you please go over this for me ? And see if there is any mistake in it ? ', " Oh . All right I'll read it soon . ", ' Excuse me for taking your time . ', " It's nothing Nancy . "]
['Why do you look so gloomy ? What are you looking for ? ', " My dissertation . I put it somewhere last night and I can't find it now . ", ' Did you finish typing it yesterday ? ', ' Yes , I kept on typing it until midnight , but it is lost . ', " Don't worry about it . It must be somewhere in your room . Let's see where you put it . Have you searched your drawers and the desk ? ", ' Yes , but there is nothing inside the drawers or on the desk . ', ' How about the shelf ? ', " I've searched everywhere . Where on earth did I put it ? ", " Don't get upset over it . At least you have another week to go . ", " I have been working on it for a whole month and it's too late to write another . Just think of all my hard work that goes for nothing . How could I do such a thing ? ", " Cheer up ! What I meant was that you can find it sometime during a week . There is no need to write a new one . Oh , what's this ? Is this your dissertation ? ", " Let me see . Yes , that's it . Where did you find it ? ", ' You ’ Ve put it among these journals . ', ' My poor memory . Thank you very much . ']
['Crazy ! He locked himself in the room . ', ' I think he was locked in it . ', ' But you can see the key in his hand through the window ! ', ' What a strange guy ! ']
["Where's Bill ? The ambassador is already here . The meeting is set to start at 9 am . ", " He's late again . Traffic is probably holding him up . You know , he commutes from the suburbs . It's not easy commuting every day . We should cut him some slack . ", " Even though the traffic is bumper-to-bumper out there , I don't think it's heavy traffic that makes Bill late . He takes the train , remember ? ", " Oh , that's right . Well , the train shouldn't be late . That means there is only one explanation ... Bill must have overslept . ", " Well , to be fare , since he's coming all the way from Lancaster , he's got to get up much earlier than the rest of us . He must get start on his commute about six thirty , no telling what time he actually gets up . ", " That's right , because he's got to get to the train station from his house , then take the blue line into the city , then switch trains to the red line . In all , the trip's got to take more than 2 hours . ", " Why doesn't he just drive to work ? ", " It's too difficult to park your car in the city . Also , the traffic coming in from the suburbs is a nightmare . "]
['What can I do ? ', ' Take the books out of the bookcase . Put them in this box . ', ' Well , the books are in the box . What can I do now ? ', ' Take the magazines out of the bookcase . Put them in that box . ', ' All right . ', " Peter ! Pack them . Don't read them . ", ' These magazines are interesting . May I borrow one ? ', ' Of course . ', ' Thanks , John . ']
["This is great , isn't it ? ", " It's the most fun I've had in years . ", ' We should do this more often . ', ' Yes , we should . ']
['What do you think of his behaviour yesterday ? ', " He's a sad dog . He came to the wedding in jeans ! ", " I don't think so . He only had no common sense . "]
['Have we sold out all the newspapers for today ? ', ' Yes . What a good job we have done ! ', ' Why are so many extra gifts left here ? ', " Many customers didn't want them . ", ' How about giving them to that old man ? ', ' Good idea . ', " By the way , do you think it's a good idea to give free gifts to attract customers ? ", " I'm not sure , but still it did attract a large crowds today . ", ' I think it should be more useful to hand out some fliers which is also cheaper . ', ' But people can just throw them into the trash can as they turn around . ', " That's true . ", " Anyway , let's just finish out job and get back home . ", ' Okay . How tiring the job is ! ']
["I'm afraid of the darkness . ", " Don't worry . I'll drive you back . ", ' Thank you . ']
["What's your number ? ", " I'm number seven . What about you ? ", ' Five . ', ' Hah hah ! You have to go before me . ', " You think it's funny . I'm terrified . ", " Don't worry . It's safe . ", " But I've never jumped off anything in my life . The highest thing I've jumped off is my bed . I'm scared . ", ' You are the one who wanted to come here , Sandy . You should enjoy it . ', " I guess I'm adventuresome , but then I'm scared too . ", " I'm not too scared . But I've done sky diving before . "]
['I think modern painting means nothing . ', " I think so too . It's just pointless . ", ' Then why are so many guys so crazy about it ? ', " I don't know . Maybe they're really crazy . ", ' Maybe . ']
["Hi ! Dick . Where are you going ? You're in such a hurry . ", " Playground . We're having sports for today's outside class activities . All my classmates have already got there . ", ' What are you going to play ? ', ' Some of us will play basketball and some volleyball . ', ' Enjoy yourself . ']
['Yesterday I had a deal with a vice manager . He acts like the point man . ', ' I always meet people like him . ']
['Wow , the view from the peak is so grand ! ', ' Look , most of the maple leaves have turned red . ', ' Did you ever see this kind of beautiful scene ? ', ' Of course , my father used to take me to Kiang Shan or somewhere like that as a child . ', " But my father did not . He didn't have much time . ", " Honey , I'm sorry . I promise you , this summer vacation , I will take you to Huang-Shan Mountains . It is more beautiful and magnificent . ", " Really ? It's a deal . Have you ever been there ? ", ' Yes , I went there five years ago . You were still a baby at that time . ', ' It really gets me interested . Is it higher than Kiang Shan ? ', ' Surely . You can enjoy the beauty of numerous streams and waterfalls . The sea of clouds has a fairy tale beauty . ', ' Can I see the rainbow ? ', ' That depends . If you are lucky , you can see a vivid rainbow across over two peaks . ']
['Tom has grown six inches within a year . ', ' He has reached puberty . His mind and body both will change a lot . ', " Yeah , do you see his Adam's apple ? It becomes bigger . ", ' Time is flying . I still remember everything when he was a child . ']
['For our lunch meeting with the investors , do we have to make a reservation at the restaurant or do we just show up ? ', " Usually for lunch , we don't have to reserve a table , they should allow walk-ins . But to be on the safe side , I'll order a table for half-past twelve . Will that suit your schedule ? ", " I've arranged to meet them at the restaurant at twelve . Can you make the reservation a little earlier ? If we start earlier , it will give us more time for a longer lunch . ", ' Are you planning on treating the investors to a full-course meal ? ', " Yes , we'll start with appetizers , follow with a soup and salad course , then main dishes of prime rib or cordon bleu chicken , and finish up with a delicious rich dessert of some sort . ", " That'll be pretty heavy for a mid-day meal , don't you think ? ", ' As along as we stay away from anything alcoholic , we should be okay . ', " With your prime rib and chicken choices , you'd better hope nobody's vegetarian . ", " We can make some special arrangement if we need to . After all , it's the company who is footing the bill . "]
["Too much , Harry . Don't blame her anymore . ", ' But it was her that makes us so embarrassed . ', " I know . But there's no point in making her feel worse , isn't there ? ", " I don't care . "]
['Hi Jane , can you let me know the best way to get to your house this evening ? ', ' Certainly , where will you be coming from ? ', ' I need to be in the city centre this afternoon so I will be coming straight from there . ', ' Ok . Take the Underground ( the Circle line ) to High Street Kensington . Make sure you take the High Street Kensington exit . ', ' Got that . ', ' Ok - when you leave the Underground , cross the road and you should see Horntown Street . Was up that street to the crossroads . As you was you should see a fast food place on your right . ', ' Hold on , I am looking at the map now . Ok , I can see Horntown Road . Do I go straight at the intersection ? ', ' No , you need to turn left into Philimore Was and take the next right . ', ' Ok , I can see that road . ', " That's fine . You will not miss it because it's just next to the Kensington centra Library . ", ' Good , I can see the library on the map . ', ' Ok , we live in the third building on your left . Will we see you around 7 pm ? ', " That's great , see you at seven . "]
['Guess what came in the mail today ? ', ' What ? ', ' My acceptance letter to Yale ! ', ' Wow ! Congratulation ! When do classes start ? ', ' Freshman orientation is the last week of august , but I want to go two weeks before that to get settled in . ', ' You ’ re so lucky ! Do you have to do many things before you leave ? ', ' Yes . I ’ ll be very busy ! I have to get a visa , buy a plane ticket , and pack my things . But first , I want to register for classes . ', ' When can you do that ? ', ' Well , they sent me their prospectus , so I can start looking now . do you want to help me decide which classed to take ? ', ' Sure . What can you choose from ? ', ' Well , I have to take all the fundamental course , plus a few from my major . ', ' What is your major ? ', ' I hope to major in English literature , but the admissions counselor told me that many people change their major many times in their first year , so we ’ ll see . ', ' What are the fundamental course ? ', ' In order to graduate , every student must take a certain amount of classes in history , math , English , philosophy , science and art . ', ' Interesting . That ’ s very different from the Chinese education system . ', ' Yes , it is . It ’ s also very different from the British education system . ', ' Really ? ', ' oh , sure . In British , students don ’ t have to take the foundation course . ', ' why not ? ', ' maybe because they think they know everything already ! ha ha . ']
['Hey John , nice skates . Are they new ? ', ' Yeah , I just got them . I started playing ice hockey in a community league . So , I finally got myself new skates . ', ' What position do you play ? ', ' I ’ m a defender . It ’ s a lot of fun . You don ’ t have to be able to skate as fast on defense . ', ' Yeah , you ’ re a pretty big guy . I play goalie , myself . ', ' Oh , yeah ? Which team ? ', ' The Rockets . ', ' Really ? I think we play you guys next week . Well , I have to go to practice . See you later . ', ' All right , see you later . ']
['Do you offer a course in business management ? ', ' Yes , we do . ', ' How many nights a week is it ? ', " It's 3 nights a week , Monday , Tuesday and Thursday . ", ' And how long does the course last ? ', ' It lasts for 9 months . ', ' When does it start ? ', ' The next beginning class starts on October 25th . ', ' What time is the class ? ', " From 7 to 9 o'clock . ", ' How much does it cost ? ', ' It costs 125 dollars a month . ', " Yes , that's all right . I want to enroll in the course . ", ' Thank you , please fill out this form for us . ', ' Do you want me to fill it out now ? ', ' Yes , please.we need a record of you education and your work experiences . ']
['Would you like to drink some coffee ? ', ' No , thanks . I have some trouble with my heart , my doctor recommend I to drink less . ', ' Would you like to try some watermelon juice ? It tastes good . ', ' All right ']
['Excuse me . Is there any body here ? ', ' Yes . ', " I've finished up all my water . I would kill for a sip of water . ", ' Sure , come on in . ', ' Thank you very much . Are you here alone ? ', ' My father and sister are out to photographing . What about you ? ', " I'm a back-packer from America . ", ' What is a back-packer ? ', ' It means a hiker who loves traveling around the world . ', ' Cool . You must have been to a lot of places . ', ' Yes , actually almost half of all the countries over the world . I love traveling places . ', ' So cool . I want to be a back-packer when I grow up . ', ' You can do it . But do work hard on your English to make it easier . ', " I'll try my best . "]
["OK , Dead Man . If this doesn't start your engine , nothing will . ", ' Thank you . Hey , do you know how espresso got its name ? ', " No , I don't . ", " It's because of the way the steam and boiling water are pressed through the coffee . Es-PRESS-o , get it ? ", ' Uh , are you sure about that ? I thought espresso was an Italian word . ']
['Hello ! ', ' Oh , hi ! ', ' Please allow me to introduce myself . My name is Tom . ', ' Pleased to meet you . My name is Alice . Did you just move in next door ? ', ' Yes , I did . Have you lived here long ? ', " Me ? I guess so . I've lived here for about six years now . Have you lived in America very long ? ", ' No , not really . When I left Vietnam , I came to America and I lived with a cousin in Dallas for two years . Where do you work , Alice ? ', ' I teach mathematics at a college . What do you do ? ', ' I am an accountant at a company ', " Well , Tom . It's good to meet you . I have to go now . I am teaching a class this evening , and I need to get to the college . ", " It's nice meeting you too , Alice . ", ' See you around ! ', ' Goodbye , Alice . ']
['Good morning , Mei ! How are you ? ', " Hi Tom ! I'm fine , and you ? ", ' Not bad thanks . ', ' Good . See you ! ', ' Bye ! ']
['You like movies ? ', " Yeah , I think it's the best way to relax . ", ' What type do you like the best ? ', " Really it depends on my mood . When I am sad or depressed , I like comedies . If I'm feeling good , I'll watch almost anything . ", ' I see . I generally like movies to help calm me down . I think a sign of a good movie is the ability to bring you into the story as if you were part of it . ', ' Yeah , unfortunately , nowadays directors are often more interested in making money than making a good film . ', ' True . The movie industry is becoming more and more commercial . You see a lot of expensive movies with little artistic value . I generally think those made in the forties are of higher quality on the average than movies today . You can name a lot of classics from that decade . ', " Yeah , many of my all-time-favorites were made in the forties . They've already stood the test of time and will stay with us for a long time . ", " I'm totally with you on that . "]
['What a washing machine ! It ’ s getting worse today . Look ! Now it doesn ’ t work at all . I think I need a new one . ', ' Here ’ s an ad . about a big sale of washing machine . Do you want to see it ? ', ' Of course ! Let ’ s have a look . Great ! In my frame of mind , I ’ d like to buy one today . ']
['Hey , your Chinese is coming along ! ', ' You think ? ', ' Yeah . It ’ s a lot better than mine . ', ' But I still get stuck on the different tones.It drives me crazy . ', ' Hang in there . It ’ ll all come together one of these days . ']
['I can ’ t wait to retire . ', ' And then what ? ', ' And then I ’ m moving to Florida where I can play golf all day , every day ! ', ' That sounds boring to me . ', ' What do you plan on doing after you retire ? ', ' Yes , I think I will do something new . I ’ Ve always wanted to be a teacher . I ’ m willing to begin studying to teach . ', ' I admire your energy , Ruth . You are young at heart . ']
['What colour is her hair ? ', " Oh , blonde , she's very blonde ... quite short hair ... ", ' What , curly ? ', ' No , not at all . Very straight . Her hair comes down like this ... just over the ears . ', ' Does she wear glasses ? ', " No ... no . I think you're thinking of someone else . ", " No . I'm sure I know her . ", " Er ... what else can I tell you ? Er ... she's got ... er a ... round face , a very round face , and a very big mouth , sort of wide mouth , when she laughs , her face is all mouth . ", " Ah ... No , I can't place her . "]
['Charles , do you have any children ? ', ' Yes . ', ' How many children do you have ? ', ' I have two kids . A boy and a girl . ', ' What are their names ? ', ' Jack and Stephanie . ', ' How old are they ? ', ' Stephanie is 18 and Jack is 24 . ', ' Are they in school ? ', ' Stephanie is . She goes to college in Washington and Jack works in Florida . ', ' What does Stephanie study ? ', ' She studies English . ', ' Is she here now ? ', " No , she's at school . "]
["I can't believe the weather is so gorgeous for your wedding . ", " Yes . It's perfect . ", ' And all of the flowers are in bloom . ', " I couldn't have asked for more . "]
['I was looking at my test score and think that it should be higher . ', ' Is the math wrong or the way the answer was marked ? ', ' I think an answer got marked wrong that should have been marked right . ', " These things can happen ; let's double-check the answers first to be sure , all right ? ", ' That would be great ! ', ' Look at the answer sheet and compare it to your answers . Do you see any place where I made a mistake in grading ? ', ' This one right here should be right . ', ' Yeah , I see the same thing ; now we can do the math and check that , right ? ', " Yeah , let's do the math . ", ' I count all of the correct answers , total them , and divide by the total . Does this look right to you ? ', ' Looks pretty good . ', ' Thank you for caring enough to check on your scores ; keep studying ! ']
["Susan , I haven't seen you in the pub for a long time . ", ' I have a part-time job now , so I work in the evenings . ', ' That explains it . ']
["Mrs . Schmidt ! What's happening ! ", " You'll never guess what happened today ! I went to the doctor after work and the doctor told me ... ", ' And the doctor told you to start listening to Bach ? ', " No ... He told me I'm pregnant ! ", ' Congratulations ! ', ' And so I bought all these books on having kids and ... ', ' And they said you should play classical music ? ', ' How did you know ! They say listening to classical music can make your baby smarter ! ']
["Guess what ! I know something you don't know ! ", " What's that ? ", ' How many planets are there in the solar system ? ', " That's easy . Everyone knows that there are nine . ", " Not anymore ! Can you believe it ? They've decided that Pluto is not a planet anymore ! ", " Nice try . I wasn't born yesterday , you know . ", " I'm dead serious . They've decided that it's too small to be a planet , but actually they haven't yet agreed on how big something has to be in order to be a planet anymore . ", " That sounds crazy . But they can't just change their mind about things like that . ", ' Yes , they can . If you remember correctly , people used to believe that the world was flat . ', " I suppose you're right . They also used to think that they were so important that the sun revolved around them , not the other way around . ", ' We actually know relatively little about space and the cosmos . ', " Do you think that we'll one day be able to travel to another planet for a vacation ? ", ' I suppose we could actually live on a planet outside of the milky way . ', " Do you think we'll ever get to meet an alien from outer space ? ", ' I hope not . I think they would be a threat to those of us that lived on the Earth . ', " You're so old-fashioned . That's what people used to think about people from another country ! ", " Point taken . Hopefully one day , we'll live in an interplanetary society . "]
["You're just left school , haven't you , Emily ? ", ' Yes , I finished last Friday . ', ' You sound relieved . ', " Well , yes . I don't mind admitting that I am . I enjoyed school , but I did object to having to go in every day once we've done all our exams . ", ' Well , what are you going to do now ? Have you made any plans ? ', " Yes , I intend to go to university . That'll be in September . But it all depends on my A level results . ", ' You mean getting into university actually depends on your passing your A level subjects ? ', ' Oh , yes . ']
['I noticed your absence in class this morning . ', " I'm sorry , I overslept . "]
['Hello , Jack here . ', " Hello , Jack . It's Mary . What are you doing in your office ? ", ' I am working . I often work late on Thursdays . I am busy this week . ', ' Would you like to come and have dinner with us on Friday ? ', " Tomorrow ? No , I'm afraid I wouldn't be able to . I'm going out of the town on business . ", ' What about Saturday ? ', ' Sorry , I never go out on Saturday evening . I always watch football on Saturday evening . ', ' Will you come round next Tuesday ? ', ' Next Tuesday ? Just a moment ! It will be the 21st of May . Oh , dear . Arm ... I promised my aunt I would be at her birthday party . ', ' What do you say to next Wednesday then ? ', " Let me see . Yes , Mary . Let's make it next Wednesday . ", ' Ok . Bye . ', ' Bye . ']
["It's snowing outside . ", ' Oh , how could it be ? ', " Let's go out and have a look . ", ' OK . Wait a minute . ', " Look at the snow , it's so beautiful . ", " Yes . It's really snowing . ", ' I love winter , I love snow . ', " But don't you think it's a little too cold ? ", ' But I like cold more than hot . ', ' You are so interesting . ']
['How often do you have English lessons ? ', ' I have a lesson once a week but I try to practice every day . ', ' How do you practice ? ', ' I usually look at English language websites every day and go to my local English Corner twice a week . ', ' Do you ever speak to native speakers of English ? ', ' Sadly , I hardly ever speak to English people . I usually practice with my Chinese friends . ']
['What happened to that girl you were seeing ? ', ' Oh Jackie ? We broke up last week . ', ' That was a short relationship . You only started dating 2 months ago . ', ' It was actually a long two months . She was a psycho . ', ' What do you mean ? ', " She would be laughing one moment , and if I said something insensitive , she would start crying . I didn't want to deal with that . ", ' She sounds very emotional . ', " She was a psycho , man . One time we were suppose to get together . I was waiting for her call , and when she finally called , she was screaming why I wasn't at her place . ", ' Were you suppose to be there ? ', ' I thought she was going to call when she was done shopping . It was a misunderstanding . She was literally screaming on the phone over this . ', " Ok . You're right . She's a psycho . ", " I'm just glad it's over . "]
['Adam . I ’ m sorry . ', " Where have you been , Alice , you're over an hour late . ", ' Yes , But I couldn ’ t help it . I was late getting off work for a start and then I miss the bus . The bus I did catch that stuck in the traffic jam . It was one thing after another . ', ' why ere you getting off work so late ? The office close at six , doesn ’ t it ? ', ' Yes . But those are the rush in that moment . And my boss ask me to do some urgent letters . ', ' Didn ’ t you tell him you have an appointment ? ', ' Well , no . I thought I ‘ Ve finish in five minutes . and I didn ’ t want to be difficult about just few minutes , if I hadn ’ t been missing the bus and in the traffic I wouldn ’ t have been so late . I ’ m sorry . ', ' Well . You ’ re here . ']
['How was the movie last night ? ', " I didn't really like it . ", ' Mary said that she was really pleased with the photography . ', ' I found it very disappointing . ', " She liked the acting , too , because that's what she wanted to see . ", " I wasn't happy with it . ", ' Nothing is to your satisfaction . ']
["I'm busy year in and year out , but now I've done nothing . ", " You've done a lot , my darling ! ", ' I may have done a lot , but none is to my satisfaction . ', " You're too strict with yourself . ", " Perhaps . I'm dead tired . "]
['Would you like to come to our party ? ', " I'd like to . But I'm not myself today . ", ' What happened ? You look so pale . ', " It's the end of the world for me . ", ' What makes you say that ? ', " Today , I'm told I failed three courses . ", " Oh , that's too bad . Work harder next term . ", " B :: I'm such a fool that duplication of effort is only a waste time to me . ", " Don't lose heart . Everything will be fine . ", ' I hope so . ']
["What do you think of the lawyer's speech ? ", ' He has a glib tongue . Few people can argue him down . ', " Don't believe him . He's liar . ", ' We cannot expect a man like him to speak the truth . ']
["hey , the new SOHO . How's everything going ? ", " everything's great . I've just returned from my office . ", " your office ? Aren't you a freelancer ? ", " sure I am . I work for myself , but I've rented a virtual office at an office building in the downtown area . ", ' a virtual office ? ', ' yeah , an office that runs efficiently by using nothing other than online communication technologies . I pay the rent and share office services with others in the same building . ', ' what kind of services do they offer ? ', ' a separated office , internet access , phone services , fax services , mail & courier services , and almost everything you have in a conventional office . ', ' sounds fun.what else ? ', ' I get a business address at an expensive location , and I can share the receptionist and secretary with other offices in the same floor . ', ' oh , that helps a lot to promote your corporate image . ', ' you bet it ! ']
['I just love your hair that way . ', ' Thanks . ', ' Where did you have it done ? ', ' My sister did it . When did you get yours cut ? ', " Just yesterday . I'm still getting used to it . ", ' Well , it looks very nice . ', ' Thanks . ']
['That was a great party . Thanks for staying behind to help me clear up . ', ' It certainly was a great party . It ’ s a pity that a glass and a plate got broken and someone spilled a drink over here . ', ' I expected that something might get broken . That doesn ’ t bother me . That spilled drink won ’ t leave a stain , will it ? ', " I doubt it , I'll deal with it right away . Luckily it wasn ’ t a glass of red wine , I ’ ll just get a bowl of water and a cloth . ", ' I ’ m going to put all the rubbish into this big plastic bag . ', ' Afterwards , we can do the washing up together . Everything will be finished within an hour . Your friend Keith is really funny . I liked his magic tricks . ', ' Yes , he ’ s very good .. isn ’ t he ? He told some funny stories too . ', ' Amanda told some very funny jokes . At the beginning of the party , she was being very serious . ', ' I think that she had a litter too much of the punch . ', ' What did you put in that punch ? It tasted great , but was quite strong . ', ' That ’ s my little secret . Did you like the snacks that I prepared ? ', ' Very much . The birthday cake was delicious , wasn ’ t it ? Emily told me that she and karen made it themselves . ', ' That cake tasted so good ! It disappeared within minutes , so I think everyone liked it a lot . How ’ s that stain ? ', ' All cleaned up . Are you ready to start on the washing up ? ']
['Mom , this is your third bowl of rice ! ', ' I know but I have no choice . My stomach just keeps crying for more and more . ', ' Why ? I never saw you eat so much before . ', " I've been going to the gym these days . The exercise makes me hungry all the time . ", ' So your stomach is the one that actually gets a lot of work-out . ', " Don't pull my leg . ", " This way you'll probably put on more weight . Will you give up ? ", " Surely not . I can feel the results . I'm starting to feel different now . ", ' Then how are you gonna deal with the problem of getting extra weight ? ', " I'm planning to meet my personal trainer to have the work-out plan fixed . ", " Oh , I've got an idea . Why don't you ask Dad to go with you ? He badly needs some exercise . ", " Your father is a bit too timid . He even doesn't know how to introduce himself . ", " He can just say , I'm Benjamin . I'm new and shy . ", " Girl , don't make fun of your Daddy . But I can introduce him to my personal trainer . Maybe one day he will be a fitness freak instead of a cough potato . ", ' Who knows ! ']
['Look , Bob . This is a photograph I took during my trip to Australia . ', ' Let me see it , can I ? This is a good photograph . Who are these people ? ', ' They ’ re people I met during the trip . That ’ s the ship we traveled on . ', ' What a beautiful ship ! Who ’ s this ? ', ' That ’ s the man I told you about . Remember ? ', ' Ah yes . The one who offered you a job in Australia . ', ' That ’ s right . ', ' Who ’ s this ? ', ' Guess ! ', ' It ’ s not you , is it ? ', ' That ’ s right . I grew a beard during the trip , but I shaved it off when I came home . ', ' Why did you shave it off ? ', ' My wife didn ’ t like it ! ']
['Hey , Jack ! Is Jenny coming with us ? ', ' Yes . Why ? ', ' Nothing . I am just asking . ', " Just asking ? ! Why is your face burning like mad ? Ah-huh , someone has a crush on Jenny , doesn't he ? ", ' Who has a crush ? ', " Come on , Ted ! Don't be such a chicken . If you like her , you ’ Ve got to tell her . Maybe she likes you . ", " Well , I don't have the guts to ask her out . ", ' What are you so afraid of ? Just tell her what you are feeling about her . ', ' I ’ d totally die if she turned me down . ', " But that's better than keeping everything to yourself . You ’ Ve got to let her know . Come on ! You ’ Ve got to take a chance . Even though you are rejected , it ’ s not the end of the world . There ’ s nothing to lose , is there ? ", " I don't know .. Well , maybe you are right , but how am I gonna tell her ? "]
['Susan has got the cancer of stomach . ', ' How terrible ! This is quite unexpected ! ', ' Yesterday when I went to hospital to see her , you cannot imagine how greatly surprised when I saw her . ', ' What happened ? ', ' Because of atomic cocktail and other medicines , all of them have the side effect . she has lost all her hair . ']
['Shall I punch out for you , Ross ? I am leaving now . ', ' No , thanks . I have got to work overtime . ', ' But today is Friday . You are not going to work overtime on Friday evening , are you ? ', " Well , I am . I'll have to finish this report for next Monday's meeting . Is Tom coming to pick you up ? ", ' No . We ’ ll meet at my house . He invited my family to spend the weekend with his family at their villa . ', " That's nice . Where is his villa ? ", " It's not his villa , but his father's . I think it's somewhere in Florida . I am not sure myself . ", ' Sometimes I envy you a lot . Tom is a good guy . ', ' Come on . You just haven ’ t met the right person and I think that you work too much . You should learn how to entertain yourself and enjoy life . ', ' I know , but I am a work maniac . ', " Well , suit yourself . I've got to run now . ", ' Have a nice weekend . ', ' You too . Oh , I forgot to tell you one thing . A girl called this afternoon . She said she was your ex-girlfriend . She wanted you to call her back . ', ' Did she mention anything else ? ', ' No , nothing else . See you Monday . ', ' See you . ']
['Are we going to have gym class tomorrow ? ', " Are you crazy ? Tomorrow's Saturday . ", " Sometimes I forget that we don't have school on Saturdays . ", " Americans also don't go to work on Saturdays . ", ' So there are only five working days in a week ? ', ' Right . What are you going to do tonight ? ', " I'm going to study . ", ' On a Friday night ? ', ' Well , I need to polish up my English . ']
['Thanks a million . ', " Don't mention it . "]
['Jacob , are you interested in helping me out and going on a blind date with a friend of mine ? ', ' That depends . What does she look like ? ', " Well , she's got a beautiful face and long curly red hair . ", ' How tall is she ? ', " She's fairly tall , maybe 2 inches taller than me . ", ' Is she chubby ? ', " Not at all . She's actually very athletic . ", " It sounds like she's pretty good-looking . Does she wear glasses ? ", ' No , but she does wear contact lenses . ', " How's her skin ? ", " She's got a gorgeous complexion with a few freckles on her nose . ", ' Does she have any piercings or tattoos ? ', ' I think she has her ears pierced and she definitely has a few tattoos , one on her lower back , one on her neck , and one on her left foot . ', " What's the tattoo on her foot like ? ", " It's a butterfly---everyone in her family has one . ", ' Even her mother ? ', ' Yes , even her mother . ', " What's her personality like ? ", " She's a lot like me . ", ' So there is something wrong with her ! It was beginning to sound like she was too good to be true ! ']
['Good morning , Jason . How did you sleep ? ', ' Pretty well , thanks . Still feeling the effects of jet lag a bit , but last night I got at lease six hours of rest . ', ' Great ! So , are you ready for a full day of shopping ? ', " Yep . Let's do it . I'm pretty excited ! ", " I know a place that should be perfect . It's called the China Friendship Shopping Center and it's pretty much like an American mall - except with more variety . You can even buy a live chicken there if you want . ", ' Live chicken ? Thanks , but no thanks . So ... tell me about bargaining . How can I do it like a local ? ', " Well . I'll be honest and say you'll never be as good at bargaining as a local person . You're a foreigner and the sellers can see that . But ... if you're smart , you can get bargains that are not too far away from the local price . ", ' Cool ! Teach me ! ', " For starters , you want to do a lot of scouting first . You've got to know what things cost . ", ' Someone told me to go to a convenience store and see how much a soft drink or a tube of toothpaste costs . The idea is that by comparing the prices of those items , you can figure out the relative prices of everything else . ', ' That could be helpful . But when you go into a shopping center ... prices become very flexible . You have to be able to read the market . ']
['I ’ m so relieved that your ankle wasn ’ t broken ! I feel just awful about this whole thing . I wanna make it up to you . Let me take you out to dinner tonight . My treat . ', ' That sounds great ! I ’ d love to ! Here is my address . Pick me up at eight ? ', ' Perfect ! ', ' Thank you for such a lovely evening ! The food was amazing , and I had a great time . ', ' Me too.You look so beautiful tonight ! I wish this night would never end.There ’ s something I have to tell you ... ', ' What is it ? ', ' I woke up today thinking this would be just like any other ordinary day , but I was wrong . A twist of fate brought us together . I crashed into your life and you into mine , and this may sound crazy , but I ’ m falling in love with you , Veronica . ']
['Hey , you ’ re early ! Where ’ s everyone ? ', ' Well ... I told them not to come . I made a reservation just for the two of us . I thought we could have an quiet evening all to ourselves . ', ' Oh ... why ? ', ' Jennifer , there ’ s something I wanna ask you . ', ' Sure . What is it ? ', ' Hmm ... okay , here ’ s the thing . I ’ Ve always seen you as more than just a friend , and I can ’ t take it any more . I know you better than anyone , I know the pros and cons of your personality , I even know what side of the bed is yours ! I think we would be great together , don ’ t you ? ', ' Are you serious ? We ’ Ve been friends for years ! We can ’ t just change that overnight ! ', ' I know ! I never had the guts to tell you ... until today . So , what do you say ? Are you willing to give me a shot ? ', ' I ... I ... ']
['How do you usually spend your time , now that you ’ Ve retired ? ', ' Well , I nearly always get up at dawn . I don ’ t like sleeping in late . The days are longer in summer than in winter , so I get up in summer . I usually do some exercise when I get up . ', ' What do you have for breakfast ? ', ' I usually have cereal , but sometimes I cook a traditional English breakfast . ', ' that sounds nice . How do you spend your mornings ? ', ' I usually do housework in mornings . I go shopping occasionally . I like to do all my shopping in one bag trip to the supermarket . I always drive to the big supermarket in the city center . It takes about 20 minutes to drive there . ', ' How do you spend your afternoons ? ', ' I usually meet some friends and we play sports together or I might spend some time alone on my hobbies . I spend winter evening watching tv , but I spend summer evening at cultural events if I have time . ']
['What do you think of being a secretary ? ', " I'm not at all keen on that sort of job.It makes me crazy . ", ' How come ? ', ' You have to type all day . ']
['Hey . Steven . You have a large chunk of money , but why do you still live in the old flat , instead of buying a new villa ? ', " I like to live here and enjoy my neighbors ' company . And I don't think I should waste money just because I have much of it . ", " But I found you always hate to part with your money . Look at the car you drive ; it's such a junker ! ", ' Oh , the car is old but still in good condition . I just think we should be thrifty , whether you are rich or not . ', ' But ... But ... ', ' But what ? Just remember that thrift is not only a great virtue , but also a great revenue . ', ' Maybe you are right . ']
['Judy , have you ever made out how much money shall we spend ? ', ' Oh , yeah . The total amount is no less than 13,000 RIB , according to our itinerary . ', " What ? That's too much . ", " Sit down . I'll show you the list of our financial budget . First of all , it is nearly 4,000 RIB that we should spend in transportation . ", ' Ah , the transportation fee always takes a great part in the budget . ', ' Then we must pay a large amount of money for the hotel . But if we want to save money , we can choose a hotel which is not so good . ', " Hmm , what I'm fearful of is that the accommodation will also deteriorate once we choose a cheaper hotel . ", " In that case , we can choose the Youth Hotel . It's a good choice , clean and economic . "]
['Julia , what do you think of the network ? ', " Network is omnipresent nowadays . It's quite convenient for people . You see , we can download music and information from the Internet ; I can study from it , too . And the most of all , we can compose , send , and receive e-mails . ", " Yeah , you are right . Internet makes our lives easier . But it's a two-blade sword . ", ' What do you mean ? ', " I mean Internet brings benefit a lot , but also some disadvantages . For example , many youngsters are addicted to the games and they neglect their study ; or some bad guys steal people's money online , etc . ", ' I agree . But I think although it has some negative effects , on the whole Internet does more good to us than harm . ', ' Yeah , you are right . But we have to know how to make good use of it . ']
["I'm tired . ", " Well , you've been working on this assignment for five hours . ", ' Yeah , I need to take a break . ']
['Where are you going ? ', " I'll accompany my wife to the hospital . ", " What's wrong with her . ", ' She is expecting . ', ' Congratulations to you . ', ' Thank you . ']
['Hi , I ’ m Susan.What ’ s your name , please ? ', ' My name is Zhang Ming.Nice to meet you , Susan . ', ' Where do you come from ? ', ' I come from China.Are you American ? ', ' Yeah , that ’ s right.SO what are you studying ? ', ' Business management ', ' That sounds interesting . ']
['Hi , Alex . How are you doing ? ', ' Just fine , Karen . I ’ m just taking a breather from all this paper work ! ', ' I know the feeling . I ’ m calling to let you know about this new Italian place I found . It ’ s right around the corner . ', ' I ’ ll have to try it . You know how I am about Italian food ! What ’ s the name ? ']
['Have you figured out where you want to transfer to ? ', ' I can ’ t think of where to go . ', ' Where would you like to go to school ? ', ' I really don ’ t know . ', ' You can ’ t think of anything ? ', ' I really like where I ’ m at now . ', ' So , why don ’ t you just stay here ? ', ' That may be what I ’ m going to do . ', ' It ’ s a perfectly good school . ', ' You ’ re absolutely right . ', ' Do you know what you ’ re going to do now ? ', ' I ’ m just going to stay at PCC . ']
['Those guys thought they would never lose . But we finally beat them . And look at them crying now . ', ' The bigger they are , the harder they fall . ']
['I can ’ t believe the cost of apartments in New York City . ', ' Oh , you didn ’ t know that apartments here are considered valuable , even if they are small and crowded ? ', ' Of course I had heard about that , but now I know how expensive it is to rent a place here . ', ' I don ’ t mind paying high rent to live in New York . ', ' Why ? You pay so much for such a tiny space to live . ', ' Yeah , but so what ! I ’ m proud to live in the world ’ s most exciting city . And , the salaries here are the highest in the nation , too . ']
['You see that chick over there ? ', ' The one in the red shirt ? ', " Yeah . Isn't she hot ? ", " She's alright . ", " Just alright ? ! ? She's hot ! ", " Why don't you go talk to her ? ", " You think she's out of my league ? ", " Hell no ! You're just a chicken that's all . ", " C'mon . I get nervous when I talk to girls . ", " Why don't you go stand next to her for a while and if an opportunity comes up , strike a conversation . ", ' What do I talk about ? ', " It doesn't matter . You gotta find what she's interested in and go with that . ", " I don't know ... ", ' Do you want me to go talk to her ? ', ' No . Stay away from her . ', " If you don't do anything , I'll bet somebody else will . ", " Ok already . I'll try . "]
['How about a movie tonight ? ', ' It doesn ’ t matter to me . ', " Does 7 o'clock suit you ? ", ' Either way . I don ’ t care . ', ' How about a snack after work ? ', ' I couldn ’ t careless . ', ' Would you rather stay home ? ', ' Whatever you say . ', ' Are you really interested in doing something ? ', ' I don ’ t mind if you want to . ']
['Have you ever played Making ? ', ' Not really , but I know it is very popular a traditional Chinese gambling game . ', ' Yes , some friends play it all day , all night , and sometimes a whole weekend . I tried to read about some basic rules online , but it is hard to understand . So I went to watch people play yesterday only to find I was even more confused . I think I have to work hard on those rules and more learning by doing . Practice makes the master . ', ' Typical Francis , whether you are at work , or engaged in leisure time activities , you always show the same eagerness and curiosity to learn something new and improve yourself . ', ' It is important to keep your mind up-to-date and active . ']
['Thank you for showing me your offices , Mr . Becker . I can see why Washington bureaucrats enjoy their jobs . ', ' Why do you say that ? ', ' The city is beautiful , the off ... , the offices are modern and comfortable , and the work is so interesting . ', ' Many people work for the federal government their entire adult lives . Government service can be a rewarding and secure career . ', ' Do you mean financially rewarding ? ', ' Well , many positions pay salaries that are comparable to those in private industries . ', ' I ’ Ve always thought that most bureaucrats are lazy . ', ' Sometimes that ’ s true , but not usually . Most feds are honest , hard-working professionals . It ’ s hard to keep highly trained people , so the pay and working conditions have to be attractive . ', ' How much do you make ? ', ' I ’ m a GS - 15 . That ’ s high on the scale of workers , but even a GS - 1 is paid a living wage . ']
['Do you have any idea for this vacation ? ', " Why don't we spend this vacation earning our tuition ? ", " Oh , yeah , let's try to find some jobs . ", ' OK . ']
["Is this Mr.Smith ' s residence ? ", ' Yes , it is . ', ' My name is Paul.Is Mr.Smith in ? ', ' Yes , he is . ']
['Mary , how was your date with John ? ', ' It ’ s OK . It seems we have a lot in common . ', ' Oh , really ? That is great news . What does he look like ? ', ' He is tall and slim , fair-haired . ', ' Sounds like he is pretty cute . What do you think of him ? ', ' He is a nice guy and very considerate . I am impressed with how smart and humorous . ', ' Oh , it ’ s love at first sight . ']
['So click here , then up to the top . ', ' Er ... Hum ... Got it . ', ' Then open that window.Yeah , that one . ', ' Right ! ', " And that's it . You're done . ", ' I see what you mean . That was pretty easy after all . ']
['Sam , we are hard up for the everyday expenses . When can you find a job . ', " I'm looking for it , but you see , the market shard for jobs , too . ", " You liar , I saw you again in the inn . I bet you don't want to work at all . "]
['I immigrated here last year . ', ' What do you do ? ', ' I am an engineer in a mechanized farm . ']
['I really should be on my way . ', ' Oh , not yet . At least have one for the road . ', ' No , thanks all the same . ', ' Well , I am sorry you have to leave so early . ', ' Thank you very much . We really had a good time . ', ' Well . Thank you for coming . ', ' So see you . ', ' Bye . ']
['I hear your daughter graduated from high school as the valedictorian . ', ' Thank you . ', ' Where is she going to college ? ', ' She has been admitted to Yale with a scholarship . ', " Really ? That's the icing on the cake . Congratulation again ! ", ' Thank you . ']
['Hey Jackie . What are you doing ? ', " Nothing much . I'm just relaxing today . Why ? What's going on ? ", ' I was thinking about heading to the mall . Do you want to go ? ', ' Are they having a sale ? ', " Yeah . Both Bon and Nordstrom's is having there annual sale . It's a great time to buy some clothes you've been holding out on . ", ' That sounds great . Where should we meet ? ', " I'll meet you in front of Nordstrom's in 30 minutes . ", ' Sounds good . See you there . ', ' What do you think about these shoes ? ', " They're cute . But do you think you'll wear them much ? ", ' No . Not really . ', ' This sweater is so pretty . I love the low neck design . ', " I bet it's expensive . ", " It's on sale for $ 80 . What do you think ? Should I try it on ? ", ' For 80 bucks it looks great . Go try it on . ']
['It ’ s so relaxing , taking a walk in the country . The air is so fresh and clean . ', ' Would you like to live in the country ? I ’ m not sure I ’ d like it . ', ' I can see a lot of advantage and disadvantage . The problem is that , for me , each advantage has its own disadvantage . ', ' What do you mean ? ', ' Well , I hate the noise in the city , but I love being around lost of people . The problem is that you can ’ t have lots of people and have peace and quiet . The tow just don ’ t go together . ', ' I see what you mean . I love being far away from a city , but I hate being so far away department stores and sports facilities . ', ' People can ’ t have it both ways . If you live in the country , it is often less convenient . If you live in a city , it is noisy , buy there ’ s more to do . ', ' I would love to be surrounded by hills and streams . They ’ re so much better to look at than concrete , rows of parked cars and tall buildings . ', ' I would love to hear the birds singing and feel the fresh breeze on my face . When the wind blows in the city , you get dust in your mouth and in your eyes . ', ' The view from the hill is so beautiful and relaxing . There ’ s so sign of pollution . The village looks so peaceful . ', ' Just remember that in that village there ’ s nothing to do . There ’ s not even a pub or restaurant . There ’ s just one small shop with a poor selection of goods . ', ' You ’ re right . I would have to travel to the city at least once a week to go shopping and see friends . I would hate living in the country ! ']
['I want to leave the motorbike outdoors . ', " Fine , just don't do it at night . ", ' Why not ? ', ' The cold weather will damage the engine . ']
['You want to go with him ? ', ' Yes ? ', ' Then you must be off your head . He is a real bastard . ']
["how's it going ? ", " I'm in a really good mood , actually . How about you ? ", " to be honest , I'm a bit fed up . ", " what's wrong ? ", ' well , my boyfriend was supposed to call me last night , but he never did . ', " that's too bad . I'm sure there's a logical explanation for it . Don't be too upset about it . ", " the thing is , this isn't the first time he's promised to do something and then didn't . ", ' I see how that can get a bit annoying . ', " a bit ? I'm extremely annoyed that he didn't phone me when he promised me that he would ! He's such a liar . ", ' so what are you going to do about it ? ', " I don't know . I've got mixed feelings about it . On the one hand , I really want to end it with him , but on the other hand , I don't want to be without him . ", ' what do you think would make you happier ? ', " in the long run , I think breaking up with him would make me much happier , but I know that I'll be depressed about it for a few weeks first . ", ' relationships can be confusing sometimes . ', ' what would you do if you were me ? ', " I'd call him and dump him now ! You deserve better than him ! "]
['Our philosophy teacher is very humorous . ', " I usually have the wrong notion that he's very serious . ", ' No , not at all.The examples he gives are very interesting . ', ' No wonder when I pass your room , I always hear your laughter . ']
['Bonjour ! ', ' What ? ', ' I said , Bonjour ! ', ' What ’ s wrong with you , Ted ? ', ' I ’ m speaking French . Don ’ t you know anything ? ', ' What ’ s wrong with speaking English ? ', ' Well , I just got back from my language school . We have to speak French all day there . No English allowed ! ', ' What are you doing that for ? ', ' I ’ m trying to learn new skills . It makes me more qualified for a good job . ', ' Good for you . ']
['What have you been up to , Johnny ? ', ' You know-sweeping , scrubbing , washing , drying , waxing , polishing ... ', " Wow , your grandma's really having a field day with you , huh ? ", " You got that right ... and my mom's still mad about what we did with the dishes . ", " You have all the fun , don't you ? ", " Listen , I'd better get back to the grindstone . ", ' Sure thing , Johnny . Watch out for dishpan hands there , kid ! ']
["I'm scared that she might not come back . ", " No , I don't think she's that strong-minded . ", ' But she took her luggage away with her . ', ' She will be back soon.You can wait and see . ']
['What time do you have ? ', ' A quarter past five . ', " I must be off now . I'm pressed for time . ", ' See you . ']
["I really enjoyed tonight's party . Thank you , Sarah . ", " You're welcome , Bob . It was nice meeting you . ", ' Nice meeting you , too . ']
['My eyes water continuously . Why ? ', ' Perhaps because of the dirty air . ', ' What is there in the air ? ', ' Some poisonous gas . ', " I can't believe that the air in this city is so dirty . ", " Yes . I think I won't come here again next time . ", ' So do I . ', ' We waste a vacation . ', ' Maybe you are right . ']
['Who did the stupid thing ? ', ' Maybe it was Dick . ', " I don't think so . Dick has been on the ball and he never does things like that . ", ' Then it must be a naughty boy who did it . ']
["Rose , the weekend is coming . Let's discuss what we will do . ", ' What about going to the zoo on Saturday and to the park on Sunday ? ', " Sounds good . But on Saturday there's a football final . ", ' Then , what shall we do on Sunday . ', " Let me see . We can visit the country . We haven't done that for such a long time . ", " Good idea . I'll go shopping in one of the department stores nearby . We'll go to the zoo and the park another time . After all , we can put that off . ", ' OK . ']
['I haven ’ t met Bob for years . How is he ? ', ' He has been keeping bach after divorce . ', ' He would have recovered from the stress and got married again . ', ' Once bitten , twice shy . He said he would rather keep bach than to live in disgust . ']
['Daniel , have you ever heard about the wildlife sanctuary ? ', ' Is that different from this kind of zoo ? ', ' Yes , of course . ', ' So tell me about it ! ', ' There are a lot of wild animals in that place , and also some special rules while visiting . ', ' Special rules ? ', ' There , you only have two ways for visiting . ', ' Details ? ', " On their bus or in your own cars , and you won't be allowed to get off the bus until you reach the special region . ", ' Why not ? ', ' Because it is dangerous to get out of the car or bus . You can just imagine how fierce the wild animals can be . ', ' That makes sense . But that sounds interesting . Is there one in Beijing too ? ', ' Yes . ', ' I prefer to go there next time . ', " Yeah , sure , you won't be disappointed . "]
['What subject do you like best ? ', ' English is my favorite . ', ' No wonder your English is so good . ', ' Thank you . ']
['Has the chief accepted our plan ? ', ' Not yet . I guess we should send Jim along to talk to the chief since he is such an apple polisher . I am sure he can help . ', ' Let ’ s have a try . ']
['What are you doing there with your mobile phone ? ', " I'm moblogging ! ", ' Moblogging ? what does that mean ? ', " Oh , moblogging is a combination of the word ' mobile ' and ' blogging ' . It's another form of blogging . Users can publish blog entries to the web from a mobile phone or other mobile devices . ", ' Sounds interesting ! That must be very convenient . ', " Yes , you're right . I can blog wherever and whenever I'm on the move . It's especially good when I'm on a business trip and my laptop happens to be away from me . ", ' How can you do that ? ', " Well , if I simply want to write a few words , I'll send it by email or edit it all from the cell phone browser . ", ' What if you want to publish some photos ? ', " Then I'll shoot some pictures , re-size the images and upload them with text descriptions to my blog . ", ' I see . Moblogging must have done a great favor for habitual bloggers like you . ', ' You bet it ! ']
['Wow . Look how polite your son has become . ', ' Yes . We had a big talk with him , and he has really turned over a new leaf . ']
["I don't think much of the film . ", " But I think it wasn't too bad . ", " Really ? Do you like the story ? It's sheer nonsense ! ", " It's exaggerated . Actually this sort of thing happens to everyone . "]
['Excuse me , can you suggest a good book for me to read ? ', ' Yes , they are all on the shelf . ', ' Do you have an English-Chinese dictionary ? ', ' Yes . Here you are . ']
['So , Karen , what do you do in your free time ? ', ' Well , I like to play the piano . ', ' Really ? How long have you been playing piano ? ', ' About 18 years , I started learning when I was a kid . ', ' That ’ s really interesting . you have to play for me some time . ', ' Sure , so , what about you ? Do you have any hobbies ? ', ' Well , I collect beer mats . I ’ m not sure that counts , though . ']
['Why are you laughing ? ', " I can't help it . "]
['Well , how was your honeymoon ? ', ' It was fantastic ! We had such a good time . The only problem was that because it was their high season , we spent hours queuing . ', ' Peak periods always entail hours of queuing . At least you got a nice tan though ! ', ' Yes , Florida had great weather while we were there . You look tan , too . Did you go somewhere ? ', ' My friends and I just got back from Bali . ', " Wow ! Bali Islands have some of the best beaches in the world , don't they ? ", " Yes , we were lucky . My friend's father owns a resort on one of the islands , so we were able to stay for free . ", ' Did you go diving while you were there ? ', " I took a few diving classes , but I didn't really like it , so I did snorkeling instead ! ", ' Did you take any pictures in the ocean ? ', " I've got quite a few pictures of all different kinds of fish . I'll show them to you next time I see you . ", ' Have you started planning your christmas vacation yet ? ', " We're planning on going skiing in Switzerland . Do you ski ? ", ' No , but I do like snowboarding . ', ' Would you like to go skiing with us for christmas ? ', " I'll talk to my husband about it ; I'm sure he'll say yes ! He loves Switzerland ! ", " It is Europe's spotless land of lakes and mountains ! Let me know as soon as you can so we can get a discount . "]
["I guess I'd better go now . ", " I've got to be going now too . ", " In that case , I'll be seeing you . ", ' See you later . ']
['I ’ Ve just take out an insurance policy . Are you insured ? ', ' Yes , I am . I have life insurance and my home and its contents are also insured . ', ' I took out a life insurance policy and make my wife beneficiary . ', ' That ’ s a good idea . You are a fireman and it can be a dangerous job . ', ' I need to make sure that my wife will be financially secure if I die . ', ' I can terminate my life insurance policy when I retire and use the money as a pension . ', ' That ’ s one of the conditions of my policy too . It covers you if you die before you retire and when you retire . ', ' Did you have to take a medical before you could take out the policy ? ', ' Yes , I did . It was one of the conditions of the insurance policy . The insurance company need to assess the risk . ']
["You look pale , Paul.What ' s wrong ? ", " I've got a headache . ", " I'm sorry to hear that.Anything I can do for you ? ", " No , thank you . I'll take an aspirin and see how it goes . "]
["I can't decide whether to go to university or to get a job . ", " Well , if I were you , I'd go on studying . ", " But I don't even know what to study . ", " If I had chance again , I'd major in English . You're good at language . ", " That's what my parents want me to do . ", " You should take their advice . They know what's best for you . ", ' But my friends will have jobs and lots of fun , while I spend all my time doing reading and writing . ', " But if you go to university , you'll still have time for fun . ", ' Hm , what you say makes sense . But you know , I still have to ask my parents for pocket money , and I hate to do so at this age . ', " And if you try to find a part-time job , you'll have some money too . ", " You're right . Thank you for the advice . "]
["Let's program your courses , since you have had English literature , you should take American literature and American prose and fiction . You transcript indicate that your english background is strong , so I don't think you have any problem with it . ", ' How many credits for each course ? ', ' Three , you also should take two three-credit-course in education department . ', " Thank you , sir , I'm sure I will . "]
['You mean it shuts off to save energy ? ', ' Yep . And it breathes , see ! ', " It's not breathing ! ", ' Yes , it is . Look at the little light ! It blinks off and on . ', " Jen , it's not alive ... but it does look user-friendly . ", ' I would look so cool carrying this around ! ']
['The art critic from the daily chronicle doesn ’ t think much of the max oreo exhibition . He says that the artwork is uninspiring and old fashioned . ', ' Really ? I thought the exhibition showed that he had real talent . What did you think of it ? ', ' I liked it . I didn ’ t think his works were masterpieces , but the certainly weren ’ t uninspiring , in my opinion . ', ' I don ’ t think I ’ Ve ever read a good review of an exhibition by that critic . He doesn ’ t seem to like anything . Which kinds of paintings do you prefer ? ', ' I like landscapes and still life . You prefer abstract paintings , don ’ t you ? ', ' Yes , I do . I like painters who use rather than watercolors . The colors appear richer . What do you think ? ', ' I agree . I prefer oils too . I collect landscapes , but I only have a small collection . You have a small collection of abstract art , don ’ t you ? ', ' Yes . Good artwork is very expensive nowadays . When I was in china , I bought some calligraphy by famous artists . You should come and see it sometime . ', ' That would be nice . Can you read the characters ? ', ' I know what the characters on the paintings mean . I think Chinese characters look very artistic . It ’ s said that the way they are written can give insight into the artist ’ s character . ', ' I think that ’ s true with any of the fine arts . ']
['What do you like to do in your spare time ? ', ' I like taking photos . ', ' Really ? ', ' Yes , look at the photos I took . ', ' They are beautiful . You did a good job . ', ' Thank you for saying so . ', ' As a matter of fact , you are really a terrific photographer . ']
["It's quite cold this early morning , isn't it ? ", " Yeah . It's already December , you know . ", " Time sure flies , doesn't it ? "]
['How did you know ? ', ' It was a kind of sixth sense . ', ' Does it happen often ? ', ' No . ']
['Paul failed again . ', " He'll never do well in mathematics . ", ' How can we help him ? ', " Well , I can't help . "]
['Hi , Elvin . How are the new programmers I got for you ? ', ' Stay away from me . ', ' Are you still mad about your nose ? How is it ? ', " I'm serious , Zina . Back off . I have a bottle of pepper spray in my pocket . ", " That won't be necessary , Elvin . Look , I want to apologize for your nose . I'm sorry . ", " Why are you being so nice to me ? Don't think for a second that I trust you . "]
["I'm afraid I've got to go . I have another appointment at five . ", ' Do you ? By the way , could you mail this letter for me as you go through the lobby ? ', ' No problem . ', " Thank you . Come back to my office at the same time tomorrow . I'll have the pictures ready by then . ", ' I will . ']
['Are you a smoker ? ', " Yes , I'm afraid I am . My husband is a smoker too . ", ' Would you describe yourself as being a heavy smoker ? ', ' No , but my husband smokes twenty or more a day . ', ' When did you begin to smoke ? ', ' I had my first cigarette when I was seventeen . ', ' Might I ask if you have tried to give up smoking ? ', ' Yes , twice . ']
['Hey man ! How ’ s it hanging ? ', ' Hey man ! Everything is just groovy baby ! ', ' Did you go to the roller rink on Saturday ? I heard it was far out , man ! ', ' I wanted to , but I ran into this foxy lady that just moved to my block ! I was chatting her up a bit and then we mellowed out at her place . ', ' Right on , right on ! Well , Jim went to the rink with Sherry and he said it was dy-no-mite ! He was low on bread , but Sherry paid for everything . ', ' Gravy ! Jim is such a jive turkey man . He is always hitting me up for cash . Anyway , you wanna book and go grab some grub ? ', ' Yeah man , I ’ m starving ! ']
['Are you a newcomer ? ', ' Yeah , this is my first visit here . ', ' You speak good English , though . ', ' Thanks , but I speak English with a strong German accent . ', " But let me tell you , you're doing just fine . I couldn't do half as well as you do when I was learning German.By the way , how long have you been learning English ? ", ' On and off , for quite a few years . ']
["That's a very nice pair of glasses . ", ' Does it really look OK ? ', ' Yes , and I like the color too . It matches your eyes . ', ' And I got it on sale . ', " That's incredible ! "]
["I want to take Shield on a date but I don't have much money . ", ' What does she like to do ? ', ' She likes to golf , dance , and eat foreign food . ', ' Hmm . Sounds like she has pretty pricey tastes . ', ' Well , I really like being with her . ', ' Have you thought about going Dutch ? ', " Dutch , where's that ? ", ' Not where , what . Dutch means you both pay your own way . ', " Oh . I wonder if she'll go for that . "]
['Do you know his sister ? ', " Her name is Laura , isn't it ? ", " That's right . ", ' How old is she ? ', " Um ... let me see now , is it 18 or 19 , I can never remember ... 18 ... 19 next birthday . Tthat's it . ", ' What does she look like ? ', ' Well ... ', ' Pretty , is she ? ', ' Yes ... quite pretty . ']
['Are you free tomorrow , Sam ? ', " Yeah , what's up ? ", " I'm going to go hiking . Do you want to join me ? "]
['I like to stay here . ', ' Why ? ', ' People are very kind down your way . You ’ re lucky . ', ' Yes , do you always gather to welcome new comers ? ', ' Never . ', ' Really ? ', ' Yeah . People down our way hardly speak to each other . ']
['You are studying here , aren ’ t you ? ', ' Yes . I have been here for three years . ', ' Do you like this campus ? ', ' Well . I ’ m rather disappointed with it . ', ' How come ? ', ' It ’ s too old . And it isn ’ t as specious as I expected . ', ' Oh.It ’ s awful , but it can ’ t be helped . ', ' I ’ ll just have to put up with it . ']
["Why don't you go out with Jack ? ", ' He makes me sick . ']
['Wow ! What happened to you ? You look sad . ', ' I just lost my job . My boss just told me . ', " That's unbelievable . Why did this happen ? ", " I don't understand of myself . It seems they have to save money . ", " I cant't believe it . You've worked here for years . "]
['How can I lose weight , doctor ? I seem to get fatter even when I just look at food ? ', ' Well , Jim . It is a combination of how much you eat , the type of food you eat , and when you eat your meals . ', ' I never eat breakfast though . ', " That's a big mistake , you should always have a good breakfast . You will not run your car without fuel , and yet you won't expect your body to work without food . ", ' I never thought about it that way . ', ' I bet you eat a large evening meal , then sit and watch TV or read a book . Then instead of burning off your energy , your body stores it as fat . ', ' Oh doctor , I feel so foolish . ', ' Well control is really using common sense when you plan your eating habits . ', ' I know doctor , thank you so much . ']
['I think the biggest environment problem in my country is air pollution . ', ' Yes , I agree . The air here is much more polluted than in my country . ', " That's because your country is more agricultural and has much less industry . ", ' Yeah , you are right . ', ' We have reduced emission of air pollutants in recent years , but cars are still a major source of them . Factories have become cleaner as stricter environment pollution laws have been introduced . ', " The problem is now on a truly global scale . I don't believe that any single country can do anything about it . ", " I think you're right . An international response to this problem is needed . "]
["Excuse me , can you tell me where I can take a taxi ? This is the first time I have been in England , so I don't know where I can do at all . ", " Of course.Don ' t worry . I'll call one for you . ", ' Thank you very much , by the way , is it quite expensive to take a taxi ? ', ' Yes , besides it versa according to the distance . ', ' All right . I only hope to get a skillful driver , and drive me to my stop safe way . ', ' No problem . ', ' Thanks a lot , bye bye . ', ' You are welcome , bye . ']
['Whose handset sounds so beautiful ', " Mine . It's My Heart Will Go On , the theme song of Titanic . Isn't it of strong character ? ", ' Are you able to compose music ? ', ' No , not yet . ', ' Who composed it for your ? ', " You needn't ask anyone . You can get on line to search for one . ", ' Can I get on line to search one , too ? ', ' Yeah . Web sites provide many melodies for handsets like my ERICSSON . ', ' What about my SIEMENS ? ', " Numerous . It's time that everybody is particular about personality.Find one and change yours . "]
["I don't know what to do about the people who live in the flat above me ! ", ' Why ? What are they like ? ', " They're incredibly selfish . They ' re always up until the wee hours of the night playing their music so loudly that I have to wear earplugs in order to fall asleep ! ", ' Have you ever talked to them about it ? ', " I tried to introduce myself to them when they moved in , but they were so arrogant that I didin't want to ever talk to them again ! ", ' What did they say ? ', ' They both just talk about how great they are all the time . ', ' They soud like the neighbours from hell ! ', " They are ! Besides being loud and arrogant , they're also terrible gossips . They're always talking about everybody else in the apartment . ", " I thought you didn't talk to them much . ", " I don't , but they talk so loudly that I can hear what they're talking about from my bedroom - and it's not very nice . ", ' What do the other people in your apartment think about them ? ', ' Most of my other neighbours are scared of them . ', ' Maybe you should think about moving . ', " I can't afford to move right now . ", " Well , perhaps you should have a party and try to get to know them better . Maybe once you get to know them , they'll turn out to be more sensitive . ", " I think you're being a bit optimistic . If you met them , you'd understand . ", " Well , I don't know what else you could do then . Do you think bribing them with chocolate would work ? "]
["It's nice and bright today , isn't it ? ", ' Yes , the autumn is marvelous here . ', ' Tomorrow will be fine too , I think . ', ' I hope so . ']
['Susan , I am inviting you and Frank to our house warming party this weekend . ', ' A house warming party ? ', ' Yes , Deborah and I are going to buy a new home in Woodlawn . ', ' Congratulations ! That ’ s wonderful . I bet both of you are quite happy . ', ' Well , we have always dreamed of owning our own home , but real estate in this area is extremely expensive . ', ' I understand . That ’ s why Christopher and I want to find a place in a small town , far from the city . ', ' That ’ s a good idea if you can find employment nearby . ', ' I agree . That ’ s why Christopher is already looking for a job in Maine , or Wisconsin . ']
["Tell me something about your Valentine's Day . ", ' Ok , on that day , boys usually give roses to the sweet hearts and girls give them chocolate in return . ', ' So romantic.young people must have lot of fun . ', " Yeah , that is what the holiday is for , isn't it ? "]
['How are you doing , Andrew ? ', ' Not well . I ’ Ve been feeling pretty lonely lately . ', ' But you have so many friends ! How could you be lonely ? ', " You know what they say'a friend to all is a friend to none ' . I don ’ t feel like I really know any of my friends . In fact , I should probably call them acquaintances , not friends . ", ' What about me ? I ’ m your friend . ', ' I know you are , you are my girlfriend . I wish I had a guy friend to hang out with sometimes . ', ' I know what you mean . I find it difficult to make new friends , too . It ’ s not as easy as it was when we were young , is it ? ', ' Not at all . ', ' I ’ Ve made a lot of new friends since I started learning English . Maybe you could join a club or take a class to make some new friends . ', ' That ’ s a good idea . ', ' What kind of qualities do you look for in a friend ? ', ' I ’ m not sure . I guess I ’ d like to meet some people who have a positive attitude and want to have a good time . ', ' People who play ultimate Frisbee have a positive attitude ; maybe you should join the ultimate Frisbee club . ', ' That ’ s a possibility . Thanks ! ']
['He dresses in plain clothes and drives an old car . Who would know he is the richest man in town ? ', " You can't judge a book by its cover . "]
['Oh , I must have been sitting in the same position too long . My legs have fallen asleep . ', ' Shift it a little before you get up . ', ' And I need to stretch my legs now . ']
['Hey Susan , what are you coming as this year ? ', ' Coming as ? ', " Yeah ... for Halloween ! We have a big office party tomorrow evening . There's a prize for best costume ! ", " Um ... I have to confess , I haven't given it much thought . I'm from China and Halloween really isn't celebrated there . ", " Really ! You don't have some kind of Chinese ghost festival ? ", ' Oh ... Sure . We have an entire month ! In traditional Chinese culture , Ghost Month is a period when the door between this world and beyond opens up and ghosts come back to earth for a visit . ', ' Cool ! A whole month ! What do you do during that month ? ', " Well , people sometimes set off firecrackers , some people burn paper money as an offering and many people go to a temple to burn incense.Mainly though , you need to feed the ghosts because they're hungry . ", ' Feed them ? ', ' Yeah ... we set up tables with food , fruit and drinks and offer that to the hungry ghosts . ', ' And then later everyone eats the food ? ', ' Yes ! How did you guess that ? ', ' It makes sense , right ? Who else is going to eat it ? ', ' Good Point ! ', ' But no dressing up like ghosts , right ? ', ' No ! So ... is Halloween essentially the same thing as ghost month ? ']
['Hey Annie , who is this picture of ? ', " Oh , that's my great , great , great , great , great , great , great grandfather . ", " I think you can say your seventh great grandfather ! Cutie ! What's his name ? ", ' Peter Madsen . A great A if I do say so myself . ', ' Nice pun . What is it you active about him most ? ', ' He loved his family and his countrymen and his freedom . ', ' He looks like a very personable man . ', ' He was . He was friendly toward and showed concern for everyone he met . ']
['Does Tom drink a lot ? ', ' Yes , he does . He often has had one to many . But I advised him not to drink too much , he just boasted that he had hollow legs and nobody had ever drunk him under the table . ', " That's a problem . He has sort of Dutch courage and that will egg him on in doing anything . "]
['Did you hear ? The state is thinking of legalizing gambling in our city ! Soon we are gonna have amazing hotels and casinos here which will be good for our business ! ', ' Are you serious ? Gambling is a vice industry built on deception and fed by the intentional exploitation of human weakness for the sole purpose of monetary gain ! It disgusts me . ', ' What are you talking about ? How does it exploit people ? ', ' Well , to begin with , Gambling is addictive , ruins marriages , destroys families and bankrupts communities . Once you are addicted it is very difficult to stop . People have lost their houses , cars and been left out on the street after becoming addicted . Secondly , it exploits because men become addicted to gambling most often because of the action and risk . Women gamble to escape , and senior citizens will start gambling for the social interaction . Underage gamblers often start gambling on sports with friends and then illegal bookies . ', ' Geez ! Now that I think about it , maybe legalizing gambling isn ’ t such a good idea ! Although , I have been to Las Vegas , and I didn ’ t become addicted or anything like that . ', ' You cannot predict who will become addicted to gambling . Now excuse me , I have a protest rally to organize ! ']
['Mr . Rogers ? ', ' Mr . : Yes ? ', " I'm not feeling too well . ", " Mr . : Would you like to go to the nurse's ? ", ' Yes , I would . ', " Mr . : Here's a hall pass for it . Do you need someone to walk you there ? ", ' I can manage on my own . Thanks . ', " Mr . : I'll drop by later to check on you . "]
['Can you give me a ride back home ? ', ' Sure ']
['Come on in . I am so glad you are here . We have been expecting you . ', ' Am I late for the party ? Looks everyone is already here . Hope I didn ’ t miss something interesting . ', ' No , you are just on time . We haven ’ t really started yet . ', ' Great , here are some flowers for you . I hope you like them . I was not sure if the color will suit your new apartment . ', ' Thank you , they ’ re beautiful . You can hang your coat over there . Try this new couch , it is so comfortable . You will love it . Want something to drink , tea , coffee , juice or Cola ? ', ' Don ’ t bother . I will help myself . ', ' Make yourself at home . ', ' It is such a nice place . ', ' Well , I don ’ t mean to boast but all the designs are done by myself and some colleagues are already trying to copy some of them for their new apartments . Look , they are making photos now of my designed kitchen . ']
['Have you got any plans for the coming holiday ? ', ' Yes , I have a very special one . I will be doing volunteer work in a zoo for two weeks . A friend of mine working there told me the other day that they were in need of some volunteer keepers . I was very interested . So I asked him to get me the application form . Lucky , my application was approved by the manager very soon . ', ' Volunteer in a zoo ? What specific things will you do ? ', ' I will help to prepare food , feed animals and clean up . I ’ m very excited about it now . ', ' It must be a unique experience . I ’ m looking forward to share your story when you come back . ', ' Ok , I will bring you photos as many as possible . ']
['He is planning again . ', ' Yeah . But whatever the planes are , he always has an eye to money . ', ' That is him . ']
['Happy birthday , Alice , here is a little something for you . ', " Thank you very much , David . It's an excellent birthday gift . "]
['Mike , did you win the lottery or something ? Why the big smile ? ', " I'm so relieved . I just passed the bar exam . ", " You did ? That's great ! You must be very happy now ? ", " That's an understatement . I'm on cloud nine . I couldn't be any happier . ", ' Did you tell your parents yet ? ', " Not yet . I didn't get a hold of them . I'll try to call them again tonight . ", " They're probably going to be so happy . ", " I think so . It's turning out to be a great day . "]
['Where should I park ? ', ' Do you have a car or motorbike ? ', ' I drive a scooter ', ' In that case , you can park either in a student lot or on the street . Are you aware of the marked handicapped spots ? ', " No , I haven't seen those spots . ", ' The handicapped logo with blue means that you are not to park there unless you have a handicapped permit . Will you mostly be parking during the day or the night ? ', ' I park in the daytime . ', ' Make sure you pay special attention to the street signs with time limits . Have you noticed those signs ? ', ' No , I have not seen the signs . ', ' Pay attention to what the signs tell you in terms of time limits and what days you can park there . Do you know what the curb colors mean ? ', " No , I don't know what the curb colors mean . ", " Just remember that red means absolutely no parking and white means loading and unloading only . I think you'll be good to go ! "]
['As we know , mobile phones bring people great convenience and shorten the distance among friends and relatives . ', ' It bears a great many of advantages , but also some weak points . ', " Is it ? I've never thought of any disadvantages of the mobile phone . ", ' For instance , the mobile phone seriously distracts the attention of people from work and study . ', " That's true . Some people pay too much attention to their mobile phones . ", " Actually , it's not the fault of the mobile phone . But people should have a proper attitude towards it . Mobile phone is a tool serving people , not the fetters restricting them . "]
["We'll miss you while you're studying in the United States . ", " Yeah . I'll miss all of you , too . But I'll keep in touch . "]
['The dinner was really good . It knocked my socks off . ', " That's very kind of you to say so . Let's try some after-dinner wines . ", ' Great . Sweet wines are my favorite . They always make a great finish to a decisions meal . ', ' Do you prefer brandy or ports . ', ' Port , please . ', ' Excellent choice . I love its smooth flavor . ', ' The port is quite exquisite . It must have spent years aging in barrels . Am I right ? ', ' Yes . You always have a good nose for wines . ', ' Next time we are about to dinner we should try some Canadian ice wine . ', " Oh , what's that ? ", " It's made from naturally frozen grapes . ", ' Why not ? It sounds great . ', " OK , here's to your health . ", ' Thanks . Cheers . ', ' Cheers . ']
['You seem to be unhappy . What happened ? ', ' My mother is ill in the hospital . ', ' What does the doctor say ? ', ' The disease fails to respond to drugs . ']
['Good evening , sir . What can I do for you ? ', ' Bourbon , please . ', ' How would you like your Bourbon , straight or on the rock ? ', ' With iced water , please . ', ' Here you are , sir . Bourbon with iced water . ', ' Thank you . Now how much do I owe you ? ', ' The bourbon is 15 dollars plus 10 % service charge . So the total is 16.5 dollars . ', ' That is OK . Here is 20 dollars and you can keep the change . ', ' Thanks a lot . ']
["Jack's been looking unhappy lately . ", ' His girlfriend broke up with him . ', " No wonder ! I'd be unhappy , too . "]
["I've just got the examination results . I am afraid you haven't passed . ", " Oh , no ! I can't have failed . surely ? ", ' I am afraid so . I am terribly sorry ! ', ' Whatever am i going to tell me parents . ', " Don't worry about that , I am sure they will understand . After all , it was a very difficult exam . ", ' What am I to do ? ', ' You can always take it again . ']
['Three other people started to bid . One called himself Buddhabuyer , so I knew he meant business . I raised my bid twice , but it kept going up . ', ' How high did the price go ? ', " I don't know . I dropped out at $ 250 . ", " You didn't watch the end of the auction ? ", " No . It wasn't the super bargain I thought it was . "]
['more and more Chinese are marrying foreigners . ', " that's true . But I have a low opinion of those women who go out with foreigners . ", ' oh , why ? ', ' I think some Chinese wone marry foreigners for money while others just want to live abroad . There is no true love between them . ', " I wouldn't say that's totally true . I've met many happy intercultural couples . ", " well , then why aren't there many East-West couples where the man is a Chinese and the woman is a Westerner ? ", " I guess it's because the Chinese women are more attractive to Western men . ", ' or because they are less attractive to to Chinese men . ', ' what do you mean ? ', ' you know , usually the woman is in her thirties and she is a left girl . ', " a left girl ? What's that ? ", " they're called that because they're left behind on the shelf . They're also known by their three H's---high diploma , high salary , and high degree . and they're also known as the three S's — single , ", ' you have a point here , but I believe some mixed marriages are based on true love . ', " that ' for sure but very few . "]
['Our maths teacher is rather humorous . ', " On the contrary , I think he's very serious . ", ' No , not at all . His examples are really interesting . ', " So they're easy to remember . ", ' Yeah , how about your maths teacher ? ', " He's an old antique , very serious . ", ' Bad luck , Anne . ', ' Hey ! How about your history teacher ? ', " She's another antique . ", " I'm sorry to hear that . "]
['I enjoy watching Channel 5.They always have films from all over the world . ', ' How about the languages . ', ' I can read the subtitles.My set is a huge-screen one . ', " That's more convenient . "]
['Happy birthday , Ann . Many happy returns of the day ! Here is a present for you . ', ' Thank you , Peter . Come into the dining room . We are going to cut the cake soon . ', ' Ok , who is that girl ? ', " That's Cathy . She is pretty , isn't she ? She likes dancing . Ask her to dance . ", " Well , I don't know . ", " Don't be afraid . She isn't going to bite you . ", ' Who is afraid ? I am not afraid . ']
['How about having a cup of tea with us ? ', ' All right.That ’ s very nice of you . ', ' Would you like to go to the cinema with me ? ', ' I ’ m sorry I can ’ t make it.Thank you anyhow . ']
['Excuse me , could you tell me where you have got that music book ? ', " Certainly . Let me see.Oh , it's on that shelf . ", " It's too high . I can't reach it.Could you help me ? ", ' Of course.Here you are . ', ' Thank you very much . ']
["Let's skip The X-files tonight , Fran . Okay ? Just this once ? ", ' Let me guess . You want to watch the History Channel again ! ', " How did you know ! There's a program on ancient Egypt tonight . ", ' Well , I guess I could tape The X-files and watch it later ... ', " Look , it's starting ! ", " Mysteries of the Pyramids . Didn't we watch this program last week ? "]
['Do you feel like going to see Paul and Claire tonight ? ', " I'd like that very much . ", ' How does 7:30 sound ? ', ' Fine . See you later . ']
['David , have you watched the 82nd Oscar Awards Ceremony ? Avatar got the Award of Visual Effect . The movie sounds great ! ', ' You are so old-fashioned . I have already watched it last week in cinema . ', ' How was it ? ', ' Its 3D animation is attractive and its colorful scenes are also unforgettable . ', ' It is said that The Hurt Locker got the Award of Best Picture . What do you think about this ? ', ' Well , its theme is moving and profound , so from the academic aspect , this is its advantage to win the award . ']
["Wow ! That's a fantastic movie ! ", ' Yes . I love it , too . ', ' Who was the director ? ', " I'm not sure , but I think it must be directed by Zhang You . That's typical of him . "]
['the May holiday is coming up soon . Are you planning on going on vacation ? ', ' I am . I just went to the travel agent ’ s and picked up these brochures . ', ' where are you planning on going ? ', ' I fancy going to Tibet for a few days . Have you ever been there ? ', ' I went a long time ago , before they built the new train that can take you there . ', ' would you recommend going there for a few days ? ', ' personally , I think it ’ d be better to go when you have more time . A few days isn ’ t really enough to get acclimatize yourself and to go on a few excursions outside of the capital . ', ' you ’ re probably right . What do you think about Yangshao ? ', ' it ’ s a beautiful city , but I think it ’ s become too touristy . How about going to a cosmopolitan city like Shanghai or Hong Kong ? ', ' I ’ d like to get away from the big city life . ', ' maybe you should consider going to a hot springs resort outside of Beijing . I heard they are very relaxing . ', ' I guess if I only have a few days , I should probably think about going somewhere that isn ’ t far away . ', ' since the May holiday is the high season , you should probably call ahead to reserve a room . Here ’ s the phone number . ', ' thanks ; I ’ ll give them a call later . ']
['What are you worrying about ? ', ' I am worrying about my husband . ', ' Where is he ? Is he in danger ? ', ' You know , he is a taxi driver . He has to have his eyes peeled all the time when he drives , especially during the rush hour . ']
['Guess who I saw yesterday ? ', ' Who ? ', ' My cousin Monk . Have you seen her lately ? ', ' Not for a couple of years . What happened to her ? ', " Nothing exactly . She's grown into a very attractive young lady . ", ' Oh , she is . ', ' You know , her long lovely blond hair and beautiful blue eyes really make her stand out from others . ', " Not surprising . I bet she's very tall and slim . ", ' Yean . Around five feet five inches tall . ']
["I'd like to talk with you again about what happened . ", " Oh , come on . Let's not beat a dead horse . "]
['What type of movies do you like ? ', ' I like all sorts of movies , primarily drama and science fiction . ', " That's an interesting combination . How about western movies ? ", " Western and horror are the two types of movies I don't care for . ", " Why don't you like horror ? They're entertaining . ", " Some are entertaining , but I find most of them stupid and childish . For example , I don't understand why a person always goes into the house alone when something is suspicious . ", " Ha ha . I know what you mean . But it's just a movie . They need for the characters to do that . "]
['Well , you seem to enjoy speaking English . ', " You can't help learning when you're using it all day . You'll see . A few weeks'study in the school will have a similar effect on you . ", " I hope so . You see , at the moment I find it difficult to get used to the teacher's speed and accent . I'm awfully worried , I can't reply as quickly as she seems to expect . ", " Oh , she likes keeping us on our toes by getting us use English throughout the class . She doesn't mind your making mistakes , though . ", ' You know , speaking in class is a very good chance to put your English to practical use . ']
['Hey , your Chinese is coming along ! ', ' You think ? ', ' Yeah . It ’ s a lot better than mine . ', ' But I still get stuck on the different tones . It drives me crazy . ', ' Hang in there . It ’ ll all come together one of these days . ']
["Tom , you're my good friend , right ? ", " Sure . What's the matter with you ? ", " The exam ! The terrible exam ! I'm not ready yet . Can you tell me how to get good marks ? ", " Don't be so nervous ! Relax ! First , sleep early at night . Second , study two hours a day after school . Third , don't tire yourself out , but don't be lazy . Will that help ? ", ' Yes , thank you . ']
['Alison , would you like to have some more ? ', " No thanks . I've had enough . ", " Actually you haven't had much . ", ' To tell you the truth , I am on the diet . ', ' That sounds ridiculous . Why ? ', ' Well , I am gaining weight these days , and I have to watch my calories . ']
['I feel that Bob ’ s father-in-law is a hard nut to crack . ', ' You have taken words out of my mouth . He is a tough customer . ', ' But his daughter is a very nice girl . ']
['Look ! There are playing The Matrix today . ', ' You are right , look at the crowd . Do you think we will be able to get tickets ? ', " I don't know . If we can't , we can buy from ticket scalpers . ", " No way . I'd rather go to another movie house . ", ' Come on . We are already here . Besides , I really wanna see this picture . ', " All right . Let's see when the next movie is playing ? ", ' Seven thirty . There is only 10 minutes left and look at the long line ! ', ' Shall we take a chance ? ', " Yeah , let's do so . ", " It's moving so slow . ", ' What can you expect with this crowd ? I am praying that no one will cut in the line . ', " I don't think anyone will . ", " I hope not . We are getting closer .. two more ... one more ... it's our turn . "]
["Don't cover up your sadness . Let it go . ", " I'm sorry . ", " It isn't your fault . No one will blame you . ", ' You are so thoughtful . ']
["I've been told that you are a very successful businessman abroad . I wonder how you managed to achieve such success ? ", ' Oh , through a lot of hard work , of course . ', " I suppose that in a foreign country it was difficult at first , wasn't it ? ", ' Surely it was , especially when you only knew few people and little English . ', " You mean you didn't know much English then ? ", ' Right . I only knew a few English sentences . ', " That's incredible . Could you tell me what you did to make a start ? ", ' First , I worked as a servant . ', ' Really ? I wish you could tell me more about your experience . ', " I'd like to , but I must run to a meeting . "]
['Hey , Mike . Can I ask you something ? ', " Sure , what's up ? ", " I'm going to gamble on the world cup tonight . Who do you think will win ? ", ' Good question . I have to think about it . ', ' My husband is betting on France . ', ' France ? Is he crazy ? ', ' What do you mean ? ', ' Well , how can I put this ? France is a terrible team . ']
['Good afternoon , sir . You are really a regular customer here . May I ask you why you come here so often ? ', " I'm a newspaper columnist . I write comments for a living . I enjoy working in a coffeehouse . ", " I see . But isn't it a bit too noisy ? ", " I don't mind . By contrast , I quite like the circumstances , as I can see a variety of people here , who can always give me tremendous inspiration . And the most important thing is coffee as it is my life . ", ' I can see that . Then what is your favorite coffee ? ', " Irish coffee is my favorite . But I can drink any other . I'm not particular on it . ", ' All right . Would you make coffee yourself when you are at home ? ', ' Not very often . Making coffee is a bit troublesome . Most of the time , I just buy takeout at Starbucks . And also , I quite like instant coffee . ', " I think instant coffee is becoming more and more popular . Though its taste is not perfect , it's really cheap and convenient . ", " Exactly . Nescafe is the world's favorite coffee . People love it all over the world ? ", ' Which country makes the best coffee in the world ? ', " Many people think Brazil makes the best coffee . Brazil exports a lot of coffee . But I love Irish coffee . So it's hard to say . Just depends on your taste . ", ' I agree . I heard in the western countries , almost everyone likes coffee . Is that true ? ', " Yes . No doubt about that . For us , coffee is more a living style rather than a simple drink . I heard Chinese people don't drink that much coffee . ", " No , we don't , especially the old people . But more and more young people fall for coffee . ", " I suppose so . That's probably why there are so many wonderful coffeehouses in China now . "]
['Why are there still so many people overweight despite the current fitness craze ? ', " Well , there are certain factors that effect people's size and weight . ", ' What are they ? ', ' One study said that low-income groups have a higher percentage of over-weight people than higher income families . ', ' Why ? ', ' The survey said that the low , income groups eat more junk food on a daily basis . ', ' That makes sense . Probably less time to make dinner and the junk food is cheaper . ', ' And junk food contains lots of fat and oil . There is one final reason why so many people are fat . ', " What's that ? ", ' Nobody exercises any more-not even kids ! The average American home has the TV on for 6 hours a day ! ', ' Wow ! No wonder people are so fat . Say , Carl , looks like you could be doing a bit more exercising . ', ' Yeah , I guess so . ', ' You should consider eating healthier food and getting some more exercise . ', ' Hey , I started a diet and lost 10 pounds . ', ' So what happened ? ', ' Well , I quit and gained it back plus 5 pounds . ', ' You should have kept trying . ']
['Merry Christmas , Lily . ', ' The same to you , Joey . ', ' This is your first Christmas in the US . Here is the gift for you . ', " It's very thoughtful of you . Wow , it is so beautiful . Could you tell me how American people celebrate Christmas ? ", ' Ok . People decorate their houses , place a Christmas tree in the room and maybe sing a Christmas carol together . ']
["Hey , Cindy , I'm so sorry about yesterday . I shouldn't have yelled at you in front of everyone . ", " Don't worry about it . ", " I don't know what happened to me . I just lost it . ", ' I think you just need to get more sleep . ', " Yeah , you're right . Good night . "]
['Jack and Mary broke up . ', ' it ’ s so sad . They had been together for only two months . Do you know what the matter was ? ', ' Mary said Jack was cheating on her . Jack was seeing a girl from his hometown . One day , Mary saw them holding hands and ended the relationship immediately . ', ' really ? I ’ m very surprised . He doesn ’ t look like a guy who ’ d ever do that sort of thing , right ? ', ' no , he doesn ’ t . Anyway , she found out that he had been two-timing her for a long time . ', ' maybe it is for the best . They are not suitable for each other because they have nothing in common and are completely different people . ', ' how so ? ', ' he is an extrovert while she is an introvert . He likes parties while she hates them . ', ' poor Mary ! She really liked him . ', ' anyway , she was right to end things and she deserves better . ', ' do you think they ’ ll get back together ? ', ' no , I don ’ t think so . I know Mary . Once she makes a decision , she won ’ t change her mind . ', ' I hope she ’ ll recover soon . ', ' so do I . ']
['Look , my clothes are wet . ', ' Mine are wet , too . ', ' Unexpectedly , a girl threw a bucket of water on me . ', ' She wished good luck to you . ', ' The Dai people are enthusiastic . ', ' Yes . ']
['Did you hear about Bob and Mary ? ', ' No , what happened ? ', ' They had an argument and split up . ', " Really , what's going to happen now ? "]
['Nick ! How ’ s it going ? ', ' Oh , hey ... ', ' What are you doing in this neighbourhood ? Do you live around here ? ', ' Actually , my office is right around the corner . ', ' It was great to meet you last week at the conference . I really enjoyed our conversation about foreign investment . ', " Yeah , yeah , it was really interesting . You know , I'm in a bit of a hurry , but here ’ s my card . We should definitely meet up again and continue our discussion . ", ' Sure , you still have my contact details , right ? ', ' You know what , this is really embarrassing , but your name has just slipped my mind . Can you remind me ? ', ' Sure , my name is Ana Ferris . Don ’ t worry about it . it happens to me all the time . I ’ m terrible with names too . ']
['Hello everyone ! I ’ m Rick Fields , and here with me is Bob Copeland . ', ' Howdy folks , and welcome to today ’ s game ! You know , Rick , today is a key game between Russia and Canada . As you know , the winner will move on to the finals . ', ' That ’ s right , and it looks like we ’ re just about ready to start the match . The ref is calling the players for the face-off ... and here we go ! The Russians win possession and immediately set up their attack ! Federal gets checked hard into the boards ! ', ' Maurice Richard has the puck now , and passes it to the center . He shoots ! Wow what a save by the goalie ! ', ' Alright , the puck is back in play now . Pavel Bure is on a breakaway ! He is flying down the ice ! The defenders can ’ t keep up ! Slap shot ! He scores ', ' What an amazing goal ! ']
["What's the matter , Lisa ? You don't look too good . ", ' I just found out that my husband is cheating on me . ', ' You mean Mark ? He seems like such an honest guy . ', " That's what I thought . It seems that he's been seeing someone else for about two months . ", ' Two months ? How did you find out ? ', ' I asked for leave and was at home when the telephone rang . I picked it up and a girl asked to talk to Mark . She then asked if I was his sister , and I said no , I was his wife . She hung up immediately . ', ' So you asked him about the girl who called ? ', ' Yeah , he first said it was someone from work . He gave me a lame excuse , and so I pressed him on it . ', " What'd he do ? ", ' He kept trying to make stupid excuses , and then broke down and admitted to a small indiscretion . ']
['What channel did you watch last night ? ', ' Channel 24.It shows some cable networks and no commercial interruptions . ', ' You did ? How do you like the fashion show ? ', ' It was very good . I followed it right to the end . ']
['Sorry to interrupt . Can I have a word with you ? ', ' Certainly.Go ahead . ']
['What are you doing ? ', " I'm surfing the Net . "]
['Would you travel around the world if you had the money ? ', ' At the drop of a hat . ']
['Hello baseball fans , and welcome back to today ’ s game ! My name is Rick Fields and of course , I am here , once again , with the man that seals the deal , Bob Copeland . ', ' It ’ s a beautiful day to see two world class teams face each other and fight for their right to be called champions . ', ' Well , the national anthem has just been sung , and the umpire has started the game . It ’ s time to play ball ! ', ' Roger Vargas is up at bat . The pitcher winds up and strike one ! ', ' A very nice curve ball by the pitcher . The catcher gives him the sign , he winds up and Vargas gets a line drive ! ', ' The players are scrambling to get the ball . Vargas gets to first base and he ’ s still going ! The outfielder throws it to second ! Vargas slides ! He ’ s safe ! ', ' Great play ! ', ' We have a runner on third and up at bat is Brian Okapi ! There ’ s the pitch , he hits it ! It ’ s going , going , that ball is gone ! ', ' Home run by Okapi ! That puts this team ahead by two as we are at the bottom of the fifth inning here at Richie Stadium ! ']
['So , this is the worst story I ’ Ve heard this month . You have my real sympathy , Tim . ', ' You know , all I was trying to do was tell the truth but they obviously didn ’ t take it that way . ', ' I understand how you feel , but you ’ Ve gotta learn to move on . ', ' Yeah , I ’ m dealing with it . Anyway . Thank you , Mike . ']
['I told you that she is no fool . ', ' I know she is quite an article , but I was not sure of her ability to cope with a boss . ', ' She cannot get in Dutch with him . He is her boss , you know . ', ' But most bosses are fools for woman . ']
["Hey , Ann , I am really sorry about last night . I shouldn't have said those things to you . ", " I am sorry too . I know we've been talking about this beach trip for a while . I should have told Bob I was busy this weekend . ", " don't be silly . You guys should spend as much time together as you can . Besides we can go to the beach anytime . ", ' thanks for understanding . ', " well that's what being friends is about , isn't it ? ", " hey , what if the three of us go to the beach together ? Besides , you and Bob haven't seen each other for a while . I don't want my best friend and my boyfriend to be complete strangers . ", " Nah , I wouldn't worry about that . But I don't want to be the third wheel . You two should have some quiet time to yourselves . ", " I know Bob won't mind . You can bring a date , like that guy from the bar you keep talking about . ", " maybe ... I'll think about it . "]
['Hello , Jill . ', " Tom , You're back , come in please.How are you ? ", ' Fine , only a little tired . ', " You'll recover after a good night's sleep . ", ' Thank you very much for looking after my house in my absence . ', " That's all right.Would you have a cup of coffee ? ", " Yes , Please.It ' s very kind of you . ", " Don't mention it . ", " The rooms are very tidy and the flowers grew very well.You are very helpful . I want to thank you for everything you've done for me . ", " It's my pleasure . ", " I bought you some books on literature , I don't know if you would like them . ", " Thank you.Thank you for the trouble you've taken . ", ' Not at all . ']
['Jack and Mary broke up . ', ' It ’ s so sad . They had been together for only two months . Do you know what the matter was ? ', ' Mary said Jack was cheating on her . Jack was seeing a girl from his hometown . One day , May saw them holding hands and ended the relationship immediately . ', ' Really ? I ’ m very surprised . He doesn ’ t look like a guy who ’ d ever do that sort of thing , right ? ', ' No , he doesn ’ t . Anyway , she found out that he had been two-timing her for a long time . ', ' Maybe it is for the best . They are not suitable for each other because they have nothing in common and are completely different people . ', ' How so ? ', ' He is an extrovert while she is an introvert . He likes parties while she hates them . ', ' Poor Mary ! She really liked him . ', ' Anyway , she was right to end things and she deserves better . ', ' Do you think they ’ ll get back together ? ', ' No , I don ’ t think so . I know Mary . Once she makes a decision , she won ’ t change her mind . ', ' I hope she ’ ll recover soon . ', ' So do I . ']
["I wish you wouldn't play the TV so loud . ", ' Sorry . Were you trying to sleep ? ', ' Yes , please ask when you want to borrow my records next time . ', " I'm sorry . You're right . I should have asked . "]
['So , Karen , what do you do in your free time ? ', ' Well , I like to play the piano . ', ' Really ? How long have you been playing piano ? ', ' About 18 years , I started learning when I was a kid . ', ' That ’ s really interesting , you have to play for me some time . ', ' Sure , so , what about you ? Do you have any hobbies ? ', ' Well , I collect beer mats . I ’ m not sure that counts , though . ']
['What do you do in your spare time ? ', ' In summer I go hiking , and in winter I ski . ', ' Do you mind if I come along sometime ? ', ' No , not at all . Glad to have you . ']
['Hi , Craig ! How are you ? ', ' Not so good . I have a terrible cold . ', " Really ? That's too bad ! You should be at home in bed . It's really important to get a lot of rest . ", " Yeah , you're right . ", ' And have you taken anything for it ? ', " No , I haven't . ", " Well , it's helpful to chop up some garlic and cook it in chicken stock . Then drink a cup every half hour . It really works ! ", ' Ugh ! ']
["She is , like , mega-intense , isn't she ? ", " Ha , she is unstoppable . I'm learning so much from her . ", " What's it like to work with her ? ", " She's demanding . But I like that . I mean , I know our timeline is tight . ", ' Tell me about it . ', ' You guys are working around the clock , I know . That guy Dave next to Zina never leaves . ', ' Vince wants us to have everything debugged and ready to go by the end of the month . ']
["I have a suggestion . Why don't we go to a ETV and sing ? ", ' A ETV ? Are you serious ? ETV ? ', ' Yes , why not ? Don ’ t you like ETV ? ', " I don't know . I never went to one . ", " Never ? Really ? I'm surprised . ", ' Many Americans have never gone to a ETV . It ’ s not an American thing to do . ', " But there are a lot of Kts in this town . There's one just two blocks from here . ", " OK , let's go . "]
["I'll see you in Sterlet , then . ", ' Where did you say ? ', " Sterlet . It's spelt 0 , S , T , E , R , L , E , Y . ", ' Right . ']
['Listen to this . Mary got married . ', ' Is she really ? I can ’ t believe it ! ', ' Yes . Yesterday . ', ' Good gracious . That ’ s incredible ! ', ' She married Jerrod . ', ' You ’ re kidding . ', ' She ’ s going to live in Paris . ', ' Really ? I ’ m surprised . ']
['I am trying to decide what school to apply to ? ', ' Are you thinking about a public school or a private one ? ', " I am not sure . What's the difference between them ? ", ' Public schools are usually state funded , whereas private schools usually get their funding elsewhere . ', ' Which is better ? ', " One isn't necessarily better than the other . It depends a lot on the school administration and the teachers . ", ' I hear you have to wear uniforms at private schools . ', ' Yes , sometimes . ']
["Let's program your courses , since you have had English literature , you should take American literature and American prose and fiction.You transcript indicate that your english background is strong , so I don't think you have any problem with it . ", ' How many credits for each course ? ', ' Three , you also should take two three-credit-course in education department . ', " Thank you , sir , I'm sure I will . "]
["I'm not comfortable about this , Sandy . I don't understand most of these games . ", " That's okay . I can explain a little . ", " I don't want to lose all my money . ", " Don't worry . You can't lose all your money.because you won't gamble all your money . ", " I guess you're right . ", " Of course I'm right . I already told you the rule for Las Vegas . Remember ? ", ' Yes , I remember.You must decide how much money you will gamble before you start to play . ', " That's right . That's the best way to have control over yourself.You say to yourself . Tonight I will gamble fifty dollars . Only fifty dollars . No more.If you follow the rule , you can't lose more than fifty dollars . ", " I know it's true , Sandy . But still some people lose control.They start to gamble , and they can't stop . ", " But I won't let you do that . I will watch you . ", ' Okay . ', ' So how much do you want to gamble ? ', ' Maybe 500 dollars . ', " 500 dollars ! That's too much ! You just said you are afraid to lose your money.If you're afraid , why do you want to gamble 500 dollars ? ", " I don't want people to think I'm stingy . ", ' That is a bad attitude to have , Karen ! If you think that way , Las Vegas will be really dangerous for you . ']
['I feel very miserable . I took the death of my wife very hard , you know . ', ' Cheer up ! Let bygones be bygones . ', ' I ’ Ve tried it , not a chance . ', ' It seems you have to take time . ']
['Mary , it was wrong of you to be so late . Mother ’ s very worried . ', ' I ’ m so sorry I ’ m late . But Henry ’ s car broke down . ', ' I don ’ t really like Henry . I like my Rose . ', ' I don ’ t like your Rose . And I do love Henry . And I ’ m going to marry him . ', ' But my Rose is great . ', ' Your Rose is a fool . ', ' Really , Mary , you ’ re horrible . ', ' Why don ’ t you marry Rose , then ? ']
['Mr . : Please open your books to page 10 . ( To Mary ) Can I help you ? ', " I'm sorry that I'm late . I couldn't find the room . ", " Mr . : That's alright . It's the first day of school , after all . ", ' What are we doing ? ', " Mr . : I'm asking the class to read page 10 to themselves . Then I'm going to ask some questions about the passage . ", ' May I have a book ? ', ' Mr . : Here . Write your name inside the front cover . Remember that you must return the textbook to me at the end of the semester , so keep it in good condition . ']
['Hi , Bob ! How are you doing ? ', ' Fine ! How are you ? ', " I'm fine too , thank you . ", " I've come to tell you I'm going to the concert this evening.Will you come with me ? I've two complimentary tickets . ", ' With the greatest pleasure.Where is the concert this evening ? ', ' It will be held at the Music Hall . ', " What's on the program ? ", " It's a piano recital . I'm fond of piano , you know . "]
["I couldn't wait to meet you in person . ", " Me , too . I've heard so much about you . ", ' Same here . ', ' I was looking forward to your arrival . ']
['John , have you ever watched Beijing Opera ? ', ' Yes , I watched once . ', ' What do you think of it ? ', ' Well , honestly speaking , I went to watch it out of curiosity . I ’ d say it ’ s really a special art form . ', ' I couldn ’ t agree more . Actually , I ’ m a Beijing Opera fan . ', ' Really ? Good for you . ']
['Hello , I need to register for a class . ', ' What class are you trying to take ? ', ' I want to take a Psychology class . ', ' Well , there are only two classes open . ', ' Can you tell me what days the classes are on ? ', ' One class is on Tuesday and Thursday from 2 p . m . to 4 . ', ' And the other class ? ', ' That class is from ten to twelve on Monday and Wednesday . ', ' Are you sure these are the only open classes ? ', ' Yes , I am sure . ', ' Okay , sign me up for the class on Monday and Wednesday . ', ' Very well then . ']
['Hi , Martin . I ’ Ve been looking for you all morning . ', ' What ’ s up ? ', ' I want to say goodbye . I ’ m leaving for America tomorrow . ', ' America ? Did you get admit to MIT ? ', ' Yes . ', ' Congratulations ! Susan . I ’ m so happy for you . ', ' Thank you . ', ' Really going to miss you . ', ' Me too . I ’ ll write to you once I get settled . But I have so much to do . You might have to wait a while . But I really will write to you . I love to write letters . I think it ’ s more meaning than the emails even than the phone call . ', ' Ok . Take care . Have a nice journey . ', ' Thank you . ', ' Look after yourself . Bye . ', ' Bye . ']
['Have you ever run into a person who tries to bleed you white ? ', ' I am always on the look out for such girls . ', ' I hear that some guys splash all their money about on them . ', ' Mark is one of them . He has trouble with a girl who turned out to be a dead beat . ']
['I ’ m sure it will be wet when we arrive . ', ' Yes . I dare say it will be . ', ' It will be Sunday so I expected everything will be closed . ', ' No . I don ’ t think that ’ s possible . Some places are sure to be open . ', " But the bank should be closed so we shouldn't to be able to get some money . ", ' Mmm , you may be right . ', ' Do you think we ’ ll need our overcoats ? ', ' No . We couldn ’ t possibly . ', ' Why not ? ', ' It will be summer . So it will be hot . ', ' Is that very likely in England ? ', ' Yes . It could happen . ']
["My disposable contact lenses . They're great for camping ! ", ' Cool ! Each contact comes in its own saline solution ? ', " Yep . They're prescription contacts with UV protection . ", ' Wow ! How high-class ... a new pair for each day ... ', " You just pop'em in in the morning , take them out at night , and then throw them away . No cleaning ! ", ' Cool . So are you near-sighted or far-sighted ? ', ' Near sighted . ']
["hey , Mary , what's up ? ", ' not much . Last night I met this great guy at the bar and we had such a wonderful time that we decided to meet again tonight . ', " oh , that's exciting . What's this guy like ? Is he hot ? ", " well , I didn't think so at first . But as we started talking , I found his extremely funny and witty . I couldn't stop laughing at his jokes ! We have so much in common . We like the same teams , music , a ", ' it seems you two are a good match . What qualities do you look for in a friend ? ', " there's nothing definite I think . I don't have a list or anything , but when I first meet somebody , I can usually tell whether or not that person is going to be a good friend . It seems I have radar h ", " well , that's something I've never heard of . But if you as me what I value most in a friend , I would have to say honesty . ", " I agree . You can't expect a close relationship with a dishonest person . Those are the people that will turn their back on you when you are in need . ", " yeah , I know . A friend in need is a friend indeed . I don't need fair-weather friends either . "]
['Are you studying here ? ', ' Yes , I am studying in Eastern Asian language department . ', ' What are you major in ? ', ' I major in Japanese . ', ' What do you think of the literature course . ', " It's very helpful.the course has let me into a world of literature . i read so many great literatures . "]
['Look at the cloud . ', " It's going to rain . ", " Let's go quickly . "]
["you haven't spent much time with Sophia lately . Are you speaking to each other at the moment ? ", " no , we're not . We've been drifting apart for a while . ", " but you two used to do everything together . I thought you really enjoyed each other's company . ", ' we did , but since she started her new job , all she does is hang out with her new friends from work . ', " can't you hang out with them , too ? ", ' I could , but all they ever talk about is work , so I always end up feeling left out . ', " maybe you should invite her over for dinner , so it's just the two of you . ", " I tried that a few weeks ago and she ended bringing a pal from work with her ! She's so busy these days that it's just impossible to hang out with her . ", " it can't be that bad . She was always a really good friend to you . ", " you're right . She would never talk about me behind my back or hold a grudge . But she just doesn't seem very interested in our friendship anymore . ", " she's probably just excited about her new job . You should give her some time . It would be a shame to lose such a good friend . ", " I've given her enough time . I'm over it now . ", ' I still think you two should try to patch things up . ', " I think I just have to accept the fact that it's time for us to go our separate ways . "]
['Do you like flowers ? ', ' Of course , I like flowers . ', " What's your favorite flower ? ", ' I like peach blossom , because I like spring . ', ' Peach blossom is really beautiful . ', ' Yes . How about you ? ', ' I like lotus . ', ' You have a perfect taste ! ', " But there aren't any lotus now . ", " Yes . It's snowing outside . Let's enjoy the plum blossoms . ", " That's not bad . Let's go . "]
['Where are you from ? ', " I'm from Canada . "]
["There's a double feature at the cinema this Saturday . Do you want to go with me ? ", ' What are the movies that are playing ? ', " There's an action movie with Harrison Ford and a chick flick with Susan Abandon . ", " I've never seen a movie I don't like that had Harrison Ford in it . ", ' So , is that a yes ? ', ' Yes . What time does it start and do you want to meet me there ? ', " It starts at one and yea , let's meet there . It's the cinema on the corner of Lincoln and Main . ", ' Great ! I have a coupon for free popcorn at that theater ! ']
["Did you hear what's going on downtown today ? All the orders from the factory are staging a demonstration in the streets . Not one of the two thousand employees showed up for work today , and they have gathered outside the city hall to demand better working conditions for all factory employees . ", ' Wow , sounds chaotic ... two thousand people in the streets carrying picket signs and shouting slogans . What gave them the motivation to finally organize and call management on the substandard working conditions ? ', " I think they gained courage after the mayor's speech last week on equality and opportunity for all town citizens . Anyway , the sentiments have been brewing for quite some time . I mean , we all know the working conditions at the factory are quite horrendous . ", ' So what kind of demands do they have ? What are they asking for specifically ? ', " They want raises and medical insurance , and I think they want to clean up the factory's safety hazards . That's probably the most important issue . "]
['Hi , Peter . I ’ m afraid I can ’ t make it to dinner tomorrow night . ', ' Oh , why not ? ', ' It ’ s just I ’ m not feeling well . I think I ’ m coming down with a cold or something . ', ' Oh , I ’ m sorry to hear that . Hey , don ’ t worry about the dinner . We ’ ll do it some other time . But you take care of yourself . ', ' Thanks . I will . ']
['Why do you want to spend your summer days in a mountain village ? ', ' I think a mountain village is splendid ! ', " I don't agree with you . It's too small to live . ", ' It has fresh air , and it is nicer than a big town . ', ' I disagree , a big town is more lively . ', ' But I like the small mountain village . The big town is noisy . How charming it is when walking along the hill ! ', ' Well , alright , I agree with you about that , but I still prefer a big town . ']
["It's getting late , and I have to go now . ", " We're sorry you have to leave . ", " Please excuse me , won't you ? ", ' Certainly . Come back soon . ']
["what's your opinion about childless couples ? Will you choose to have no kids ? ", " to be honest , I wouldn't . ", ' why ? Do you have to make a choice now ? ', ' not really . But it has puzzled me for a long time . ', " what's the puzzle ? ", ' my husband and I prefer to have no kids , but my mother-in-law is very traditional and wants grandkids . ', ' oh , I see . I think the older generation tend to think in a different way . ', ' yes . It seems she can never accept a childless marriage . We had a fight last night . ', ' oh , really ? Maybe she is just eager to see her grandchildren . ', " but it's absolutely our own business to have a child or not . ", ' definitely . ', " you know , I often overhear our neighbor , the young couple , fighting about how to raise their kid and I really don't want kids to spoil our happiness . ", " don't worry . I think in most cases , children are the glue that keeps a family together . ", " I guess you're right . But I still prefer to have no child . ", ' sure . You can fully enjoy your time together . ']
["I've had enough of that ! ", ' Why , this is the most interesting film ! ', " I hate the hero.He ' s too cruel . ", " But it's only a film . "]
['How much did you bid ? ', " Eighty-five dollars . If my bid is the highest after three more days , I win ! It's fun ! ", " We'll see how much fun it is after they take all your money ! ! ", " But they won't ! I checked the seller's history , and he got good reviews from other buyers . ", ' What if he had his friends fake the reviews ? ', ' You are so paranoid ! Not everybody is a crook , you know . ']
["It's taking you forever to do my hair . ", ' Give me a minute . ', " You should've been done already . ", ' There you go . ', " I don't think that you're done . ", " What's wrong ? ", ' My hair looks hideous . ', " What's so bad about it ? ", " It doesn't look good at all . ", ' Sorry about that . ', " I really hope that you didn't expect me to pay you for this . ", ' Well , let me talk to my manager , okay ? ']
["Excuse me ! I don't have time to waste . I've been here almost one full hour ! ", ' Sorry , madam . You have to wait your turn . The parking lot is full . ', ' Unbelievable ! Parking in this city is such a nightmare ! ', ' Madam , patience is a virtue . ', " Oh , gosh ! I have to go to the restroom so bad ! I can't bear it anymore ! ", " I'm sure a spot will open up soon . ", " Oh , look ! There's a spot open next to the public restroom ! Can I take it ? "]
["What are we going to do ? I can't get the car out of this ditch . I'm stuck ! ", " I'm worried , Tom . I haven't seen any other cars for almost an hour . ", " I know . This is terrible . What can we do ? This snow doesn't stop falling ! ", ' I told you we should have stayed in town today.The weather report said 100 percent chance of snow.Why did you want to come up here ? ', ' I wanted to show you the cabin . We only had another half-hour to go . ', " Well , now we're stuck . What can we do ? ", " I don't know . ", " I've heard that when this happens , it's important to save energy . ", ' What do you mean ? ', " We're stranded here , Tom . We may be here a long time.We need to conserve the gas in the car . The car's energy is what will keep us warm . ", ' I have plenty of gas . ', " Yes , but the gas and the battery both have to stay working.We can't just let the car run and run.If we do , it will die soon . Then we'll freeze . ", ' So what can we do ? ', ' Turn the lights off.Then , run the car and the heater only about fifteen minutes every hour.That will conserve the heat as long as possible . ', " Alright . That's a good idea . ", " I wish we hadn't come up here . Now we'll probably be here for days . ", ' Days ? ', ' Yes , it happens.That is what happens in big snowstorms . People get stranded for days . ', " Oh , my God ! It's good we have food . ", " Probably we'll survive.But turn the car off for about forty-five minutes . Then we'll turn it on again . ", " Okay , I'll follow your advice . "]
["let's go out for a walk . ", " I don't really feel like a walk . ", ' Well , shall we go to the cinema ? ', ' All right.That sounds more interesting . ']
['Mr . Bellow , have you anything in mind as to what to drink or may I make a few suggestions ? ', ' I have had enough gin fizz and bloody mary . But I have no idea about Chinese cocktails . ', " Would you prefer our cocktail — Shanghai cocktail ? It's a mixture of real Chinese ingredients . ", ' That ’ s good . ', ' ( The waiter makes the cocktail for Mr . Bellow and hands into him . ) Here is your Shanghai cocktail , Mr . Bellow . ', ' Thank you . Oh , it tastes excellent . ']
['Jack I hear you have a chance to go to college without taking a test . Is that right ? ', " The news goes so fast . Ah , yes , I haven't decided yet . ", " Don't hesitate . That's a very famous university which a lot of students are longing to attain . ", ' Maybe you are right . But the major is not fit for me . I like architecture more than computers . ', ' But this chance is really precious . ', ' Well , I know . So I am thinking now . ', ' I hope you can make a clever choice . Anyway , the opportunities around you are not that By . ', ' Thank you for your kindness . I will think about it carefully . ']
['Hi , Janice . Our first weekend after being employed is coming . Show me your plan . ', ' My mom phoned me this morning , and asked me to go back home to have housework chores . ', ' What are you assigned to do ? ', ' God knows . Speaking of chores , I would rather do some washing than cooking . ', ' For me , I think I will iron my shirt and trousers . Actually , weekends tend to be the most hectic day in the whole week . ', ' I really hope that I could sleep like a log all through two nights . But ... Some one said that weekends are a bit like rainbows ; they look good from a distance but disappear before we get up close to them . ', " I couldn't agree more . "]
["Hurry up . We're going to be late . ", ' I am hurrying . ', ' What are you doing ? ', " I can't figure out which dress to wear . "]
['So , did I tell you about my New Year ’ s resolution ? I ’ Ve decided to go on a diet . ', ' And you ’ re going to completely transform your eating habits , right ? ', ' Exactly ! I ’ m going to cut out all that junk I eat . no more chips , no more soda , no more fried food . ', ' I ’ Ve heard this one before . ', ' But this time I ’ m going to stick to it . I really mean it ! Trust me , Carol , I ’ m going to be a new man in one year ’ s time ! ', ' Well , I guess we ’ ll just have to wait and see . ', ' Thanks , honey , that was a great meal . I ’ m stuffed . Do we have any chips left ? ']
['Will you be joining Billy and I at the Bar ? ', ' Which one will you be going to ? ', ' We are going to try the new one that opened up on 17th Street . ', " Sure , I've been meaning to visit that place myself . ", ' I want to stop off at my apartment to get changed so I should be there by 9 pm . ', ' OK , can I bring a date with me ? ', ' Certainly . But if there are going to be four of us , I had better make reservations . ', ' Yes . that is a very good idea . It would be a shame if we could not find a place to sit . ', " Then I'II make reservations for 9 pm for a party of four . ", " I'll be there . Oh , is there a cover charge at the bar ? ", ' Not that I know of . Why do you ask ? ', ' I want to make sure I bring enough money for my date and I . ', ' I hear the drinks and food there are moderately priced.You should be fine . ', ' One last question.Is there a dress code there ? ', ' No , its very casual there . Leave your jacket and tie at home . ', ' Perfect . I wanted to have a casual evening tonight . ', " I'll see you there at 9pm . ", ' Okay . See you then . ']
["What's the most popular sport in your country ? ", ' Table tennis . ', ' Do you play table tennis ? ', ' Not really , but I like watching . ']
["I've really enjoyed your party , Lisa . ", ' Not at all , Sam . ', ' I wish I could stay longer , but I must be going . ']
["It's snowing heavily . ", ' It is very common in the winter in Ottawa . ', ' The snow is so beautiful . ']
['Give me Scotch , please . ', ' What brand ? ', ' Black Rose . ', ' Soda or water ? ', ' Just plain water with plenty of ice rock . ', ' All right . Please wait for a minute . ']
["Have you ever seen Bill Gate's home on the internet ? ", " No . what's it like ? ", " It's got its own library , theatre , swimming pool , and a guest house . The house itself has about ten different rooms that are all hooked up to computers so you can get things done in each room through a remote control . It's also located near the sea , so he can park his boats next to his house . It's absolutely amazing ! ", ' Would you want to live there ? ', " I think his house is fantastic , but I wouldn't want to live there . You would have to hire one or two people to clean all the rooms in the house , plus a few people to take care of the gardens , and probably an au pair or two to take care of the children . It's just too big of a place to take care of on your own . ", " What's your dreamhole like then ? ", ' My dream home is actually just a small cottage in a quiet village in England . ', ' Would you want to buy an old cottage or build a new one yourself ? ', " Old homes are great because they've got character . I think that's important . ", " Is that why you wear second-hand clothes as well ? Because they've got character ? ", " No , that's just because I don't have enough money to buy new cloths all the time ! ", ' I see . If you lived in an old house , would it be decorated in a modern way ? ', " No , I'd definitely try to restore it to its original state . I love to imagine what it'd be like to live in another time in history and living in a house decorated like it would have been 200 years ago would be a great way to feed my imagination even more ! "]
['Rachel , do you like music ? ', " Of course . I can't live without it , so I always bring my CD with me no matter where I go . ", ' What kind of music do you like best ? ', ' Light music and classic music . ', " Really ? I can't believe this . I am also keen on classic music . And do you know there is a concert of classic music tomorrow evening ? ", " But I didn't get the ticket . And it is said that they were sold out yesterday . ", ' I got two . We can go there together . ', ' Amazing ! I can imagine the feeling when I hear the smooth tune around my ears . ']
['Look at what you have done . All thumbs . ', ' I ’ m so sorry , and I will pay much attention to it later . ']
['What is your hobby ? ', ' I spend most of my spare time reading . And I subscribe to various newspapers , magazines and periodicals . ', ' What kind of reading materials do you like best ? ', ' I am interested in science fiction . ']
['You look great ! ', " Thanks to you . I'm totally pumped up . ", ' So you are happy that you made the decision to join us . ', ' I surely am . But still there is one single problem . ', " What's that ? ", ' I eat more and more these days . And it puts even more weight on me . ', " It's not good to start with too much work-out at the beginning . What about trying something else ? ", " I'd love to do that . What do you recommend ? ", ' More and more people are warm up to Yoga these days . Do you want to have a try ? ', " Do you think it's a good option for health and relaxation ? ", ' Absolutely . But it takes great perseverance to master . ', ' I can so that . ', ' Here is a free class going on right over there . Go and join them . ', ' How did it go ? ', ' Everything was okay when it started , but the music made me drowsy . So I think I may have dozed off for a minute over there . ']
['Do you have to leave soon ? ', ' No . Actually I can stay longer . Dave called to say that there is a beautiful Chinese girl who ’ s going to pick me up at the school gate tonight at ten thirty instead of eight thirty . ', ' Oh , that ’ s better . So you don ’ t have to rush . ', ' Yeah . You know what Dave just said ? ', ' What ? ', ' He said I should put on something very nice , because this girl will be my next target . ', ' He knows you very well . ', ' He always makes fun of me . He always says things like that . You know the new coming teacher , a Chinese Canadian . He said she would really be my chance . ', ' I ’ m sure you have chances everywhere . You ’ re handsome , talkative , and got a sense of humor . You must be very popular . ', ' No , you ’ re kidding . I ’ m not taking it seriously . ']
['This small town has many serious problems . ', " What's the cause ? ", ' The mayor and high official practice crony is mand a large number of guys who are good at nothing occupy many important positions . ', ' I see why it lags behind other towns . ']
['Do you see the woman ? Is she a teacher ? ', ' Yes , she is . ', ' Does she teach Chinese ? ', ' No , she is an English teacher . ', ' And who ’ s the man in the green beside her ? ', ' You mean the man wearing jeans ? He ’ s her little brother . ']
['which countries have you been to ? ', ' I ’ Ve been to most of the countries in Europe , several countries in asia , china , Japan , korea , and Thailand , and to the united states and Canada . ', ' I thought you had been to Australia too . ', ' no , but I ’ m planning on visiting Australia and New Zealand soon . I ’ Ve heard that they are beautiful countries . Which is the most beautiful country you ’ Ve been to ? ', " I think I'd say Norway . It has many pictures as fjords , waterfalls , and mountains . ", ' isn ’ t it really cold there ? ', ' well , the north of Norway is almost always cold , but further south it can be fairly warm in summer . It ’ s a wet country , so there ’ s snow almost everywhere in winter . ', ' I ’ Ve been to other Scandinavian countries , but not to Norway . Perhaps I should go and do some winter sports there . ']
["What's bothering that guy ? ", " Nothing . He's just got a chip on the shoulder . "]
['Jane , I was wondering if you you had any plans for saturday afternoon . ', " A friend and I are planing to go out , why ? what's up ? ", " There is a special exhibition of french sculptures at the museum , I was hoping you ' d like to come with me . ", " I am afraid I can't I am going to be out all day . ", ' What about sunday ? ', " I wish I could , but it's my mums birthday . ", ' Maybe next week . ', " Much as I ' d like to , I am afraid i wont be free next week , I have a lot of work . ", ' Sorry to hear that , I was really looking forward to spending some more time with you , I really enjoyed our last chat . ', ' I am really sorry too , maybe I can give you a call sometime . ']
['Hello , Mrs Turnbull . How are you ? ', " Fine , thanks . How's your boy , Jack ? ", " He's a bit tired . You know , he goes to school at eight o'clock every morning.He doesn't get home till after four . then he does his homework after tea . It often takes him a couple of hours to finish ", " Poor boy . They work hard at school nowadays , don't they ? Does he like it ? ", ' School , you mean ? Yes , he does . He likes his teachers , and that always makes difference . ', ' Yes , it does . Does he go to school by bus ? ', ' No , he walks . He likes walking . He meets some of his friends at the corner another go together . ', ' What does he do when it rains ? ', ' My husband takes him in the car . He passes the school on the way to the office . ']
['Are you an American ? ', ' Yeah . ', " Why don't you speak English ? ", ' Oh , my mother is a German , so I can speak German . ', ' Oh , do you like Chinese ? ', " Yeah , I'm eager to learn Chinese , but it is too difficult for me . ", ' I want to study German . Can we exchange lessons ? ', " Very Good . I'd like to do that . ", ' When will we begin ? ', ' How about tomorrow night ? ', " That's all right . "]
['Your muscles are a spectacle ! ', " Thank you.That ' s the result of exercise.By the way , do you work out ? ", ' No , but I am starting working out from now on . ', ' Fine . ']
['You are an eager beaver . ', ' Thank you . I just consider working as part of my life . ']
['I visited the famous variety show host , Dennis . ', " What's he like ? ", " Oh , he's a very serious person . ", ' You must feel very uneasy at his home . ']
['Lily , do you know Lizzy ? ', ' Lizzy who ? ', ' Lizzy smith . ', ' Of course I do . ', ' Then , Do you know her younger sister ? ', ' You mean Mary ? ', ' Yes . ', ' Sure . I know her elder sister Sue and younger sister Mary . ', ' Oh , not bad . Then do you know her mother ? ', ' Yes , certainly . I know her mother and father , and brother and sisters , too . ', ' That sounds terrific . ', ' Why do you ask me these questions ? ', ' I just want to visit the family some day . ']
["This place serves good breakfasts , don't you think ? ", " Yes . But I'm not used to eating American-style breakfast . ", ' What are you planning to do today ? ', ' I saw yesterday that they rent windsurfers at the beach . I want to rent one . ', ' Have you done windsurfing before ? ', ' No , but it looks fun . I always wanted to try it . ', ' Can you take a little advice from a friend ? ', ' Sure . What ? ', " Don't waste your money . Windsurfing is very hard . And it will be windy today.They will charge you fifty dollars for a half-hour , and you won't be able to windsurf.You will fall and fall and fall . ", ' But I always wanted to try it . ', ' Yes , but it takes a long time to learn.You would spend a thousand dollars to learn it on a rental windsurfer . ', ' Well , I will see . How was your day at the office ? ']
['I don ’ t know what I ’ m going to do ! It ’ s going to be impossible to make ends meet if I lose my job ! ', " Don ’ t worry . I don't think you ’ re going to lose your job over one mistake . ", ' It was a rather big mistake . When you work as an investment adviser , one small mistake can cost the company millions . ', ' But it wasn ’ t just you who was involved , right ? You were only doing what your supervisor told you to do . ', ' That ’ s true , but my supervisor is very dishonest . There ’ s no reason he needs to tell our boss the truth . I ’ m sure he will tell our boss that it was all my fault , and there ’ s nothing I can do about that . My boss won ’ t believe me if I tell him the truth . ', ' Let ’ s think realistically about what might happen . How much money do you have in your savings ? ', " I have enough to live off of for about 3 months . But I really don't want to spend my life savings on just living ! I ’ d rather invest my money somehow . ", " Well , you can't have everything . Let's just figure out what you will do if you lose your job . When is your contract up on your apartment ? ", ' Next month . So I can either move out then or renew my contract for another year . ', ' Well , that ’ s good . If you lose your job , you can just move in with me until you find another job . That will save you plenty of money . ', ' That ’ s very generous of you . I guess that would work . ', ' If you lose your job , you just have to go for a few months without buying all the junk you usually buy . If you live frugally , you ’ ll save plenty of money . ', ' I guess working with so much money has made me rather greedy . Maybe losing my job would be a good thing ! ']
['Excuse me , I need your assistance . ', " Sure , what's up ? ", ' I have no idea where my class is . ', " Tell me which building it's in . ", ' My class is in the C building . ', ' I know where the C building is . ', ' Do you mind telling me where it is ? ', ' Of course , which room number is it ? ', ' Number 261 . ', ' I actually have a class right around there . ', ' Can you please show me ? ', ' I can do that . ']
["I'm more worried about snipers . ", ' Snipers ? ', ' Sniping is when someone makes a bid at the very last minute to steal something for a bargain price . ', " So you're afraid someone is going to snipe your Buddha ? ", ' I heard about a software program called turbid . It automatically submits a bid with just a few seconds to go in an auction . ', ' Count me out . I can do without shills and snipers and turbo-bidders . ']
['So , Fred , what are your plans for after graduation ? ', ' Well , I ’ Ve already got a job waiting for me back in my hometown . ', ' That ’ s cool . Have you already found an apartment to live in ? ', ' I ’ m planning on living with my parents . Won ’ t you ? ', ' I couldn ’ t even if I wanted to . My parents told me that if I went home , then ’ d have to find my own place . ', ' You mean they ’ re kicking you out ? ', ' Not really , they just don ’ t want me living at home . My older sister did that , and she lived at home for seven years . Once she started living at home , it got harder and harder for her to move out . ', ' Well , it ’ s not like my parents want me to live at home the rest of my life . They said that it ’ s ok if I move back home to begin with , but they want me to find a place of my own after a year or so . ', ' My parents just didn ’ t handle my older sister very well , and because of that , they want me to be more independent . They think that it ’ s important that I should learn how to live on my own . ', ' I know I need to learn that myself , but I just don ’ t have the money for it at the moment . Living at home allows me to save up some money before I started finding a place . ']
['Hi , Mel , would you like to come and have a cup of coffee this afternoon ? ', ' I ’ d love to , but you know I ’ Ve got another appointment . I ’ m really sorry . ', ' I see . Then what about tomorrow , at Starbucks ? ', ' I ’ m afraid not , George . You gotta know something , I ’ m not available any more . but I know Becky has a crush on ya . ', ' Are you kidding me ? Becky ? She ’ s a real bitch . ']
['Ok , so who are we going to invite to our dinner party ? ', ' Well , we have the Thompsons , the Greens , and the Anderson , about twelve people total . ', " Don't forget my friend Andy from the office . He has nothing to do on Friday , so I invited him over . ", " But that makes thirteen people ! We can't have thirteen people for dinner on Friday ! ", " Why can't we ? ", " It's an old superstition . If we have thirteen people at the table , then it means bad luck . Can Andy bring a date ? ", " I'm not sure . He just broke up with his girlfriend recently , and I don't think he's in the mood to start again so soon . ", " But we can't have thirteen for dinner ! ", " I think you're making a mountain out of a molehill . It's only a superstition . It really doesn't mean anything . ", ' Absolutely not ! I refuse to have thirteen people for dinner on Friday ! ', " Ok , ok . I'll ask my sister to come . That way we'll have fourteen for dinner . ", " That's better . "]
["I can't believe it , I had faith in Bob and he let me down . ", ' I know what you mean . ', ' Really ? ', ' Yes , he did the same to me . ']
['Hello , Alice . Would you like to go to the temple fair with me ? ', ' Temple fair ? ', ' Yes . The ancient custom of holding temple fairs is to offer sacrifices to the god of the earth , and they have developed into a festival filled with food , performances and games now . ', ' Sounds interesting ! ', ' Absolutely , I love temple fairs . Beijing has several temple fairs recently . They are different from each other to some extent , but also have a lot in common . ', " I just can't wait to see them . Which one do you choose today ? ", ' What about Tianqiao Temple Fair ? A variety of opera performances , acrobatics shows , and food will dazzle you . ', ' Great ! Do you know how to get there ? ', ' Of course . ', " Couldn't be better . "]
['Excuse me , Supen . ', ' I hope nothing is wrong . ', ' Please forgive me , but I have to leave . I feel terrible . but ... ', " What's the matter ? ", " My daughter isn't feeling well . ", ' Oh , no . Is it serious ? ', " I don't know . Will you forgive me ? ", " Of course . I'm sorry for your daughter . ", " Thank you . It's our first date . I hope it's not too offensive . ", ' Not at all . ']
['Hello . Can I help you ? ', ' Yes , I hope so . I would like to register for Comp Lit 287 . ', " I'm sorry , but that class is already full.And also , students are supposed to register through the touch-tone registration system . ", " I know . I already tried to register for it by phone , but the computer won't let me . ", " That's because it's full . ", " But I'm a new student here . I thought maybe there was some way I could get into the class . I thought I should come and talk to you in the department office . ", " Well , I could put you on a waiting list.But that doesn't guarantee you will get into the class . What is your name ? ", " My name is Karen Huang . That's spelled H - U - A - N - G . ", ' Alright . And what is your major ? ', " I'm a comparative literature major . ", " Wait a minute . You're a Comp Lit major ? ", " Yes , that's right . ", " Why didn't you tell me ? I didn't know you were one of our students . ", " That's why I'm trying to get into Comp Lit 287 . I know it's a required class.And Professor Cohen told me I need to take it . ", ' The university computer system saves extra places , in class 287 for comp lit students . I can give you a special code.When you register by phone , you can use the code to get into the class . ', ' Even if the class is full ? ', " That's right . ", " Oh , I didn't know that . ", ' Sure . Here is the code number , with information on how to use it . ', ' Thank you . So you think I will be able to get in with this ? ', ' Sure . Just call the touch-tone registration system again.Then , follow the directions on the sheet . You will get in no problem . ', ' Thanks . ', ' Next time you come in here , I will recognize you . ']
["Who's that man over there talking to James ? ", " Where ? Oh , that's Henry . ", " He's very handsome , isn't he ? What's he like ? ", " He's very nice , actually , but rather eccentric . ", ' Really ? I love eccentric people . ', ' Yes , but he may be too eccentric even for you . ', ' Why ? What do you mean by that ? ', " Well , haven't you heard ? ", ' Heard what ? No one ever tells me anything . ', " Well , apparently , he's been having an affair with his secretary . ", ' Really ! How fascinating . ', " According to Mary , he's divorcing his wife and there's a big fight going on about the children . I thought everyone knew . ", " Well , what can I say ? I didn't know . Oh , I meant to tell you earlier , your blouse doesn't really match your skirt . Those colors don't really suit you either . ", " Oh . Thanks . Look , I must just go and say hello to someone . I'll be right back . "]
['How did you first meet Jack each other ? ', " That is a heavy raining afternoon . I was standing under the eaves of a shop to evade the heavy rain . It's getting dark . ", ' And then ? ', " I was trembling in the wind when he ran to me with an umbrella in his hand and asked , ' Where is your home ? ' ", ' Then he sent you to your home ? ', ' Yeah . ', " It's a romantic meeting . I can say that a hero saves a beauty . ", ' He joked later that I was so poor that he had a kind of impulse to protect an ant . ', ' He is so humorous . ']
['Where are you from ? ', " I'm from Germany . ", " So you speak German , don't you ? ", ' Yeah , but I can speak English , too . ', ' Oh , I see . What other languages can you speak ? ', ' A little French . ', ' Good . ']
['What are you reading ? ', ' Gee ! You scared me ! ', " Aha , Fitness Consultant . Very good , Don't you know about the rules in this office ? ", " Yes , Ma'am . No magazines during the office hours . I'm sorry . ", " Well , don't do this again next time . What is it about , anyway ? ", ' It is about sports for white-collar workers , people like you and me . ', ' What kind of sports ? ', ' Aerobic sports , for example , jogging , yoga , skating ... ', ' Interesting . What were you reading just now ? ', ' Stretching exercise after sitting a long time . ', ' Really ? That sounds interesting ! ', ' Can I have my magazine back now ? ', " No . It's confiscated for now . And I will return it to you after I finish reading it . "]
['I like NBA very much . ', ' Did you watch NBA games before you came to the U . S . ? ', " No , I didn't . ", ' What a pity ! ', ' Do you like NBA ? ', ' Yes , of course . ', ' Who do you like best of the NBA players ? ', ' Kobe . ', ' So do I . ', " Let's go to watch an NBA game tonight , shall we ? ", " That's fine . "]
['Hi , could you help me find a place where I could buy some lunch ? ', ' Sure ! What kind of food would you like ? ', ' I was thinking of pizza or something else Italian , maybe . ', ' I know the perfect place ! ', ' Good ! Where is it ? ', " It's right past that last building on the left . Do you want me to go with you ? ", ' That would be great . ', ' Glad you asked me to join you . This will be fun ! ']
["I'm reading an interesting report on Mars . ", ' Oh , what does it say ? Does it say water could still exist under the surface of Mars ? ', " Absolutely ! It says there is water on Mars buried beneath the surface . It's just a matter of how deep it is . ", ' Then could the soil on Mars somehow be fertile enough to Groh simple plants ? ', ' The soil would need quite a bit of fertilizer to grow anything . And it would need to be protected from the UV radiation . ', ' Actually , we are doing a project in school that involves landing a ship and staying on Mars for an extended period of time . Does NASA have any type of portable habitats that could be used to stay on the planet ? ', " I'm not sure NASA has built any portable habitats for extended stays on Mars , but they have looked at various designs . ", ' One of the most exciting things about Mars is that there could have bean life on it . What are your personal opinions on the life on Mars theory ? ', " Well , I'm not really an expert in this area , but my understanding is that anything is possible . It's just that it is so hard to determine what went on 4.5 billion years ago . ", ' But maybe there is a chance of gradually improving the surface and atmosphere of Mars so it may be inhabitable by humans . ', " I'm skeptical . Mars is made of rocks containing silicon , iron , and various minerals . It also has an atmosphere of carbon dioxide . It is so different from what we have on earth , you know . ", " I'd still like to hope that some day we could set up a human colony there . ", ' But there are still other big problems we need to solve such as prolonged weightlessness , food storage , and a series of physiological effects . ']
['Would you like to go sightseeing tomorrow ? ', ' Not a bad idea . ', ' What would you like to see in Beijing ? ', ' Well , let ’ s see . I ’ d like to go to see the Summer Palace . ', ' I ’ ll pick you up here tomorrow . ']
['When are we leaving for our field trip ? ', ' Our science field trip is next Monday at 8 a . m . in the morning . Can you mark that on your calendar ? ', ' Yes , I will write that down . ', ' That will be Monday , December 2nd . We need to start loading the buses half an hour early , so plan to arrive at 7 . ', ' Yes , I will be there on time . ', ' We will return 6 days later on December 8th . Will someone be picking you up ? ', ' Yes , someone is coming to get me . ', ' The return bus will leave the campground at 5 p . m . and return to campus 3 hours later at 8 p . m . ', ' What should we bring with us ? ', ' I am going to post all of that information on the geology club web page . Check it out when you get a chance . See you Monday ! ']
['Mr . : Hello , Mary . ', ' Hi . ', " Mr . : I'm Mr . Taylor , and I'm your counselor . I'm going to show you around the school . ", ' OK . ', ' Mr . : Right here is the cafeteria . ', " It's huge ! ", ' Mr . : But not big enough . And here is our computer room . ', ' There must be about 50 computers in here . ', ' Mr . : And over here is our gymnasium . ', ' Do I have to take gym ? ', ' Mr . : Just like everyone else . ']
["Oh , my ! It's really hot . I've never seen such scorching weather in my life . ", " Tell me about it ! It's like the whole world is broiling . ", ' Oh , look at the thermometer ! The temperature has hit 98 . ', " I hope it's not gonna break into three digits ", " But it's already awfully close . ", " Well , I just hope it'll level off . ", ' I guess you can ’ t do anything until after dark then . ', ' I guess so . What else can we do ? You can ’ t stay in the heat for long . ']
['In the discus throw , you scored 30 meters at the final throw . How did you make it ? ', " Well , I've been practising for 5 weeks . ", ' Is this your best score ? ', ' No , once I did 32 . ']
['Hi , where have you been ? ', ' I was away for my vacation . ', ' Oh , how was it ? ', ' Good . I wish I could have another vacation . ']
['do you want to go out for dinner tonight ? ', ' sure . Have you got anywhere in mind ? ', " I'm starving , so maybe we could go somewhere with large portions . ", ' that Italian restaurant in the city centre always has large portions . Do you want to go there ? ', " I'm not really in the mood for Italian , actually . I was thinking of something a bit spicy . ", " if you want spicy food , then I'd recommend going to a Thai , Indian or Chinese restaurant . How about that Chinese buffet on Cowley Road ? ", " I really like that restaurant ; you get a lot for your money there . But , they've westernized their food , so it's not actually that spicy . ", " you're right . Most of their dishes have sweet sauces . We could try that Indian restaurant just down the road from us . ", " the Taj ? They're a bit expensive , but they do serve large portions of very hot food . ", ' the Taj it is then . ', ' shall we bring our own bottle of wine to save some money ? ', " they'll still charge us a corkage fee . ", " that's right . It'll probably work out to be about the same then anyway . ", " don't worry about money . I'll treat you tonight . ", ' are you sure ? We could go Dutch . ', " no , I'll pay . It's my turn anyway . You paid last time . ", " I won't argue with that ! Let's go ! "]
['Robin , what are you going to do tomorrow ? ', ' Bob and I plan to play hockey in the morning . ', ' And later ? ', ' Well , in the afternoon , after a long nap , we ’ ll go yachting with Nora . ', ' It seems that you will have a nice day tomorrow . ', ' How about you ? What are you going to do tomorrow ? ', ' I have a lot of work in the office and a lot of chores in the house.How I envy you , Robin ! ']
['So do you think I can take it ? ', ' I ’ d stay over there , if I were in your shoes . ', ' I know , but things are getting a bit out of hand and I just can ’ t do nothing . ', ' See your problem ? You get so restless when it ’ s time to calm down . ', ' You ’ re right . ']
["You married Joe , didn't you ? ", " Joe ? I don't know what you mean . ", ' I remember you are in love . ', ' Oh , I took a shine to him when we met for the first time . But it comes and goes . ', " It's Greek to me . "]
['Watch out , Patrick ! ', ' Whew ! Thanks , Karen . That car almost hit me . ']
['Well , humans could never make something like that . ', ' Those poor Egyptians slaves worked so hard and you want to give aliens all the credit ! ', " Be a little more open-minded , Stu ! Don't believe everything you read in your history books ! ", " OK , but don't believe everything you see on The X-files , either ! ", " Speaking of The X-files , it's on right now ! "]
['Hi . are you new here ? ', ' Yes . I moved here last week . ', " I'm Steven , your neighbour . ", " I'm Charlie . Nice to meet you . ", ' Nice to meet you , too . ', ' Since we live in the same neighbourhood , maybe we can help each other from now on . ', " I guess so . I live next door but one , and hope you'll drop in now and then . ", ' Thank you . I will . ']
['The winter in Ottawa is freezing . ', ' From mid-November , snow started to pile up in Ottawa . ', ' I think I will be adapted to it . ', ' Although the weather here is very cold , the people are warm . ', " Yes , that's the reason why I remain here . "]
['The summers are so great here ! Not hot at all . I love the cooling breezes , the clear air , all the greenery . ', ' This really has been a wonderful holiday for us . Shall we take a walk around the pond or into those woods for a while ? ', " Let's do both ! Are we in a rush or anything ", " No , not really . I had thought we'd stay in Hamburg tonight , but we can't unless we rush it . Let's stay in Bremen instead . Tomorrow we can have lunch in Hamburg , then check into a hostel in Copenhagen and have dinner there . ", " Sounds fine to me . Whatever , let's enjoy this pond first . ", ' Sure . We can walk around to that path that leads into the woods there . Hey , look ! There are some wild ducks over there in the reeds . ', " I see them ! Wow ! How do you know they're wild ? ", " I used to go hunting with my uncle , that's how . ", " They're neat . Now Let's take that path into the woods and see what we can see ... "]
["Wow . She can be really nasty , can't she ? ", ' No . She was right . I was too nervous . I kept thinking , What if we blow it ? ', " Well , I guess Zina figured you couldn't blow it if you were in the hotel room . ", ' She even stayed at a different hotel . She said I might be contagious . ', " Well , at least we have Stars.com . That'll be great publicity . "]
['Hi , Bob , this is Mary . ', ' Hello , Mary , where do you work ? ', ' I work for an Internet company . ', ' Is the pay good ? ']
["Hey Jack . What's going on ? ", " Hey Matt . I'm going to ask Martha to marry me ? ", ' Really ? When did you decide this ? ', " I always knew she was the one , but I decided to pop the big question about 2 weeks ago . I'm just debating on how to do it . ", " That's exciting , man . ", ' So how did you propose ? ', " You shouldn't use my example . It wasn't special . I kind of wish I made it more special but it's too late now . ", ' What do you think I should do ? ', ' There are a lot of options . You can surprise her over dinner , or ask her in a public area , or if you have the balls , ask her father in front of her . ', ' I never thought about that . ', ' Thought about what ? ', ' Asking her father in front of her . How do you think she will react ? ', " I don't know . You should know how she's going to react . She is your girlfriend . ", " I think that's the idea I was looking for . Thanks , man . ", " Don't mention it . Good luck . You're going to need it . "]
['The bridegroom looks a bit nervous . ', ' On this occasion , most people do . ', ' Oh , they are playing the wedding March . Here they come . ', ' She is a beautiful bride . ', ' I am so happy for them . ', ' Are you crying ? ', ' Yes , I always cry at weddings . ', ' Harris and Anne are perfect for each other . ', ' Yes , they are . ', ' You and Tom also make a great couple . ', ' In fact , we are beginning to make preparations . ', ' For the wedding ? ', ' No , no , for the engagement . ', ' Try to catch this bouquet then . ']
["What's this , I wonder ? ", " I'm not sure.Let me have a look ... It could be a coffee grinder . ", ' A coffee grinder ? ', ' Yes , it must be used for grinding coffee beans . ', ' Oh , that would be very useful . ']
['Hi , Jack . Long time no see ! ', " Yeah . How's everything going ? ", ' Not bad . At least I am still alive . ', ' Just alive ? I guess you are some lucky guy . I heard you are going out with Jane . ', ' Where did you get that idea ? ', ' Oh , come on . Jane is a very nice girl , someone you meet only once till lifetime . ', ' You are right . I am not boasting , but she is really as beautiful as she is intelligent . ', ' Well , I really envy you for finding such a nice girl . ']
["Here's your drink , sir . ", " No , that's not right . I didn't order a coffee . I ordered a cola . ", " Oh , I'm terribly sorry , sir . I'll go and get you cola right away . ", ' Waiter ! ', " Yes , sir . I'll bring your drink right away . ", " It's not that . There's an animal in my soup . ", " Is there , sir ? I'm very sorry . I'll change it straight away . ", " I've never been to such a dirty restaurant , and never seen such slow service . ", " I'm really sorry . "]
['Dalian is a beautiful city . Do you agree ? ', ' I suppose I do . ', ' The climate here is pleasant . ', ' You said it . ', ' This city is really comfortable to living . ', ' It sure is . ', " No other city can match it . It's heaven . ", ' Well , If you live in other as long enough you love them just as much . ', ' Maybe . ']
['Well , I ’ d better get back to work . I ’ Ve got a ton of stuff on my desk ! ', ' Me too . I ’ ll see you after work , huh ? ', ' Yeah , definitely . I was hoping to catch a ride with you . ', ' Sure . Meet me at five . ']
['Where will you go in your vacation ? ', " Oh , I'm hoping to take courses in my vacation . ", " You're so industrious . "]
['you are dressed to kill . You look gorgeous , Alexander . ', ' thanks . This is my power suit . I have a dinner date tonight . ', ' how did you meet each other ? ', " she's a friend of Amy . We met at Amy's birthday party . ", ' is this your first date ? ', ' yes . I hope it pans out . Cross your fingers , Lily . ', " sure it will . Oh , no , it's seven fifteen already . I'm going to be late for my date . ", ' oh ... so you buried the hatchet with Steven ? ', " absolutely not ! He's a cheater . I will never talk to him again . I'm over with him . He's history ! ", ' then who will you meet tonight ? ', ' a guy I met on the internet three month ago . ', ' really ? Are you sure this is a good idea ? ', " please don't be so fussy ! I didn't just meet him yesterday . ", " I know , but remember to meet in a public place and don't give out your personal information . "]
['I can ’ t believe that Anthony is finally getting married ! ', ' Yeah well it ’ s about time ! He ’ s been living with his parents for 40 years ! ', ' Don ’ t be mean . Look here come the bridesmaids ! Their dresses look beautiful ! ', ' Who are those kids walking down the aisle ? ', ' That ’ s the flower girl and the ring bearer . I ’ m pretty sure they ’ re the groom ’ s niece and nephew . Oh , they look so cute ! ', ' I just hope the priest makes it quick . I ’ m starving . I hope the food ’ s good at the reception . ', ' That ’ s all you ever think about , food ! Oh , I think the bride ’ s coming now ! She looks gorgeous . Wait , what ’ s she doing ? Where ’ s she going ? ', ' Oh great ! Does this mean that the reception is canceled ? ']
["I've just got the examination results . I am afraid you haven't passed . ", " Oh , no ! I can't have failed . surely ? ", ' I am afraid so . I am terribly sorry ! ', ' Whatever am i going to tell me parents . ', " Don't worry about that , I am sure they will understand . After all , it was a very difficult exam . ", ' What am I to do ? ', ' You can always take it again . ']
['hi , Meally , do you know that guy over there ? ', " The tall one ? Sure , that's Drive , he works with Lily . ", ' He is cute . What dose he do ? ', " I'm not sure , he is a manager I think . ", ' Really ? Are you going to introduce us ? ', " Well , he has already taken you know , that's his wife right there . "]
["Hello , I'm Lance . ", ' Hello , my name is Paula . Nice to meet you ! ', ' Nice to meet you , too . ']
['It seldom rains this summer . ', ' Yeah , some places are very short of water . ', ' Because of pollution and other things , our environment has become worse and worse . ', ' You see , . This time I traveled to the West . When I looked out of the windows of the rain , all the lands that I could see are as dry as a bone . ', ' It is serious . ']
['These things are always oooo boring . Heard any gossip ? Anybody making the big bucks ? ', ' Rich struck it rich in advertising . And he and Cath got married and just had a child . ', " That's no news . Those two were high school sweethearts anyway . ", ' Teresa Jones got a boob job . ', ' Uh , I can see that . And Erica Falls has lost a lot of weight . ', " I've got something . You saw Taylor Smith ? Looks terrible , doesn't he ? I heard he ... "]
['How are your Chinese lessons going ? ', ' Oh I ’ m learning very slowly . I think Chinese is more difficult than English . ', ' Well I guess you have fewer characters but I think Chinese grammar is easier . ', ' Maybe , but I think people usually learn English more quickly than Chinese . ', ' Yes , I guess basic speaking in the English is easier . ', ' Maybe that ’ s why your English is much better than my Chinese . ']
['Let me hold the door for you , miss . ', " Thank you . You're very kind . "]
['Can we talk ? ', ' Sure , honey , we ’ re talking now , aren ’ t we ? ', ' You know what I mean . ', ' Yeah . I know . ', ' I want to know where this relationship is going . I ’ m in love with you and I need to know ... ', ' You know , I think you ’ re awesome . ', ' I ’ m awesome . Well , I guess that ’ s my answer , isn ’ t it . ', ' Honey ... ', ' Look , if you don ’ t love me , it ’ s not a thing , alright , we ’ Ve had our laughs , but I don ’ t appreciate ... maybe it ’ s just time we ... ', ' Baby , I love you so much . ', ' You do ? ', ' I love you . And I think you ’ re awesome . ', ' Oh , I love you too ! ', ' Come on . Put the gun down . ', ' Oh baby , I ’ m so sorry . ']
['How do you do ? I ’ m Parker . ', ' How do you do ? Mr . Barker . ', ' Parker . ', ' Oh , Parker with a P ? ', ' Yes , with a P . ', ' Er ... I ’ m Barker . ', ' Barker ? With a B . Of course . ', ' Yes , with a B . ', ' Won ’ t you come in , Mr . Barker ? ', ' Thank you , Mr . Parker . ']
['Let ’ s go to WAngFuJing by bus . ', ' Better take the subway . It ’ s faster and more convenient . ', ' Okay . It will be a new experience for me . ', ' We have a rather comprehensive subway system here . we can get almost anywhere rather quickly on the subway . Especially at this time of a day when the traffic is heavy . ', ' where do we pay the fare ? ', " Just give the man standing there three yuan and he'll give you a token . Then you slip it into slot at the turnstile and push the turnstile to get in . ", ' Let me pay for it . ', ' Where can I get the subway Madam ? ', ' Ask the worker who sells token to give you one . It ’ s free of charge . Actually maps showing subway routes are posted at most stations . ', ' Do I have to pay additional fare to change train ? ', ' No , you don ’ t have to . Here comes the train . ']
["I've heard The Hitchhiker would be on next week . I want to see it . ", ' Is it horror movie ? ', ' Yeah , I love horror movies the most . Would you like to go with me next weekend ? ', ' No way . I will be scared out of my wits . ', ' Well , What kind of movies do you like ? ', ' Er , let me see . Romance , comedy , documentary , action , science fiction , cartoon and so on . ', ' In a word , you like all the movies except for the horror movies . ', " Yeah , It seems like we don't talk the same language as far as movies are concerned . ", ' Not quite . I also like romance and comedy movies very much . ', ' The Terminal is a movie of this type . ', ' So we can relax now . ', ' Yeah , I could hardly wait to see it . ']
['Excuse me , sir . Could you spare a minute ? ', ' Uh , yes . ', ' Do you go to work by train every day ? ', ' Yes . I commute five days a week by train . ', ' And would you mind telling us what you think of the rail service ? ', ' It ’ s really very good . ', ' Why do you say that ? ', ' Well , trains are frequent and come on time . ', ' Which train do you catch in the evening ? ', ' I usually take the 5 thirty home . ', ' And can you get a seat ? ', ' No , I usually have to stand . ', ' Would you agree that the service is fast ? ', ' Yes , it ’ s reasonably fast but it certainly isn ’ t cheap . Fares have gone up25 % . ']
['Hi , Kate . ', ' Hi , Don . What a surprise ! ', ' Yeah , I saw someone walking like you , but I wasn ’ t sure . We haven ’ t seen each other for how long ? Almost three months ? But you look quite different now . ', ' Have you noticed what has changed ? ', ' Oh , you look quite slender and more vivacious . What have you been taking ? Are you on a diet ? ', ' Yes . I ’ m on a diet , but I ’ Ve not taken anything . I just eat less and exercise more . And it really worked in the past three months . I ’ Ve lost twelve pounds . ', ' Wow ! That ’ s great . I sincerely want to achieve my weight loss goals , but it ’ s difficult for me to keep up the exercise . Also you know , old habits are hard to break . ', ' What kind of exercise do you think I do ? I just go to dance everyday after work . I ’ m taking an amateur dance class . I dance two hours everyday . ', ' Dance ? You only go dancing ? That ’ s not hard . I can do that . ', ' Sure . Join my class next week . ']
['How do you usually sell your products now ? ', " I'm doing business through Internet now . ", ' Oh , really ? Is it a good way ? ', ' Yes , very good . ', ' What advantages does it have ? ', ' It is very convenient . You know you can browse the website and send e-mails to your customers at any time . ', ' Yes , if we do business through other ways , it will cost a lot of time . ', ' Also it has low cost , and you know you only need to pay the fee of Internet , which is very cheap . ', ' Yes , going abroad to join the exhibition will cost much . But does it have any disadvantages ? ', ' To be frank , sometimes it is not so safe as doing business through traditional ways . ', ' You mean there may be credit problems ? ', ' Yes , but if you choose some good B2B websites , such problems can be avoided . ', ' Will you give some suggestion ? ', ' Of course , such as the Alabama , which is a famous website . ', ' Thanks . Maybe I will do business through Internet in the future . ']
['Alright everyone settle down . Let ’ s get started.As you know , an important aspect of becoming a good citizen is understanding the genesis of our legal system . It is not enough to simply memorize our laws , it is necessary that we comprehend why and how they were formed . This brings me to our topic for today . Does anyone know what we celebrate on May first ? ', ' Cinct de mayo ? ', ' No , that ’ s May fifth in Spanish , James , no wonder you are failing my Spanish class . No , May first is International Workers ’ Day . ', ' Do we get a day off from school then ? ', ' No ! It is not considered to be a national holiday here in the US , but in other countries it is . ', ' Www , man ! ', ' In the nineteenth century , working conditions were appalling , with workers being forced to work ten , twelve , and fourteen hours a day . Support for the eight-hour work day movement was growing rapidly , despite the indifference and hostility of many union leaders , and by April 1886 , 250,000 workers were involved in the May Day movement . Previous legislative attempts to improve working conditions had failed , so labor organizers took drastic measures . They passed a resolution stating that eight hours would constitute a legal day ’ s work . And , on May First 1886 , the resolution took effect . ', ' Cool ! Is that why we only work eight hours now ? ', ' Yes ! But the happy ending came at a high price.On May third , 1886 , police fired into a crowd of strikers at the McCormick Reaper Works Factory , killing four and wounding many . A mass meeting was called for the next day to protest the brutality . ', ' And then what happened ? ', ' Well , as we say , the rest is history ... ']
['Did your wife give birth yet ? ', " Yeah . She's a healthy beautiful girl . ", ' Congratulations . How is your wife doing ? ', ' She is tired , but getting a lot of rest now . ', " That's good to hear . ", " I'm just glad there were no complications . ", ' If your wife and baby are both happy , what more can you ask for ? ', " It's been a week , and I haven't slept that well . ", " That's normal for anyone with a newborn . ", " Yeah , but it's so hard . I have to work , and then go home and take care of my wife and the baby . I'm going to get sick at this rate . ", " You'll get used to it . After everything stabilizes , you can regain your health . ", " That's true . I should make sure my wife and baby stay healthy during this time . "]
['Irene ! I heard you were on a date last night ! So , how how did it go ? I want all the juicy details ! ', ' Um ... well , actually , we had a fantastic time last night . He was ... amazing ! ', ' Okay , now you really have to fill me in . What ’ s he like ? ', ' He ’ s really good looking . he ’ s quite tall , around 61 , he ’ s in his early thirties , and he ’ s got the most beautiful dark brown eyes ... ', ' He sounds hot ! What does he do for a living ? ', ' You know what , this is the best part . David is a junior investment banker at Fortune Bank , so he ’ s got a great career path ahead of him ! ', ' Hold on a sec , his name is David ? ', ' Yeah ? ', ' That ’ s my brother ! ']
['Hi , Lucy . What are you going to do this weekend ? ', ' I have no idea yet . Do you have any suggestions ? ', ' Would you like to play tennis with me ? ', " I'd like to . ", " Be sure to get to the sports hall at nine o'clock on Sunday morning . ", ' OK , will do ! ']
['I heard that Jim lost 100 yuan . Do you know that ? ', " I don't know . ", ' Really ? ', ' Yes . ', ' But some classmates said you took the money . ', ' It is not true . ', ' Look at my eyes . ', " Well , I confess . I did it , because I urgently need money to buy some medicine for my mother for she is badly ill . I'm ashamed that I did that . ", ' Return the money to Jim and make an apology . I think he will forgive you . ', ' I will . ']
['Howdy ! Nice car ! What seems to be the problem ? ', ' I don ’ t know ! This stupid old car started spewing white smoke and it just died on me . Luckily , I managed to start it up and drive it here . What do you think it is ? ', ' Not sure yet.How about you pop the hood and we can take a look . Mmmm , it doesn ’ t look good . ', ' What do you mean ? My daddy gave me this car for my birthday last month . It ’ s brand new ! ', ' Well missy , the white smoke that you saw is steam from the radiator . You overheated your engine so now the pistons are busted and so is your transmission . You should have called us and we could have towed you over here when your car died . ', ' Ugh ... So how long is this going to take ? An hour ? ', ' I ’ m afraid a bit more than that . We need to order the spare parts , take apart your electrical system , fuel pump and engine and then put it back together again . You are going to have to leave it here for at least two weeks . ', ' What ! How am I supposed to get to school or go shopping ? This is not happening ! ']
['I like this kind of weather . ', ' Yes , a little breeze and a lovely moon . ', " And it's calm . I like the peace . ", ' Me , too . ']
['A friend of mine is now in the big house . He was caught red-handed for selling cocaine . ', ' That is a deadly risky business . He should have it coming on him . ', ' He must be regretting about having done the business . ', ' I bet he is . He domed his own life . ']
['Do you like climbing ? ', ' Yes , I like it very much . ', ' How about climbing up the Fragrant Mountain tomorrow ? ', ' Where is it ? ', " It is located at the east foot of Western Mountain of Beijing , in a park with the same name . There are some huge stones within the mountain which look like the censer , so it is called ' Fragrant Mountain ' . ", ' Have you visited it before ? ', ' Many times . Except climbing , there are many attractions worth visiting . ', ' Like what ? ', ' It is the best season to view red leaves from the Mid-October to the first ten days of November . During the period , thousands of hectares of maples on the sloping field are so red that you would recognize them as fallen petals by mistake if looking from a further area . The bright red , pink , scarlet , and peach-puff leaves are distributed in different layout , with some green pines and cypresses dotted in between . ', ' Sounds marvelous . ', ' You can take a bird-eye view at the glorious picture when you arrive at the top of the mountain . ', ' Great . I will prepare some clothes and food for the climbing . ']
['What had make you so upset ? ', ' Frank has gone out with Lucy again . ', ' What ’ s wrong with that ? ', ' Lucy is known as a social butterfly . She has taken many rich men for a ride , you know . ']
['To be frank , I find philosophy rather boring . ', " To tell you the truth , it's the most tedious course I'ever had . ", ' How could you manage to pass the exam ? ', ' It is still a mystery to me . ']
['That one looks pretty big . Are you going to keep it ? ', ' Of course . I always keep what I catch . ', ' Not me . I like to throw back what I catch . ', " If it's within the legal limit , I prefer to keep it . "]
['Lester , you are really fantastic at automobile repair . ', ' Thanks , June . But I think I need to be certified as a mechanic before I ’ m allowed to repair cars for a living . ', ' That ’ s not a big problem . There are many small schools for adults like you who can study to be certified . ', ' I guess I never thought of that before . ', ' And you can easily get a student loan from a vocational school , or from the government . ', ' Wow , you ’ Ve inspired me to do something ! ']
['Hey , Ted . What are you up to this Friday ? ', ' Well , I have the day off from work . ', ' That ’ s great ! Do you have any plans ? ', ' Well , I ’ Ve been working so hard lately , so I ’ ll probably just take it easy . ', ' Sounds nice . ', ' Yeah , I ’ ll probably just stay in and relax . Maybe watch a few movies . ', ' Can I stop by ? ', ' Sure . Any time . ']
['Judy , what is everybody talking about ? ', ' Haven ’ t you heard ? Richard was fired by our manager . ', ' You ’ re kidding . It can ’ t be true . ', ' Believe it or not . Everybody is talking about it in the company . ', ' Really ? I ’ m surprised . ', ' Me too . ']
['How do you like waltz ? ', " It's very nice , I like it very much . ", ' May I invite you for the first dance ? ', " My pleasure . But I'm afraid I'm not much of a dancer . ", ' In fact , I took up dancing quite recently , too . ', " Oh , really ? But you're doing the tango wonderfully well . ", " I'm glad you say so , you dance beautifully too . It's lucky that I got a partner . ", " Thank you for your compliments . It's just that you are a good leader . Do you like the samba and waltz ? ", ' Yes . And what dances do you like best ? ', ' Waltz is my favorite . I like it better than any other dances . ', ' Oh , the music has stopped . Thank you for the dance . ', " My pleasure . Let's go and have a drink . ", ' Fine . ']
['What can I do for you today ? ', ' I need to return a book . ', ' Can I do anything else for you ? ', ' I want to check this magazine out . ', ' We don ’ t allow people to check out magazines . ', ' Why not ? ', ' It ’ s just a policy of ours . ', ' So what am I allowed to check out ? ', ' You may check out books or videos . ', ' I need to check out this magazine . ', ' You will have to just read it in the library . ', ' That doesn ’ t make any sense . ']
["Happy Valentine's Day ! ", " That's nice of you . ", ' Could I treat you to dinner tonight ? ', ' Wonderful . ']
["Wow ! Look at the time . lt's about 11 0 ' clock . ", " Really ? I didn't realize it was so late . ", " I've got to catch the last bus . See you later . "]
['Where are you going this weekend ? ', ' I have no idea . Maybe I will sleep for the whole day . ', ' So boring ! Shall we go out for a picnic with my friends ? ', ' Sounds interesting . Who are the other people ? ', ' Fred and David , my college class mates and Rachel . ', ' Gorgeous ! What should I bring on that day ? ', ' Your tent and enough food and water . ', ' You mean , we can do many other things after the picnic , right ? ', ' We can go fishing , chatting and camping . ', ' What are we waiting for ? Come on ! ', " Don't hurry . Wait for my call . "]
['so ... what kind of things do you do in your free time ? ', " I'm really into watching foreign films . what about you ? ", ' I like to do just about anything outdoors . Do you enjoy camping ? ', " camping for an evening is ok , but I couldn't do it for much longer than one night ! ", ' have you ever been camping in the Boundary Waters ? ', " no , but I've always wanted to do that . I've heard it's a beautiful place to go . ", " it's fantastic . My family and I are very fond of the place . ", ' do you have any photos of any of your camping trips there ? ', ' sure , would you like to see them ? ', " that'd be great . What kind of camera do you have ? ", ' I have a Canon SLR . ', ' so , you must be pretty interested in photography then . ', " I'd call it one of my hobbies . Do you know much about photography ? ", ' actually , I do . I took quite a few photography classes at University . ', " have you heard about the photography exhibit that's going on at the art gallery this weekend ? ", ' yes , I was planning on going . Are you ? ', ' yes.In fact , maybe we could go together . ', " that'd be great . what time should I meet you there ? ", ' how about at 11:00 ? ', ' sounds great . see you then . ']
['So Janet , do you do any sports ? ', ' Well , I go to the gym a lot . I am a member of a gym nearby . ', ' Yeah , how often do you go ? ', ' About three times a week if I can . ', ' Not bad ! Do you do any other sports ? ', ' Not really . I ’ d really like to try golf , though . ']
['Guess what ? I won the speech contest at my school . ', " Wow , that's great ! "]
['Oh , hi Pam . When did you get back from Canada ? How was it ? ', ' The day before yesterday . I only visited Montreal and Ottawa , but I had a great time . ', ' Which city did you like better ? ', " That's hard to say ... I think Ottawa is prettier.It has better sightseeing , too . A lot of museums and galleries . ", " And what's Montreal like ? What did you think of it ? ", ' Montreal is more exciting . It has better shopping.The stores are cheaper and more interesting . ', ' Which one has better nightlife ? ', ' Oh , Montreal of sure . It has more restaurants and clubs.They say Montreal is the most exciting city in Canada . ', " Well , I've always wanted to see Vancouver . I've heard it has the most beautiful views . "]
['Well , you seem to enjoy speaking English . ', " You can't help learning when you're using it all day . You'll see . A few weeks ' study in the school will have a similar effect on you . ", " I hope so.You see , at the moment I find it difficult to get used to the teacher's speed and accent . I'm awfully worried , I can't reply as quickly as she seems to expect . ", " Oh , she likes keeping us on our toes by getting us use English throughout the class . She doesn't mind your making mistakes , though . ", ' You know , speaking in class is a very good chance to put your English to practical use . ']
['What happened to my cup ? ', " I accidentally knocked it off the table and it broke . I'm really sorry . ", " Don't worry about it . I've got another one I can use . "]
['Are you going out , Jack ? ', " I'll be right back . I just need to mail this package . "]
['Which language do you speak ? ', ' Well , I studied French at school , but I ’ Ve forgotten most of it . I learnt some Russian while I was studying there and now I study Spanish in evening classes . Do you speak Japanese at home with your pa ', ' Yes , I do . I ’ m learning Chinese now on the internet . ', ' How do you find studying a language on the internet ? ', ' It ’ s not easy , particularly with listening and speaking , because sometimes the connection isn ’ t too good . ', ' I bet you find the character difficult to write ! ', ' Actually , many of the characters are the same or very similar in both Chinese and Japanese , so they ’ re easy for me . ', ' So , you can read and write much better than you speak and understand other speakers , right ? ', ' Yes . How are the Spanish classes going ? ', ' In a way , it ’ s similar to your experience of learning Chinese . Some Spanish words are very similar to English ones . But I need to practise listening to native speakers and saying the words myself . ']
['What happened to John ? ', ' He quit ']
['Professor , I will not be here for our next class meeting . ', ' Is this absolutely necessary ? ', ' I tried to work something out , but I really do have to miss one class . ', ' Will you be able to make up the work you missed ? ', " I'm going to be doing a lot of extra reading . ", ' Remember that I will only let you miss one class meeting per semester . ', ' Yes , I remember . ', ' Could you e-mail me this week as a reminder ? ', ' Sure , no problem . ', " Make good use of that day off ; you'll only have one this semester ! "]
['Ms.Green , are the schools more or less similar everywhere throughout the United States , or do they differ in various sections ? ', ' The system of public schools is fairly uniform everywhere throughout the United States . ', ' Do most students in the United States attend private schools or public schools ? ', ' Most public schools in the United States are very good , and the majority of students attend the public schools . ', ' Which students go to private schools , then ? ', ' Children needing special instruction . Children whose parents can afford to send them to private schools , and children whose parents want them to receive a religious education . ', ' But are the public schools good everywhere ? ', ' No , public schools can be very different . Even in the same city . ', ' Dose it cost anything to attend the public schools ? Are there any restrictions as to who may and may not attend ? ', ' The public schools in the United States are free to everyone and there is no cost to the student . In most states , even the textbooks are free . There are no restrictions as to color , race , or religion.Any student wishing to attend the public schools may do so . ']
['We thought you might like to participate in our rehearsal . ', ' I ’ m afraid I ’ m already booked up for next Sunday . But thank you just the same . ', ' That ’ s a pity . We can arrange another time hopefully . ']
['Have you seen this ? ', ' What ? ', ' They killed another hostage . ', ' Oh , how awful . What a terrible thing to do . ', " I agree completely . I just don't understand what's wrong with them . Don't they have any humanity ? ", " Well , maybe they've got a point . I mean , I suspect that they think the same about us . ", " Yes , but that doesn't make them right , does it ? Just because they think so ? ", ' I guess not . My view is that we should give in to their demands , so that innocent people can stop getting killed . ', " Come on , you can't be serious ! We should never give in to terrorist's demands , otherwise where would we be ? ", " Well , that's probably true , but I don't think we should be dogmatic about it . A colleague of mine was kidnapped once , so perhaps I have a different view of things . ", ' Really ? What happened ? ', " Well , it was in the Balkans during the war . He was only held for three days , and then they simply released him . It was a case of mistaken identity , and they just let him go when they found out he was no use to them . It was lucky they didn't kill him . ", ' Oh , sure . ']
['How have you been ? ', ' Fine , thank you . ', ' And how ’ s everyone in your family ? ', ' Very well , thank you . I ’ m meeting my wife and daughter for lunch at 12 , would you care to join us ? ', ' I ’ d love to but I ’ m afraid I can ’ t . I ’ Ve already got a lunch engagement . ']
["Where did you get your mobile ? It's really cute . ", ' Oh , this ? I got it in Singapore . Here , do you want to take a look ? ', " Thanks . Gee , it's really light ! ", " Yes , it is , isn't it ? A bit too light , really . What make have you got ? ", " I've got an old Ericsson . Here . Take a look . ", " Wow , that's really old . ", ' Yes , I like collecting antiques . ', " Why don't you get a new one ? ", " I don't know . I like this one , and I don't have any need for all the bells and whistles you get on the new ones . ", ' Really , what makes you say that ? ', " Well , I just need to make and receive calls , and it's quite reliable . I find that the more fancy stuff they put into these things , the more likely they are to break bown or go wrong , you know ? I mean , this camera function , for instance-how often do you use it ? ", " Sometimes , but I guess not very often . It's more for fun . Sometimes when I'm on a trip , for example , I can take a picture and send it to my kids . Or I can send a picture of a sample back to my office and get it costed up immediately . ", " Well , that's nice I guess . So how many kids do you have ? ", ' Three . Two boys and a girl . ']
['I ’ m sorry , but I can ’ t find the book that you lend me . ', ' Oh , that ’ s alright . ', ' I must apologize . I ’ ll buy you a new one tomorrow . ', ' No . Please don ’ t . I couldn ’ t let you do that . ']
['How did Jim get the money ? ', ' He borrowed it from Nick . ', ' He must be mad ! Nick is a loan shark . ', ' He was too desperate to find some other way . ']
['Are your ready to go to the supermarket ? ', ' Yes , are you ? ', " I've got my money and my keys , so I'm ready . ", " You do know that it's absolutely freezing out , don't you ? I'd put a coat on if I were you . ", " It wasn't cold out this morning . ", " Well , it's started raining since then . Look out the window ! It's pouring rain out there ! ", ' Have a look outside for me . Does that look like hail to you ? ', ' It does , actually . Maybe we should wait for it to clear up before we go shopping . ', " That's a good idea . But maybe we should move the car so that the hail doesn't dent it . ", " Ok . I'll go move the car if you turn the heat on . It's a bit chilly in here . ", ' How long do you think this hailstorm is supposed to last ? ', " I don't know . The weatherman didn't say anything about this in his weather report last night . ", " Maybe we should turn on the news in case it's supposed to get worse . ", " I don't think we have anything to worry about . Do you want to put on a cup of tea as well ? ", ' Good idea . That will help us to warm up . ', " If I'm not back in ten minutes , come and find me . ", " Alright . I'll have a cup of tea waiting for you . "]
['Is everything ready for the Christmas party ? ', ' Almost . I ’ Ve put up the decorations , and we ’ Ve decorated the Christmas tree with plenty of tinsel and baubles . ', ' I like the big star on the top of the tree . I ’ ll put the presents under the tree later , how ’ s the food . ', ' I ’ Ve prepared most of it already and we ’ Ve got plenty of snack foods-you know , crisps , biscuits , and things . Are you going to make the punch ? ', ' Yes . I ’ Ve bought all the things to go in it . It won ’ t take long to make . How many people are coming to the party ? ', ' I think everyone will be coming . Dave don ’ t come because he has to go to his parent ’ s home and they live in Scotland . ', ' Do we have Christmas pudding ? ', ' Yes , we do . I hope we have enough for everyone . Did you send out all your Christmas cards in time ? ', ' Yes , I did . I send most of them a week ago . I ’ Ve brought some with me to the party to give to people in person . ', ' I did the same . I spent hours yesterday evening wrapping presents . I hope I didn ’ t forget to buy anyone something ! ', ' I hope you didn ’ t forget mine ! ']
['Today is the old couple ’ s golden wedding . ', ' That must be a long love story . ', ' Yeah . They promised to stick together forever when they were young . ', ' They have made it . Will our love last 50 years ? ', ' I don ’ t know . ']
['Do you think you could keep the noise down ? ', " I'm sorry . Am I keeping you awake ? ", ' Yes . And another thing , would you mind not making long distance calls ? ', " I'm sorry . I thought you wouldn't mind . "]
['Hey , Brad . How was your day ? ', ' Pretty good . Where are you going ? ', " I'm going home . ", ' Wait . We have to return to our homeroom and wait to be dismissed . ', ' Is that right ? ', " Our homeroom teacher has to take attendance again to make sure that we're all here . ", ' So he takes attendance once in the morning and once in the afternoon . ', " Yeah . I'm going to my locker to get my jacket . Catch you later . "]
['Mary and I decided to ring the curtain down on our love affair . ', ' What ? You have been in love for six years , haven ’ t you ? ', ' Don ’ t make a fuss . Many people divorce after having living together for many years . ', ' What a pity . ']
['Did you enjoy the movie ? ', " Oh , it's really a drag . ", " Sorry to hear that . I think it's even better than On the Golden pond . ", ' Hell with it ! Nobody will give it an Academy award ! ']
['I have some photos here taken by myself . Would you like to see them ? ', " Sure . Speaking of photos , what type of film will be the best ? You know , I'm planning a tour to Jiuzhaigou Valley . ", ' I would get Fuji 200 film for taking photos of natural beauty . ', " Thank you so much . You're an expert . "]
['How about you , Chuck ? Where did you grow up ? ', ' Well , I was born in Ohio , but I grew up in Texas . ', ' And when did you come to Los Angeles ? ', ' In 1978 . I went to college here . ', ' Oh . What was your major ? ', ' Drama . I was an actor for five years after college . ', " That's interesting . So why did you become a hairdresser ? ", ' Because I needed the money . And because I was good at it . Look ! What do you think ? ']
['How are your wedding plans going ? ', ' Very well . We ’ Ve got everything taken care of already . ', ' Are you going to get married in the church ? ', ' Neither of us is very religious , so we decided not to get married there . ', ' Have you booked the hotel for the reception ? ', ' Yes . The Palace Hotel . You have to be there . ', ' No problem . ']
['Look ! The girl is so beautiful and she is smiling at me . She is lovely . ', " I can't agree with you . She's pretty , but she always blows hot and cold . ", ' What makes you think so ? ', " She's my sister , you know . "]
["What's the matter with you ? You don't look well . ", ' Nothing . Maybe it is just the weather . Rainy days often make me feel a little sad . ', ' Really ? I like rainy days . The moisture in the air is good for my skin . ', ' Sure . But it is too cold today . I have to put on warm clothes and look stupid . ', ' Me , too . At this time of the year , I often miss my home in the warm south . ']
['Philip , I was really glad to hear about your award . Congratulations ! ', ' Thanks , Denise . Actually , I was really surprised . I mean , there were a lot of qualified people out there . ', ' Sure . But the work you did was really exceptional ! You definitely deserved it ! ', ' Thanks a lot . I expect to see your name nominated pretty soon , too . You ’ Ve been doing some great work ! ']
['Hi ! I see you are having fun with your new computer and internet connection . ', ' There ’ s so much I want to do . I ’ Ve just finished sending lots of emails to friends and family all over the world . I just ran a search for music to download . ', ' I can give you the name of a few useful website to visit . ', ' Thanks . That would be very helpful . I ’ Ve discovered that it can take a long time to find exactly what you want . There ’ s too much information on the net . ', ' When you sent your emails , did you attach any files to them ? ', ' Yes , I did . There ’ s an anti-virus program with my email account that scans all attachments , so I ’ m sure I haven ’ t sent anything nasty to anyone . ', ' When you use the internet , be careful not to give out your email address very often . If you do , you might get a lot of spam-unwanted email from companies trying to sell you things . ', ' That ’ s good advice . I should also be careful about giving out confidential information about myself , such as my password and credit car number . ', ' That ’ s right . Another thing to remember when you are surfing is that you can add a web page to your list of favourites . Your computer will remember the page and you can return there quickly next time you want to visit . ', ' How do I do that ? ', ' Take this web page for example . Press the keys “ control ” and “ d ” together . Click on “ favourites ” at the top of the screen . There you are . It has been added to you favourites list . If you click it , you will automatically go to that web page again . ', ' That ’ s useful to know . Thanks . I ’ ll just log off and shout down my computer and we can go for a coffee . ']
['If you fall in love like him , you will go soft in the head , as well . ', ' Come off it . ', ' You want a bet ? ', ' Why not ? ']
['Is there any more vodka in that bottle ? ', " Hum , I think there's enough for one more , yes . ", " Marvelous . Pass it over . My name's George , by the way . ", " Nice to meet you , George . I'm Irene . ", ' So Irene , what do you do ? ', " I'm in computing . I work for Macrohard . ", ' Macrohard , eh ? ', ' What do you do ? ', ' I have my own company that designs computer systems . ']
['Are you still busy today ? ', ' It seems to be . How about you today ? ', " Fine , honey . Rome couldn't be built with in one day . ", " OK , I'll find the time to relax soon . ", ' Take care , honey . I am always expecting you . ']
['How are you feeling , champ ? Ready to go ? ', ' You know , if I can keep up my workouts , I think I have a chance in 2004 . ', ' In what ? ', " In gymnastics . I'm pretty flexible . Look ! I can even touch my toes ! ", ' Can you do the vault ? ', ' I do back flips at the pool all the time . ']
["I've come to say good-bye . ", ' When are you off ? ', " I'm flying home on Sunday afternoon . ", ' Well , good-bye . See you soon . ', " Please don't forget to say good-bye to the rest of the family for me . "]
['Have you ever noticed that serious pollution in modern cities goes from bad to worse ? ', ' You said it . We ’ er breathing poisonous air every day . ', ' I think it ’ s time for the government to take strong action . And people should try to protect environment . ', ' I absolutely agree with you . ']
['When will you be able to come here ? ', " I can't come until next week . ", " Okay , I'll have everything prepared for you when you get here . ", " Thanks , I'll see you around Wednesday then . "]
["Who's that tall guy over there ? ", " Oh , that's George . He looks very drunk . ", " What's he like normally ? ", " Oh , he's really reserved , normally . But , from what I hear , he's got lots of problems . ", ' Really ? What kind of problems ? ', " Well , off the record , of course , but I hear that he's got terrible debts . He has his own company , and it's not going very well . ", " Really ? Well , I hate to say this , but I'm not surprised . ", ' Really ? What makes you say that ? ', " Well , he doesn't look very honest . ", " I know , that's the problem . He can't find any customers . It's a pity , really , because his products are very good . Oh , that reminds me . Did I tell you about my new laptop ? ", " Oh , don't talk to me about laptops . Mine crashed on Friday and I lost everything . I hate them . ", ' Oh , really ? ', ' Look , I need another drink . Do you want one ? ', " Yes , I'll have another cocktail . ", ' Vodka martini ? ', ' Absolutely . ', " I'll be back in a sec . ", " OK . I'll wait here for you . "]
['John passed away . ', ' When ? I saw him well last month . ', ' Yesterday . He suffered from a serious disease . When he saw the red light , it was too late . ', ' How terrible ! ']
['Peter is a bag lady now . ', ' That black sheep . It serves him right . ', ' He was so rich in the past . Maybe he ’ s regretting his past mistakes now . ', ' It ’ s too late . ']
['Hello . Is this Ann ? ', ' Yes , it is . Kelly ? ', " Yes , it's me . ", ' Do you have a cold ? ', " No . Worse than that . I have a flu . I'm in bed with a fever . ", ' Oh , no ! What about your presentation today ? ', " I'd like to do it , of course . But I just can't . I'm afraid I'd fall down in the middle of it . ", ' I understand . What should I tell Mr . Morley ? ', " Why not just tell him I'm sick ? I'll ring him myself this afternoon . ", ' Alright . Have you been to see a doctor ? ', " Not yet . I feel too lousy to go out.Anyway , I have a flu . I know what it is . I don't need a doctor to tell me that . ", " Do you think you'll be able to come in tomorrow ? Or should I call off your appointments for tomorrow too ? ", " I'm not sure yet.Maybe this will all be gone in a day.So it's probably better if you don't call off my appointments . I will call you later this afternoon and tell you what I think . ", " It's rainy weather today . Maybe it's better if you just stay inside.Make yourself some chicken soup and sleep . ", " Yes , that's what I plan to do . Except I won't make the chicken soup.Right now I don't think I could swallow more than a spoonful of it . ", ' That bad , huh ? ', " Yeah , I'm very nauseous.It ' s mostly nausea and a fever . ", " Well , I'll cancel your appointments for today . And I'll tell Mr . Morley . ", ' Thanks , Ann . Talk to you this afternoon . ', ' Hope you feel better . ']
['Susan , good evening . Why are you so dressed up ? ', ' I am on my way out to a New Year ’ s banquet . How do I look ? Is my make-up OK ? ', ' You look great . Your make-up is perfect . ', ' Do you think I should wear a different dress ? ', ' No , the one you have on looks fabulous , especially with your hair like that . ', ' Thanks for saying . Do you have any ideas which necklace I should wear ? ', " With that dress I'd say your white diamond necklace would look perfect . ", ' Thanks for helping out . Now that I ’ m ready , what are you doing tonight ? ', ' Not much , just a house party with some friends . ', ' Sounds fun . Anyone I know ? ', ' Yeah , most of the people are from our office . ', " Sounds Like I'm missing out on a good time . Oh , well , there is always next year . ", ' I ’ m sure you ’ ll have fun no matter where you go . Remember to take your bag . ']
['Is it true that rice is the staple food in most of Southeast Asia ? ', " I'm not an expert , but that's the impression I have . ", ' Is rice your staple food , too ? ', " Needless to say , as a Westerner , it's bread . "]
['What do you like to do with your free time ? ', ' Study English . ', ' You mean you like to study English ? Why ? ', ' It gives me great satisfaction . ', " Studying English wouldn't give me any satisfaction . It's hard work . ", " I don't mind the work . I think it's worthwhile . "]
['Hi Bob , how ’ s business ? ', ' Just okay . ', ' Okay , enough small talk . Let ’ s get down to business . ', ' Good idea . ', " Since we ’ re good friends , you don't have to pay me . ", ' No , I can ’ t accept it . Business is business . ']
['What a coincidence seeing you here . ! ', " It is , isn't it ? "]
['We used to be very friendly , but it seems now that my daughter ’ s marriage has taken its toll of our relationship . ', ' What do you mean ? ', ' I don ’ t like her husband , that bad egg , but my daughter insists on marrying him . ', ' She is a grow-up . She can make her own decision . ', ' I wish she wouldn ’ t regret for her decision . ']
["How wonderful it is to be in love ! It's love at first sight ! Oh . he's my Romeo ! ", " Hey , Julie . How's it going ? ", " Oh , Mary . You've surprised me ! ", ' Who were you talking to ? ', ' Um — I was just thinking aloud . ', ' You look so happy . I see a twinkle in your eyes . ', ' Come off it , Mary . ', " Oh , you have a crush on someone , don't you ? Maybe those are wedding bells in your eyes ! ", " You certainly do like teasing me , Mary . Well I'm in love with someone . The question is , how do I get his attention ? ", " Well , that's easy . Walk up to him and kiss him . ", ' I guess I asked the wrong person . ']
['Are you ready for the big competition today , Todd ? The winner gets two tickets to the Sydney Olympics ! ', ' Steve , I was born ready ! I ’ m going to blow you guys off the treadmill today . ', ' We ’ Ve still got a lot of time before we have to start running . ', ' Let ’ s hit the whirlpool for a bit . It ’ ll help me loosen up . ', ' You bet . I used to take a whirlpool almost every night back home . ']
["John's very late.Do you think he's coming ? ", " Well , it doesn't seem like it.He must have forgotten . ", " I suppose you're right.He can't have remembered . "]
["I've come to apologize for what I said yesterday . ", ' Don ’ t think any more about it . ', ' I must make an apology for losing my temper . ', ' It ’ s really not necessary . I know your intention was good . ', ' I ’ m relieved to hear that . Anyway , it ’ s my fault . ']
['You are saying he will be promoted to the general manager ? ', ' Yeah . ', ' Are you sure ? ', ' Yes . I bet my bottom dollar that he will get promoted . ', ' Just because he gets on well with everybody ? ', " Partly , and he's also a hardworking man . "]
['Would you like to come by and play bridge ? ', " Well , let's see.Why don't we go dancing for a change ? We haven't done that for a long time . ", " Well , to tell the truth , I don't really feel like it tonight . I had a pretty hard day and I'm sort of tired . ", ' Hmm.Well , in that case , we could go to the movies . ', " Oh , we always go to the movies.Can ' t we do something different ? ", ' Well , do you have any suggestions ? ', " Let's see.How do you feel about playing bridge ? ", " It's OK with me , but we don't have any beer and things . ", " Well , shall I call Janet and ask her and Tom to come over , and I'll go to the store and buy some stuff . ", ' OK . ', " Hello , Janet.It ' s me ... Oh , fine.Just fine.Say , Janet , I was wondering if you and Tom were doing anything tonight ... No ? Well.would you like to come by our place and play a few hands of bridge ? "]
["Hello , Tom . I'm really glad to meet you here . ", " I'm glad too . Steven , I want to tell you that I'm going to divorce my wife . ", " I'm so surprised , B . Why did you decide to end your marriage suddenly ? ", " We don't get along well with each other and fight a lot . ", " I didn't know that . I thought that you were happy together . ", " That isn't true . Actually , we have been separated for six months . ", " I can't believe it . But if you both determine to divorce , I hope you will have an amicable split . ", ' Thank you , Steven . I accept your advice . ', " Hello , Tom . I'm really glad to meet you here . ", " I'm glad too . Steven , I want to tell you that I'm going to divorce my wife . ", " I'm so surprised , B . Why did you decide to end your marriage suddenly ? ", " We don't get along well with each other and fight a lot . ", " I didn't know that . I thought that you were happy together . ", " That isn't true . Actually , we have been separated for six months . ", " I can't believe it . But if you both determine to divorce , I hope you will have an amicable split . ", ' Thank you , Steven . I accept your advice . ']
['Dad , I want to learn how to drive this summer vacation . ', " That's a good idea . You'd better hurry up before they've filled all classes . Many people are learning how to drive now . ", ' I will get registered now at once . Do you know any training schools ? ', ' I am not sure . You can search for them on the Internet . ', " OK . look , I've typed driver schools , and there are so many results coming out . ", " Let me see . teetee Training School , summer program , 3,000 Yuan , learn how to drive within one month , and get driver's license within three months . ", ' 3,000 Yuan is a little bit steep . ', " I think so . Let's see the next one , 3,500 Yuan , summer program . Forget it . ", " I've heard that the Ideal Life School is famous . They offer many programs and there are many classes available . The charge is also fair . ", ' Search on the Internet then , see if we can find something more about it . ', ' Ah , got it . Ideal Life School , programs ', " Don't worry . Let's check out some other schools . "]
['Did you have any hobbies ? ', ' Yes , reading is my hobby . ', ' What kind of books do you like to read most ? ', ' Many kinds of books . When I was a child in elementary school , I enjoyed reading fables and science fiction . When I became to a teenager at middle school , I was interested in detective mystery stories . Now I like reading romance stories . ', ' Are you in love ? ', ' Why ? ', ' People say only those that are in love like to read romance stories . ', ' Well , maybe . ']
['I want take shell on a date , but I don ’ t have much money . ', ' What does she like to do ? ', ' She likes to golf , dance and eat foreign food . ', ' Sounds like she has pretty pricy tastes . ', ' Well , I really like being with her . ', ' Have you thought about going in Dutch ? ', ' Dutch , where is that ? ', ' Not where , what . Dutch means you both pay your own way . ', ' Oh , I wonder if she ’ ll go for that . ']
['Hi Rose , what are you busy with right now ? ', " Hi Jack , I'm working on these documents . The manager wants them for half an hour . ", ' Well , Rose , ', ' Is there something you need ? ', ' Are your free this weekend ? ', ' Yes , I have nothing to do . ', ' Great , Is it convenient if i visit you this weekend ? ', ' I beg your pardon ? ', " I'd like to call on you this weekend . I just want to a drop in for a chat . ", " Really ? well , ok , you're welcome . ", ' Is 5 PM . a good time for you ? ', ' Hmm , how about seven ? I can treat you to dinner . ', " Sure , that would be great . I'll bring the wine . ", " OK.Then I'll be expecting you . ", " I'll be there on time . "]
["you're rather energetic today . What's going on ? ", " nothing really . I think I've had a few too many coffees . ", " free coffee is one of the perks at this place , isn't it ? ", " it's the only perk of this job ! How's your day going ? ", " not that well . I've got that Monday morning feeling today . ", ' why is that ? ', " my boss has been breathing down my neck all day . I can't wait for the weekend ! ", " your boss is a real salve-driver , isn't he ? ", " you can say that again ! He won't even let us check our personal email at work ! ", " that's not just your boss . No one is allowed to send personal emails from the office . ", " really ? I didn't know that it was against company policy . ", " maybe your boss isn't so horrible after all ! ", ' no , he is . Some bosses will bend the rules a bit sometimes , but not my boss . He always follows the rules to a T . ', ' try not to let it bother you too much . ', ' thanks . I better get back to my work before my boss yells at me again ! ', " ok , I'll see you in a bit . ", ' alright . See you later ! ']
["Hi , Mr . James , what's the rush ? ", ' The bank closes in 30 minutes and I need to cash a check . ', ' I can lend you some money . ', " Thanks . But it's necessary for me to buy a TV set . ", ' Can I help in anyway ? ', ' You can take me to the bank if you want to . ', ' Sure . Let ’ s go . ']
["He came to work late every day that week . Then on Friday , he didn't show up at all . ", " That was the straw that broke the camel's back . "]
["Bob , you're so lucky that you've come at the right time-the 2005 International Tourism Festival is around the corner . ", " We've heard about that festival before . It would be quite helpful if you could give us some highlights of the festival . ", ' My pleasure . Well , the festival is going to start on the third Saturday of October , and covers over one hundred diverse programs in one month . ', ' What do you think we can see during the festival ? ', " I don't know what to suggest . There're so many attractions , and they all sound interesting . One exciting program might be the Ten Thousand People Cycling round the Town . You can choose from the five routes that lead to different destinations . ", " I'd like to take the one that goes to the Wild Animal Park . ", ' Then you can take Route No . 5 . Next I would suggest the International Dragon Boat Race where you can watch Lion Dance , Dragon Boat racing , and many other water shows . ', ' Wow , must be interesting to watch dragon boats compete a-gainst one another on the city river . ']
["How do you know ? I thought Taiwanese people didn't have garage sales . ", " You're right . We're not really into used stuff . ", " Well , I've grown to like second-hand things . I wouldn't have gotten through university without them ! ", " There aren't many places that sell used things in Taiwan , besides auction websites . ", " I use those sites . Hey ! Let's go check out a flea market later . ", ' Great ! I can teach you men a thing or two about shopping ! ']
['What do you think of AC milan and the team of Argentine ? ', " They aren't evenly matched . ", " Yes , I think AC Milan's foot work is much better on the whole . ", ' Yet the Argentine attacker is worth a bet . ']
['Did you move into your new apartment ? ', ' Yes , but I ’ m afraid it ’ s still a mess . I haven ’ t put anything away yet . ', ' Don ’ t worry . It ’ ll probably take you about three weeks to get everything organized . ', ' Don ’ t say that . It looks like a dump now . I can ’ t stand it . ', ' Have you taken a walk around your neighborhood yet ? ', ' Unfortunately , yes . ', ' What do you mean by that ? ', ' I took a long walk through the neighborhood this morning on my way to the train station . It took me 20 minutes . ', ' Yes , but you only pay 800 dollars a month . Emm , it ’ s hard to decide which is better , shorter commuting time or lower rent . ', ' I thought paying a lower rent would be better , but now I ’ m not sure . ', ' Is there a supermarket nearby ? ', ' Yes , if you consider 7-11 is a supermarket . ', ' Sounds like you better buy a bicycle . ', ' That ’ s right , or I ’ m going to spend a lot of time walking . ']
['I want to buy a parking permit , please . ', ' Are you a full-time student or do you attend part-time in the evenings ? ', ' I attend both day and evening classes . ', ' Will you be riding a motorcycle or do you drive a car ? ', ' I ride a motorcycle . ', ' That permit will run twenty-five dollars ; will that be cash or credit card ? ', " I'll use a credit card , thank you . ", ' Do you need a second permit for a car ? ', ' No , just the motorcycle permit . ', ' Fine , here it is and have a great semester ! ']
['What is that you have there ? ', " Aah ! Close your eyes . You aren't supposed to see this . ", " Ah ha ! I caught you . Just let me peek . I won't tell anyone . ", " You can't peek ! This is a surprise . ", ' How about one little hint ? ', " Here's one little hint . If you don't go out right now , this won't be under the tree . ", " That's a very good hint . ", ' And please shut the door and lock it behind you ! ']
["Here's 30 yuan for my ticket . ", " Keep it . I'm buying tonight . ", " No , you can't do that . ", ' Sure I can , my treat . ']
['How are you doing with your English Language studies ? ', " I think I'm making good progress . ", ' Is it harder than you thought ? ', " At first it was , but now I've got the basics.It ' s fun . "]
['I am told that you dance like an animal . Why don ’ t you give a show in the front stage ? ', ' Thank you . But I ’ m sorry I ’ m in a bad mood at the moment . ']
['Did you enjoy that new movie ? ', " That movie's just a lot of noise , same as Simon . ", ' Oh , what happened , Carole ? ', " I had to go by myself , he couldn't make it . ", " What ? I met him just before I took off from Kitty's , he said he was coming . ", " Kitty's ? He sure gets around , doesn't he ? ", ' Looks like it . So how did he handle it to ? ', ' His excuse was familiar . He said his car died again . ', " I think that's a bunch of nonsense . It seemed ok to me . ", ' I know . Last week he gave me a lie about being too busy . ', " Doesn't sound promising . ", " Well , I think it's the time to pull the plug . ", " If you want I'll let him know if I run into him . ", " Thanks anyway , but I'll do it , Rebecca . Let's get to class . "]
['Have you run into your cousin Jimmy lately ? ', ' As a matter of fact , I have . I ran into him just the other day . ', " How's he doing ? ", ' Not too well . He had to have four teeth pulled last week . ', " He did ? That's too bad ! ", ' I think so , too . ', " Next time you see him , please tell him I'm thinking of him . ", " I'll be sure to do that . "]
['Oh , my god ! ', ' What ! ', " That's the cutest little doll I've ever seen in my life ! ", " Chill out . It's just Kenny from South Park . ", ' What park ? You found a doll in a park ? Gross ! ', " South Park is a popular cartoon . You're so out of it , Jen ", " Well , don't blame me ! I never get a chance to watch TV . "]
['Wait for me 。 ', ' Okay . Take your time . ']
['Can you believe the headlines ? ', ' What are you reading ? ', " I'm reading about Michael Milliken , the Bond King . ", " Didn't he sell worthless stocks to people or something ? He got arrested for that , didn't he ? ", ' He got arrested all right . ', ' If I remember , he got off with a light sentence . Something like three years in a minimum-security prison . ', " Yup , that's him . He made millions of dollars selling bonds to people and ended up with a pile of cash when they became useless . ", " I think the government fined him a small amount , and he kept the rest in his foreign bank accounts . He's still a millionaire . ", " That's the kind of thing in America that gets me mad . Some guy pulls off a stock scheme and makes millions while spending the bare minimum sentence in jail . ", ' I know . And some poor guy that robs a liquor store makes $ 500 at most and ends up in jail for five to ten years . ', " Yup , you got it . Criminals in America do a lot better if they're white-collar thieves . ", " So what's Michael Milliken up to these days ? ", " He's giving lectures on business at colleges . "]
['He was once a poor man but now he is a man of means . ', ' How did he make a fortune ? ', " He didn't make any effort . His aunt died and left him a fortune . "]
["I didn't see you at Mr . Johnson's class today . ", ' Yeah , I quit . ', ' Why ? ', " I'm fed up with his boring lectures . "]
["Why don't we Chinese have our own Valentine's Day ? ", " Of course we have . It's on the seventh day of the seventh lunar month . ", ' Oh ? Why is that day ? ', " It is said that the Cowherd and the Spinster , the lover stars in heaven , can only meet on the seventh Eve , so this day has become the Lover's Day . "]
["The idea about Friday the Thirteenth is totally ridiculous . I don't believe it at all . ", " Maybe you can't be so sure . ", ' Why not ? The whole idea is superstitious . ', ' But some people use this occasion to create trouble . Have you heard of the Black Friday Virus on the computer ? It is designed to break out on every Friday the Thirteenth . ', ' I know that . But that has nothing to do with being unlucky . Those who created the virus are deliberately making fun of people . ']
['I am not sure what to do during the holidays , any suggestions ? ', ' Well , going to a cinema , visiting the galleries , exhibitions and museums , finding and meeting old friends , exercising in the health club or mountain biking . There are so many good choices . ', ' The problem is that I find all of them are full of fun . I just don ’ t know what to do first . ', ' Why not start with the most interesting one ? ', ' Actually , I ’ m interested in all of them . The more choices we have , the harder to make a decision . ', ' Toss a coin to decide then . ']
['Hello , Jack ! Fancy meeting you here ! ', " Yes , it's really a surprise . How are you ? ", ' Fine . How is Jim ? ', " Oh , he is all right . But busy as usual . Well , why don't we have a good chat at a bar ? It's been long time since we met each other last time . ", ' Good idea ! ']
['Jenny , are you having a good time ? ', ' Yes , of course . This is a really wonderful party with interesting people and great food . ', ' I ’ m glad you are enjoying yourself . ', ' Thank you for the invitation . ', ' It ’ s my pleasure . Can I get you another glass of champagne ? ', ' Yes , I ’ d love another glass . You ’ re a wonderful host . Thank you for everything . ', ' It ’ s my pleasure having you here . ']
['I was wondering if I could borrow the company van for a fundraiser this weekend . ', ' Sure , I think that would be possible . Where is the fundraiser ? ', ' It is in the park downtown . ', ' Would you need it for both Saturday and Sunday ? ', ' We will need it for Saturday only . ', ' I think that would be OK . Who will be driving it ? ', ' Mary and I will be driving the van . ', ' Could you drop it off on Sunday night ? ', ' Yes , we can do that . Can we borrow the chairs from the lunchroom also ? ', ' Yes , that would be fine . Just make sure that everything is returned by Sunday night . ']
['Good morning , Kevin . ', ' Morning , Lee . How are you ? ', ' Very well , thank you . ']
['I ’ d like to take this opportunity to thank you for everything you did for me . ', ' It ’ s my pleasure . I enjoyed working with you . ', ' I wouldn ’ t be able to make it without your help . ', ' Then keep up the good work . ']
['Hi , dear , do you know what the important day is today ? ', ' I don ’ t know . ', ' Please think it over . ', ' Oh , I see . ', ' Come on , dear . I know you mustn ’ t forget it . ', ' It ’ s Saturday , a great weekend . ', ' Ur , you really let me down . ', ' Don ’ t be angry with me . I have a bad memory . ', ' No , you haven ’ t . You just don ’ t care about me . You ’ re an indifferent husband . ', ' What day is it on earth ? ', ' It ’ s an anniversary of our weeding . ']
['What can I do for you ? ', ' Would you recommend some materials on the World War Two ? ', ' Have you found a particular item from the card catalogue ? ', " Yes , but I don't think they are enough for me . ", ' Oh , maybe you can find something from the New York Times , or the Washington Post during that period . ', " That's a good idea . Thanks a lot . ", ' You are welcome . ']
['Some people pile on their agonise and try to seek other ’ s sympathy by telling them how miserable they are . ', " Yeah . They take the advantage of other people's hospitality and generosity . ", ' I was fooled once . A lady told me she needed some money to keep the pot boiling . So I gave her some money and bailed her out of the situation . But later I learned that she had lied to me . ', ' You are still wet behind the ears . You should have seen through her . ', ' Nothing rang a bell . ']
['Hi , Celia ! How was your trip to the United States ? ', ' It was terrific . I really enjoyed it . ', ' Great . How long were you away ? ', ' I was there for about three weeks . ', " That's a long time ! Was the weather OK ? ", ' Yes , most of the time . But it snowed a lot in Chicago . ', ' So , what was the best thing about your trip ? ', " Oh , that's difficult to say . But I guess I liked Nashville the best . "]
['I am really impressed with your presentation skills . ', ' Thank you . I have been working on it for several years . ', ' Well , your time has been well spent ! ', ' It also helps that I have strong team members , such as yourself . You really know your stuff ! ', ' Thanks , but I have to admit I am really good at bluffing ! ']
['welcome back ! How was your vacation ? ', " it was fantastic , but I'm glad to be back ! Being a tourist is really tiring ! ", ' where did you end up going ? ', " because it's off-season , we got a really good package deal to Paris , so we went there . ", " I've always wanted to go to Paris . The Eiffel Tower is one of the most famous tourist attractions in the world ! Did you go to the top ? ", ' that was the first thing we did . I have a few pictures . Do you want to see them ? ', " sure . What's this one a picture of ? ", " oh , that's a picture of me on our fourth day of travelling . I'm standing next to a famous foundation in the centre of the city . ", " you don't look very happy in that picture . ", ' no , by that time , I was sick of sightseeing . I had had enough of art galleries , cathedrals , fountains , statues , and palaces ! ', ' so what did you do ? ', ' we spent that afternoon walking around a flea market . We had a few coffees , watched a movie , and went for a swim in the pool at the hotel . ', ' my travel agent always reminds me to plan a day of relaxing for every 3 days of sightseeing . Did you go to the Louvre ? ', " of course ! You can't go to Paris without going to their famous art gallery ! I was surprised by how small the Mona Lisa was though . ", " that's what everyone says ! I can't wait to see it for myself some day . "]
['What does she do ? ', ' She works as a teller in a bank . ', ' Does she go to night school ? ', ' Yes . She goes three times a week . ', ' Why ? What does she want to be ? ', ' She wants to be a manager . ', ' What classes does she take ? ', ' She takes classes in accounting and business . ']
["I'm afraid I've spilt ink all over the table-cloth . ", ' Oh , never mind about that . ', " I'm terribly sorry . Won't you let me pay for it ? ", " No , I won't hear of it . "]
["Hi , Mike . We're having a party tonight , wanna come join us ? You can bring your girlfriend . ", ' Well . I am breaking up with Cathy . ', ' What happened ? Did you have a fight ? ', ' No . She is really a very nice girl ... ', ' Yeah , she is . She is pretty , caring , getting easy-going and she is a great cook . She is a gem . ', ' Well , you are right . But sometimes she is too caring . Well , no ... she ’ s just possessive and I kind of want a break ... you know ... for some room for myself . ', ' Oh ? ! Did you talk with her about it ? ', " I've tried , but it didn't work . ", ' So , when are you going to tell her ? ', " Maybe tonight . I don't know . I don't know how to tell her . ", ' I know she ’ s head over heels in love with you . She will be badly hurt ! ', ' I know ... ']
["You saved my life yesterday , Rachel . I can't believe I forgot to bring my wallet when we went to lunch with those clients . ", ' It was a good thing I had enough on me . ', ' Let me buy you lunch today to pay you back . ']
["Jenny , what's wrong with you ? Why do you keep weeping like that ? ", ' Mary told me that she had seen you with John last night . I got to know the fact that you are playing the field . ', " Honey , cross my heart , I'v never looked at another woman since the first day I set my eyes on you ! Believe me , that's the truth . "]
['How delicious ! Tender and crisp ! ', ' This is the specialty of our restaurant , sir . ', " Yes , it's really savory . ", ' Thank you for appreciating it . ']
['I am tired of everything in my life . ', ' What ? How happy you life is ! I do envy you . ', ' You don ’ t know that I have been over-protected by my mother these years . I am really about to leave the family and spread my wings . ', ' Maybe you are right . ']
["What's all the security check about , Jimmy ? Does it mean the bar may be a dangerous place ? ", " No , of course not . Just in case . Nothing to worry about . Don't you also do this in China ? ", " I don't know . Maybe the same . Actually , this is my first time being in a bar . ", " Oh , then it's my honor to be here with you . I can see now why you've been so curious about the bar . You like this place ? ", ' Sure . I love this place , especially the decoration . So tasteful ! ', ' Yeah . Other than that , the real feature is the excellent drinks . Can I have your ticket ? ', " Here it is . But , what for ? We're already in . ", ' Well , with the ticket , you can get a free drink . What would you like ? Orange juice ? ', " Yes , orange juice will be fine for me . But how can you get the drink ? It's so crowded there around the counter . You can barely move . ", " I'll show you how . The bar tenders know whose turn it is . And also , I can snap my fingers to catch his attention . ", ' Cool . Thanks . ( Jimmy brings May a glass of orange juice . ) ', ' Oh , fresh juice , I love it . Well , I heard American people love hanging out in bars . Is that true ? ', " Not everyone . But a lot of people do , especially the young . It's a fine place to spend an evening with friends or to make some new friends . ", ' Interesting . Hey , look over there . The dance floor is already packed with people . Oh , the girl in red dances great . ', ' Yeah , a dancing queen . Wanna go and join them ? ', ' Maybe later . I wanna take some photos first . ', ' OK . Let me help you to hold the drink . ', ' Thank you . ']
["Hey , Mary , nice to see you again . I heard you're going back home to the U . S .. ", " Yes . I'm leaving tomorrow . I came here just because I want to say good-bye to you . ", " You're so thoughtful . Wish you a good trip home . And we'll miss you . ", " I'll miss you too , my friends . "]
['You know that ? Dan got a divorce . ', ' Really ? I thought he loved his wife very much . ', ' Yeah . But his relation with Sally come to a sticky end and was found by his wife . ', ' He deserved it . ']
['Mr.Ben , What do you think of the book ? ', " It's an excellent one . I like it very much . ", ' Why ? ', ' It includes a lot of useful words and phrases . ', ' I agree with you . ']
['Come and sit down . Would you like a drink ? ', " Oh , yes please ! I'd love a gin and tonic . ", ' Do you like olives ? Or would you prefer crisps ? ', ' Oh , just olives please . What music is this ? ', " Do you like it ? It's Irish music . ", " It's great ! Where did you get the CD ? ", ' Arm - I think it was in the CD shop in the Mall . Have you been there ? ', " Yes . I buy a lot of stuff from there . It's a good shop , isn't it ? ", " Yes . Hey , I've got some photos of our holiday in Ireland . Would you like to see them ? ", " Why not ? I'd love to ! "]
['Anita , I ’ Ve been here only three days and you ’ re leaving already . ', ' Just for a few weeks . I need this vacation . You ’ ll be all right . You know the project we ’ re working on , and you ’ re a good scientist . Don ’ t worry . I ’ ll be back as soon as I spend or gamble all my money . ', ' Gambling ? Where ? ', ' Las Vegas . I find gambling relaxing . I don ’ t take it seriously , the way some people do . Besides , I love the shows and the all-night atmosphere of the town . The casinos never close , you know . ', ' If you gamble all night , you ’ ll run out of money in a few days . ']
['What ’ s the Mountaineering Club doing this weekend ? ', ' We are going to climb a cliff on the Colorado River . ', ' How hard is the climb ? ', ' It is a very difficult climb because there are not many places to put your hands and feet . ', ' What did you do last week ? ', ' We rappelled down the side of 300 - foot cliff . It was very exciting . ', ' Wow ! That sounds like a lot of fun . I ’ m sorry I missed it . ', ' Well , you should come this weekend . I think you could do the climb . ', ' Yeah , I will . See you then ! ', ' O . K . See you . ']
['Lucy , what are your priorities when buying a car ? ', ' I guess the first thing is the price , the second is the size , and of course the color will play a role too . But I have to be honest . It is our today ’ s responsibility to take care about our environment . Therefore , I will also pay attention to the fuel consumption of the car . You know , the rise in gasoline prices is huge . So I would rather to consider a smaller car with smaller engine . For which I can also save some tax . Last of the list , I also consider the safety . ', ' What about the environmental factors ? ', ' Well , I do prefer the lower emission cars as long as it doesn ’ t cost much . Some environmentally-friendly cars are really expensive . ', ' Sure they are . Some hi-tech devices are built in to make sure they pollute less . Some of these green cars have not become standard . So the production costs are still high . But anyway , we should make efforts to start with . ']
['I don ’ t think I can take another semester of this dorm food . ', ' I know what you mean , it leaves a lot to be desired . ', ' Sure , like taste , variety , nutritional value , what I should do is move into an apartment off campus where I can cook for myself . ', ' Have you found anything yet ? ', ' You know how hard it is to find a decent place at this time of year ? ', ' You should be able to find something comfortable in town , though that would be kind of far from school . ', ' I got a car , so the distance wouldn ’ t really be a problem . ', ' But the parking might be . ', ' You bet ! ']
["Richard , why didn't you come to school today ? ", " I'm sick . I think I've got the flu . ", ' Well , take care of yourself . ']
['Thanks for everything . ', " Don't mention it . "]
['You look pale , you must have poor health . ', ' Yeah . You said it . ', ' Why not go to see the doctor ? ', ' I ’ Ve done that . The doctor advised me to cut out smoking and drinking . ']
['William , do you like studying English ? ', ' I like studying English , and I can read well , but speaking can be difficult . ', " It's not that bad . If you talk to your American friends every day , you'll learn quickly . ", ' Can I ask you a question ? ', ' Sure , what do you want to know ? ', ' I have my book from class here . How do you say this word ? ', ' Laptop . ', " Sorry , I don't understand . What does that mean ? ", ' A laptop is a type of computer that you can carry with you . Do you understand ? ', ' Yes , I think so . Can you say it again ? ', ' Laptop . ', ' Laptop . Did I pronounce that correctly ? ', " Yes , that's right . That's very good . ", ' Thanks . And this word ? How do you pronounce this ? ', ' That word is pronounced kitchen . ', " Thanks so much . You're a good teacher . ", ' Thanks . ']
["I can see you've got some color back in your cheeks . ", ' Yes , I find jogging does good to me , so I keep on doing it . ', " You've formed a sound habit . ", ' I think so , too . ']
['I ’ m not a Christian . I just want to know why Americans believe that sort of thing . ', ' Believe what ? ', ' You know ... like , say God is the creator of the universe , the Bible , and Jesus Christ ... ', ' You don ’ t believe that ? Everyone interprets the Bible in a different way . To some people , the Gospel 5 is a source of much comfort . ', ' What do you believe , John ? Are you Christian ? ', ' To tell you the truth , I don ’ t know if I ’ m a Christian or not . Christians don ’ t often share the same belief . But I believe that we all possess , by the grace of God , the potential to create fantastic changes on this earth . ', ' Do you believe that one religion is better than another ? ', ' No , all religions are essentially based on the same ideals , so no one is really better . ', ' Do you go to church regularly ? ', ' When I ’ m home in the States , I go , but not in China . ']
['I ’ Ve decided to go to the cinema alone this evening . ', ' What has caused you to make such a decision ? Didn ’ t you used to go with Helen ? ', ' Helen is nice but she talks a lot . ', ' Oh . That ’ s really annoying when seeing a film . ', ' It sure is . ']
['Hello everyone ! I ’ m Rick Fields , and here with me is Bob Copeland . ', ' Howdy folks , and welcome to today ’ s game ! You know , Rick , today is a key game between Russia and Canada . As you know , the winner will move on to the finals . ', ' That ’ s right , and it looks like we ’ re just about ready to start the match . The ref is calling the players for the face-off ... and here we go ! The Russians win possession and immediately set up their attack ! Federal gets checked hard into the boards ! ', ' Maurice Richard has the puck now , and passes it to the center . He shoots ! Wow what a save by the goalie ! ', ' Alright , the puck is back in play now . Pavel Bure is on a breakaway ! He is flying down the ice ! The defenders can ’ t keep up ! Slap shot ! He scores . ', ' What an amazing goal ! ']
["Well , Mike , nowadays there's much talk about nanometer . But what on earth is it ? ", " Nanometer is a length scale . It's one billionth of a meter , roughly ten times the size of an individual atom . ", " Hmm ... it's hard to figure out the exact size , I'm afraid . ", " Well , let's make it this way . For comparison , 10 NM is 1000 times smaller than the diameter of a human hair . There are as many nanometers in an inch as there are inches in 400 miles . ", ' I see.Thank you . ']
['What are you doing for Christmas this year ? ', ' All my relatives are getting together at my house . ', " That's great . M OST of my family is coming home too . ", " Who can't make it in your family ? ", " My sister.She is going to her in-law's house this year . ", " That's too bad . So , what did you ask for Christmas this year ? ", ' I asked Santa to bring me a new sweater and some computer games . ', ' I want some computer games also . I gave my parents a really long Christmas list . ', ' I hope that I get what I asked for . ', ' So what does your family do on Christmas Day ? ', ' We wake up early and go to church.Then we come back home and open our gifts together . How about you ? ', ' Our family is a little different . We go to church on Christmas Eve instead . ']
['Matthew ? Hi ! ', " Steve ! Haven't seen you in ages ! How long's it been ? ", " it's got to be almost a year now . ", ' how have you been ? ', " I'm pretty good . I've been looking for a place to live recently . My lease runs out next month and I don't want to renew it . ", ' yeah , I remember the neighborhood . Have you found a place yet ? ', ' not yet . I am still looking through the classifieds . Wish me luck . ', ' well , maybe I can help . Remember my neighbor ? ', ' Mrs . Thou ? ', " yes , her daughter's having a baby , so she's moving in with her to help out . I think if you are interested , you can come over and have a look . ", " great . It's a lovely neighborhood . And it would be nice to be neighbors again . It would be just like the old days ! ", " I'll ask Mrs . Thou when she's available to show the apartment and let you know . Has your number changed ? "]
["Hey , How's it going ? ", ' Not good . I lost my wallet . ', " Oh , that's too bad . Was it stolen ? ", ' No , I think it came out of my pocket when I was in the taxi . ', ' Is there anything I can do ? ', ' Can I borrow some money ? ', ' Sure , how much do you need ? ', ' About 50 dollars . ', " That's no problem . ", " Thanks . I'll pay you back on Friday . ", " That'll be fine . Here you are . ", ' What are you going to do now ? ', " I'm going to buy some books and then I'm going to the gas station . ", ' If you wait a minute I can go with you . ', " OK . I'll wait for you . "]
['Well , Jeff , that was a very productive meeting , I thought . You had some really great ideas in there ! ', ' Really ? Well , thanks for saying so . ', ' No , I mean it . Look , are you hungry ? Shall we go get something to eat ? ', ' Sure . Why not ? ', " OK , well , let me just get my coat and we'll go to the diner around the corner . ", ' OK . ']
['Sometimes you look like brains , and sometimes you are simple a Barbie Doll . ', ' I don ’ t know whether I am a Barbie Doll or you are one . ', ' Maybe I am a Barbie Doll , but I won ’ t do Barbie Doll things . ', ' Well , I am not going to flog a dead horse . Let get down to our brass tasks and tidy these things up . ']
['I heard you were on a date last night ! So , how did it go ? I want all the juicy details ! ', ' Um ... well , actually , we had a fantastic time last night . He was ... amazing ! ', ' Okay , now you really have to fill me in . What ’ s he like ? ', ' He ’ s really good looking , he ’ s quite tall , around 6 ’ 1 ” , he ’ s in his early thirties , and he ’ s got the most beautiful dark brown eyes ... ', ' He sounds hot ! What does he do for a living ? ', ' You know what , this is the best part . David is a junior investment banker at Fortune Bank , so he ’ s got a great career path ahead of him ! ', ' Hold on a sec , his name is David ? ', ' Yeah ? ', ' That ’ s my brother ! ']
['Hi , Steven ! What do you like to do during the weekend ? ', ' I love swimming and cycling . On Saturday morning I usually ride my bike around the city or the country road for almost two hours . ', ' That ’ s great ! I think they do you a lot of good . ', ' Sure , they do . ', ' But why do you choose cycling at first ? ', ' Because it is convenient and good for environmental protection . ', ' You are really a good citizen . ', ' That ’ s what I can do . ']
['Matthew , do you know much about body language in countries around the world ? ', " Sure , I've picked up a few things from travelling around for work . Why ? ", " Well , I had a meeting today with a woman from Japan and she wouldn't stop bowing ! I didn't know what to do ! ", ' Did you bow back ? ', ' No , I tried to shake her hand , but her hand was so limp I was a bit offended . ', ' Well , Japanese businessmen and women typically bow to greet each other in Japan . She might have been offended by your strong handshake . ', " But she was in America ! Shouldn't she have known that strong handshakes in America signify confidence and respect ? ", ' Things are different in Japan . You know , in some countries , making eye contact with others is considered rude . ', ' Is that why she wouldn ’ t look at me in the meeting ? ', " I think it's highly possible , yes . ", ' The meeting really didn ’ t go down well at all . I think I need to read up about intercultural communication before I have another meeting with someone from another country . ', " That's a good idea . When you don ’ t know much about other cultures , the simplest thing can offend someone . ", " That's so true . It's great that we see eye to eye on this . "]
["It's raining . ", ' Oh , no ! Not again . ']
['How was your trip to Brazil ? Did you learn anything ? ', ' I had no idea how seriously that country takes soccer ! ', ' Tell me about it . ', ' Okay . In the middle of their streets there are parks , big soccer fields as far as you can see . ', ' Really ? ', " That's not all . They use them ! Every night men , women , children all out there till 3 and 4 a . m . ", ' Are you serious ? ', " I don't know how they function the next day ! It's like they eat and breathe soccer ! "]
['What courses did you major in ? ', ' I took more than 10 subjects including Theoretical Economics , Political Economics , Western Economics , Statistics and so on . In addition to the courses of my major , I took minor courses too . ', ' What courses did you minor in ? ', ' I took computer science and English courses as my minor subjects . ']
['Do you know what E-commerce is ? ', " Well , I'm not sure . Maybe it means we can buy something through the Internet . ", " That's right ", ' It must be very convenient and pretty quick . ', ' Sure , but you must have access to the Internet . ']
['Michael Johnson doesn ’ t look graceful , but he sure is powerful . ', ' If I were on as many steroids as he was , I think I ’ d be powerful , too . ', ' What are you talking about ? ! He ’ s passed every drug test he ’ s taken ! ', ' Those drug tests don ’ t mean anything ! He probably took some other drugs to mask the steroids . ', ' Just because Ben Johnson was juiced up doesn ’ t mean all athletes are . ', ' OK , OK . I ’ m feeling a little dehydrated . Let ’ s get something to drink . ']
['Hi Wei , what are you going to do this weekend ? ', ' I think I ’ ll stay in on Saturday and rest . ', ' Oh right ... How about Sunday ? ', ' Ah , I ’ m going to the pub to watch the football . ', ' Oh really ? I ’ ll come along with you if that ’ s ok . ', ' Sure , you ’ re more than welcome . I ’ m meeting everyone at three o ’ clock . ', ' Oh great , I ’ ll see you there ! ']
['Will we drive to the seaside ? ', ' Yes , it will take about four hours . We can leave about noon and get there by supper time . ', ' Let me help pay for gas . ', ' All right . There will be three of us going so we will each pay a third . ', ' What other expenses will we have ? ', " There won't be many other expenses expect food . "]
["Who's singing in your home , Jim ? ", " It's Ellie and her friends . ", " Who's Ellie ? ", ' She\'s my little niece.It \' s her birthday.They \' re singing " Happy Birthday " . ', ' Oh , I see.how old is she ? ', " She's ten . ", " I suppose they're playing games . ", " Oh , yes.Ellie was playing games all day yesterday.By the way , Alice , when's your birthday ? ", ' Today . ', ' Today ? ', ' Yes . ', ' Well , imagine that ! How old are you ? ', ' Eighteen.Some friends are having a birthday party for me tonight.Do you want to come ? ', ' Very much.What time ? ', ' About 6 . ', " I'll be at your house at about five thirty.Happy birthday . "]
['You say he was around average height . ', " Yes , that's right , around five nine five ten . ", ' Weight ? ', " I'm not sure . Medium I suppose . Maybe a little on the heavy side . ", ' Any marks on his face ? ', " No , I don't think so . ", ' Glasses ? ', ' No . ', ' What about his hair ? ', ' Black or dark brown . ', ' Long or short ? Straight ? Curly ? ', ' Straight , I think , and about average length ', " Boy , this sure doesn't help us much . It could be anybody . How about his cloth ? What was he wearing ? "]
["I'm feeling wonderful . ", " Are you crazy ? The papers make everybody listless . I don't think you are the exception ", " I'm no exception , and that's why I spent a whole afternoon in the swimming pool . ", " I'd better exercise my body too.My limbs are rusty now . "]
["I'm going to the store downtown this afternoon to try on my wedding dresses . ", ' Oh my gosh , how exciting ! ', ' Will you come with me and help me choose ? ', ' Sure , I will . How can I miss that ? ', " Good . I think I'll get too nervous to look at myself in the mirror ! ", " Oh , don't . I'm sure you'll be the loveliest bride ever ! "]
['Tom , did you see the film last night ? ', ' Yes , I did , I thought it was a failure . ', " Do you really think so ? I don't think so . It wasn't that bad film at all . Didn't you hear the applause of the audience ? ", ' Well , maybe so . But I still think everyone has their rights of their own opinion . ', " Well , i don't see the point of arguing this . "]
['Do you surf online regularly , Joe ? ', ' Of course . I stay online for four hours at least every day . ', ' Are you crazy ? What are you doing four hours online ? ', ' Millions of things . I surf the Net , check my e-mail , and most importantly , I chat with my friends . ', " Online chat ? Aren't you afraid of meeting bad people who pretend to be what they are not ? ", ' No , I am not . And I love to meet new people in the chat rooms who share a lot in common with me . ', ' It sounds interesting . ']
["Let's take a coffee break , shall we ? ", " I wish I could , but I can't . ", " What keeps you so busy ? You've been sitting there for hours . You've got to walk around.You just can't stay on the computer forever . ", " Well , I am up to my neck in work . I've got to finish this report . Sarah needs it by noon . I don't want to be scolded if I can ’ t finish my work by the deadline . ", " I understand that , but you'd feel better if you took a break , even for just a short while . "]
['Are there many idioms in English ? ', ' There are hundreds and hundreds . English is particularly rich in idiomatic expressions . ', ' Can you give us an example ? ', " I'll look up the rate . To look up doesn't mean to look high into the sky or to look at the roof . It means to search for and find some information . ", ' What about the expression Goodbye ? Is that an idiom ? ', ' That is just a natural , grammatical English expression . It has a direct translation in other languages . ', ' This is interesting , Ms.Parker . ']
['Have you ever thought of going to Africa ? ', ' No , it might be dangerous there . ', ' Would you like to go with me ? ', " I'd like to , but I'm tied up with my paper . "]
['Are you a wrestler or a boxer ? ', ' No.Why ? ', ' Your muscular shoulders and chest impress me so . ', ' Oh , really ? I go to the rye every day . ']
['Merry Christmas ! ', ' The same to you ! ', ' Are you doing anything special ? ', " We're having some friends over.What are you doing ? ", " Oh . I'm just going to take it easy . "]
['So Kim , have you ever had anything stolen ? ', ' Stolen ? No , why ? ', ' My uncle just had his motorcycle stolen a few nights ago . I was just thinking about how clever criminals are these days . ', " Criminals are clever ? They're only successful when people are careless . ", " I don't know . The ones who stole my uncle's motorcycle were pretty good . ", " If your uncle had an alarm system , then it wouldn't have happened . ", " He did . It was one of the best ones available . But that didn't stop them from disabling 11 it . And on a crowded street too . ", " Didn't anyone stop them ? ", ' You would think that people would be smart enough to stop something like that . No one knew his motorcycle was being stolen . The thieves came in a truck and convinced everybody that my uncle was parked illegally and they were there to tow it away . ', " Wow , they were good . I guess criminals aren't that dumb after all . ", " That's not the end . They were so good that they convinced a bystander to help them lift the motorcycle and put it in the truck . "]
['He has a long head , I bet he will do well in his business . ', ' He does , he started five years ago and now ends up the richest among us . ', ' When we were students , he was no good in any subject . ', ' It seemed to be useless to study well when we were young if we examine his case . ']
['Charles , have you finished your homework ? ', " Not yet , Grandma , What's the matter ? ", ' I want you to have a walk with me . ', " I'll finish soon . "]
["Look ! There's even a built-in handle to carry it with . ", " But it's so thin . There's no way that it comes with a CD-ROM . ", ' Oh , yes , it does . Look , here it says that the CD-ROM is built-in ! ', ' What other features are listed ? ', ' It says that it comes in teal and tangerine . ', ' Totally cool colors ! ', ' And it says that it sleeps . ']
['Actually I have a passion for Chinese literature . ', ' You do ? ', ' Yeah , those classics from the great writers . ', ' But I find Japanese ones better . ']
['How is grandpa doing recently ? ', ' Not good . The doctor told him not to smoke again , but it just rolls off him like water off the duck ’ s back ! ', ' Maybe I would talk with him someday . ', ' I hope it will be of some use . ']
['How is everything going with your girlfriend ? ', ' Didn ’ t I tell you ? It ’ s over ! ', ' Oh , I am sorry to hear that . I did ’ t know that you had split up . What happened ? ', ' It was a few things . The first thing that happened was that we were supposed to go out for a romantic dinner for our one year anniversary , but she stood me up ! ', ' Really ! Did she tell you why she didn ’ t show up ? ', ' No , but I ended up finding out later that night when I saw her with another man at a club near my home ! ', ' What was she thinking ? Did you confront her about it when you saw her ? ', " I wanted to , but I knew that if I spoke to her , I'd just blow up at her , so I decided to just go home . I called her later that night , but she didn't answer the phone . ", ' I can ’ t believe she would do that to you . It ’ s so dishonest---and rude ! ', ' I know . I still haven ’ t heard from her . The good thing is that I ’ m so angry with her that I don ’ t feel sad about not having her around . ', ' I bet you she regrets what she ’ s done . You were such a good catch ! She really lost out , didn ’ t she ? ', ' I guess so . It would be nice to know why she did this though . ', ' I know . It ’ s always nice to have some closure , but I don ’ t think you ’ ll have a problem finding another girlfriend . ']
['Eric , how long will you be in China ? ', " I don't know . Well , my contract here is for one year , and I don't know what I should do after that . Maybe going around for a while . ", ' Well , have you ever thought about learning some Chinese ? ', " Actually , I am learning that now . But it's too hard for me . You know the four tones and the stuff . It really freaks me out . ", " Don't worry . All things are difficult before they are easy . ", ' You hit the nail right on the head . ', ' Well , are you invested in some language-exchange program ? ', ' What is it ? ', " It's where I teach you Chinese , and in exchange you teach me English . ", " Awesome . I've been giving this a lot of thought . When can we do this ? ", ' How about this sunday ? ', ' Ok , cool . ', " Good . I'll give you a call tonight . ", ' No problem . ', ' Bye . ']
["Doris , I'm glad you're home . I'm terrified . I don't know what to do ! ", ' What is it ? What happened ? ', ' I think someone is stalking me . ', " No , it can't be . Really ? Who ? ", " I don't know . I saw him the first time Tuesday . He was at the cafe . I noticed he was looking at me a lot . Not just the usual looking , but staring.He just kept staring at me . He didn't stop . ", ' What did you do ? ', " I didn't do anything . Finally , he left.But then I saw him again today . Outside the shoe store . Near the cafe . I went into a CD store and pretended I was looking at CD's . But then he came in too . ", ' Did he leave when you left ? ', ' Yes . Then I noticed he was on the sidewalk behind me . He was following me . ', ' What did you do ? ', ' He followed me all the way home ! ', " That's about five blocks . And around corners too.So he was definitely following you . ", " Yes , he was . I'm not imagining it.Finally , just when I got home , I turned around and looked at him.He was just standing there . He didn't smile . He just stood there . It was so obvious.What should I do ? I'm so scared . Can I call the police ? ", " Actually , I don't think you can call the police . Not yet at least.He hasn't done anything . And probably the police will just ignore it.But if anything happens again , then maybe you should call . ", " Why can't I call the police now ? He was definitely following me ! ", " Of course you can call the police if you want . That's not what I mean . I'm just saying that they probably won't do anything . ", " I suppose . What can they do ? I don't even know who he is . ", " Listen , Carol . Don't let this bother you too much.Probably it's nothing . Just keep your eyes open when you go out.If you see him a third time , and if he follows you again , then I think we should go to the police.But for now , just try not to worry . ", " Alright . And I won't go to that cafe for awhile . "]
["Hello , Mrs . Taylor . I'm here to pick up Diane . ", " Hi , Ben . Come in . Diane's not ready yet , so you'll have to wait a few minutes . "]
['Hi , Lucy ! ', " Hi.It ' s a wonderful wedding , isn't it ? ", " Yes , It's very great . ", " Mary's father is a rich man , isn't he ? ", " You are right , Mary's father is responsible for the entire wedding-arrangement , costs , etc . I think he must spend much money . ", ' Will Mary and her husband be ready to leave for their honeymoon ? ', ' Yes.Look ! Mary is going to throw the bride bouquet . ', " Oh , I'll try to catch it . "]
['What dressing would you like on the salad ? ', ' French dressing , please . ', ' I beg your pardon ? ', ' Oh , French dressing . ', " Sorry , it's not available now . Anything else ? ", ' We still prefer French dressing . ', ' Will you say it again ? ', " Who's your manager ? Tell me ! Would you ? "]
['I ’ ll be away for a moment . ', ' Yes ? Anything I can do for you ? ', ' Look ! I ’ v been watching that man down in the street . He keeps peeping into the shop . Keep your eyes skinned for that guy , will you ? ', ' Ok . ']
['Is there something wrong ? You look so sad . ', ' My house was robbed last night and the thieves stole all my furniture . ', ' No wonder you look so upset . Have you called the police ? ', ' Yes , I have . But I have to wait . ']
["Hi , Doris . You look a little bit down . What's the matter ? ", " Well , I'm leaving Japan and I'm going back to London , tomorrow . ", ' Really ! ', ' Yeah . ', ' How do you feel about that ? ', " Well , I do feel quite down because I am going to miss Japan after being here for 9 months , in Japan . I am going to miss it so much , cause I've had a great time here . ", ' Mm , so what are you going to miss about Japan ? ', ' Oh , I am going to miss the people , the food , the night life . Especially the nightlife . ', ' What especially about the night life are you going to miss ? ', " Well , I really like dancing . And I enjoy going out to night clubs and to restaurants and eating Japanese food also and I'm really going to miss that because it's very different to London . ", ' How are the clubs different in Japan than in London ? ', " Well , here there are many different clubs you can get into , for free , you don't have to pay , some of them . In London it's really expensive for drinks and an entry fee . "]
['Ahh ... What a fine day ! I do feel like an outdoor exercise . ', ' How about taking a walk in the park ? ', " OK . It's delightful to have a walk in the park with the air so fresh . ", " Oh , it's so quiet here . We have the park to ourselves , only you and me ! ", " Don't you see many people over there ? Just on your left . ", ' Oh , I see them . Some are doing Taijiquan , some are performing swordplay , some are practising the Chinese Wushu . ', ' A growing keep-fit fever is sweeping over China . ']
['You are late again , Maria . The teacher is about to come . ', ' I know . I have to prepare the supper for the whole family before I leave . ', ' Oh , Ben has been cooking for us since I started attending this evening class . The good thing is , he has made great progress in cooking . ', ' The housework is really a big problem for me . My husband is on a business trip to the U . S . now and I have to take care of everything myself . ', ' How about your one-year-old baby ? ', " I've asked my parents to live with us for a while , so they can look after her for me while I am at work or in the class . ", ' How sweet of them ! I have to work in the day time , study at night , and do housework during my spare time . I really hope I have eight arms and legs , like an octopus . ', " Me too . Sometimes I do want to give it up . I can't deal with so many things at a time . ", ' When is your Adult College Entrance Exam ? ', " It's close coming up at the end of this month . That will be no more than 15 days from now on . ", " Oh , my Adult College Entrance Exam is also around then . I don't know if I can pass it . ", " Why don't you take the CPA exam ? You are already a good accountant , having so many years of experience . ", " I just want to study in a college , majoring in economics . I've had this dream for a long time . "]
['Steve , when are you going back to America ? ', ' Next week . ', " Wow , so soon ! I'm going to miss you . "]
["what's the matter with you ? You look so upset and tired . ", ' My father failed in business . ', " Oh , that's really tough . ", ' Maybe it is the most difficult period of my family have experienced . ', ' I can understand . By the way , is there anyway I can help ? ', ' No , not now . I have found a part-time job . So perhaps I can help my family to come over the difficulties . ', " Oh , that's so great , bless you ! if you need me , I'll always be there . ", ' Thank you . ']
['How did you two meet ? ', ' To tell you the truth , it was completely accidental . ']
['Have we met ? ', " I don't think so . Michael . ", " Hello , Michael . My name's Shirley . Pleased to meet you . ", ' Pleased to meet you , too , Shirley . So , what do you do ? ', " I work in marketing . I'm a regional marketing manager for an IT company . Normally , I work out of Beijing , but I'm here on business . My friend Judy over there , she lives here and she invited me to this party . And you ? How about you ? ", " I live here . I was invited by George-he's the tall guy over there . He looks a bit drunk , actually ... "]
['Well , what a nice day ! ', ' Yeah , the air is really fresh . ', ' But it was not at all so fine yesterday . ', ' Because it rained last night . ', ' Did it ? ', ' It sure did . It was a heavy storm , with lots of thunder . ', " I was fast asleep , and didn't hear a thing . ", ' Well , it may rain again later today . ', ' Maybe . I see some dark clouds moving in . ', ' There may also be a strong wind coming in . ', " It'll be dusty , too , I guess . ", ' Maybe not . Dust is no longer a big problem in Beijing . ', ' Why is that ? ', " We've been planting trees for many years . ", ' I see . The fall in Beijing is really beautiful . ', " But the summer isn't . It's scorching in the summer . ", ' Then what about spring ? ', ' Spring is warm and short in Beijing . ', ' It must be cold in the winter , though . ', " You got it . Oh , by the way , it may be really cool in the evening around this time of the year . Don't forget to put on more clothes , or you might catch a cold . ", ' Thanks for reminding me . ', " You're welcome . "]
["I hear you're being sent to Madrid for the annual conference . Is that right ? ", " Yes , it would be my first trip overseas . Actually , it's going to be my first time leaving the country . ", " Are you serious ? You haven't even been anywhere on vacation ? ", " No , I have never vacationed anywhere exotic . But even if I don't get a chance to travel on my personal time , at least I can travel on company time ! ", ' Well , being able to go to the conference sounds like such a great opportunity . Have you applied at the embassy for a visa yet ? ', " Yes , it wasn't too hard to get . All I had to do was fill out the paperwork and pay the application fee . ", ' You leave next Tuesday , right ? What time is your flight ? ', ' My flight departs at 7 am . I have everything except for my luggage ready . ', " If your flight is leaving so early , I can take you to the airport and see you off . I'll still be able to make it into the office by 9 . ", ' That would be great ! Thanks a lot ! ']
["I've been thinking of taking I've been thinking of taking a Crazy English course.Do you think it's a good idea ", ' Sure ! You should do anything you can to improve your English . ', ' Really ? Do you think English is that important ? ', " Of course it is.In fact , I'll even take the course with you if you want . ", " Great ! It's always better to do things with a friend . ", ' Do you have the phone number ? I need to call for registration . ', ' No , I left it at home.Sorry ! ', " That's OK . I can get it from you later . ", ' So , do you want to go somewhere for dinner and practice our English together tonight ? ', " All right . I know a great restaurant near here.But , it's a little expensive and I don't have much money with me . ", " No problem . I just got paid.It ' s my treat . ", " Thank you ! I'll be sure to return the favor after our first class , OK ? ", " Forget it ! That's what friends are for ! Besides , I have a VIP card for a discount . ", ' Good job ! This is going to be a great night ! ', " I think so too.Let ' s go ! "]
['What are you and Corey doing for Valentine ’ s Day this Friday ? ', ' Probably nothing . ', ' You have to do something romantic . ', " Romantic ? I can't remember what that word means . ", ' Well , you have three kids , so you knew what it meant once upon a time ! ', ' Ha , ha ! Those days are long gone . ']
['Do you take a bus to and from work ? ', ' Yeah , everyday . And there ’ s only one choice.All the other buses are going the other direction . ', ' Hmm . I have the same problem . When I leave work , it ’ s always rush hour.So the buses are always crowded . ', ' Oh , yeah , it ’ s terrible . I will tell you the funniest thing I have seen in China . It ’ s when so many people try to get onto one city bus , and the last guy is squeezed in so tight that the door is tightly pressed against his butt . ', ' That sounds terrible the way you describe it . But you know , not long ago I really suffered on the bus . ', ' What happened ? Were you having a hard time getting on a bus ? ', ' You just can ’ t imagine ! I waited for the first bus but it was too full , so I waited for the second , and it was still very crowded . Then I decided not to wait for the next one , and got on the second bus . It was so full that I had to stand on one foot ! No kidding ! ', ' Hmm . Good exercise , uh ? ', ' Yeah , absolutely ! ', ' And it ’ s so much fun . One day , the bodies were so tightly packed that some girl ’ s behind was pressed against my front . I was afraid to put my hands down for fear of accidentally groping her . ', ' You were so happy , weren ’ t you ? ', ' What do you think ? I ’ m a good boy . ']
["I think it's high time we had lunch . ", ' Of course . I can eat a horse now . ', ' I am sorry for that . I was so attracted by the beautiful scenery . ', ' Where shall we go now ? A Chinese restaurant or a local one ? ', ' I suppose the local one . ']
['Are you busy with your work ? ', ' Yes . What about you ? ', " Yes , I'm very busy , too . Sometimes I work overtime . ", ' Then your salary must be high . ', ' Just so so . But we can travel twice every year . ', ' Is this time one of them ? ', " Yes , we won't travel again until October . ", ' Really ? We have only one chance every year . ']
['What a beautiful sweater ! ', ' Do you think it looks good on me ? ', ' Yes , and it goes beautifully with your pants . ', " You won't believe it , but it was really cheap . ", ' I wish I could find one just like it . ']
["Let's go for a drink after work . ", ' Nothing doing . ']
['What kind of sport do you often do ? ', ' I go jogging , how about you ? ', " I used to swim a lot , but now I'm taking gym classes . ", " Oh , that's fantastic ! "]
["I can't believe the boss was absent from today's meeting . ", ' Neither can I . ']
['Any chance of using your telephone ? ', ' You ’ Ve been using it for two weeks without paying . ', ' Well , I thought it was not that serious . ']
["Hey Jack . How's it going ? ", " I'm falling in love . ", ' What ! With who ? ', ' That girl in my econ class . She is so hot . ', ' Did you guys go on a date already ? ', " No . I didn't even talk to her yet . But I think I'm in love . ", ' Does she have a boyfriend ? ', " I don't think so . I've been following her around campus and I haven't seen another guy . ", " Dude , you're a stalker man . Just ask her on a date . ", " I plan on running into her in the cafeteria when she's alone . I think I'll ask her then . ", " So why do you think you're in love ? ", " She's the only thing I can think of all day long . ", " That's called blind love . Well , I gotta run . Tell me how it goes next week . ", " Aright . I'll talk to you later . "]
["Your husband is very helpful , isn't he ? ", ' Willing to help , maybe , but not as helpful as you think . ', ' Really ? ', ' Last night he told the children a cliff-hanger story and both of them were scared out of sleep . ']
["Henry married Rose only after her father's money , didn't he ? ", ' Yeah . But he soon feel regretted for it . ', ' But he seems to be very happy with Rose . ', ' He is more nice than wise . ']
["Hey , David . Where did you get the sofa ? It's so beautiful . Look at the color , I really love this yellow , so bright ! It must be very expensive . ", " Not really . To be honest , it's very cheap . I only spent $ 100 . ", ' Are you kidding ? $ 100 for this big leather sofa ? ', ' Yes . I bought it in Johnson thrift store . ', ' Is it a used one ? ', ' Yes , it is . ', " Oh , I don't think I will buy a used sofa even it looks so attractive . "]
['I am tired of everything in my life . ', ' What ? How happy you life is ! I do envy you . ', ' You don ’ t know that I have been over-protected by my mother these years . I am really about to leave the family and spread my wings . ', ' Maybe you are right . ']
['Would you mind going to dinner with me tonight ? ', " I'd love to go out with you , but I'm sorry I'm busy tonight , but I'd like a rain check . ", ' OK . ']
["Ikebana , it's an art of flowers and it's quite different from Western style flower arrangement because in Ikebana's theory you can decorate one flower , only with one flower . ", " What's another Japanese art ? ", ' Japanese art ? Mm , Ikebana ! Tea Ceremony ! ', ' Tea Ceremony ! Tell me about Tea Ceremony . ', " Tea Ceremony ! It's , there's a certain way you have to make tea , not only make tea , there's a certain way to for example wipe a bowl . ", ' I see . ', ' Yes , with one piece of cloth , and you need to learn how to fold the cloth so that you you use each part of the cloth only once to wipe the bowl ', ' How do you learn that ? Is that something that your mother would teach you ? How do people learn that ? ', " There's some professionals for both flower arrangement and tea ceremony . So you need to go to a school , yes , and learn from your teacher and their hierarchy and the organization and you need to pass each test to go , climb up the ladder in the hierarchy . "]
['So , you finally got your doctorate in genetics . Well done ! ', ' Thanks . Now , I have to find a job . ', ' What are you thinking of doing ? ', ' I ’ d like to conduct some scientific research into genes . It would be wonderful to make a medical breakthrough . ', ' There must be several private companies that are interested in employing someone like you . You could do some research for a university . There ’ s a lot of discussion about genetics nowadays . Someone wit ', ' Many companies and universities investing resources in genetics , because there are so many possibilities . Few people know where next discoveries will be made . ', ' Well , I hope scientists don ’ t decode to make a clone of me in the future ! I wouldn ’ t like to be the subject of an experiment . ']
['What newspaper are you reading ? ', ' New York Times . I read it everyday . ', " Why don't you read the local newspaper ? ", " It's too biased . I just don't agree with their one-sided reporting . ", ' New York Times is better ? ', ' Yes , they have a good reputation for fairness . ']
["Don't be too sad . If you really think that you have no feeling with him , then , in my opinion , getting divorced maybe is the best way to solve the problem . ", " I know clearly at the bottom of my heart . I just can't set my mind at rest because of the child . She's little . She cannot understand us and accept such truth . ", " Yeah , child is the matter . Don't tell Jenny the truth , only tell her the white lie . When she grows up , you find the suitable opportunity to tell her . ", ' I see . OK . ']
['Mark . Where have you been ? I ’ Ve been calling you all morning . ', ' I ’ Ve been playing computer games . ', ' What ? So you blew me off yesterday and today over a stupid video game ? What game is so important that you have no time for me anymore ? What are you playing ? ', ' It ’ s called Counter Strike . It ’ s a first person shooter game . It ’ s awesome . It ’ s a multi player game where you can go online and compete against players from all over the world . ', ' You ’ Ve been wasting your time on this ? I can ’ t believe it ! It doesn ’ t even look fun or challenging ! ', ' My laptop is on my bed . If you think it ’ s so easy then get on line and try to beat me . ', ' Fine ! ', ' Damp it ! How are you killing me with a single shot ? It ’ s not fair ! I don ’ t want to play anymore ! Let ’ s go get something to eat . ', ' Can you bring me something ? I am totally hooked on this game ! ']
['Hey , that ’ s a very nice hairdo you ’ re wearing ! ', ' Oh you ’ re exaggerating . I ’ m never really good at making hairdo . ', ' You did it yourself ? Wow , you are good ! ', ' Thanks for saying so , but my husband thinks otherwise . ', ' He ’ s just got no idea of how good you are . ']
["Hey , Lily ! You won't believe what happened in class today ! ", ' What ? ', ' A man sent Miss Smith flowers , and Bryan got kicked out of class ! ', ' Cool ! I wish I could have been there ! ', ' Me , too . I miss you . Are you any better ? ', " Yes . But if I have any more soup , I think I'll die . "]
['Does your wife work ? ', ' Yes , she does . She works at home . ', ' Oh , I understand . She cooks , cleans and takes care of children . Is that right ? ', ' Oh , no . Most of the time I do these things . She is a writer . ', ' You are really a hen-pecked husband . ']
['What kinds of Tv programs do you enjoy watching ? ', ' I like current affairs programs and documentaries , especially wildlife ones . How about you ? ', ' I like those kinds of programs too . They ’ re very informative . I think that many people underrate the education value of Tv . ', ' I agree . People often criticize Tv for showing too much sex and violence . ', ' Yeah . And that ’ s so funny because most people prefer watching sex and violence to watching something more educational ! ', ' Right . You can ’ t blame the tv stations for showing popular kinds of programs . They need to make money from advertisements shown during and between programs . ', ' In my country , there ’ s a time limit on the advertisements that can be shown . I think it ’ s about six minutes per hour . ', ' That ’ s great idea . But don ’ t the Tv station lose a lot of money because of that ? ', ' No . they don ’ t . they simply charge higher prices at peak times . Is there no limit on the amount of advertisements that can be shown on Tv in your country ? ', ' Not as far as I know . We have so many advertisements . the interruptions are unbearable sometimes ! That ’ s one reason that many people prefer satellite or cable Tv , where you pay a fixed amount each month . ', ' Some people have satellite and cable Tv in my country , but people don ’ t seem to keen to pay for their Tv programs . Besides , the terrestrial channels offer a good range of programs . ', ' Well , there ’ s a wildlife documentary on Tv in a few minutes . Shall we ? ']
['Hi , Ann . I was wondering if you are free tomorrow night ? ', ' Well , George . I guess I am . Why do you ask ? ', " I've just gotten a pair of pre-sale Star Wars movie tickets from a friend and was thinking of inviting you along for the opening premiere . Are you interested ? ", ' Yeah , definitely ! Thanks for inviting me . ', ' My pleasure . ', ' I really wanted to watch the Star Wars on the opening day , but the pre-sale tickets were sold out . How did you manage to get hold of them ? ', ' A friend of mine works at the corporate headquarters of Pepsi , which is a major sponsor of the movie . He was able to get the tickets for free , and then he sold two more for me for 50 dollars a piece . ', " You paid 50 dollars for each ticket ? That's a huge premium over the regular price . ", ' Not really . Considering the fact that other people were willing to pay as much as 200 dollars each on the black market . Besides , I knew you were really looking forward to watching Star Wars on the opening day . ', ' Wow ! I am really honored you went through all this trouble just for my sake . I really appreciate that . So , what time are we going ? ', " Well , let's see . The movie stars at 10 . We should be there at least 1 hour earlier , because there is a big line . I could pick you up at your house at 8 , if that's ok with you . ", " 8 pm , that's fine with me . ", ' Okay . ', " So I'll see you tomorrow then at 8 . ", " Yeah , that's great . I'll see you tomorrow night . ", ' Ok , George . Bye ! ', ' Bye , Ann ! ']
["Hurry up ! Mom , I can't wait any more . ", " Look out , honey . Let's come to the shoal waters . Follow me ! ", ' OK , Mom . Can I swim now ? I want to learn butterfly stroke . ', ' Honey , listen to me . First , you should learn how to breathe in and breathe out . ', " Mom , it's so terrible . Water went down into my throat and I almost got drowned . ", " Do be patient , Honey . Let's do it slowly and correctly . ", " Oh , Mom , I think I'm not the right person for swimming . ", " Come on , sweetie , you've done very well . It is the first step that is tough . ", " Right , I'll make up my mind . Please correct me if any of my movements go wrong . ", " Yes , well done . That's the way to go . How clever you are ! You've got it . ", " Really ? I can't believe it . Everything is possible to a willing heart . ", ' Exactly , next , you should hold your legs together and extend your arms above your head . ', ' Yes , like a dolphin . Am I on the right track ? ', " That's the way to go . Now , you are flying , my boy . "]
["Hi.Ed , what's up ? ", ' Nothing . ', " Doesn't look like it to me . ", ' Just get out of my face ! ', ' Woo , easy . ', ' Leave me alone ! ', ' What are you so ticked off about ? ', " I don't want to talk about it . ", ' Maybe I could help . ', ' I blew the finally exam . ', " You've got be joking . ", " No , I'm not . ", " Well , don't get bend on a ship about it . "]
['Do you like playing table tennis ? ', ' Certainly . ', ' When did you start it ? ', ' Several years ago . ']
["Don't just stand outside . Come on in . ", ' Yeah . ', ' This is Alex . Remember ? This is Sean . ', ' Nice to meet you guys . ', " Over there are Stacy and Rebecca . We're all on the school's tennis team . ", " Who's that guy who's handing out beer to everyone ? ", " That's my boyfriend Matt . Isn't he cute ? ", ' He sure is ! ', " Come on . I'll introduce you two . "]
['Don ’ t you think that ’ s good idea to hold a party outside ? ', ' I don ’ t think so . ', ' How about going to a concert ? ', ' That ’ s should be fun . ']
['Hello , Jack here . ', ' Hello , Jack . It ’ s Mary . What are you doing in your office ? ', ' I ’ m working . I often work late on Thursday . I ’ m busy this week . ', ' Would you like to come and have dinner with us on Friday ? ', ' Tomorrow ? No , I am afraid I won ’ t be able to . I ’ m going on business to Birmingham . ', ' What about Saturday ? ', ' Sorry , I never go out on Saturday evening . I always watch football on Saturday evening . ', ' Will you come round next Tuesday ? ', ' Next Tuesday ? Just a moment . It will be the twenty-first of May ? Oh , dear . Hum , I promised my aunt I ’ ll be at her birthday party . ', ' What do you say next Wednesday then ? ', ' Let me see . Yes , Mary . Let ’ s make it next Wednesday . ', ' Okay . Bye . ', ' Bye . ']
['I lost all my lottery winnings playing the stock market . ', ' Easy come , easy go . ']
["I hear you're moving to New York . ", ' Yes , I found a very good job down there . ', " Well , we'll certainly miss you in Boston . ", " I'm going to miss you folks , too . ", " Let's keep in touch . ", " OK . I'll drop you a line as soon as I get there . "]
["What's a good place for sightseeing ? ", " Don't ask me . "]
['we are going out for dinner tonight . Are you coming , Betty ? ', " I'm not sure . I have to check my schedule . Where are you going ? ", " oh , Jake made a reservation at Friday's . ", ' Jack ? ', ' yes , the one with the R $ D team . Is that a problem ? ', ' I will never go out with him anymore . ', ' why did you say so ? ', " last time when we had dinner at the Smith's , it was a horrible experience . He had no manners at all ! ", ' oh , really ? ', ' he made a lot of noises while eating . He talked with his mouth full and sipped loudly . ', ' are you kidding me ? How could he behave like that ? ', ' it is true . Everyone kept looking at him . It was so embarrassing as I was sitting right next to him . ', " what a shame ! Didn't he realized that ? ", ' I have no idea . He seemed to enjoy the dinner very much . ', ' maybe he should really something about eating etiquette . ', ' oh , he really should . ']
['Hey Matt . I just got a job at a consulting firm . ', " Congratulations . That's great ! ", " I'm so happy . I don't have to worry about finding a job and interviewing anymore . ", ' When do you start ? ', ' I start next Monday . ', " You're going to have to put in a lot of hours you know . ", " I know . I'm a little nervous , but it's pretty exciting . ", ' I bet . You must be stoked . ', " Yeah . I'm going to celebrate tonight . Wanna hang out ? ", " Sure . It's on you right ? ", ' Of course . How about Toby ? Should we call him ? ', " I don't know . He's a little depressed . He's having a hard time finding a job right now . ", ' I should still tell him . In the least , I can refer him to my company . It might help . ', ' That sounds like a good idea . ']
['So , did I tell you about my New Year ’ s resolution ? I ’ Ve decided to go on a diet . ', ' And you ’ re going to completely transform your eating habits , right ? ', ' Exactly ! I ’ m going to cut out all that junk I eat , no more chips , no more soda , no more fried food . ', ' I ’ Ve heard this one before . ', ' But this time I ’ m going to stick to it . I really mean it ! Trust me , Carol , I ’ m going to be a new man in one year ’ s time ! ', ' Well , I guess we ’ ll just have to wait and see . ', ' Thanks , honey , that was a great meal . I ’ m stuffed . Do we have any chips left ? ']
['Can I help you ? ', " Yes . I am a bit confused . My sociology class is supposed to read a chapter in a book called Sociology and the Modern Age . According to the syllabus , the book is in the library , but I haven't been able to find it . ", ' Do you have your syllabus with you ? May I see it ? ', ' Yes , uh ... I put it in the front of my sociology notebook . Oh , here it is . ', " Let me see . Oh yes . Your professor has placed this book on reserve . That means you cannot find it on the shelves in its usual place . You need to go to a special room called the reserve room . It's down the hall and to the right . ", " I'm sorry - I still don't understand . ", ' You see , your professor wants every one in the class to read the chapter . If one student removes the book from the library , it is likely that none of the other students will have the opportunity to read it . So , your professor has insured that all students have the opportunity to read it by placing it on reserve . ', ' So , will I be able to find this book ? ', ' Yes , when a book is on reserve , a student can go to the reserve room and ask the reserve librarian for the book . The student can have the book for a few hours , and he or she MUST read it in the library during that time . That way , the book stays in the library , and all students have a chance to read it . ', ' Okay . Thank you . I understand now . ', ' Will there be anything else ? ', ' No ! I am on my way to the reserve room . Thanks again ! ']
['The government has to face a lot of social problems now . ', ' I think it is unemployment that gives rise to such social problems . ', ' But it is very difficult for any government to handle it efficiently . ', ' You are right . ']
['How time flies ! ', ' Bill and Betty have already grown up . ', ' I can still remember our first date . ', ' Look at that big tree over there . ', ' Yeah , oh my god ! It ’ s still there . We have our first date right on there . ', ' Do you know that I fell in love with you at the first sight then ? ', ' You seemed to be dull at that time . ', ' But you agreed to go out with me at last . ', ' ( Smile ) I can ’ t believe this for it ’ s been 20 years since we got married . ', ' So do you feel happy now ? ', ' I couldn ’ t have been any happier ! ', ' Of course , we are the happiest family in the world . ']
['Good morning Mike ! ', " Morning Sally ! What's up ? you seem many hurry ! ", " I am having an exam at 9 o'clock , It's already 8 thirty . ", " Don't worry , I'll drive you . ", ' Thank you very much ! ', ' How are your cases coming along ? ', " Very well , thanks , I will probably finish next week , but this is still a lot of work , I have been worked on in for six months , and i ' m so closed to end . I can fill in . ", " Wow , Good for you . It sounds like a lot of work . I'm proud of you ! Is this the red of building ? ", " Yes , It's only 8 forty . Thanks so much ! ", " You're welcome . Good luck , bye ! ", ' Have a nice day , bye ! ']
['Merry Christmas , Mr . Wang . I would like to give you the book I specially chose as my appreciation for your sincere help to me in the past few days . ', " Thanks , Mr . White . That's very kind of you . ", ' I hope it will be of some use to you . ', " I am sure it will . It'll be of great help in carrying on the work I have done so far . ", ' That will be great . ']
['Excuse me , could you tell me how much is the ticket ? ', ' It is free on weekend . ', " That's great ! ", ' Here is a guiding plan . ']
['I would back him up to the hilt anyway . ', ' Why are you so kind to him ? ', " He's my brother . ", " So that's how it is ! Now he ’ s in trouble , but I belive he will rise to his own feet again . ", ' Thanks for your belief . ']
['What can I do for you ? ', ' I need a passport . ', ' You can apply for one here . ', ' When can I do that ? ', ' If you like , you can apply right now . ', ' That would be great . ', ' I ’ m going to need you to complete this application . ', ' What else do I have to do ? ', ' Then I will take your picture for your passport . ', ' How long will it take ? ', ' Your passport will be ready in a few weeks . ', ' Thank you . That ’ s perfect timing . ']
['Her dress looks funny . ', " I wouldn't say that . It looks fine to me . ", ' Are you kidding She is behind the times . That style went out last year . ', ' Oh , come on , as long as it looks good on her . ', ' Well , you ’ re really as out-dated as she is . ', " You ’ re darn right . I am out of style . So what What's the point of keeping yourself in style ", ' No wonder you never buy me a new dress . ']
['Hey , Sandy . Do you want to go to the ETV with us ? ', " I'd love to , but I'm broke . Maybe after payday . "]
['What date is today ? ', ' Why ? ', " Didn't you notice the roses everywhere ? ", " I hear it's Chinese Valentine's Day ! Don't you know ? ", ' Oh , God . I just forgot it . I should have brought roses for my girlfriend . ', " It's not too late . Go to buy some now . "]
["What's your favorite sport ? ", " It's hard to say . Perhaps swimming is my favorite . I like swimming because it helps improve my lung capacity . In the scorching summer days , there's nothing like a cool swim . Currently , I go to the pool twice every week . ", ' Is the entrance charge expensive ? ', ' Well , it costs an arm and a leg — 30 yuan per person . What a costly sport ! That is why I have to refrain from even thinking about it . And I find jogging a very agreeable substitute . ', ' Haha , jogging ? Perhaps it might be a bit too boring ? ', " You know what ? You won't get a rush from it until you fully understand it . It is a simple sport and doesn't require skills of any sort . This leaves room for me to enjoy the beautiful suburban scenery while jogging . Fresh air caresses my face and blows into my chest , which translates into inspirations . Inspirations are really good stuff for a writer like me . Sometimes , I even come up with a verse or two . ", ' You are really a man who knows how to enjoy being alone . ']
["I'll need a parking permit for next semester . ", ' Do you attend school during the day or only at night ? ', ' I only attend class part-time in the evenings . ', ' Do you drive a motorcycle or an automobile ? ', ' I have both , but I usually use my car to get to school . ', ' Great , the price for that permit is thirty dollars ; cash , check , or credit card ? ', " I'll pay cash . ", ' Do you need to buy a duplicate permit for a second vehicle ? ', ' No , thank you . ', ' OK , here is your permit ; enjoy the next semester . ']
['Thanks for lunch . It was delicious . ', " It's OK . ", ' Next time lunch is on me . ', " Don't be silly . ", " I'm serious . ", ' All right . Next time you will treat . ', " It's a deal . "]
['Guess , what I ’ Ve bought for you . ', ' Oh . it ‘ s a case flowers . It ’ s very kind of you . ', ' I hope you like it . ', ' I love flowers you know . Thank you very much . ', ' that ’ s all right . ']
['What a terrible house ! ', " I'm sick of it , too . ", " The door bell doesn't work , the sink is leaking , there's no hot water , and the building is falling apart ! ", " It's no use complaining.If we had got enough money , we wouldn't put up with it ! "]
["Oh , no . It looks like we're late . ", " Let's just sit in the back . We can still hear the service from here . ", " There're so many people here . Where are Rich and Cath and Taylor's parents ? ", " They're probably up front . The preacher's about to speak . Let's listen . ", ' That was such a touching speech . He must have really known Taylor well . ', " Oh , how I wish this all wasn't happening ! "]
['Mary , Pam and I are going to the mall later to buy some new clothes . Do you want to come ? ', ' Can you say it again slowly ? ', " Pam and I are wondering if you'd like to go to the mall with us . ", " Oh , I see . I'll have to sink about it . ", ' Sink ? ', ' Oops . I meant , " think " ', " Mary , you're going to have to work on your pronunciation . ", ' I know . ', ' But give yourself some time . You just got here . ']
['... The rings please . May this ring be blessed so he who gives it and she who wears it may abide in peace , and continue in love until life ’ s end . ', ' With this ring I thee wed . Wear it as a symbol of our love and commitment . ', ' Honey , that ’ s my pinkie . The ring goes on the ring finger ! ', ' This one ? ', ' That ’ s my index finger ! ', ' Oh , right . This one , right ? ', ' Umm ... that ’ s the thumb , Nick . ', ' Okay , Okay , I got it ! This is the ring finger ! ', ' That ’ s my middle finger , Nick . This is my ring finger ! ']
["Have you heard about Michael's new home ? It's in one of the poshest areas in this area . ", ' Is he living in the new housing estate in Killington ? ', " No , he's living in an old house in Warton . ", ' Do you mean the one near the health centre on Old Slate Road ? ', " That's the one . ", ' His house must be worth millions ! That is one of the most beautiful areas in Oxford . The surrounding area is really peaceful , and getting into the city centre from there is very convenient . How can he afford that place ? ', " He didn't buy it . His grandfather died recently and left him loads of money . ", ' Did he know that his grandfather was so wealthy ? ', ' No one in the family expected to get a dime from him . It was quite a surprise . ', ' What a lucky man . ', ' He still has a complaint though . ', " What's that ? ", " He wanted to live right on a bus line , but he doesn't . so , if he wants to take a bus anywhere , he has to walk 1/4 mile to get to a bus stop . ", ' The poor thing . It must be difficult being him . ', ' You can say that again . ']
["It's said that the government will clamp down on the new policy . ", ' Are you sure of that ? ', ' I am not certain about that . ', ' They may have some difficulty in doing it . ']
['I couldn ’ t believe you should crack such a joke to them . ', ' What was wrong ? ', ' You carried it too far . You obviously offended someone . ', ' I didn ’ t mean to hurt anyone . ', ' I know , I know . But someone took offence . ']
['hello . Where are you headed today ? ', " I'm off to Barcelona for a week . ", ' do you have your passport with you ? ', " yes , here you go . I don't need a visa to go to Spain , do I ? ", " fortunately for you , you don't . Next time , if you have any questions about visas , you should try to find out before you get to the airport . ", " that's good advice . ", ' would you like a window seat or an aisle seat ? ', ' are there any seats available by the emergency exits ? ', " let me see here ... yes , there's one left . ", " ok . I'll take that one then . ", ' alright . How many pieces of luggage are you checking in ? ', ' I like to travel light so I just have this one . ', " if that's your only piece of luggage , it is small enough to carry on with you . Would you like to do that so you don't have to wait in luggage reclaim once you arrive ? ", " yes , please . That's a fantastic idea . Which gate do I need to go to ? ", " you're here a bit early , so check the departure screens in the waiting area in about a half hour . Here's your boarding pass . Enjoy your flight ! "]
["I think it's important that all people have the ability to read . ", " I agree with you , but that's easier said than done . "]
['Hey , Cindy , I ’ m so sorry about yesterday . I shouldn ’ t have yelled at you in front of everyone . ', ' Don ’ t worry about it . ', ' I don ’ t know what happened to me . I just lost it . ', ' I think you just need to get more sleep . ', ' Yes , you ’ re right . Good night . ']
["We can't wait any longer ... ", " I'm terribly sorry to be so late . I had an article ... ", " You'll knock yourself out the way you've worked.Why don't you slow down ? ", " I can't afford to . ", " All right.Now that everybody's here . Shall we be getting started ? Miss Lin , are you ready ? ", " Yes , thanks.Before I start , I'd like to thank Professor Smith for all his help in giving me unlimited access to his research materials . ", " Excuse me , Miss Lin.Would you mind speaking up , please ? I can't hear you very well . ", " Sorry , I'll try to speak louder . "]
["Mark , you've been coming home late these days . What are you busy doing ? ", " Nothing important . I've been working overtime lately . ", ' How many hours do you work each day now ? ', ' 12 hours , including 5 hours overtime . ', " That's tough indeed ! Do you think your health can afford ? ", " I don't care . I need money . ", " Surely you'll be paid extra for overtime , but do you think it's really worth ? ", " Yes , I think so . When I work overtime I'm paid time and a half . ", ' Oh , yes . Money comes faster in that way than otherwise . ', " But jobs with a lot of overtime are quite limited . Employers usually don't like to pay for overtime if they can manage . ", " That's true . "]
['Which sports are popular in your country ? ', ' Most people like football . More boys like football than girls . A few girls play it really well . Some people like playing basketball . ', ' Do many people like tennis ? ', ' More and more people like it now . fewer people play table tennis than before . Many people like swimming , because it is fun and keeps you fit . ', ' In my country , many people enjoy golf , but it is too expensive for some people . A few people like extreme sports , but I think the vast majority of people are afraid to try them . ', ' Extreme sports are only for a small minority of people . Several people from my university enjoy them , but most of us just watch . No one I know plays golf . ', ' I know loads of people who play it regularly . There are plenty of golf courses around the country . In the past , only a tiny number of people played . ', ' A great deal of people follow rugby in my country . ', ' There are plenty of rugby fans in my country too . ']
['Trina , will you marry me ? ', ' Yes ! Yes ! And yes ! Jared , of course I ’ ll marry you ! ', ' Oh , Babe , I can ’ t wait to spend the rest of my life with you ! I can ’ t wait for all the adventures we ’ re going to have , for all the fights and the laughter . I can ’ t wait to grow old and wrinkly with you . ', ' Oh , Jared ! I can ’ t wait for our wedding ! I hope you don ’ t mind , but I ’ Ve already chosen a date ! Six months from now in the summer ! Melissa saw you buying the ring last month so I ’ Ve had plenty of time to start planning ! ', ' She what ? ', ' Oh don ’ t worry , sweetie , I didn ’ t know when you were going to propose . It was still a nice surprise ! As I was saying , I ’ Ve got it all planned out . There ’ s almost nothing left to do ! I wrote up our guest list and we will have roughly four hundred guests attending . ', ' Four hundred ? ', ' No need to sweat it . My parents agreed to pay for most of the wedding , which is going to be low-budget anyway . So roughly four hundred people , which means that the hall at Northwoods Heights will be our reception venue . I thought it would be nice if we had the wedding at your parents ’ church and my uncle of course would be officiating . We ’ ll meet with him soon for some pre-wedding counseling . The music for the wedding ceremony was a no-brainer . My step-sister and her string quartet will take care of that . My cousin will be the official photographer . I thought it would also be nice if his daughter could sing a solo . Did you know that she ’ s going to be a professional opera singer ? ', ' Ah ... ', ' And then of course the ladies at the church would love to be our caterers for the banquet and we ’ ll get the Youth Group to serve us . I was thinking that your friend ’ s band could be our entertainment for the night . though they might have to tone it down a bit . Or we could hire a DJ . Your sister ’ s husband could get us a discount with that company that does the decor at weddings . what ’ s their name again ? I was thinking that we could have an island paradise-themed wedding and our theme color would be a soothing blue like Aquamarine . And there will be a huge seashell on the wall behind the podium where we ’ ll make our toasts ! What do you think of small packages of drink mixes for our wedding favors ? Who else am I missing ? Oh , your uncle could be our florist and his wife could make our wedding cake ! ', ' Wow . ', ' See ? It ’ s going to be wonderful ! Oh this wedding is going to be everything I ever dreamed of . ', ' If I survive the next six months . ']
["No . 164 in lane 3 achieved 11 ' 16 in the 100 meter dash . Isn't that something ? ", " Yeah . He's the most experienced athlete in the field . ", ' He won the first place ! ', ' Good boy ! ']
['When is your vacation going to start ? ', " I'll be leaving on the fifth of August for the vacation ", " Oh , that's only a few days from now ! How many weeks are you going to be taking ? ", " I'm taking two weeks now . but I want to save the other week and take it sometime during the winter . ", ' Where are you going now . ', ' To the beach ', ' Have you made your hotel reservation yet ? ', " Oh , I don't need to do that . I'll be staying with friends ", " You're lucky . It's hard to find a place to stay at the beach in August ", " Just think , in a few days , I'll be swimming and lying in the sun and just taking it easy . "]
['What a hot day ! ', ' Yes , summer is coming . ', ' Where are you going this summer vacation ? ', " I'd like to go to Tianjin . ", ' Do you want to go to the beach there ? ', " Yes , of course . And what's your plan ? ", ' The same to you . ', " That's great . "]
["I don't think I'm getting better . ", ' Believe me , you really look much better than before . ', " I'm still not sure whether I can recover from it . "]
['Hey John . I have some great news . ', ' What happened ? ', ' I got a job offer from Dell . ', " That's great . I thought you said you didn't get the job . ", " I thought I did bad on the interview , but I guess I was wrong . I'm so happy right now . ", " I bet . That's great news . I'm very happy for you . ", " Thanks . I feel like celebrating . Let's go have a beer . It's on me . ", ' Sounds good . ']
['What would you like to drink ? Tea or coffee ? ', ' Coffee , please . ', ' So , you also like Coffee ? ', " Yes , of course . I can't go through a day without coffee in the morning . ", " Me too , but I think we shouldn't drink too much of it , as it's not very healthy . ", " I totally disagree . The other day I read in a book that a number of recent studies suggest that it can be a highly beneficial drink . Researchers have found strong evidence that coffee reduces the risk of several serious aimed 3 ' including diabetes , heart disease and cirrhosis of the liver . ", ' But I also heard that coffee and its caffeine content , serve as a drug on the human body that negatively affects the central nervous system , as well as other organs , and leads to addiction ', " I don't think so . Coffee helps me wake up , keep alert , and improve my short term memory . ", ' Well , I adjust going to have to disagree with you . A healthy body wakes up without caffeine ! ', ' Maybe you are right to some extent . ', ' You may try to have some alternatives and see how you feel . ', ' Maybe I could have a try . ']
['May I have two tickets for Tiny Times ? ', ' OK . What time ? ', ' 2:30 , please . ', " It's 60 yuan , please . ", " Sorry , we have student cards . We can get discounts with these , can't we ? ", " Sure . That'll be 40 yuan , please . ", ' Here is 50 yuan . ']
["Whoa . Now I'm awake ! Zina has a secret admirer . ", ' I really do not have time to deal with some lovesick computer geek . ', " I know what you mean . I can't stand computer geeks . ", " Sorry , Dave , I didn't mean you . I am just not in the mood for this . I have work to do . ", ' Who do you think it is ? ']
['Do you have brothers and sisters ? ', ' No , I am the only child in my family . ', ' Oh , I have an elder sister . She is married .. Her husband is a businessman . ', ' Do they live with you and your parents ? ', ' No , they live alone . ']
["I don't know how to deal with Jack . He is indeed a trouble maker . He has loused up my business several times . ", " You mean Lily's boyfriend ? ", ' Yeah . ', ' Well , he is a hard case . Everyone would feel headache about him . ']
['Mike , what are you doing tonight ? ', ' Nothing special . I just want to get plastered . ', " I don't feel like drinking tonight . I'm gonna hang out at YY's . ", " YY's ? That place is boring . How about Xara's ? It's real classy , and they keep the place spin and span . ", " Yeah , but it's expensive . Nah , I'm going to YY's . ", " On second thought , I think I'll join you . ", " They ' Ve just renovated the place . You may be surprised . ", ' Wow , they really went to town on this place ! ', ' Quite a difference , huh ? ', ' Sure is . Waiter , bring us two drafts , please . ', " Ah hah.Thought you were't drinking . ", ' When in Rome , do as the Romans do . ']
['Hey , Rose , how are you feeling ? ', ' Much better today . ', " Oh , Look at the baby.It ' s so beautiful.Is it a boy or a girl ? ", " It's a girl . ", ' Can I hold it for a moment ? ', ' Sure.She is a peaceful child . ', " Oh , how adorable ! She's got your eyes . ", ' So they say . ', ' When are you returning home ? ', " Well.The doctor said I have to remain here for at least two more days because I'm rather weak after childbirth . ", " You can use some time off.You ' Ve been working too hard anyway . "]
['Mom , have we got any cookies ? ', ' Cookies ? You just ate an hour ago . ', " I know , but I'm hungry . ", " Well , why don't you have some fruit instead ? ", " Aw , Mom . I don't want fruit , Aren't there any chocolate chips ? "]
['Are you cold ? ', ' Yes , a little . ', ' I wonder if we can change the temperature . ', ' I tried before . There are no buttons on the air conditioning . ', ' There must be buttons . How do they turn it on and off ? ', ' I think it is centrally controlled . They control it at the main desk . ', " Well , they have it too cold in here . I want to be warmer . I won't be able to sleep . ", " I'm going downstairs for more drinking water . I will ask them . ", ' What did they say about the air conditioning ? ', " They said it is centrally controlled.All the rooms are the same . They can't change it . ", " That's stupid . How can I sleep in this ? ", ' You can wear more clothes . ']
['hello ! How are you today ? ', ' hi . I ’ m feeling very nervous . I just had a test and I ’ m not sure how well or how badly I did . ', ' it ’ s not use worrying about it now . you ’ Ve done test and you can ’ t change any of your answers . ', ' that ’ s true . I really should go home and prepare for the next test , but I ’ m feeling tired . ', ' let ’ s go and get a coffee together . That will help you to wake up again ! ', ' ok . I feel like sitting down and having a chat . How have you been recently ? ', ' oh , you know me . I ’ m always happy ! If I think I ’ m getting into a bad mood , I call some friends and socialize or have a chat . ', ' that ’ s a good idea . I usually just sit at home alone and get increasingly moody . ', ' I hate spending too much time at home . I get bored of it really quickly . I ’ m always excited about going out to party or other social event and meeting people . ', ' perhaps I ’ m being too shy . I should go out more too and not spend time worrying about tests ! ']
['Hey , Lily , what are you doing ? ', ' Waiting for someone . ', ' You mean the boy you met on MSN ? ', " You're right . He is so funny and I think I'm in love with him . ", " You must be joking . You can't fall in love with someone you've never met ! ", " I know , but I keep thinking of him every day . And I get really depressed when he's not online . ", " I think it's just a crush . You can't be serious . ", " Well , this might be silly . But I just can't get him off my mind . And I can't help missing him . ", ' Did you tell him ? ', " Yes . He said I'm his dream girl . ", " You shouldn't take it too seriously . It might be a lie . ", " I know . I can't tell whether he's serious or not so I need your advice . ", ' I think you should enlarge your circle of real life friends , and then the right person will come along . ']
['The new computer software is driving me crazy ! I really need a break ! ', ' I know what you mean , Carol . I ’ Ve had nothing but trouble with it . They say it ’ s supposed to be easy ! ', ' That ’ s what I ’ Ve heard . But as far as I ’ m concerned , it takes a genius to figure it out . Can you pass the sugar , please ? ', ' Sure . Why don ’ t you sit down for a minute ? You haven ’ t taken a rest all morning . ']
['So , Is this your first time to TAIWAN ? ', ' No , I first came here 1995 . ', ' Oh , really ? And you are from the State , right ? ', ' Well , I am from Canada . Actually . ', ' Oh , I am so sorry . ', " That ' ok . That's happens all the time . "]
['Susan is going to get a divorce . ', ' How do you know that ? ', ' She told me that peter and she has a quarrel last nigh , and she left this morning , bag and baggage . ', ' Oh , I see . But I think you are making a fuss . They will make it up . Bet it . ']
['Tomorrow will be my first day at work , what do you think I should be wearing ? ', ' Well , if you want to look professional , serious and more conservative , a blue dress , white shirt and not-too-high shoes would be the best choice . But sometimes , very formal clothes will keep you at a distance from your colleagues . It depends on the company ’ s dress code . ', ' Indeed , I found most of the employees dress casually when I went to the interview . Only the manager was in suit and tie and he just came back from a ceremony . It seems that their dress code is not that formal . Probably , I should put on car key and simple shirt . ', ' Whatever you choose , make sure they are neat and clean . ']
['Ye Ting , who are these people in the picture ? ', " They're my family ", ' So you have two brothers ? ', " Yes , I'm the third child . "]
['Are you going out again ? ', " Yes , I'm going to the cinema , dad . ", " You mustn't go to bed very late . Can you be home before nine . ", " Oh , I won't be back so early . The film will be over at nine . Can I have the key to the bicycle ? ", " No . I won't let you ride a bicycle late at night . ", " Oh , dad , I'm not a child . I'm 17 already . I'll come back as soon as the film is over . ", " OK . Here's the key . Take care . ", ' I will . Thank you , dad . ']
['Hello . Could I speak to Justin , please ? ', ' Speaking . ', " Oh , hi Justin . This is Karen Hepburn.We met at Chris and Jim's party . ", " Of course . How're you ? ", " Great . Uh , Justin , would you like to see Otis Lesley on Thursday night ? He's at the Kangaroo Club . ", " I'm sorry , Karen , but I can't . I have to work late this Thursday . ", " Oh ... that's too bad . ", ' Yeah . I really like Lesley . ', " Actually , are you doing anything on Friday or Saturday ? He's playing those two nights as well . ", " Well , I can't make it on Friday either , but I'm free on Saturday night . What time does it start ? ", ' At eight sharp.How about meeting in front of the club at about a quarter after seven ? ', " That sounds perfect.And let's go out for coffee after the show . ", ' Sure ! ', ' See you at seven fifteen , Saturday . ']
["OK . I'll take your bet , as long as the winner gets to pick the movie . What about you , Nick ? ", ' Sure . Do you want to go first , Sally ? ', ' Why not ! I rolled a five . The category is Best Pictures . ', " OK , here's your question What movie won the 1996 Oscar for Best Picture ? ", " I know that , it's The English Patient . It was one of the only good American movies of the 90s . ", ' Well , along with Jurassic Park ! Nice going , you got the right answer . ']
['I often go to a place of leisure . ', ' Really ? ', ' I very much like to go to a cafe and doze in the afternoon sunshine . ', ' Sounds great . ', ' The coffee , books , music and sunshine are just beautiful there . ', ' How nice . ', ' I may take you there some day . ', ' Good . ']
['So Jen , what did you think of William ? Did you guys have a nice time on your first date ? ', ' Oh yeah , it was great ! He took me to an Italian restaurant and we had an amazing conversation . I told him about how many kids I want , and how my parents will be so excited to meet him . ', ' You said all that on the first date ? Alright ... Well are you two going out again ? ', ' Yeah ! I called him after I got home to arrange our next date , but unfortunately his grandma is sick so he has been busy every night visiting her in the hospital . ']
["I think Andy's party will be fun . ", ' Yeah , I think so . Oh , by the way , I need to ask you something . ', " What's that ? ", ' Could I get back the sweater you borrowed ? ', ' Sure . Oh , that reminds me . Could I borrow your black leather boots ? ', ' My boots ? Er ... Sure , ok . ']
["That sounds pretty good . But isn't downloading music illegal ? ", " Not if you pay for it . For example , if you download from iTunes and pay with your credit card , it's legal . ", " OK , I'm going to get iTunes and download some Vanilla Ice songs . ", " Awesome . You'll see that they are really catchy . "]
['Do you believe in god ? ', ' Not at all . I ’ m an agnostic . Do you ? ', ' I ’ m not sure . Why don ’ t you believe there is a god ? ', ' I think everything has a scientific explanation rather than a theological one . ', ' I basically believe in science over theology . I mean , I believe in evolution for example . However , there are many things that science hasn ’ t explained yet . ', ' I ’ m sure that science will explain everything eventually . I think that the strangest thing about religion is that so many religions people act in ways that their religion claims are wrong . ', ' For example ? ', ' Religions preach tolerance , but many wars are caused by intolerant religious fanatics . ', ' Yes . Such people don ’ t appear to be acting in accordance with their religious beliefs . ']
['Cindy , I have this room to myself ? ', " It's all yours . ", " It's twice as big as my room in Taiwan ! ", " Well , I hope it's comfortable enough for you . ", " I think I'm going to like it here . ", ' You have a phone on the bedside table that you can use . ', ' Wow , I have my own bathroom ! ', ' Kind of . It leads to my bedroom . ', ' We share the same bathroom , in other words . ']
['Joe , how are you doing ? ', ' Pretty good . Mary , I was wondering if you would like to come to a party on Friday night ? ', ' I am free that night , and a party sounds good . ', ' Fine . It will be at my house . Do you know how to get there ? ', ' I kind of know where you live , but could you e-mail me your address ? ', ' I can do that . Do you have anyone that you would like to bring with you to the party ? ', ' I would really like to bring my friend Jake , if that would be OK . ', ' Oh yeah , I remember Jake . That would be fine . ', ' Would you like some help with the food ? ', ' Just bring along whatever it is that you and Jake would like to drink . ']
['Come on in . Make yourself at home . ', ' Thanks a lot . ']
['Are you Elvin ? ', ' Elvin Dixon . Who are you ? ', " I'm Mary . I want to say I really admire the software you're designed . ", ' Easy stuff . But thanks . And the admiration is mutual . ', ' It is ? ', " You're selling invoking subscriptions like nobody's business . And we don't even have a working demo yet . ", " I can't take the credit for that . I'm just Zina's assistant . She's the pro . "]
['I wish you would not be so selfish . ', ' Selfishness is one human beings instincts . It is very difficult to get it out root and branch . ', " But you should at least consider your son's future . ", ' His mother , not me , should do this . ']
['We ’ re going to the movies . Will you join us ? ', ' I ’ m very sorry I can ’ t . ', ' Why not ? ', ' I ’ m afraid I have some business to attend to . ', ' Then would you like to have lunch with us ? ', ' I ’ d love to but I have to help John with his math problems right now . ', ' Would you like me to give you a lift ? ', ' No , thanks . His home is not far and I can walk there . ', ' Come on . It ’ s no trouble at all . ', ' Ok , thank you . ']
['Way to go ! It seems beautiful and very delicious . ', ' Thank you.Thanks to the baker , I benefit a lot from him . ']
['Is this the A housing office ? ', ' Yes , it is . Are you looking for housing for this semester ? ', ' I was hoping to get into something on campus , but my friend told me that everything is full . ', ' It is , but I can put you on a waiting list , if you would like . ', ' Please . And in the mean time , can I look at apartments available in the area from this office ? ', ' Yes , here is a catalog that is put out every year with locations that meet campus requirements for As . ', ' Who do I talk to if I want I to see some of them ? ', " The individual landlord's numbers are next to each entry . You can call them with any questions you may have . "]
["Hello , let me introduce myself . I'm your neighbor . My name is Shirley . ", " Hi , Shirley . I'm Sophie . It's nice to meet you . ", ' Nice to meet you , too . ', ' Please come in . ', " Here is a little gift for your family . It's a calendar with all the community events on it . I hope it can be helpful . ", ' I really appreciate it . ', ' Since we are neighbors , if you need any help or anything , please come to me . ', ' I will . Actually , I am worried so much about the security of this community because my house has been burgled twice before . ', " Oh , don't worry about that here . There are security guards on duty 24 hours a day and they patrol all over the neighborhood . You know , they are all very strong . ", " Really ? That's good . Is there any supermarket in our neighborhood ? ", " Of course . There is a Carrefour near the neighborhood . I'll show you there if you want to . ", " That's terrific ! ", ' By the way , a party will be held for new neighbors the day after tomorrow . I hope I can see you there . ', ' Yeah , and we can get to know each other at the party . ']
['Dave , wake up . ', ' Which ? Zina ? What time is it ? ', " It's seven-thirty . I want to know who left this note on my desk . ", " What note ? I can't see . I just pulled an all-nighter . ", " It's a little green post-it note , stuck right in the middle of my computer screen . ", " And ? What does it say ? Isn't there a name ? ", ' It says , Zina , I like how you rhumba . An admirer . ']
['I know I ’ m going to bite the dust going down this hill . I almost got killed on the chair lift ! This is going to be so embarrassing . ', ' Don ’ t worry . Everyone knows you ’ re getting your feet wet . I ’ ll show you how . I bet you ’ ll be proficient at this in five minutes . ', ' This is only your second time skiing . This is definitely a case of the blind leading the blind . ', ' Relax . I can hold my own . Now , point your skis toward the bottom of the hill . Easy does it ! ', ' I don ’ t think I can get up enough nerve to do this . ', ' Here . I ’ ll just give you a little push ... ', ' No ! ! ! ', ' There . Now , wasn ’ t that fun ? As soon as you get a second burst of energy , we ’ ll ... ', ' Don ’ t hold your breath ! ']
['Are you busy next Saturday ? ', ' No , why ? ', " I need to get a costume for a fancy dress party , and I reply don't know what to get . Will you come shopping with me ? ", ' Sure I like shopping . Who is organizing the party ? ', ' One of the girls in my office . ', " What's the occasion ? ", ' There is no specie occasion . She just likes to organize parties from time to time . This time it is a country theme . ', " That's easy , how about a cowgirl ? Oh I know even better , a Canadian Mountie . ", ' Well where am I going to get that sort of costume ? ', ' Leave it to me . I know exactly where to find it . ', ' Oh good . ', " Excellent , come over at ten o'clock and we will start at the shopping center , the one around the corner from my house . They have just the shop we need . "]
["What do you think of when you're praying ? ", " I try to picture the Lord's face in my mind . ", ' Does that help you faith ? ', ' Yes . ']
['Tom ! How are you ? We missed you at the party last night . Are you OK ? ', ' I don ’ t know . I didn ’ t really feel like going out . I guess I ’ m feeling a little homesick . ', ' Come on.We ’ Ve been through this already ! Look , I know the adjustment was hard when you first got here , but we agreed that you were gonna try and deal with it . ', ' I was . It ’ s just that the holidays are coming up and I won ’ t be able to home because I can ’ t afford the airfare . I ’ m just longing for some of the comforts of home , like my mom ’ s cooking and being around my family . ', ' Yeah , it can get pretty lonely over the holidays . When I first got here , I ’ d get depressed and nostalgic for anything that reminded me of home . I almost let it get to me , but then I started going out , keeping myself busy and before I knew it , I was used to to it . ', ' I see what you mean , but I ’ m still bummed out . ', ' OK . how does this sound . let ’ s get you suited up and hit the dance club tonight . I hear that an awesome DJ is playing and there will be a lot of pretty single girls there ! ', ' You know , I could really go for that . You don ’ t mind being my wingman for tonight ? ', ' Not at all ! It be fun ! It will be like a boys ’ night out ... well kinda ... ', ' Great ! I must warn you though , whatever happens , don ’ t let me go on a drinking binge . Trust me , it ’ s not a pretty picture ! ']
['Excuse me ? Is this where I register ? I ’ d like to sign up for my courses for next semester . ', ' Yes , of course . I need your student ID please . ', ' Here you are . ', ' Okay , Susan . It says here that you are a business major and you are in your second year . Is this information correct ? ', ' Yes . I do want to take some additional credits this year to get a minor in psychology . ', ' Sure . That ’ s not a problem . Do you have the list of courses you want to take this semester ? ', ' Yeah . Here ’ s my list . I ’ m not sure if the class schedule will allow me to take all of them though . ', ' Yeah , that ’ s perfect . What about the subjects for your minor ? ', ' Oh yeah ! Almost forgot ! I need to take fundamental linguistics , consumer psychology and neuroanatomy . ', ' Wow , you are going to be busy this semester ! Okay , here you go . You are registered now , you ’ ll have to make your first tuition payment before classes start . ']
['I used to be down on the sales people until I saw her in action . ', ' She means business , for sure . ', " Most salespeople seem like half-brains . Zina's definitely an exception . ", " We'd better get back to work . ", " Yeah , I'm not too worried about Vince , but I'd hate to face Zina if we don't deliver ... "]
['It seems like it rains every time we plan a picnic . ', " Well , that's life . "]
['You are late . What ’ s the deal ? ', ' Sorry , I was delayed by something and stuck in traffic . ']
['Has Alan shown up yet ? ', ' Nope . I guess something might have come up . ', ' I wonder what happened . ', " I don't know . I hope it's nothing serious . ", ' Last week his sister was admitted to the hospital . ', ' Oh ? What happened ? ', ' His sister had a car accident last week . ', ' Is she fine now ? ', ' She is still in a coma . ', ' Oh , poor Alan ! His sister is the only one he has left since his parents died last year . ']
['This cake is excellent . Where did you buy it ? ', ' Actually , my mother made it from scratch . ']
['Excuse me . Mr . Li . May I ask you some questions ? ', ' Sure . Take a seat , please . What would you like to know ? ', " Can you tell me how many credits would be enough for a Bachelor's degree ? ", ' A Bachelor is awarded to a student who successfully completes over 120 units , including general and specific requirements , for his or her undergraduate major and elective courses . ', " How long does it take to earn a Bachelor's degree ? ", ' Normally it can be completed in four years . ']
['I would much rather see her once or twice and not do anything about it — — what could I about it anyway ? ', ' Don ’ t say things like this . Please be confident . I think you still have the chance to win her love , unless you don ’ t love her anymore . ', ' Don ’ t you think she is a bit out of my way ? ', ' In some way , she is more modern . ', ' If I do try to do anything , I ’ d only be sent off with a flea in my ear . ', ' If you really think so , in my opinion you should give up this feeling completely . ']
['Excuse me . Have you got the time ? ', ' My watch says half past five . ', ' Does your watch keep good time ? ', ' Oh yeah . It loses only a few seconds in the whole month . ', ' Thanks a lot . ']
['Thanks for the loan . ', ' Think nothing of it . ']
["I haven't danced for a long time . ", ' Neither have I . ', " We must go to a dance soon , or we'll forget how to dance . ", ' Yes , we must . What have you been doing since I last saw you ? ', " I've been studying hard for my examinations . And you ? ", " I've been learning Japanese every evening . ", ' Why have you been learning Japanese ? Why not English ? ', ' I hope to visit Japan next year . ', " Well , we'll both have to start learning all the new dances . ", " Yes , let's go into the dance-hall and ask if we can take dancing-lessons . ", " A good idea . They can teach elephants to dance nowadays perhaps there's hope for us ! "]
['Come in and have some coffee , Anna . The kids have just gone out to the mall to hang out with their friends . ', ' I saw a lot of teenagers when Alan and I were there yesterday . ', ' They spend hours there , especially on weekends . ', ' Speaking of that trip , Alan bought a shirt at a department store , but the sleeves are too long . Do you know a seamstress or tailor who can shorten them ? ', ' I know several . But wouldn ’ t it be easier to take the shirt back and exchange it for the right size ? ', ' Isn ’ t that complicated ? ', ' No , it ’ s easy . We ’ ll just take the shirt back to the men ’ s department and show them the sales slip . They ’ ll exchange it for the correct size or give you a refund . ', ' We ? Do you want to go with me ? ', ' Sure . I love going to the mall . ', ' What do you do there ... hang around , like the kids ? ']
['Come on , you must tell me everything about him . ', " Well , he's very tall and handsome . ", ' Hmm ... ', ' He has big blue eyes and long blonde hair . ', ' Oh , how long ? ', " Down to his shoulders . It's beautiful , like gold . ", " OK . OK . You'd better tell me what he does . ", " He's a very creative painter . His paintings sell well . ", ' Really ? ', " He's quite a patient teacher , too . ", ' Fine . ', " You're going to like him . Everybody says he's a nice guy . "]
['My wife gave birth to our first child today . ', " Wow ! I'm so happy for you . "]
['Man , I ’ m freaking out ! You gotta help me ! ', ' Whoa , whoa , take it easy , relax . Geez , you ’ re sweating like a pig ! What ’ s going on ? ', ' I can ’ t go through with this ! I just can ’ t ! I ’ m not ready for marriage ! What was I thinking ? I ’ m only thirty five years old ! I ’ Ve got my entire life ahead of me , adventures waiting ! I can ’ t settle down yet ! ', ' What are you talking about ? It wasn ’ t more than a month ago that you were rambling on about how you are tired of living the life of a bachelor and how you envy your friends that have a family ! ', ' I know . I know ! ', ' Let ’ s think this through . First of all , you cannot leave Amy at the altar . Not only will she be humiliated and kill you , but she is the woman that you love and the woman of your dreams ! Why would you want to end that or jeopardize it like this ? Second of all , you are just getting cold feet . You know deep down inside that you want to marry her , so cut the crap and do it ! ', ' You ’ re right . I ’ m being crazy ! Ok , I ’ m ready , let ’ s do this ! ', ' Great ! Phew ! That was a close one ! You had me going there for a minute I thought I was gonna have to slap some sense into you . ']
['Yesterday was April the first . ', ' Was it quite special ? ', ' Not for the others , but for me . I was in the library going over my lessons when suddenly one of my roommates came in . He told me that I was wanted on the phone in my dormitory , and that person would call me again several minutes later . ', ' Did you hurry back to the bedroom ? ', ' Yes . I went back to the dorm only to find my roommates laughing and shouting " April Fool , April Fool " . ', ' Oh , your classmates took you in . ', " Only then did I realize it was April Fools ' Day . "]
['You look great today . And so beautiful . I love your elegant haircut . ', ' Thanks . Wendy . There will be an important dinner party tonight . So I must make me the focus of my friends . ']
['Hey Jack . Are you excited about starting work ? ', " Yeah . I'm really looking forward to it . ", ' What was more exciting , starting college or starting work ? ', " They're pretty similar , but in different ways . I really can't decide . How about you ? ", ' For me , I think starting school was more exciting . ', " Does that mean work isn't that great ? ", " It's different for everyone , but because I knew school was going to be so much fun , I really got excited about it . ", " But work is a huge portion of our lives . I'm looking forward to making it fun . ", " That's a great attitude to have . I don't think you'll have any problems in the workforce . ", " I hope you're right . "]
['So did you get in touch with your brother ? ', " No , not yet . I'm really worried . ", " Well , it'd be foolish to call the police . He probably just went away overnight . ", " Maybe you're right . But I'm still worried . "]
['Hi , Mark , did you catch the game last night ? ', ' No , I was out . Was it worth watching ? ', ' You didn ’ t hear ? Spain won , two to zero . ', ' Oh , really ? So , Spain is through to the next round ? ', ' Yeah . The final is next week . You have to watch it . ']
['How were things in the Tokyo branch when you were there ? ', " Good ! They have expanded and are doing better than they were last quarter . It's nice to see some improvement for a change . ", ' Do you see the trend continuing over the next few months ? ', ' Yes , especially with so many of our executives going back and forth from here to Japan . The only problem is , they may have trouble when they go to open up business here . ', ' Why would you say that ? ', " They aren't too familiar with doing business outside of Japan . There are a lot of cultural differences to account for . ", " I'll say ! Sometimes they just do things really differently . But one thing I can say , they are really hospitable . ", ' Have you ever been to Japan ? ', " Sure ! I just got back yesterday . I'm still suffering from jet lag . "]
['Morning . ', ' Hi there Mr . Anderson ! How are you on this fine morning ? ', ' Fine , thank you . ', ' It sure is cold this morning , isn ’ t it ? I barely even get out of bed ! ', ' Yeah . It ’ s pretty cold , alright . ', ' Did you catch the news this morning ? I heard that there was a fire on Byron Street . ', ' No , I didn ’ t hear about that . ', ' Did you happen to watch the football game last night ? The Patriots scored in the last minute ! ', ' No , I don ’ t like football . ', ' Oh . . . By the way , I saw you with your daughter at the office Christmas party . She is really beautiful ! ', ' She ’ s my wife ! Oh , here ’ s my floor ! Nice talking to you . Goodbye . ', ' Sir this is the 56th floor ! We are on the 70th ! ', ' That ’ s okay , I ’ ll take the stairs ! ']
['You look hot and tired . Jack , have you been exercising ? ', ' Yes . We just had a basketball match with Class Two . ', ' Who won ? ', ' They did . ', ' What was the score ? ', ' Seventy to sixty-seven . ']
["You'll have to take a make-up exam in logic . ", ' Oh , I thought I did a good job . ', ' Sorry to say you failed . ', ' Anyway , I have to face the music this time . ']
['May I help you ? ', ' I ’ m returning a book . ', ' Do you need anything else ? ', ' I also need to check out this video . ', ' This is all you want to check out ? ', ' Just the video . ', ' I ’ m going to need your library card . ', ' I have it right here . ', ' You ’ ll need to take care of the video . ', ' I will . ', ' We will fine you if you damage it . ', ' I get it . Thank you . ']
['Hi , how are you doing ? ', " Everything's great . And you ? ", ' Same here.Have you seen any new films recently ? ', ' No , I haven\'t had a chance to . But I have been watching a Chinese TV scries called " Chinese-Style Divorce " . ', " Oh . really ? I saw it two years ago . It's worth seeing and it's thought-provoking . ", ' Yeah . I found it is so close to our life . ', ' It reflects some of our difficulties in this ever-changing world . ', ' You said it . You know , the divorce rate has been on the rise in recent year . ', " Well , it's said that a lot of young people favor getting married quickly which tend to end quickly too . ", ' I know a couple who divorced a week after getting married . ', " Oh , that's too short-lived . ", " That's true . It's said the short-lived marriage is typical of the post - 80s ' generation . ", " II can't agree more . The only-child-generation in China tends to know little about marriage . ", " Definitely.They don't take relationships and marriages very seriously . ", ' In their mind , love is nothing but passion and marriage is over once the passion is gone . ', ' I think , as the saying goes haste makes waste , it is the same with marriage . ']
['Which is your preference , tea or coffee ? ', ' My choice would always be tea . ', ' When did you form this hobby ? ', ' Last year when I visited China . ']
["How do you get paid ? If you don't mind my asking . ", ' Not cash . But if our launch goes well , my stock options will pay off , big time . ', ' And in the meantime , how do you pay the rent ? ', " I don't have to worry about rent . I live right here . ", ' What ? In your cubicle ? ', ' Right here . Me and my PC . Home sweet home . ']
['Excuse me . Have you forgotten our drinks ? ', " Sorry , I'll bring them to you right away . ", ' Why is it taking so long ? ', ' We are short of staff today . ', ' There is something wrong with this dish . ', " What's wrong ? ", " I don't think this is fresh . ", ' They were delivered this morning . ', ' Would you please ask the manager to come over ? ']
["I've been looking forward to the new semester . ", ' I hope we can make great progress in this new semester . ', ' Hope so . ', ' I hear we ’ ll have a new English teacher this semester . ', ' Really ? I hope we will do much better under her guidance . ', ' I am sure we will . ']
['I am considering going for the new job that was posted yesterday . ', ' Are you certain that that is what you want to do ? ', ' It may not be the best choice for me , but I am considering it . ', ' Why do you think that this would be a good move ? ', ' I believe that this job would allow me to move up but might be a little boring for me . ', ' Yes , there are always pros and cons to making a career change . ', ' Also , the matter of pay is also a consideration . ', ' I think the slight pay decrease might be worth it . The benefits are much better . ', ' Yes , sometimes giving up a little to move forward is the best choice . ', ' I think you should definitely apply for the position . ']
['What do you do ? ', " I'm a teacher . "]
['How much do you make a month ? ', ' Mind your own business . ']
['I wish I could unsay the sharp words to him . He must hate me very much . ', " He doesn't mind . As a matter of fact , he's very pleased . ", ' Really ? Oh , thank Goodness ! ']
["I don't know . I think you might be over the hill . ", ' Well , if not gymnastics , then mountain biking . ', ' Mountain biking is an Olympic sport ? ', " Since 1996 it has been . And I bet I'd be pretty good at it . I ride my mountain bike to work almost every day . "]
['What ’ s your city like ? ', ' It ’ s quite an interesting place to live . The best thing to do in my city is go shopping . There are several indoor and outdoor markets , department stores and shopping malls . ', ' Is the traffic bad in the city centre ? ', ' Not really . Cars are not permitted in several parts of city centre , especially in the main shopping areas . The public transport system is pretty good . ', ' What about restaurants and entertainment ? ', ' There are restaurants with food from all over the world . We have a small china-town near the city centre . There are many Indian , Thai , and Italian restaurants all over the city centre . There are many sports events in my city . We have several sports venues for football , rugby , and cricket-even ice-skating and ice hockey . ', ' Is there a lot of nightlife in your city ? ', ' There are several good clubs near the city centre . Many people in my city prefer something more ’ cultural ” , so we several theatres and venues for classical music concerts and operas . ', ' It sounds like a really exciting city to live in . ', ' It is . I hope you ’ ll have time to come for a visit soon . You really should come during the summer , when the weather is better and there ’ s more happening outdoors . ']
['When do you celebrate Thanksgiving ? ', ' On the fourth Thursday of November . ', ' What do you eat on that day ? ', ' People cook turkeys for Thanksgiving dinner . ', ' Anything else ? ', " Besides the turkeys , we'll also have other delicious food . Such as pumpkin pies , puddings , mashed potatoes , bread , a lot of fresh fruits and vegetables . ", " I'm almost hungry . "]
['Great party , isn ’ t it ? ', ' Yeah , really . ', ' By the way , my name is Liu Wei . ', ' Hi , I ’ m Susan Marshall.You can call me Susan.Nice to meet you . ', ' What do you do , Susan ? ', ' Well , I ’ m a college student.How about you ? ', ' I work for the Bank of China , in the International Section . ', ' I work for the Bank of China , in the International Section . ']
["Oh , please ! Don't be so old-fashioned ! It's totally safe . ", " I sure hope you didn't trust anyone with your credit card number . ", ' All I did so far was make a bid on the Buddha . It was easy ! ', ' Easy ? Ha ! ! It was easy for them to cheat you ! ! ', ' Oh , come on ! I just gave them my e-mail , my address and my phone number . And my name , of course . ']
['I think that ’ s settled . ', " I'm tired of your cut-and-dried opinions . Who do you think you are ! ", ' How dare you speak to me like this . ', ' Why not ? ']
['Honey , I ’ ll be right back ! ', ' Where are you going ? ', ' I told you already ! I ’ m going to get my nails done . ', ' Again ? You just went last week ! You spend more time at the nail salon than you do here at home ! Honestly , why do you need a manicure every week ? ', ' Well , first of all , I like to pamper myself , and my nails look great . You should come with me ! ', ' Why ? I don ’ t want to have nail polish or anything like that ! ', ' They don ’ t only paint my nails ! The manicurist will remove my cuticles , file my nails , and apply at least nails coats of nail polish ! ', ' Yeah , sounds like something I should definitely do . ']
["Excuse me . Do you have a minute ? I'd like to tell you about the Bucky Card . ", ' Well ... alright . I guess I have a minute . ', ' Do you know about the Bucky Card ? ', " I've heard about it , but I don't really know about it . ", ' The Bucky Card is a great way for you to save money while you have a good time here at school.It gives you discounts on all kinds of things . Movies , pizza , clothing , school supplies . ', ' What about beer ? ', " The Card doesn't actually give you discounts on beer.But it will give you discounts on certain club cover charges.So if you want to see your favorite band at Amy's or Cosmo's Club , you get a discount on the entrance fee . ", " That's pretty cool . How much of a discount ? ", " Usually it's two dollars off the cover price . ", ' And all these other things , pizza and movies for instance--how much of a discount do I get on that stuff ? ', " This pamphlet shows you what restaurants and movie theaters have discounts.And twice every semester we will send you a new issue of the pamphlet.The Bucky Card has just started.Every couple months we have new businesses joining our program.It ' s a great way for students to save money ! ", " Alright , alright . Let me look at that pamphlet.Hmm . Alessio's Pizza Parlor . That's cool . I go there all the time.And Cosmo's Club . And 4 - D records . Alright . How much does it cost ? ", ' It costs only 19 dollars a year for a card . ', " Whoa ! That's expensive ! It should be cheaper . ", " But think of how much money you'll save ! You can use it for a year . ", ' Yeah , maybe . Alright . Give me an application form . ']
['who are you writing a letter to ? ', " I'm just responding to Sue's letter . Do you want to help ? ", ' OK . I guess I could add something . Tell them that I send my love . ', " that's kind of boring . Don't you want to tell them anything else ? ", ' well , maybe you could tell them about my promotion . ', " you've been promoted ? when did that happen ? ", ' just today . I guess I forgot to mention it . ', " congratulations ! That's really exciting ! Let's get out a bottle of wine to celebrate ! ", " shouldn't we finish writing this letter first ? ", " ah . That can wait . Your promotion is the best news I've heard in a long time ! ", ' it is good news , but it looked like you were almost finished . We might as well just sign off . ', " ok , you're right . I'll just tell them how round I am of you for getting a promotion and then I'll thank Sue for her kind letter . ", " I guess you can write that I'm looking forward to seeing them in June . ", " that's thoughtful of you . ", ' and also thank them from the bottom of my heart for the Christmas package they sent us . ', " that's right ! I almost forgot about that . ", ' what would you do without me ? ', ' we do balance each other out well . I guess we were really made for each other ! ']
['May I help you with something ? ', ' I would like to return these books . ', ' What happened to this book ? ', ' I dropped it , and the cover tore off . ', ' I ’ m going to have to charge you for the damage . ', ' How much ? ', ' It ’ s only $ 5 . ', ' That ’ s not too bad . ', ' I know it ’ s not . ', ' Here ’ s the money for the book . ', ' Thank you for your payment . ', ' You are very welcome . ']
['He is penny wise and pound-foolish . ', ' Why do you say so ? ', ' The trash of the world he sets high price upon , but the heavenly things he shamefully undervalues . ', ' Maybe all of us are the same . ']
['Hey , Tom . You look tired . Are you all right ? ', " I didn't sleep much last night . ", ' How come ? ', ' You know Miao Li-my roommate , he bought a computer last month . He has turned his computer into an electronic playground . He plays football , rides horses , drives racing cars , and does a whole bunch of other games . Every night he keeps me up . ', " Don't you like games ", ' I usually get a lot of information on the computer and use E-mail to send messages to my friends . ', " Me too . Recently , I've made many friends on the net . Every day I talk to them and share many interesting things with them . ", " Don't you think it's a sheer waste of both time and money ? ", " I'm afraid not . To me getting in touch with each other has more fun than the coolest computer games or the hottest information . ", ' Yes . ']
["What's the weather like in your city ? ", ' In the summer it gets very hot.the temperature is often between 37 and 40 centigrade.when it is hot we often get rains.the winters are drier . ', ' The summer temperature usually often reaches about 20 or25 in my city.the rain falls mostly in the winter.and we often get snow . ', ' What are the temperatures in winter ? in my city it is about 15 or 20 degrees . ', ' In winter temperature often falls to zero at night temperature can be below that.the streets are often icing in the morning.with high such temperatures you must get some thunderstorms . ', ' Yeah , we do . in the middle of summer there can be thunderstorms every day usually in the afternoon . i heard your city has a lot of fog , is that true ? ', ' We do have a few foggy days in winter.but i would not say we have a lot of fogs.the sky are usually clearly over your city , are they ? ', ' Yes , they are . like i said we have thunderstorms.but each one usually only last a few hours.then the skys are clear again . ', ' Have you ever had snow in your city ? ', ' My grandmother said there was snow once when she was a child.but my parents and i only see it outside of our city . ', ' The river in my city sometime freeze over.people go ice-skating on it.on summer people go boating on the river.but few people go swimming because it is not very clean . ', ' As you know , my city is on the coast.the water is also not clean.but people still go swimming all year around . i prefer to sand bath on the beach when the weather is hot in sunny . ']
['I used to think that Americans had so much money they didn ’ t know what to do with it . ', ' You did ? ', ' Yes . But now I ’ Ve learned differently . Now I have a more realistic opinion . ', ' What do you think now ? ', ' There are lots of jobs , and almost everybody works . There is a high standard of living . People earn a lot , but they spend a lot to live . So there isn ’ t so much money after all . ', ' But I still say Americans spend a lot more money on useless things than we Chinese do . ', ' That ’ s true . But Americans work hard for their money like we do . I don ’ t know why our spending habits are so different . ']
['I am exhausted . I need some sleep . ', ' Didn ’ t you sleep well last night ? ', ' I twisted and turned all night , and couldn ’ t sleep . I was worried about my mother ’ s health . ', ' Don ’ t worry . It ’ s only a cold . ']
["Fairly warm this morning , isn't it ? ", " You're right.The air is so warm and everything looks so fresh and green . ", ' Say , how about a walk along the river ? ', ' Marvelous idea ? ']
['How do you like other films starring Charlie Chaplin ? ', " Well , I like others very much , but I really don't think much of this one . ", " You don't like the performance , do you ? ", " Yes , but I don't like the story . "]
['Lots of elderly people want peace and quiet in their old age , but young people want an unconstrained life . ', ' It would be good for both if they lived separately . My parents want to live apart from us . ', ' What if old people are in poor health and need to be looked after ? ', " Young people ought to carry out their responsibilities . If it's needed , they would live with their parents . ", ' When I ’ m old , I ’ ll also be like that . ', " You need a child first , and that's your duty , too . ", " I know that's what I must do . "]
['I went to visit a customer in IVS Company the other day . Their offices were very impressive , especially their company Logo which is all over the place . There are Logo models in metal , copper , clove , paper . They are even printed on the wall paper and the balls of the table-lights . It is really decorated identity . ', ' It is just too much . Don ’ t you feel it is an exaggerating style to decorate offices in that way ? ', ' Not at all ! I like the design so much . The designer must have thought really hard to come out with such a brilliant concept . ', ' Wow , I doubt that . ']
['Oh , Linda . You must be so excited about going to study in America . ', ' Oh yes I am . I have always wanted to go to the States . I love meeting new people and making new friends . ', ' Well , I am sure you will . ', ' Well , there is one thing . ', ' What is the matter ? ', ' I am a little worried about my host family . You know , in the agreement , I have to do some cooking for them . ', ' Yes ? ', " Well , I am just afraid they won't like my Chinese way of cooking . ", " Oh , listen , you'll soon learn , and I am sure they will explain to you how they like to get prepared . ", " Oh , let's hope so . "]
['So what did you think about the movie ? ', ' Well , I think this Star Wars episode is an excellent piece of work , but not as good as the previous ones . ', " Really ? I don't agree . This Star Wars episode was incredible ! ", ' Why do you think so ? ', " Well , one of the most spectacular things about this one was the special effects . State of the art special effects are the main reason for the success of previous episodes , so audiences have high expectations for this one , and I don't think they will be disappointed . ", ' You are right . The special effects were amazing . And I like the fact that they created so many fantastic settings and otherworldly costumes , weapons and creatures . ', " It's kind of cool that they are still using the same Star Wars theme song for this movie . ", ' Yeah ! It reminds me of the previous Star Wars scenes . ', ' I know exactly what you mean . Hearing that song gives me a nostalgic feeling . ', " I thought the overall plot of the movie was very interesting , but I don't think the character development was that strong . ", ' Do you think that they had anything to do with the casting of the movie ? ', ' No , the casting is great and the actors were excellent . They just didn ’ t have a lot of funny or meaningful dialogues . The writing was also a little weak . ', " Well , maybe . But I like the little kid who played Manakin Skywalker . I can't imagine anyone else playing that role . ", " I liked him too . He is so cute ! You know , even though I was slightly disappointed , I can't wait for the next episode . I wonder when they ’ re going to start making it and when it ’ s scheduled for release ? ", " I've no idea . But looking at the success of Star Wars episode , I've a strong feeling production for the next episode will be selling pretty soon . I hope It will be even better than this one . ", ' I hope so , too . ', " Well , I think we should go now . It's getting pretty late . ", " Okay , let's go ! "]
['Well , you know what , don ’ t do it , ‘ cause the minute you do , they lose all respect for you . ', ' Well , it ’ s not like that . We just e-mail , it ’ s really nothing . On top of which I am definitely thinking about stopping because it ’ s getting ... ', ' Out of hand . ', ' Confusing . But not , because it ’ s nothing . ', ' Where ’ d you meet him ? ', ' Oh , listen , I can ’ t even remember . Ok , on my birthday , I wandered into over 30 rooms , for a joke , sort of and he was there , and we started chatting ... ', ' About what ? ', ' Oh , books , and music , how much we both love New York . Harmless , harmless , meaningless . Bouquets of sharpened pencils . Oh . ', ' Excuse me ? ', ' Forget it . We don ’ t talk about anything personal , so I don ’ t know his name or what he does or where he lives exactly . So it ’ ll be really easy for me to stop seeing him , because I ’ m not ... ']
["What's so special today ? ", ' Why ? ', " Didn't you notice all the roses ? ", " It's July 7th . Chinese Valentine's Day ! ", ' Oh , God . I just forget it . ', ' I thought you had trouble with Clive ! ', " No . But now he will be in bigger trouble ! What's a boyfriend for ? Forget about Valentine's Day ? ", " Poor guy ! It's not fair . You forgot it too . ", " Oh , it's Clive . ", ' Wow ! Good timing . ', ' Excuse me for a while.Clive asked me out to a movie ! Do you want to join us ? ', ' Come on . Two is company . ', ' So what ? ', " It's Valentine's Day . Come on . Just go . "]
['John , I ’ d like you to meet Charles Brown , our new manager at the airport . ', ' Yes , certainly . How can I recognize him ? ', ' He is short , well-built , and he ’ s got light blond hair . ', ' Is there anything else ? ', ' He has a mustache , if I remember correctly , and a light complexion . ', ' How old is he ? ', ' He is in his late thirties . ', ' Well . I shouldn ’ t have any trouble recognizing him . What time does his flight arrive ? ', ' At two thirty . ']
["Hi , Tony . You look unhappy . What's wrong ? ", ' Oh , Steven , I made a big mistake . ', ' What happened ? ', ' I really wish I hadn ’ t done it . ', ' What on earth are you talking about ? ', ' I got caught cheating . I feel so ashamed . The teacher saw me and told me I failed . ', ' What were you thinking ? ', " You know my father . If I fail , he'll kill me . I have to do well . ", ' But what you should do is study hard . ', " I know ... I know ... it's all my fault . I feel awful that I didn ’ t study , and I cheated , and I got caught . ", ' So long as you learn from your mistakes . ']
['Hello , John . How are you ? ', " I'm fine , thanks . And you ? ", " Very well , thanks . Nice to see you again . I haven't seen you for a long time . What have you been doing lately ? ", ' Oh , nothing much really . And how is everything with you ? ', " Fine , thanks . I've been busy lately . ", ' What have you been doing ? ', " I've been studying for my exams . My school exams will begin next month . ", ' Really ? Good luck for them . ', ' Thanks . And how are your parents ? ', " They're both very well , thanks . ", ' Where are you going now ? ', " I'm going to do some shopping . Why don't you come with me ? ", " I can't . I have to meet someone . ", " It's been nice talking to you . ", ' Good-bye . See you again sometime . ']
['Good evening . Welcome to our program . ', ' Thank you . Good evening , Mr.Dean . ', ' Would you tell us your name , please ? ', " I'm Helen Baker . ", ' Glad to meet you , Ms.Baker . ', ' Glad to meet you , too . ', ' Where are you from , Ms.Baker ? ', " I'm from New Zealand . ", ' What do you do for a living ? ', " I'm a teacher . ", ' Thank you for coming , Ms.baker . ']
['I ’ m tired , Larry . Can we have a break ? ', ' What ? You ’ re tired ? But we just started about twenty minutes ago . ', ' I know , but I ’ m really tired . My stomach feels funny . ', ' What ’ s the matter ? Didn ’ t you sleep well last night ? ', ' I was too excited to sleep last night . I didn ’ t go to sleep until quite late . ', ' Then when did you go to sleep ? ', ' About 2 o ’ clock in the morning . ', ' When ? ', ' About 2 o ’ clock . ', ' Oh , Susie . Didn ’ t I tell you over and over again that you wouldn ’ t be able to climb the mountain unless you got enough sleep ? ', ' You did , but I can ’ t help it . ', ' This is a one-day trip . We ’ ll have to keep going and try to reach the top by noon or give up right now and go home . Which one do you choose ? ', ' Which one do I choose ? I don ’ t want to give up , but I really feel tired . ', ' So , make up your mind quickly . Whether to keep going or give up . ', ' Let me think about it . What should I do ? I think I will not give up . ']
['Man , that sunset is beautiful . I ’ Ve never seen one so red . ', ' Yeah , it ’ s pretty nice , but its so red because of air pollution . ', ' Really ? ', ' Yeah , the smog from all these cars gets into the air and turns the sunlight red . ', ' I never knew that . ', ' Yeah , more people need to take public transportation or carpool . ', ' Well , we ’ Ve already done our part . ', ' Yeah , it ’ s your turn to drive next week . Don ’ t be late picking me up . ', ' Don ’ t worry . I ’ m getting more sleep these days . The baby ’ s finally growing up a little more . ', ' Well , give me a call if you can ’ t make it for some reason . ']
['Happy New Year , Jim ! ', ' Thank you , same to you ! Lee , have you got any plans ? ', " Yeah , I'm going to the Temple Fair with my family . ", ' How nice ! Have fun ! ']
['Henry , don ’ t get out of doing housework . ', ' It ’ s none of my business . ', ' You mean that is my business . ', ' I don ’ t say that . But it seems to me the housewife should do that . ', ' I ’ m your wife , not a housewife . I have my own work . ', ' Hum ... ']
['Darling , I have news for you . Bobby and his wife , Evelyn , are going to have a baby soon . ', ' Really ? I thought his wife couldn ’ t have a baby . ', ' Actually they ’ re expecting the baby to come on my birthday . ', ' Oh , what a coincidence ! I bet Bobby must be very happy about it . He likes children and always wants a child of his own . ', ' In fact , they ’ re both very excited about the coming baby . Evelyn imagines what their baby would be look like , since one parent is American and the other one is Chinese . ', ' Oh , right . Now I know why they would want to see our boy . It ’ s hard to imagine the wonder ! Are they expecting a boy or a girl ? ', ' It ’ s still a mystery . Because Evelyn is only three-month pregnant . But she begins to take her maternity leave now . ', ' Oh ! You mean she doesn ’ t have to work now ? It ’ s hard for young parents not to overreact , isn ’ t it ? ']
['I want to know how to buy something from this machine . ', ' Yeah , the new ones can be tricky . What are you trying to buy ? ', ' I want to buy one of those snack things . ', ' Are you ready to go ? ', " I'm clear so far . ", ' The money goes in the slot over there . It has to be smooth to go in . ', " It won't go in ! ", ' Just remember that you might have to feed the money in a couple of times to get it to work . ', ' Yes , next step . ', " Make your selection and hope for the best . Vending machines aren't all that reliable . ", " They're totally unreliable . ", ' You seem to have it down . Have a good day ! ']
['Hello , Lily . ', ' Hello , Mr . Clark . You ’ re early for lunch . It ’ s only eleven o ’ clock . ', ' When I come late , there ’ s usually nothing left . ', ' What would you like today ? ', ' I ’ ll have the leg of lamb . ', ' And would you like salad ? The salad plate today is lettuce , tomatoes , and black olives . ']
['How may I help you ? ', ' I couldn ’ t find the book I was looking for . ', ' Have you checked the database ? ', ' I checked . ', ' Was it on the shelf ? ', ' It should have been , but it wasn ’ t . ', ' Maybe someone took it . ', ' Will you be getting another copy anytime soon ? ', ' I ’ m sure we will . ', ' Would you be able to reserve it for me ? ', ' I sure will . ', ' Thank you very much . ']
['do you have internet in your room ? ', " sure , I am a total internet junkie , I can't survive without internet . ", ' really ? What do you usually do online ? ', " well , there are a lot of things , like reading news , email , shopping , etc . but mostly I chat online . You could say I'm addicted to online chatting . ", " I never chatted online before . What's it like . ", " well , basically it's similar to face-to-face chat , but you type instead of talk . You should try it at least once . ", ' really ? Who do you chat with ? ', ' to people all over the world ! I have a lot of net pals . See , the magic of internet is that it connects people from all over the world . You can chat with someone thousands of miles away as if they were ', " that's amazing . I will install an online messenger program when I get home . ", " well , my suggestion for a newbie like you is that don't get lost in the cyberspace . You know internet won't do the filtration for you , so you still need to use your judgement . There are a lot of per ", " don't worry . "]
['What are you doing now , Steven ? ', ' I am reading a book about money management . ', ' Oh , my God . Do you want to be a millionaire ? I can see you are very crazy about money . ', " Everyone wants to earn a lot of money . Don't you think so ? What's more , I am interested in money management . ", " No , you are wrong . Money can't buy happiness and health . I won't sacrifice my health in order to get money . In other words , I don't want to be a millionaire and I want to have more free time to enjoy life . ", ' Oh , I see . But a proverb says " Money makes the mare go . " I think it will be better if you have more money . ', ' Maybe you are right . Please take care of yourself when you make money . Anyway health is the most important thing . ', ' Thank you for your caring . I will . ', ' No thanks . ']
["It's the 17th week now , isn't it ? ", ' Yes , it is . ', ' Oh , the final exam is coming soon . I feel a little bit nervous . ', ' Take it easy . There is still one more week left before the exam begins . Have you prepared for it well ? ', " No , I haven't began my preparations . ", ' Then shall we make preparations together ? ', ' Great . You can help me a lot with English . ', ' All right . But I am very poor at math . Would you like to help me with my math ? ', ' No problem . ']
['Have you ever been to any other country ? ', " Pity I haven't . If I can afford it , I'll certainly take a trip abroad . ", " That's also my dream . ", ' How about going to italy next summer vacation ? ', ' Why not ? ']
["You are blue in the face , arn't you ? ", " The cat has eaten my fish , I'll kill it . ", ' But supposing your son killed like the fish , what do you think then ? ', " I'll beat him . ", " So beat the cat , but don't kill it . "]
['You ’ re all set now ? ', ' Oh , thank you so much . ', ' Really , it was nothing . ', ' I really appreciated it . ', ' I was happy to help . ', ' It was so kind of you . ', ' Don ’ t mention it . ', ' You ’ re a real friend in need . ']
["Let's get together this weekend . ", ' Sounds good . ']
['What time is it , Tom ? ', " Just a minute . It's ten to nine by my watch . ", ' Is it ? I had no idea it was so late . I must be off now . ', " What's the hurry ? ", ' I must catch the nine-thirty train . ', " You've plenty of time yet . The railway station is very close . It won't take more than twenty minutes to get there . "]
['Are you still at that work ? ', " Yes , I'm still working there . But I really find my job boring . I'd like to change my job . ", ' What sort of job do you have in mind ? ', " I think I'm quite fit for a driver . ", " But it's very tired . ", " I don't care . ", " What's your parents ' opinion ? ", " I haven't told them . Maybe I'll make them know after the vacation . "]
['is this seat taken ? ', ' no . please sit down . ', ' thanks . ', ' are you also going to Beijing ? ', ' yes , on a business trip . How about you ? ', " I'm taking a vacation to visit a friend there . Have you ever been there before ? ", ' yes , I went there once last summer . ', ' really ? What did you think ? ', " I think it is amazing . You can enjoy both the traditional Chinese culture as well as the vitality of a modern cosmopolitan city . The only thing I didn't enjoy was the subway . ", ' was it that crowded ? ', ' yes . There were always so many people . After taking the subway during the rush hour , you ’ ll envy sardines in their cans . ', ' oh , maybe I can take the bus or even rent a car . ', " that's a good idea . Wish you a great vacation ! ", ' thank you very much ! ']
['Do you like watching TV ? ', ' Yes I do , usually . ', ' What do you exactly mean by usually ? ', " I don't like spending time on commercials.There ' re too many commercials on TV . "]
["We're forming a study group to prepare for the finals . Do you want to join us ? ", ' But the semester just started ? Why the rush ? ', " After you try it once this way , I don't think you'll ever put off studying till the end again . ", ' How often do you meet ? ', ' We plan to get together once a week . ', ' What days , do you know ? ', ' We were talking about Wednesday evenings at the library , from seven to eight . ', ' Okay , count me in . ']
['What is wrong with Peter ? He sure looks unhappy . ', ' His girlfriend dumped him , and he is tearing his heart out over her . ', ' How foolish he is . The girl is inviting . She often makes a pass at boys . ', ' Love is blind , you know . ']
['Can you lend me your car ? ', " Nothing ' doing . "]
['Peter , which club do you want to join ? ', " I haven't decided yet . What about you , Andy ? ", ' I am a member of the basketball club . Do you want to join us ? ', " But I don't know how to play basketball . ", " It's OK . Don't worry about it . Our school coach will train us to play basketball . "]
['You ’ re all set now ? ', ' Oh , thank you so much . ', ' Really , it was nothing . ', ' I really appreciated it . ', ' I was happy to help . ', ' It was so kind of you . ', ' Don ’ t mention it . ', ' You ’ re a real friend in need . ']
['Hi , Jason ! ', ' Hi , Linda . I have two concert complimentary tickets . Will you go with me tonight ? ', ' With the greatest pleasure ! Where is the concert held this evening ? ', ' It will be held at the Central Music Hall . ', ' What is on the program ? ', " It ’ s a piano solo . I'm fond of piano , you know . ", ' Hah ! OK . Let ’ s go together ! ', ' Let ’ s meet at the park at 6:00 . ', ' See you then . ']
["I'm tired of this job . ", ' So am I . ']
['Good afternoon , would you mind if I sit here ? ', ' Of course not . ', ' I ’ m Jack . What ’ s your name ? ', ' Laura . ', ' Do you like this place ? ', ' I don ’ t think it ’ s very nice . And my father doesn ’ t like it . But my mother likes it very much . So we often come here . ', ' How often ? ', ' Well , we come here almost every month . ', ' Who ’ s that ? ', ' It ’ s my mother . She ’ s fond of swimming . And the man beside her is my father . ', ' Do you like swimming ? ', ' No , I hate swimming . I prefer playing tennis . ']
['What shall I call him ? ', ' Oh , you may call him Uncle , or Henry . ', " What's he doing ? ", " He's checking bags.He ' s an official in the customs . "]
['Hi , John ! How was your vacation ? ', ' We went to Malaysia and Thailand . ', ' That must have been wonderful . Do anything interesting ? ', ' Well . We went bungee jumping when we were in Malaysia . ', " Wow , isn't that dangerous ? ", ' A little , but the rush was worth it . ', ' Tell me about it . ', ' We jumped off a bridge and fell 500 feet before the bungee cord caught us . ', ' 500 feet ! I would never be able to do that . ', ' Yeah , It was scary but exhilarating . ']
["It's a lovely day , isn't it ? ", ' Yes , the weather sure is nice today . ', " I love it when the weather is like this.Why don't we sit down outside and have our lunch ? ", " That sounds like a good idea.The sky is clear , the sun is shining and there's a nice cool breeze , so it is not too hot . ", ' I really miss the change of seasons like we have in Colorado ; but I must admit , this sure is a nice spring day . ', ' Hey , this spot in the shade looks really comfortable . ', ' Okay.Hey , is that a dark cloud over there ? Do you think it will rain after all ? ', " I don't think so . I say the weather report last night , and it said the weather should be fine all day . ", " If the weather stays nice perhaps we can go to the beach this weekend.It ' s been a while since I've not really gotten some sun . "]
['Did you go to the movie yesterday ? ', ' Yes , I did . ', ' What did you think of it ? ', " I don't think much of the film . ", ' I think it is the worst one I have ever seen . ', " Oh , I'm not sure I agree with you . It was not a good one , but it was not the worst one . Actually , it wasn't too bad . ", " I can't think the same . ", " What's more , some scenes were good , much fit for the children . ", " I couldn't agree with you . "]
['There has been talk at school about canceling the concert . ', ' Really ? Who did you hear that from ? ', ' Just word of mouth . ']
["Do you have the notes from last week's class ? ", ' Did you come late ? ', " I couldn't make it . ", ' Why is that ? ', ' I was sick . ', ' Oh , okay . Well , here you go . ', ' Are these all of them ? ', ' Oh , wait , here are the rest . ', ' Thanks a bunch . ', " Don't mention it . "]
['Excuse me , Professor . I think there might be an error in my test score . ', ' Sure . Do you think that the total is wrong or that you got something marked wrong that should have been marked right ? ', ' I think that the percentage is incorrect . ', " Let's just go over all of it to double-check . ", " Sure , let's do it . ", ' Here is the answer sheet . Do you see a place where I marked something wrong that should have been right ? ', " I don't see any mistakes . ", " OK , now that we've gotten those straightened out , let's total the score . ", " Yes , let's total it . ", ' Well , if I total that like this and divide by this number , I get this total . Do you agree ? ', " Yes , you're right . ", ' Well then , we are all straight . Have a good day and thanks for bringing that to my attention . ']
['A new film is on.Have you ever seen it ? ', ' What kind of movie is it ? ', " It's a feature film . ", " Oh , I've no interest in such films . "]
['Mary , I heard you moved again . ', ' Yeah . I could not stand living here . There is always much noise in the neighborhood . ', ' You mean noise ? How could it be ? ', ' You know , on weekends when we wanted to have late rise in the morning , our neighbour started to raise Cain . ']
['What do you think of your teacher ? ', " He's very strict with us . ", ' And I hear he gives very good lectures . ', " Indeed . He's strict with himself too . We can see every lecture of his is well-prepared . "]
['What do you want to do tomorrow night ? ', ' What--is tomorrow night something special ? ', " It's Friday . We should go party . ", " I don't need to drink every weekend . I could be happy just staying home , you know . ", ' Okay . Stay home Sunday . But Friday we should go out dancing . ', ' Do you feel like dancing ? ', ' Yes ? Why not ? ', " Alright.At least that's better than sitting in a bar with your alcoholic friends . ", " They aren't alcoholic ! ", " No , maybe they're not . But they're close . ", ' So where should we go ? ', " Let's go to the Latin Club . I think they will have a Brazilian band there this weekend . Maybe it's Friday night . ", " You always want to go to the Latin Club . I don't know those dance steps . I'd rather go to the New Bar . ", ' The New Bar is all techno music on Friday night.You really want to dance to that ? ', " It's not all techno music . It's not a special techno night . ", " No . But they play techno all the time . It drives me crazy after forty minutes.And anyhow , if we go to the Latin Club you could actually learn some Latin dance steps.At the New Bar you'll just shake yourself around for an hour.And then you'll get sick of stand you'll want to go get drunk somewhere where the drinks are cheaper . I know you . ", " It's fine with me if we go to the Latin Club . I like Latin Music.The only thing I never want to do again is listen to country rock.What was that bar called ? ", " Oh . You mean Jerry's , over on the east side.That wasn't my idea going there . ", ' No . It was that friend of yours , Melissa.Her and all her lousy country music Cds . Yecch ! ', " It's true . I would never go there again either.Country music is a nightmare . So is it the Latin Club ? ", ' Yes . You have to teach me the samba , and the tango , and whatever else they do . ', " Well , it seems you'll have to learn some Spanish too , won't you ? ", ' Maybe . ']
['David , do you think we are lucky to have the weekend ? ', ' Definitely . I need to have enough time to have a rest on this weekend . We worked like bees in the whole working days . ', ' I agree with you . What do you want to do , except sleeping ? ', ' Let me think . Oh , awful ! I still have not finished the chart which was assigned by Mr . Wharton on Friday . So that task will make my busy . ', " I am better . I will go out to have a visit to my aunt . Why don't we have fun on weekend ? ", ' So what ? ']
["And what's your vision ? ", ' 20/350 . ', " Mine's 20/20 . Life just isn't fair , is it ? ", ' Oh , yes , it is . ', ' What do you mean ? ', " You'll find out when we're in the woods and you have to go to the bathroom ... ", " They don't have toilets at the campground ? ", " Let's just say I'll have it easy ... "]
['A funny thing happened to me the other day . ', ' Oh , yes ? ', ' I was just thinking about someone I went to school with , this boy I was quite friendly with in third grade . We used to hang out together - he lived next door - but then my parents moved and I changed schools and never saw him again . ', ' Mmm . ', ' Well , I was walking down Nan Jing Dong Lu ( Nan-Jing E . Rd . ) during my lunch break thinking about this boy-I have no idea why I was thinking about him . ', ' Really ? ', " Yes . And suddenly I heard someone call my name . I turned around and there was this man looking at me . I didn't recognize him at all , but he obviously knew who I was . ", " Oh , yeah , that's embarrassing when that happens . ", ' You got it . Well , he walked up to me and said my name again and then I realized it was the boy I had been thinking about , the one from third grade ! ']
['You look tired . Did you sleep well last night ? ', ' I stayed up all night writing a report . ', ' Go easy . Overwork is bad for your health . ']
['Hi , how ’ re you doing ? ', ' Terrible . ', ' Oh , what ’ s the matter ? ', ' I ’ Ve got a fever and really a bad headache . ', ' Oh , that ’ s too bad . Why don ’ t you take some aspirin ? ', ' I ’ Ve already tried some but it didn ’ t help . ', ' Well , it ’ s necessary for you to see a doctor . ', ' Yeah , I guess I should . ', ' Well , you ’ d better get some rest . ', ' Thank you very much . ', ' Bye . ']
['Did you hear the news ? Two of our major suppliers , Murphy Music and U-Tunes are merging ! If they are conglomerated into one company into one company , it would have some serious affects on our market strategy . ', " Are you sure ? Who told you that ? I highly doubt that they would take the step to merge into one company ... They're supposed to be bitter enemies , the strictest of competitors.It must be a rumor.It can't be true . ", " I read it myself on the financial page.They ' re really going to join together . U-Tunes was bought out by Murphy's , they will take over the company as of next month . ", ' The competition must have been too stiff for U-Tunes.Otherwise why would they allow themselves to be taken over by their sworn enemy ? ', " I guess they must have figured it would be easier to merge than to keep up the cutthroat competition.If you can't beat'em , join'em . "]
['Daniel , would you like to have a look at my dorm ? ', " Of course , I'd like to . ", ' It is a small room , just for 4 people . ', ' What is in it ? ', ' It only has 4 beds and 4 writing desks , but it is spacious and bright . ', ' Do you get along with your roommates ? ', ' Of course . They are very friendly . ', ' Which floor are you on ? ', " We are on the 5th floor , and there's a very nice view from the balcony . ", ' Oh , you can climb the stairs as a workout . ', " Yes , that's a good idea . ", ' Wow , your roommates are cleaning the room . ', " Let's give them a hand . "]
['I like hitchhiking.will you go with me ? ', " Oh , no . I don't think I'm in that good form . ", " It's a pity.Say , how about a place near enough ? ", ' To where exactly ? ', ' New England . ', " That's still too far for me . "]
['Excuse me . Nature calls . ', ' If you gotta go , you gotta go . ']
['Julia , will you be my wife ? ', " I'm sorry , Steven . ", ' Please , Julia , I have made proposal to you five times . I really want to share the rest of my life with you . ', ' I know . But I ’ m not ready for married life yet . ', ' Julia , I really love you . I hope I can stay with you no matter you are happy or sad in future . ', ' Your way does touch my heart . ', ' So , will you marry me ? ', ' I want to think of it for some time . ']
["Yeah , it's really cute . But why a monkey suit ? Is Hello Kitty having an identity complex ? ", " No , she's wearing my Chinese zodiac sign . ", ' You were born in the year of the monkey ? ', ' Yeah , are you surprised ? ', ' Not at all ! That explains everything ! ']
["What's the time ? My watch has stopped . ", " Let me see . It's five minutes to eleven . ", ' Is your watch right ? ', ' I think so . I see it by the radio this morning . ']
['How long will it take to learn English ? Will I be able to take other courses next semester or will English take up all of my time ? ', ' It ’ s hard to say . Language isn ’ t like other studies . ', ' You mean I could finish this course and still not know English ? You ’ Ve got to be kidding ! ', ' I ’ m not kidding . Learning a language is a question of forming language habits and that takes time . ', ' So do we have to stay in this English class forever ? ', ' No . You just have to stay here long enough to get some orientation . Then you go on practicing and learning outside . A lot of learning depends on your personal motivation . ', ' So it ’ s really the same story . Practice , practice , practice and more practice is the only way to learn a language . ', ' You said it . ']
['How nice it is here ', ' You can say that again . The sunny shining and there ’ s pleasant raise . it ’ s so lovely ', ' I ’ Ve heard the whether here is ideal , just like spring most of the year ', ' That ’ s correct . we have four seasons of spring ']
["You're going to get into a lot of trouble if you do that . ", ' What makes you say that ? ', " I don't see anything wrong with what we're doing ! That's just the problem . In these kind of things , the trouble doesn't always appear at first . ", ' But everything has been so easy . ', ' Everything has gone as smooth as clockwork . Just like we planned ! That may be true , but if you were to do it , you would have trouble on the horizon . You always say that . ', ' Yeah , you never look at the positive side of things . ', " Okay . Have it your way , but don't say I didn't warn you . "]
['Excuse me , is this seat taken ? ', ' Er ... no , go ahead . ', " You work upstair , right ? I think I have seen you before . I'm Karren , Karren Brown . ", " Nice to meet you , Karren . I'm Tim Wang . ", ' Happy to know you , Tim . ']
['I can bet the farm that you will regret about your decision . You cannot find a better one . ', ' How can you be so sure ? You haven ’ t been together with her , have you ? ', ' No . But I ’ m sure she is a good girl . My sixth sense tells me so . ', ' Then try it yourself . ']
["Betty , would you please read this letter of application I've just written ? I'd like to have your opinion . ", " I'd be glad to tell you what I think . ", " Good ! I'm interested in your advice . ", ' If I were you , I would change the beginning . You should write about your education first because we like to judge a man by his abilities . ', ' Good idea , Betty . What would you think about the second part ? ', " I think it's too short . You'd better say something about your work experience . ", " You're right , I'll change it . How about the last part ? ", ' Very good . But you should talk about your family , too . ', ' I agree . I appreciate your helping me . ']
['I see you have bought the latest copy of beauty and fashion . Are there any interesting articles in it ? ', ' There ’ s an interesting interview with a top fashion designer about the latest fashions . I enjoyed reading her thought . The which ? section is very interesting this month . They tested facial cleaners . T ', ' I like to take the tests that they print in this magazine . ', ' Which tests do you mean ? ', ' You know . Tests like how jealous are you ? and are you a fashion victim ? ', ' Oh , I see . I like to do those tests , too , but I don ’ t take them seriously . ', ' Of course not , but sometimes the results make you think about yourself and what you do . According to the jealousy test , I ’ m quite a jealous type of person . Perhaps I need to control my jealousy . ', ' You ’ re right . It ’ s sometimes hard to tell which pages are advertisement and which ones are articles . ']
['If I can improve my vertical jump a few more inches , I think beach volleyball might be my ticket . ', ' But whenever we play , you just sit on the sand , drink beer , and watch the girls ! ', " It's a beautiful sport , isn't it ? ", " To be honest , I don't think you could even win a gold in hopscotch ! ", " OK , OK . Enough already . We'd better hustle . The contest starts in five minutes . "]
['Will it be all right to visit you this evening ? ', " I'm sorry , but I have an appointment this evening.How about tomorrow evening ? ", " It's fine with me . "]
['How is night life in Beijing ? ', ' Very interesting ! ', ' What do you suggest then ? ', ' How about going to dance ? There is a very good nightclub nearby . ', " That's a great idea . Let's go ... Oh , the dance hall looks very nice and the music is wonderful . ", ' I\'m glad you like it.The band is called " Four and One " . They are especially good at playing rock and roll . ', " That's great ! I love to dance to fast music . ", " Then you must be interested in disco dancing , aren't you ? ", " Yes , disco dancing is my favorite.It ' s great fun and good exercise as well . ", " OK . Let's disco . ", ' Now the band is playing a slow dance . ', " That's a waltz . Would you like to try it ? ", " Sorry , I think I'Il sit out the next dance . ", ' All right . Let me get you something to drink . ']
['Just remember . The main thing right now is to make sure Stars.com is happy . ', " Right . You're right . But she's just evil . Someone should drive a stake through her heart . ", ' Elvin , please . Can I count on you to keep your cool for a week , or not ? ', " I'm OK . I'll be fine . I'v cool . I'm cold . I'm like ice . She won't know what hit her . ", " By the way , how's the nose ? Boy , that must have hurt . "]
['What do you need ? ', ' I would like to check out a book . ', ' I ’ m going to need your library card . ', ' I don ’ t have a library card . ', ' Why don ’ t you apply for one right now ? ', ' Sure . That would be great . ', ' Please fill out this application . ', ' Okay . Here you go . ', ' Now , sign your name on the back of the card . ', ' Here you go . ', ' Here ’ s your library card . ', ' Thanks . Now I ’ d like to check out this book . ']
['I can ’ t believe my English teacher is making me read pride and prejudice ! ', ' Why not ! It ’ s a classic ; in fact , it ’ s one of my favorite novels . ', ' But it ’ s so old . ', ' Don ’ t judge a book by its cover . Do you Kwon what it ’ s about ? ', ' No , not at all . ', ' First of all , it ’ s a romance novel , set in the early 19th century . ', ' I didn ’ t realize it was a romance novel . What ’ s the main storyline ? ', ' It ’ s basically about a father who tried to marry off one of his five girls . ', ' Why does he want to do that ? ', ' Since he doesn ’ t have a son , he hopes that one of the girls will marry a wealthy man . That way , all of his daughters will be cared for . ', ' Won ’ t they get his inheritance ? ', ' No , that ’ s the problem . Though they are well-off , once he dies , his house will go to his cousin . So , when he dies , the girls will have nothing . ', ' I see . This sounds interesting ! Maybe my teacher isn ’ t so horrible after all . ', ' So , are you going to read the novel or watch the movie ? ', ' There ’ s movie ? My teacher didn ’ t tell me that ! ', ' That ’ s probably because she wants you to read the book first . ', ' It would take a lot less time .. ', ' How about this . When you finish the book . I ’ ll get the movie and watch it with you . ', ' Ok . That sounds like a deal . ']
['What is the matter with him ? ', " I don't know , what's wrong ? ", ' I feel he is as cold as charity to me . ', ' Maybe you should ask him openly . ']
['Are there many idioms in English ? ', ' There are hundreds and hundreds . English is particularly rich in idiomatic expressions . ', ' Can you give us an example ? ', " I'll look up the rate . To look up doesn't mean to look high into the sky or to look at the roof . It means to search for and find some information . ", ' What about the expression " goodbye " ? Is that an idiom ? ', ' That is just a natural , grammatical English expression . It has a direct translation in other languages . ', ' This is interesting , Ms.Parker . ']
['Good morning , Mr.Black . I am the new secretary . ', ' Good morning , Miss White . You are half an hour early . ', " I don't want to make a bad impression . ", ' Come on over . This is your desk , and this is your time card . Be sure to clock in and out before and after you work . ', ' I will . ', " One more thing , keep your desk neat . It's the rule . There is no exception , even the art designers have to keep their desks neat . ", " I'll keep that in mind . Does everything on the desk belong to me ? ", ' Not belong . You can use them as long as you work here . When you quit , you ’ ll have to return them to the company . ', " What's the extension number for my phone ? ", " The operator will put all your calls through . You don't have to worry about that . ", ' Can I make personal phone calls during my office hours ? ', " Of course you can . Every one has his personal matters to deal with more or less , but don't chat over the phone . What's more , don't let it hinder your work and the company's business . ", ' I understand . ', " When you settle down , I'll show you around and introduce you to the department managers . "]
['Oh ! I just want to drop in on him for a chat . ', ' Please come in , Mr.Jackson . ', ' No , thank you.Please tell him to phone me when he comes back . ']
['When in Rome , do as the Romans do , they say . ', ' What do you mean ? ', ' Roman is living in Rome , of course . And go to work by car , or bus , or on foot . ', ' I think the Romans do what everyone else does . ', ' Certainly . ', ' And Roman really loves life . He knows how to enjoy himself . ', ' Not always . But they like good meal . ', ' Really ? ', ' How can I go there to have a taste ? ', ' By air of course . ']
['it seems the department still has some money left in the budget . Do you have any suggestions how to use it before the budget is renewed ? ', ' what about renting a restaurant and treating the employees to a nice dinner ? ', " but we've done that many times . We want something fresh this time . ", ' okay , let me think . What about a party-and-movie night ? We can rearrange our reference room , invite a band to play some music , order in some food and watch a movie later . ', ' sounds like a good idea , but a band sounds too expensive . ', ' well , we can ask people to make small contributions . ', " I don ' t think so . I don't think people are going to like it if they have to pay to come . But we certainly can cut costs in other ways , such as make the party BYOB . ", " BYOB ? What's that ? ", ' bring your own beverage . We can provide food , but people have to bring their own drinks . ', " so we're just going to have a party where they bring their own drinks and we just give them some snacks ? I don't know how well that will go over . ", " maybe you have a point . How about having a party on a Friday afternoon ? We'll stop early , order some pizza , and serve drinks . There'll be music but no band . Having the party in the office will make ", ' oh , that sounds like fun ! ']
["just don't understand why we have to take the subway . Look at this place . It's modern enough . But it's far from lively . ", " It's convenient . People in network go everywhere by subway if they don't drive . ", " This isn't network , Frida . We are in San Francisco . ", " What's the difference ? ", " We haven't come here in business but for pleasure . We should go out exciting . What can you see in the subway ? Nothing ! ", ' What can you see from a tram or a double-decker ? ', ' I can see people who are walking on the sidewalk . I can see cars driving on the streets . I can see the sun shining and beautiful flowers dancing in the wind . I can even smell the scent of flowers and the freshness of the air . ', ' But they are not as convenient as the subway . ', ' You miss the point ! We are not in a hurry to go anywhere . ', " Well , maybe you are right . We'll be more amused in a tram or a double-decker than on the subway . ", " I'm so glad you can finally see things in my way . Can we leave this dull place now ? ", " What about the tickets ? I've already bought them . ", ' Just throw them away ! ']
['It is really exciting news . ', ' What news ? ', ' You don ’ t know ? The company is going to replace these old computers with the latest ones . ', ' You know what we will get ? ', ' We will all get a docking station on our own desk from which you can remove your laptop easily . And if you come back to office , you just reconnect your laptop with docking station . ', ' What docking station ? ', ' This is a kind of socket mounted to your desk . The socket has all the wire connections of the company line and all the other office automation equipments , like fax , copier , a screen , printer and scanner , and it will be very convenient . ', ' Another big step forward in saving on our office equipment , I don ’ t need a desktop anymore . A laptop is enough . ']
['Mary , I have something to tell you . ', ' Go ahead . ', ' I ’ m afraid you ’ ll become angry . But I think I must tell you . ', ' Come on . Don ’ t hesitate . ', ' John made out with other girls at the party yesterday . ']
["I'd like to talk to you about my grades . ", ' Sure ! What exactly do you have questions about ? ', ' I am worried that I messed up on a test . ', ' Well , let me take a look at my grade book . How do YOU think you are doing ? ', ' I think I am doing great , except for that one test ! ', ' Well , your scores show that you could do a little better . What do you think you could improve on ? ', ' I think that I could study a little harder for tests . ', ' Fine ! Please remember that regular attendance is the most important way to begin . ', ' Yes , I know . ', " I'm sure you'll do fine . "]
["Sandra is actually blue chipper . I don't think she could realize that she has married a fool for women . ", " That's fate . ", ' I feel sorry for her . ', " Maybe this is God's will . "]
['good morning ! ', ' good morning , Gav ! Did you sleep well last night ? ', " I slept like a baby . I fell asleep right away last night , didn't wake up once , and didn't have nay nightmares ! ", " that's great news ! You look much more relaxed than you did yesterday . ", " I feel much better , but I'm still worried about something . ", " what's that ? ", " well , I have to drive to school for a meeting this morning , and I'm going to end up getting stuck in rush-hour traffic . ", " that's annoying , but nothing to worry about . ", " for me , traffic jams are quite stressful , because I'm pretty impatient . How can I prevent myself from getting stressed if I get stuck in a traffic jam ? ", ' just breathe deeply when you feel yourself getting upset . ', " Ok , I'll try that . ", ' is there anything else bothering you ? ', " just one more thing . A school called me this morning to see if I could teach a few classes this weekend and I don't know what to do . ", ' do you have any other plans this weekend ? ', " I'm supposed to work on a paper that'd due on Monday . ", ' try not to take on more than you can handle . ', " you're right . I probably should just work on my paper . Thanks ! "]
['Do you want to hear a funny joke ? ', " OK . Are you sure it's funny , though ? ", " Well , you'll see . ", ' OK . ', ' OK , an Englishman , a Scotsman , and an Irishman were going on a trip across the desert , and they could only take one thing with them . ', ' I see . ', ' So they met up at the start of the journey and showed each other their equipment . ', " Oh , that's funny ! ", " Hang on , I haven't finished yet . ", ' Oh , sorry . ', ' Well , as I was saying , they showed each other what they had decided to bring . The Englishman had brought some water . " If we get thirsty , we\'ll have something to drink , " he said . The Scotsman brought a map . " If we get lost , we\'ll be able to find our way . " The Irishman had brought a car door . ', ' A car door ? You mean just one car door ? ', ' Yep . A car door . " Why the door ? " the others asked him . " Well , " he said , “ If it gets hot , we can open the window . " Do you get it ? ', ' Well ... ']
['Have you ever run into a person who tries bleed you white ? ', ' I am always on the look out for such girls . ', ' I hear that some guys splash all their money about on them . ', ' Mark is one of them . He has trouble with a girl who turned out to be a dead beat . ']
['I ’ m sorry , Sam . I don ’ t want to foc-concert . ', ' How about going to the theatre ? ', ' I don ’ t like going to the theatre . ', ' Well , what do you like doing ? ', ' traveling , swimming , going to the cinema . And you ? ', ' I like painting , sailing , watching football and talking to you . ', ' I like talking to you too . ', ' Do you want to go to an Exhibition ? There ’ s one of xinghai exhibitions hall tomorrow . ', ' That ’ s a good idea . ']
['I find Beijing Opera is quite a bore . ', ' Young people enjoy pop songs more . ', " It's just like listening to a language which you know nothing at all . ", " But you don't have such a problem as to pop songs . "]
['You are married to a foreigner , huh ? So what ’ s it like ? ', ' Well , the first year of our marriage , we had great difficulty getting along . The things that are important to me are not important to him . We had a lot of conflicts . ', ' Yeah , I know what you mean . The first year of any marriage is difficult for all couples , not to mention two people from different cultures . ', ' And now we have a two-year-old boy . We ’ re very happy that he ’ s healthy and smart . ', ' Oh , so he ’ s half Chinese and half American . That ’ s unusual . What languages does he speak , then ? ', ' Right now he speaks mostly Chinese , and he can say a few English words . But he will learn . ', ' What does he look like ? Can people tell ? ', ' Yes , people surely can . He ’ s whiter than the Chinese kids , and his hair is a little blonde . My husband says his eyes are very Chinese though . ']
['Congratulations ! I heard that you are going to take a two-week training course in the headquarter . ', ' Thank you . I am very happy to have this opportunity to learn something new . You know information and knowledge in this field update very fast . ', ' Sure it is . This is a changing world . Does the training course cover the new law and regulation issued last month ? They are very useful for us . ', ' Yes , according to the agenda , there will be a seminar on these issues at the very beginning of the training course . ', ' Well , good for you . I hope you can get what you want from the training . ', ' I will do my best . ']
["Hi ! Tom . Fancy seeing you here It's a nice party isn't it ? ", " Yeah . Well it's quite some days since we were together last summer.How is everything going ? ", ' Quite well . I got my MA degree two weeks ago . ', ' Congratulations ! ']
['When will the ceremony begin ? ', " The ceremony will begin at 9 0 ' clock . After the ceremony , there's a reception . By the way , do you know why they have chosen September 9th for their wedding ceremony ? ", ' No idea . ', ' As in English , Chinese also has some lucky numbers . The number 9 stands for perpetuity in Chinese . ']
['Hi , Francis . ', ' Oh , Mike . How are you doing ? ', ' Not bad . It seems you are super yogurt lover . You have so many in your cart . ', ' Well , I prefer yogurt to all the other drinks . Have you ever tried a kind of yogurt with old milk in it ? It tastes great and very healthy too . ', ' Oh , I haven ’ t noticed that before . Maybe I will try next time . ', ' Why don ’ t you go ahead of me ? I have more items than you . ', ' Thank you . In fact , I am in a hurry . My wife is waiting for me at the parking lot . ', ' You ’ re welcome . It was good seeing you again . ', ' Me too . Have a great day . ']
['Does your country export a lot of natural resources ? ', ' We export some coal to European countries , but our biggest exports is copper , which we export to Europe , north America , and China . ', ' Which resources do you have to import ? ', ' We import a little oil from Venezuela , but we are fairly self-sufficient . We import some iron and a lot of aluminium from neighbouring countries . ', ' I heard that you country recently discovered deposits of precious stone . ', ' Yes , that ’ s right . So far , only small deposits have been found . Engineers in my country are focusing on drilling for oil . The government is keen to exploit our natural resources to get money to improve our country . ', ' If your government invests in your country ’ s infrastructure , it will be money well spent . ', ' Yes . We need to put the money into long-term projects rather than wasting it on short-term ones . ']
['Have you seen any good movies lately ? ', " It's ages since I went to see a film . ", ' Why ? You were a real movie buff when you were a student . ', ' But now I would stay at home watching TV . ']
['Mandy , Would you like to come for dinner tonight ? ', ' Dinner ? Where ? ', ' At the new Five Spices restaurant in Chaoyang . ', ' What kind of food do they serve ? ', ' It ’ s Asian fusion . I heard it ’ s delicious . ', ' Oh really ! That sounds lovely . ']
['Bob is really disturbed these days . ', " We'd better have a heart-to-heart talk with him . ", ' But we cannot talk like elders . ', " Of course not . Let's talk to him in a very friendly way . "]
['How was the movie last night ? ', " I didn't really like it . ", ' Mary said that she was really pleased with the photography . ', ' I found it very disappointing . ', " She liked the acting , too , because that's what she wanted to see . ", " I wasn't happy with it . ", ' Nothing is to your satisfaction . ']
["What's the matter with you then ? You look miserable . ", " It's us . ", ' What do you mean by us ? ', " Well , you always say you're busy . ", " That's right . ", ' And you often go back to live with your parents and leave our son in the room by himself . ', ' I ... I ... I miss my parents , also they miss me . ', " Oh I remember , I cut terrible calls , and you didn't say anything about it . ", ' You mean I am groaned a few words ? ', " Totally not . Perhaps it's about our marriage . "]
["Everybody , I'd like to propose a toast to Mary Johnson , Teacher of the Year . She worked hard all year . She really deserved the honor . ", " Yes , we're all proud of her ! ", " Here's to you , Mary ! ", ' Cheers ! ']
['He thought he could take Jimmy in , but you know , Jimmy is no fool . ', ' So ? ', ' So Jimmy just took him in instead and it cost him an arm and a leg . ', ' You mean finally Henry bought the broken car himself . ', ' Exactly . Herry is almost broken now . ']
['Do you have any plans for tomorrow night ? ', ' Not really . I wasn thinking of maybe going to a movie . Do you want to go with me ? ', ' Sure . What movies were you thinking about going to ? ', ' Have you heard of Hot Fuzz ? ', " Yes . Isn't the director of that movie the same guy who directed Shaun of the Dead ? ", " That's the one . It's an actioncomedy . What do you think ? ", " To be honest , I didn't really like Shaun of the Dead . Besides , I like movies with a happy ending best . ", ' What do you have in mind ? ', " I was thinking of seeing You , Me and Dupree . It's a typical Hollywood blockbuster . ", " Isn't that the chick flick with Kate Hudson and Owen Wilson ? ", " Yeah , I suppose you wouldn't want to see that , huh ? ", ' Not really . Do you like biographical / drama films ? ', ' It depends on who the film is about . Which movie did you have in mind ? ', ' Anne Hathaway is in a new movie called Becoming Jane which is based on a true story about Jane Austen . ', ' That sounds fantastic ! What time is it playing ? ', " It's on at 8 pm at the Phoenix Theatres . I have a membership there , so I can book the tickets ahead of time . ", ' Great . Shall I meet you there around 7 forty-five tomorrow night ? ', " Sounds good . I'll see you then ! "]
["Didn't Joe feel it a shame to live on his parents since he has graduated from college ? ", ' He has no sense . ', " If I were him , I wouldn'tbrazen it outby asking my parents for money . ", " But Joe won't you . "]
['Hey , Ray , what are you doing right now ? ', ' Not much . Joann . Do you want to hang out ? ', ' Yes , I do . I ’ m at home myself right now with nothing much to do . ', ' Me , too . What would you like to do ? ', ' Well , we could go to a movie . Have you see Shrek 2 ? ', ' I have , actually . How about the movie , Million Dollar Baby with Clint Eastwood ? ', ' Hmm ... I ’ Ve seen that , too . We could go for a walk in the park . ', ' We could , but it looks like it ’ s going to rain soon . ', ' I guess that ’ s out . Why don ’ t we go shopping ? ', ' I ’ d really rather not . I ’ ll be too tempted to buy something that I can ’ t afford ! ', ' Ok . I guess we ’ d be not do that , either , then . What do you want to do ? ', ' I don ’ t know . Do you want to go bowling at the new bowling alley on 1st street ? ', ' I would like to , but I injured my wrist last weekend . ', ' Let ’ s see . Do you want to go to a bar and sing some karaoke ? ', ' That sounds interesting , but I can ’ t drink alcohol with the medicine I ’ m taking . ', ' Doesn ’ t sound like that ’ s be fun , then . Do you want to come here ? ', ' I don ’ t have a car . ', ' Goodness , we ’ re not having much luck here , are we ? ', ' No . do you have a car ? ', ' No , but I could take the bus . ', ' Oh , good . Why don ’ t you take the bus to mine and we could play Mah Tiang ? ', ' That sounds great ! Have you eaten ? ', ' Not yet . I ’ ll cook dinner and have it ready by the time you get here . ', ' Perfect . Are you prepared to give me all your money ? ', ' Huh ? We are going to play for money , aren ’ t we ? ', ' Oh , right . I suppose so . As long as you promise to lose ! ', ' Hey ... as long as I ’ m not alone on a Saturday night , I don ’ t really care what I do ! ', ' See you soon . ', ' Bye ! ']
['Is this your new teacher ? ', ' Yes , it is . ', ' Is she short ? ', ' No , she ’ s average . ', ' What color are her eyes ? ', ' They ’ re dark gray . ', ' What color is her hair ? ', ' It ’ s blond . ', ' And how old is she ? ', ' I don ’ t know . ']
["What's the matter with you ? You look so upset and tired . ", ' My father failed in business . ', " Oh , that's really tough . ", ' Maybe it is the most difficult period of my family have experienced . ', ' I can understand . By the way , is there anyway I can help ? ', ' No , not now . I have found a part-time job . So perhaps I can help my family to come over the difficulties . ', " Oh , that's so great , bless you ! if you need me , I'll always be there . ", ' Thank you . ']
['I hear your daughter graduated from high school as the valedictorian . ', ' Thank you . ', ' Where is she going to college ? ', ' She has been admitted to Yale with a scholarship . ', " Really ? That's the icing on the cake . Congratulation again ! ", ' Thank you . ']
['Where are you going for your holidays , Charles ? ', " To Australia . I'm going to visit my uncle in Brisbane for three weeks . ", ' Good gracious ! You certainly are lucky . How are you going there ? ', ' By air , of course . It takes over two weeks to go by sea . ', ' I once went to Singapore by air . It was very exciting-but never again . ', ' Why ? Did you feel frightened ? ', ' For a short time . One of the engines caught fire . ', ' What did the pilot do ? ', ' He put it out and flew back to the airport . Then he asked the people at the airport where the emergency runway was . ', ' Did you land safely ? ', ' Yes , we did . But I shall never fly again . ']
['I heard you are going out with John ? ', ' Yes . To be frank , I really love him to death . ', ' You are so lucky . ', ' Why do you say that ? ', ' Why ? Are you kidding me ? A guy like that is hard to find . Few boys are so caring , so patient , and did I mention he is hottie ? ', ' You really think so ? ', " Totally . I am saying it from the bottom of my heart ! And it's obvious that he ’ s head over heels in love with you , too . ", ' I sure hope so . ']
['I heard a rumor this morning ... It seems Trusten Tools is going out of business.Another competitor is going bankrupt.That could be good news for us . ', " I think you must have heard wrong.The truth is we are going to be taken over by Trusten.We are being bought out , and our company will be merging with our largest competitor.It ' s not good news at all ... ", ' What ? We are merging with Trusten ? I never thought that would happen.Will we be getting new owners ? Will it affect our jobs ? ', ' Probably.The new owners will be coming to start alignment meetings nextweek.One of the big question is what to call the new conglomerate company . ', " Wow , with such a big change.We won't have the same name ? ", " It's not only the name of our company that will change ... I expect that after this acquisition , there'll be a ton of things up in the air . "]
["Well , I'm thinking of going to see the ballet Swan Lake by the famous Russian National Ballet Troupe this evening at Beijing Grand Theater . Why don't you join me ? ", " I'd like to , but I've got to write a term paper . It will be due by this Thursday . ", ' You always work too hard , Jim . As the saying goes , all work and no play makes Jack a dull boy . You should spare some time for a rest . ', ' I know it is no good for my health if I am staying in the classroom all day . But how about my paper ? ', ' Just take it easy . Come on with me . ', " I'm terribly sorry I can't go with you . Shall we find some other time ? "]
['Is your father in the habit of having naps ? ', ' Yes , all of us have naps . ', " Don't you feel dizzy when you have to get up ? ", ' No , not at all . ']
['so nice to see you again , Louise . How are you doing ? ', " Pretty good . How's your business going , Kevin ? ", ' Not too bad . ']
['What do you think of this suit ? Do I look good or what ? ', ' You look great ! However , I think you are a little over dressed for dinner . ', " Didn't they say we're going to the Ritz ? ", ' Yes , but not the Ritz Carlton , the " Ritz " is a pizza place with peanut shells on the floor . ', ' In that case , let me make a quick change into my street clothes . ', " I'll wait right here for you Superman . ", " Ta da ! Let's go to the Ritz ! ", ' Can we go to the Carlton next time and can you wear that fabulous suit ? ']
['One family skeleton of my family was that my younger brother has an axe to grind . ', ' What did he aim at ? ', ' He began to be interested in finance because he thought he would be able to inherit the family ’ s fortune . ', ' How could he have such an ill intention ? I think your father can see that through . ']
['Did you hear peter just retired ? ', " Are you sure ? He is quite young , isn't he ? ", " He is not young as he looks . I think he's almost sixty . ", ' Really ? He looks so young . ']
['You really look familiar . ', ' Really ? My name is Gretchen Hammer . What is your name ? ', ' My name is Phillip Hammer . I think we are related . Who is your dad ? ', ' Jacob Hammer . He is originally from Holland . ', " That's my uncle . You're my cousin ! Hi cousin ! ", " It's really a small world , isn't it ! The Hammer family isn't very big . ", ' It really is . Do you have time to eat dinner and catch up ? ', ' I always make time for family . ']
['I plan to buy a car this year . ', ' How do you pay for it ? ', " I'm going to work in holidays and pay by installments . ", ' Tell me if you need help . ']
["It's very dark in here.Will you turn on the light ? ", ' Okay.But our baby has fallen sleep . ', ' Then , turn on the lamp , please . ', " But where's the switch ? ", " It's there by the window . "]
['London is such a historic city ! There ’ s history everywhere you look . There ’ s nelson ’ s column , built as a monument to one of the Britain ’ s great admirals and his important victory . He won the battle of ', ' I ’ m looking forward to seeing Westminster abbey , where many historic figures are buried , like Isaac Newton , the great mathematician and Winston Churchill , the great wartime leader . ', ' Nearby , on the banks of the thames , there ’ s the statue of Boadicea . She fought the Romans when they invaded Britain . ', ' Women have often played an important role in british history . Queen Elizabeth I built a navy strong enough to fight off the Spanish armada in 1588 . more recently , Margaret thatcher transformed british ', ' She was a very controversial leader . Are we going to visit the famous tower of London later ? ', ' There ’ s a lot to see there . Perhaps we should go tomorrow . ', ' I ’ m looking forward to seeing the famous castle and prison . Many historic figures were imprisoned there in the past . I really want to see the crown jewels too . ', ' I ’ Ve seen them before . They ’ re quite incredible . If you want to see historical figures in London , there ’ s one place you have to go . ', ' Where ’ s that ? Oh , I know ! Madame Tussaud ’ s the waxworks museum . ', ' There you can see british leaders , entertainers , criminals , and royalty . ', ' Sometimes , it ’ s hard to know who belongs in each section of the museum ! ']
['Where is my contract ? ', ' It ’ s all my faults . I forget where I put it . ']
['I hear Jean married a business tycoon . ', " That's true . Her husband is a fat cat . ", " But I don't think she really loves him . ", ' She is only after his money . ', " If I were her , I wouldn't marry a man I don't really love . ", ' But many girls nowaday do want to marry a man filthy with dough . ']
["There's a concert in Capital Theatre this Sunday . ", ' So what ? ', ' Look , I have two tickets.Will you go with me ? ', ' Wow , I like concerts . ']
['Have you heard about Anlesen David ? ', ' No , have they have another fight ? ', ' No , they got engaged . ', ' You must be joking.Those two . ', " Well , my dear . I didn't believe either.But got it straight form the horse's mouth.Davi called me this morning . ", ' So when did this happen ? ', ' Last weekend , while they were on the Sik trip . ', ' Well , I believe it now , and when are they are getting marry ? ', ' Next june . ', ' I can hardly believe it . ']
['Ted is so scared by dogs that he shakes in his shoes whenever he sees one . ', ' The reason is that he once was bitten by a dog . ', ' No wonder . ']
['I think the government needs a radical plan to improve things . The government just talks , but in the long run , nothing is done to improve the economy . ', " That's right . They always talk about a need for new , progressive tactics , but they haven't done anything to stimulate new jobs . ", " Well , income taxes were decreased last year in hope to give the economy a boost , but I think it's backfired . The immediate effect of the tax reduction was to cause inflation to rise . ", " The worst part is that the inflation hurts the poor more than the rich . It also leads to more unemployment in the long run . I don't know what a good solution would be to make the economy more vibrant again ... ", ' I have a good solution ... We need some new blood ! We should get rid of this president and boat in some new leaders ! ']
['You have a nice apartment . ', ' Thank you . My wife would be very happy to hear this . ', ' She must have done a lot of work on it . ', ' You bet . ']
["I tried to ask the bank teller why it changed , but she didn't speak English well enough.So I decided to go to the magazine shop . The one around the corner.And I bought an American newspaper . ", ' What happened ? ', " It seems that yesterday the Mexican government declared wouldn't pay back the loans it got from the World Bank.The government declared a default on the loans . ", " That's serious . ", ' I know . The economy here is having serious problems.But because the government declared a default , the currency value went way down . ', ' So now Mexican pesos are worth about half as much . ', " Yes , it's an amazing drop . ", " Wow . I feel sorry for the Mexicans . But it's good for us . ", " Yes , it's very good . We suddenly have twice as much money to spend here.Our hotel is now half as expensive as when we got here ! Isn't that strange ? ", ' Yes , and you know what ? ', ' What ? ', " I don't really like this hotel that much.So tonight , now that we are so rich , tonight why don't we stay in the most expensive hotel in town ? ", ' Why not ? We should do it . Because now we can afford it . ']
['You are starting to learn English ? ', ' Yeah . I like it , Dad . ', ' You ’ re lucky you start to learn it so easily . I learned English very late , and learned it all by myself . At that time we didn ’ t have a good English studying environment . I have to keep my dictionary on hand . ', ' Really ? ']
["I spend all my time looking after my baby . I'm so tired . ", " Why don't you ask your husband to help you with it ? ", " I've tried it , but he would have none of it . "]
['I ’ m itching for moving ! ', ' What ’ s the matter ? What annoy you ? ', ' It ’ s so wet and dark , I ’ m just fed up . ']
['I understand your feeling . When someone is feeling at loose ends , we may show mercy on him . This is what we call the " milk of human kindness " . ', " That's right . But feeling sorry for someone is one thing , and sticking to our principles is another . We must make a clear cut between them . ", " You've take the words out of my mouth . "]
['I ’ m so excited about Chinese New Year ! When do I get to visit Grandma ? Grandma makes the best dumplings in the world ! ', ' Ha ha , right . Sounds to me like you ’ re more excited about the dumplings than seeing your Grandma . ', ' Of course I miss Grandma , too . I bet she ’ s gonna teach me how to play Mahjong ! Hey , Dad , are you going to buy me firecrackers this year ? We ’ re going to have the best fireworks ! I ’ m really looking forward to lighting them ! ', ' Son , firecrackers aren ’ t toys.they ’ re dangerous ! ', ' No , fireworks are awesome ! ', ' Whoa , don ’ t you remember ? Last year when I set off the firecrackers , you covered both your ears and hid behind your mother ? ', ' I was scared because ... because I saw a bug . That ’ s all . ', ' Ahahah ... really ? ', ' Oh , and I can ’ t wait to watch the dragon dance ! Dad , can I sit on your shoulders this time ? ', ' Hey , I offered last year ... ', ' Well , I ... anyways , I was just thinking of the red envelopes . I wanna make a list of all the things I ’ m gonna buy with my red envelope money ! I can ’ t wait ! I ’ m gonna have so much money ! Mom , can I get a pen and a piece of paper ? I want a new transformer , no , two transformers ... the Optimums Prime , and ... maybe the wheeljack ? I ’ ll get a PSP game , ahahah , and I ’ ll buy the entire class lunch at MacDonald ’ s ... ']
["Hi , Tom . You forgot to put on your sports shoes ! It's Games Day today ! ", " Well , I have them in my bag . I'Il put them on right away ! ", ' Let me give you a hand . You are carrying so many books . ', ' Thanks ! ', ' Have you forgotten the cheers ? ', " No , I haven't . I've tried hard to remember and I'm quite sure I've memorized the rhythm correctly . ", " That's good ! "]
['What a brilliant smile ! ', " That's my cousin Hubert . He likes smiling . ", ' He must be very easy-going . ', " Sure , he's ready to be friendly with anyone . "]
['My goodness.She is thirty seconds faster than the world records in five thousand meters race . ', ' Excuse me.What did you say ? ', ' A chinese girl have broken the world record in the Olympic Games ', " That's incredible . I cann't believe it . ", " You have to . It's sure . ", ' How amazing ! ']
["What's the matter ? You don't look well . ", ' I am worried . ', ' What about ? ', ' My exam . ', ' Oh , is that all ? ', ' I feel very nervous about it . ', " Don't worry about it . Try to look on the bright sight of things . "]
['What do you think of the way people use and treat animals ? ', ' I think most people treat animals well , but we are often cruel to animals . When we raise animals for food , the conditions they live in are often poor . ', ' Perhaps people should stop eating animals . We could grow more crops . ', ' What would you do with all the animals ? You couldn ’ t just let them go . Besides , some people would still hunt them . Meat has become an integral part of our diet . ', ' We could provide them with better conditions anyway . We should certainly try to improve the conditions at zoos . We should try to recreate the natural conditions as much as possible . ', ' That ’ s true . I think zoo are a good idea , because they allow people to get close to animals . I think it ’ s good for kids to see wild animals . ', ' I agree . I ’ m an adult and I love going to the zoo . I don ’ t like animals experiments though . I believe that we can do tests in other ways . ', ' I read that the number of animals being used in experiments is falling dramatically as new techniques are being introduced . ', ' That ’ s good news . The good thing is that most people treat their pets well . ', ' Sometimes you read about people who have been cruel to pets or other animals , but those stories are rare . ', ' Have you every given money to any of the charities that take care of animals . ', ' Yes , I have . They do an excellent job . ']
["It's said you will go abroad to pursue your graduate studies . ", " Yes , I've been thinking about visiting you . I hope to get some advice from you . ", ' Which country do you want to go to ? ', ' My field is electronic engineering . Which country do you think I should go ? ', ' Were I in your position , I ’ d go to America . ', ' Which university should I apply to ? ', ' There are many universities for you to choose from . Some famous universities such as Harvard , Yale , the University of Michigan , and Massachusetts Institute of Technology are really wonderful places to study , but they are very competitive and expensive . Some smaller universities or institutes are also very nice but much cheaper . ', ' Oh , I see . Thank you very much . ']
["How's it going ? ", ' Great ! ']
['So how long have you know Jack ? ', " We go way back.We ' Ve known each other since we were toddlers . ", ' Really ? You guys must be really tight . ', " Yeah , We're buddy-buddy still . ", ' He seems sincere , and trustworthy . ', ' Well , he is , but he can be conniving at times . ', ' What do you mean ? ', " Well , I know that he would never stab me in the back.But I've seen him double cross other people . ", ' Oh , my ! Really ? I never thought he would be like that . ', " Don't get me wrong , I'm not saying he's like that all the time . ", ' So , can I trust him or what ? ', ' Well , I think you should decide for yourself . ', ' But I need someone that I can count on for this job . ', ' Okay , Okay.You can trust him . I was just trying to give you a hard time . ', " Come on you're confusing me.Give it to me straight . ", " Actually , he's the most dependable person I know , and he would never turn on anyone . "]
['Are you free this Saturday evening ? ', ' Oh , it seems there is nothing that evening . ', ' Would you like to go to the concert with me ? ', " I'd like to , where ? ", ' At our club . ', ' When ? ', ' At 7:30 p . m . ', " I'll go in time , thank you . ", " I'm so pleased that you can go . "]
['Can I help you ? ', " Yes . I'd like to borrow these books . ", " Just a second . I'll see if I can find them for you . ", ' Thanks . ', ' Here you are . You must return them within a month . ', " What happens if I'm not finished with them in a month ? ", ' You can come in and renew them unless someone else has reserved them . ', ' OK . Thank you very much for your trouble . ', ' No trouble at all . So long . ']
['You look tired . ', " Yeah , I've been working so much overtime lately . ", ' Really ? How come ? ', ' My boss gave me a big project . I had to have it finished by this morning . It was so difficult . ', " You shouldn't work so hard . ", ' I know , but hard work pays off . You know . ', ' What do you mean ? ', " Maybe now I'll get that promotion I was hoping for . "]
['How do you like Korea ? ', " I like it . It's a beautiful country . ", ' What part of the visit excited you most ? ', ' The best island of Korea-Jizhou island . ', ' Why ? ', ' Attractive scenery , pleasant climate , these make it charming . ', ' Yes , I think so . But there is also something terrible . ', ' What do you mean ? ', ' Sometimes the traffic is too busy . ', ' Yes , you are right . ']
['How should I dress for the party ? ', ' Dress casually . ']
['I love her so much , you know . I want to be alone . Please keep quiet . ', ' I am just casting pearls before swine . ']
['Are you saying you saw an eagle ? There are no eagles here . ', ' Yes , I saw one . Believe me . ', ' You must have seen some other kind of bird . ']
["I haven't met the Smiths for a long time . ", ' They have moved to Chicago . ', ' Why ? ', ' Mr.Smith has changed his job . ']
['Did you go camping last Saturday ? ', " We went to the coast . It's really a nice place for camping , really good time around the fire singing and dancing . ", ' How many members were in your party in all ? ', ' There were six of us . ', ' Did you get caught in the bad storm ? ', ' Yes , we got wet through . But we still enjoyed ourselves . ']
["Thanks for the advice , Mr . Macmillan . I'll keep it in mind . I had better head off though . I ’ m meeting my husband for dinner . ", " Sure , I'm heading out myself . Enjoy your evening . ", ' Thanks , sir . You too . Drive safely , I hear there ’ s a lot ice on the roads . ', ' Thanks for the warning ! See you tomorrow ! ']
["Tomorrow I'll take you to some places that I'm sure you will have interest in . ", " Where else haven't we been to yet ? ", ' They are the Folk Antique Handicrafts and Collectibles Exhibition Halls . ', ' Sounds great ! How many kinds of folk collections do they have ? ', " Well . there're actually over 200 kinds of folk collections in this city . That's half the collections of antique objects in China . There's one exhibition half for multiple collection , and several individual display rooms for private collectors . ", " Private collectors ! They must have excellent collections . I'II go and see each of them . What kinds of collections can I see ? Come on , don't keep me in suspense ! ", " No hurry ! I'II tell you now , The collections include ancient cases and caskets , tea sets , abacuses , precious sea shells and conches , drama costumes , agates , ancient coins , fans , mini-musical instruments , root-carving , rare stones and rocks , model ships , model cars ... ", " Enough ! I can't wait anymore . "]
["The show will be starting in a few minutes . We'd better go in and find our seats . ", " Number 7 and 9 of the Row 11 in the stalls , aren't they ? ", " That's right . This entrance is for even numbers . That entrance over there is for odd numbers . Let's go over there . ", ' What a nice theatre ! I guess it can seat hundreds of people . ', ' Maybe you are right . ', " Look . It's begin . ", ' Well , how did you like the show ? ', " It's so interesting , I like it very much . "]
["Now , you are to board the plane.We ' re sorry that we haven't done much to help you when you stayed in China . ", " I appreciate what you have done for me.Everything I have seen here has left a deep impression on me . I really don't know how to express my thanks to you . ", ' We are ready to help you . ', ' Will you be kind to say " Thank you " to Mr.Zhang and other friends for me ? ', " I'd like to . I'm sure your visit will help to promote the friendship and understanding between both of us.Welcome to China again . ", " Of course , I will.Well , it's time for me to say goodbye.The plane will take off soon.Hope some day you will come to America for a visit . ", ' Thank you . I will if I have chance.Goodbye and happy landing ! ', ' Goodbye ! ']
['Is the lake very polluted ? ', " Well , I wouldn't swim in it - but the water is much cleaner than it was a few years ago . ", ' Are local factories allowed to discharge waste water into the lake ? ', ' Yes , but it must be treated in an effluent treatment plant first . ']
['Isn ’ t this great ? I always wanted to own a farm , live out in the country , grow my own food ! ', ' This is very beautiful . Though I have to confess , I don ’ t know the first thing about farming ! ', ' That ’ s fine ! Don ’ t worry about it ! ', ' What was that ? ', ' Relax , it was just a goat ! ', ' And that ? ', ' It ’ s just the cows that are grazing over there . We can milk them later . ', ' What was that ? ', ' Honey , seriously , It ’ s just a sheep . Relax ! Relax , that was just the horses and donkeys that are in the stable . ', ' You know what ? I don ’ t think I can hack it here out in the countryside . I ’ m going back to the city ! ']
['Well , thank you.Mr.Parry , for all your information.Just one more question . ', ' Yes , sir ? ', ' Do you play any sports or games ? ', ' I used to play football regularly when I was at university.And I used to do athletics in the summer . ', ' And what athletics did you play ? Can you remember ? ', ' I was a runner_a long-distance runner . ', ' And now ? ', " No . I'm afraid I haven't had time since I got married . ", ' Well , thank you again for coming to see us.But just remember that we like people who join the company to play in the company sports teams . ', ' Certainly , sir . ']
["Hey , that's a really nice outfit you have on . ", " Thank you . I wasn't sure if it looked okay or not . ", ' Oh , you look stunning . Your dress really goes well with your shoes . ', " I'm glad that you think so . I thought it might be a bit too revealing . ", ' No , not at all . It looks really classy on you . Where did you pick that up ? ', ' I got it on sale down at the department store . ', ' When did you go there ? ', ' I was just there a couple of days ago . You know , you should go down there too . They have a lot of stylish clothes on sale . ', ' I might just do that . What style of clothes do they have ? ', ' Anything you want . They have both casual and formal styles . ', ' I was hoping to get a few new ties for my collection . ', " That's a good idea . "]
['The poor girl is up to the eyes in study all the day . ', ' Yeah , she has a lot of homework . ', " Today's children have not the chance to play , to make fun of them . ", ' Right . So in some way we are happier . ', ' Yeah , at least when we are children , we have not so much homework to do . ']
['Could you just hold this for me ? ', ' What are you doing ? Is anything wrong ? ', " Yes , but I've nearly fixed it . Just take it , will you ? ", " Oh , yes , of course . I'm sorry-I wasn't thinking ... "]
['Sometimes I think television is too biased . None of them are completely objective . ', " That's unavoidable , but think , How would you keep up to date without television ? ", ' Newspapers or the radio I guess . I just wish TV was more objective . ', " Look , you can still learn a lot from watching television , you just need to be smart when you're watching . Filter the information and decide if you believe what you are hearing or not . ", " The internet's a lot worse . ", ' Really ? Why ? ', " There's no one moderating it . Anyone around the world can put information onto the net for anyone else to see . The information on the internet is mostly unsubstantiated and you can never know who has written it , or why . A lot of people get conned online . ", " Again , you need to think carefully . If you don't trust others online , have nothing to do with them . "]
['I went to the doctor yesterday . ', ' I beg your pardon ? ', ' I said I had been to the doctor the day before . ', ' What did he say ? ', " He said I ' d got the flu . ", ' Oh dear ! What did he tell you to do ? ', ' He told me to stay in bed for ten days . ', ' Ten days ? Would you please repeat it again ? ', ' Yes , ten days . ']
['How nice it is here . ', " You can say that again.The sun is shining and there is a pleasant breeze.It ' s so lovely . ", " I've heard the weather here is ideal , just like spring most of the year . ", " That's correct . We have four seasons of spring . "]
['What did you think of the teambuiding session this morning ? Do you think it did much good ? ', " Well , a lot of the games were pretty silly . I don't know how much it helped us to be a better team , but i think everyone had a good time . ", " I think that's an important part of it all ... we've got to be able to see another side of our co-workers and boss ... We can see what they're like as real human beings , working together on some project , for fun . I really think it helped our team jell together better . ", " Yeah , I guess you're right . I think the trust game was my favorite . I think in order to have a strong team , we've all got to learn how to trust each other more . ", ' The trust game was your favorite , huh ? My favorite part was the personality tests . I think to know more about what kind of personality type you are will tell you a lot about how you can fit into a team.Also , when you know the personality strengths of your colleagues , it helps you understand them better . ']
['Beautiful weather , isn ’ t it ? ', ' Yes , it is . Are you here on business ? ', ' No , I ’ m on a vacation to see the famous Three Gorges . ', ' I ’ m going there for a tour , too . Is this your first trip to China ? ', ' Yes , it is . ', ' Why don ’ t we go together ? I can show you around . I think you ’ ll have a better time . ', ' I couldn ’ t agree more . ', ' Great , let ’ s go ! ']
['Tiffany , why are more and more people turning to the Web to find a mate ? ', ' I think that , as more people use the Internet for both work and pleasure , it makes more sense as a tool to connect with people , and the stigma of meeting someone online is reduced . ', ' There are actually special sites for people looking to date within their specific ethnic group and age group . But how should you screen potential mates ? Do you suggest talking to them on the phone right away or communicating via e-mail ? ', ' I would say do not make the e-mail exchange too long . A lot of times a connection via e-mail creates almost a false sense of intimacy . Quickly make sure there is a connection in the physical world . ', ' Can you give us any other safety tips for people pursuing relationships on the Net ? ', " I'd suggest you not give out too much personal information , like your home address , until after several dates . Just keep up the same guards you would keep up if you were meeting any stranger . ", ' Besides the growth of these matchmaker sites , do you have any stats on success rates ? Are people out there finding true and lasting love through the Internet ', " Well , for a site like ecrush.com , since their debut in Valentine's Day in 1999 , of the 1.5 million people who have joined ecrush.com , 300000 have actually matched . ", ' Do you have any successful stories to share ? ', " Yes , the couple that I highlighted at today's show met on Match.com and they're getting married this summer . "]
["Isabelle , you know I'm not interested in fame . ", " Well , you don't seem to be interested in getting a real job , either . ", " You know I'm interested in teaching . I'm looking for jazz students ... ", ' Yeah , and every high school student in town is banging on your door , right ? ', " I know they're out there . I'll find them . ", " You're such a dreamer ! You think that you can spread the word of jazz in an underpass ? "]
['I think your speech was excellent . ', ' Was it ? ', ' Sure it was . ', ' Thank you.It was really a challenge to speak before such a large audience , you know . ', ' But you did it and did it well ! ']
['Smith is always careless , it is his Achilles ’ s heel . ', ' He would get very angry if anyone criticized him . ', ' He will burn his fingers . ', ' If only he knew it . ']
["Here's some dancing . See those guys stomping , clapping and shouting ? They're practicing step-dancing . ", ' It sounds cool . The rhythms look really difficult . ', " They basically turn their bodies into drums . There's a national step competition every year . ", ' Well , black people are supposed to be great dancers . ', " Wen ! That's only a stereotype . Like all Asians are supposed to be math geniuses . I'm not a great dancer , and you said you failed calculus . ", ' Ha-ha ! You got me there ! ']
["This is the end , Jane . I don't want a girlfriend who goes out with other guys all the time . ", " I won't do it again . Please forgive me . ", " No way . I've given you too many chances already . "]
["What's the bonus like at your company ? ", " Well , it's OK , I suppose . We get about the equivalent of six months ' salary . ", " Six months ' salary ? Are you serious ? That's incredible ! ", " Maybe . But you'd be amazed at how little's left after the credit companies have deducted their share from my account . ", " Hey , I know what that's like . I bought a BMW on my Visa card . Now the payments really hurt . ", " Well , you're lucky that you're still able to make your payments . I missed a credit payment last month . Now my bank account's overdrawn , and the company is threatening to take back my purchases . ", ' What did you buy ? ', ' A new home health monitor . ', " Health Monitor ? I read an article about that racket.They ' re overpriced to begin with ! Listen , if I were you , I'd let them take back their monitor and spend my money on something more practical . ", " You're kidding ! ", ' No joke ! ', " That's something else ! Maybe I'll return it to them . "]
["OK , Ann , you spent quite a bit of time in Australia recently so why don't you talk about that ? ", ' I really liked living in Australia . I was an international student and I studied education at the university of Sydney . And living in Sydney was fantasticbecuase I could go to the beach anytime I wanted and there was a great nightlife in Sydney . There are lots of great clubs . And people were very , very friendly and easy-going and I met a lot of international people in living Sydney . ', ' Mm-hm . How long were you there ? ', ' I was there for almost a year . ', ' Oh , OK . ', " And I travelled a little bit in Australia . I went up the east coast . Up to Frasier Island . Which is a world heritage site . And I saw dingo running along the beach and sharks in the water . We climbed cliffs and went through a rain forest and went camping and then we went up to the ... , which is a but north . And the further north you go in Australia , the hotter it gets . So we were able to go swimming in the ocean and I went diving for the first time but it was a little bit risky cause I didn't have a diving license , so I went on an introductory dive and I saw a giant clam that had a really purple spongy inside that I was able to touch and then the clam closed up really quickly . ", ' So , did you , did you lose your finger ? ', ' Almost . ', " Almost . Ah , you're lucky . Um , it's funny , you go in the water and you worry about sharks , but not clams . ", ' Exactly . ', ' Will you be going back to Australia soon ? ', " I'd like to go and live there for at least another year . Probably I'll go back to Sydney or maybe I'll go down to Melbourne because it's a really interesting cultural city . They have lot of museums and parks . "]
['Tom did me many favors . ', ' For example ? ']
['I have just had my new paper published . ', ' You have done excellent work . ', " I'm going to Britain . ", ' Really ? How did you get the chance ? ', ' I have been accepted by Oxford University on PhD . ', ' My warmest congratulations on your entering the Oxford University . ', ' I really appreciate your kind words . ']
['Happy birthday ! This is for you , Kate . ', ' Thanks , Miss . Wang . ', " You know in China we usually don't open presents until the guests leave . ", " Really ? I've already opened it . Great ! And it is exactly after my fancy . Thank you very much . "]
['Guess who I saw yesterday ? ', " I don't know . Who ? ", ' Avril Lavigen ! ', ' The Canadian rock singer ? But I heard you had a part-time job yesterday . How did you see her ? ', ' Yeah , I worked as temporary staff in her concert . Look , her poster , a CD ... ', " So you're a big fan , eh ? ", " Not really . But I like some of her songs . She's actually very talented . She's a song writer and fashion designer , too . ", ' And she was in a movie once again , right ? ', " Yeah , though I don't think her acting skills are that great . ", ' What was your impression of her when you saw her in person ? ', ' She looked sweeter than her pictures . ', ' Did you take a photo with her ? ', ' No , there were too many people . When she got out of the car , her fans were all screaming , trying to give her flowers and to get her autographs . ', ' Crazy ! ']
['I have to go home now , Jenny . Thanks for inviting me to your party . ', " I'm glad you came . I hope you enjoyed it . ", ' I had a wonderful time . ']
['I was wondering how you are going to calculate our final grades . ', ' Grades are based on many things ', ' What counts the most ? ', " Actually I look at all of it and let's not forget class participation . ", ' Do you grade on a curve or use percentages ? ', ' Homework , attendance , and quizzes are sixty percent ; the mid-term and final are worth twenty percent each . ', ' What if we miss something ? ', ' I will allow one unexcused absence ; after that you need to contact me ahead of time . ', ' Will you tell us if we are failing during the year ? ', ' You will be able to track your progress during the year . ']
["Okay , show me your card hand . Here's mine . I have three Kings and a pair of Aces . ", ' How did you get that ? No need to show you my hand , I lose.This is not as much fun as the music concert we just saw . ', " Thanks again for buying the tickets . That was the most exciting live concert I've ever seen . That silver electric guitar was really cool . ", " They're quite popular now . Wasn't her voice good ? ", ' That , My Heart Will Go On . It warms my heart . you know , JanetJackson , Shanna Twain and Celine Dion are so very different . ', ' Janet Jackson is more pop music.Shania sings country music . Celine just seems to hit all the right notes . ', ' Have you heard Maria Carey ? ', " Yes , l have two of her Cds , l'II lend them to you if you like . ", " Excellent . You can borrow my Janet Jackson's CD . It's her new one . ", ' I hope you have a good stereo . ', ' Why ? ', ' Because you have to hear it really loud to get the full concert effect . ']
["Sarah . You look terrible . What's wrong ? ", ' My grandmother just passed away . ', " I'm so sorry to hear that . When did this happen ? ", ' A couple of days ago . I just go back from the funeral . ', ' Is there anything I can do ? ', " No ... not really . The sad thing is that I wasn't there when she died . I really wanted to be there one last time . ", " I'm sure she knew you loved her . Did she pass away in the hospital ? ", ' Yeah . She died in her sleep . ', " I'm sorry she's gone . ", " At least she didn't suffer . ", ' I think your grandmother would want you to think of all the good times you spent together . ', ' I know . But I miss her . ', " When my grandmother passed away , I frequently visited her in the cemetery . I always talked to her . Even though she wasn't there , I somehow knew she heard what I said . ", " Yeah ? That's what I was thinking too . Thanks . ", " It looks like you haven't eaten anything all day . We should get you something to eat . ", " You're right ... I should eat something . Let's go . "]
['It will do you good to go out for entertainment at weekends.What kind of movie do you like best ? ', " It's hard to say , I like interesting and significant ones . I don't care whether they're blockbusters or not . ", ' Shall we go downtown for a movie this Friday evening ? ', " Very good , What's on ? ", " I'm not sure . Let me give a call to find out . "]
["Let's go eat . ", " 0kay . Dinner's on me . "]
["I can't seem to progress up the career ladder no matter how hard I try and I have been here for 2 years already ! ", ' Well , have you thought of getting an MBA ? I heard it does wonders in getting you to the top . ', " An MBA , hey . . . well my degree wasn't in business , the business schools won't be interested in me . ", ' Nonsense ! The business schools measure your ability through a test called GMAT . ', ' GMAT ? What does that stand for and what will the test contain ? ', ' Graduate Management Admission Test , it contains three parts ', ' Okay , this sounds a little tough , how am I supposed to practice for this ? ', ' Up to you , you could have a one on one session with a tutor or group sessions , you can also use free or private computer software . Going to church might help as well ! ', " No matter what I do , I'm going to ace this test and go on to become a corporate fat cat ! ", " Umm . . . That's the spirit ! "]
['hello , Kate ! How are you doing ? ', ' fine , thanks . How are you ? ', ' fine . How are your term papers ? ', " oh , my lord . I haven't really started them . ", ' how could it be ? They are due two weeks later . ', ' I know but I was busy with my part-time job the last few days . ', " Kate , you know , I am thinking of getting a part-time job next year because I really need more money and I don't want to ask my parents for any more . But I'm so busy ! How am I going to work and study ", " to be honest with you , Jason , I don't think I'm doing a very good job of balancing my schoolwork with my job . I'm always two steps behind . I've got to get back to the dorm and continue writing tha ", ' my advisor ? ']
['This is the good life ! We have it good don ’ t you think ? ', ' Yeah of course ! Although , don ’ t you ever wonder what could have been ? ', ' What do you mean ? ', ' Well , sometimes I think of how things could have turned out if I had done things a little differently . ', ' For example ? ', ' Like for example , if I hadn ’ t studied architecture , I would have become an artist like I wanted to . ', ' I see . Yeah now that I think of it , I wouldn ’ t have gotten married if I hadn ’ t moved to this town and met Sally . ', ' You see ! Everything happens for a reason ! We wouldn ’ t even have met if I hadn ’ t been in that car accident ten years ago ! ', ' Well , I have no regrets ! ', ' I ’ ll drink to that ! ']
['Would you like to go to the movies tonight ? ', ' Well , I just saw a horror movie last night . It almost frightened me to death . ', ' Well , we could see something different like a detective film . ', " I don't care for a detective film . It also makes me nervous . ", ' How about a comedy ? ', " No , I don't think comedies today are natural or cheerful . ", ' How about a love story then ? ', ' No , romance is boring . ', " What's you opinion ? ", " Let's go to see a war movie , shall we ? ", ' Really ? ', ' Certainly . Is there anything wrong ? ', " No , but I can't imagine that a girl like you would wonder to see a war movie . "]
["Hi . Bob ! We've been working hard at our lessons for a fortnight . So why don't we take it easy this weekend ? ", ' Okay ! What do you suggest ? ', ' How about seeing a play ? I hear Hamlet is on at the National Theater . ', ' Is that so ? Why not ? ', " ( looking at a newspaper ) Oh , dear me ! There's no performance at the National theater this weekend . So we have to go to cinema instead . ", " What's on ? ", ' Let me see .. um . Gone With the Wind . It is on at six cinemas on Saturday night . ', ' That sounds interesting . Which is the nearest ? ', ' Ah . The Royal , I think . ', ' What time does it start ? ', " Why don't we go to the 7:30 show ? It is convenient to us , I think . ", " But we won't have enough time for dinner . ", ' Do you want to go to the earlier or the later show ? ', ' Ah ... I fancy going to the later show . ', " Then , there's a 9:30 show . ", " That's Okay , I think . ", ' All right . ']
['Her ex-boyfriend was terrible , but this new one is even worse ! ', ' Out of the frying pan and into the fire . ']
['The man behind your mother must be your elder brother . ', ' Yes , he was 29 then . ', ' He looked his age . ']
["Well , I've got to go . See you later . ", ' See you . Have a nice day ! ', ' Thanks , you too . ']
['What did you say ? ', ' Are you deaf or what ? ']
["Who's your favorite singer ? ", ' Coco Lee . ']
["Hey , Ann . You don't have a pen , do you ? ", ' Sure , here you go . ', " Thanks . I don't suppose you have some paper , too . ", ' Of course . There you are . ', ' Thanks so much . I owe you one . ']
['Are you ready , honey ? ', ' Sorry , not yet ! can you help me to select the dress ? i don , t what i should wear to fit thinner party . ', ' Just dress formal . ', ' How about transom ? ', ' It is too loud , we ’ ll handle some official business first before the dinner . ', ' Oh , i nearly forget it . ', ' You can put on your white shoes , it fits every occasion . ']
["What's the matter with you , then ? You look miserable . ", " It's us . ", ' What do you mean by us ? ', ' Well , we used to talk to each other before we were married.Remember ? ', " What do you mean ? We're talking now , aren't we ? ", ' Oh , yes , but we used to do so much together . ', ' Yes . I remember.But we never used to argue.You used to think I was wonderful.Where are you going ? ', " Back to live with my parents.That ' s something else I used to do before we were married.Remember ? "]
['I think it is time to study . Our chemistry exam is coming . ', ' Oh , I know . When is it ? ', ' December 1st . ', " What's on the test ? ", ' It seems to be from chapter six to chapter ten . ', " Well . I think I'm going to fail my chemistry exam . ", ' Why are you so pessimistic ? ', " I'm not being pessimistic . I'm being realistic . My chemistry is so bad . ", " I believe you can pass the exam with good preparation . Don't lose your heart . ", " Thank you . That's very nice of you . "]
['Are you new here ? ', ' Yes , I am . ', ' Is this your first year in college ? ', ' I actually transferred here from another school . ', ' Which school ? ', ' I transferred from PCC . ', ' How do you like it here compared to PCC ? ', ' I love it here . ', ' Do you like it better here or at PCC ? ', ' Don ’ t get me wrong . I like it here , but PCC is better . ', ' So , why did you leave PCC ? ', ' Because I got my AA and now I am going towards my bachelor degree . ']
["I don't know what I can do now . I'm down and out . ", " You are not the gray train , I guess . But bite the bullet and you'll soon be in the chips again . ", " I hope so . But I'm always caught short . ", " But the darkest hour is the nearest dawn . I bet you'll soon turn the table . "]
['I was just about to go to bed when the telephone rang last night . ', ' Who was it ? ', ' Kate . She said she was too excited to go to sleep . ', ' She never cares about others . ', ' It ’ s true . Guess what we were talking about last night . ', ' Her new boyfriend , right ? ', ' Yeah , how do you know about that ? ', ' I was also interrupted by her last week because of such a thing . ']
['if you can choose , will you marry a foreigner or a Chinese ? ', ' why ? Did tom pop the question ? ', ' not yet . But I wonder if I can get my parents ’ consent . ', ' let me guess , your parents want you to marry a Chinese man , right ? ', ' you are right . It is giving me a real headache . I feel like I ’ m between a rock and a hard place . ', ' I used to have the same problem when I was with my ex . ', ' oh , how did you deal with it ? ', ' I just let it go and continued dating with my Korean boyfriend . But finally we broke up . ', ' oh , it ’ s a pity . What was the matter ? ', ' simple . We had personality clashes and there were too many cultural differences . ', ' like what ? ', ' he hoped to live in the Korean way and asked me to give up working and stay at home to take care of the family . ', ' Oh , I see . In their culture women should put family first . ', ' yes , he said it would be batter for me and for the whole family . But I simply can not quit working . ', " so that's why it ’ s hard to have a happy marriage with a foreigner . ", ' not really . There are many successful mixed marriage around us . ']
["I don't know how to adjust my life . Would you give me a piece of advice ? ", " You look a bit pale , don't you ? ", " Yes , I can't sleep well every night . ", ' You should get plenty of sleep . ', ' I drink a lot of wine . ', " If I were you , I wouldn't drink too much . ", ' I often feel so tired . ', ' You better do some exercise every morning . ', ' I sometimes find the shadow of death in front of me . ', " Why do you worry about your future ? You're very young , and you'll make great contribution to the world . I hope you take my advice . "]
['Hi Joe . You met my new assistant , right ? ', " Emm ... yes . But I wasn't too impressed . I found her a little stuck up . ", " You are kidding , but she's so helpful . ", " Tom ... you are her boss , you kown.Of course , she's helpful to you . ", " Come on . She's like that with everyone . ", ' I don\'t think so actually . She never even says " hello " to me . ']
['Hey , you , pick up that piece of garbage ! ', ' Huh ? Me ? ', " Yeah , you . I just saw you throw a piece of garbage on the ground . Can't you read the No Littering sign ? It's a $ 500 penalty for littering , so go pick it up and put it in the garbage can over there . ", " Why should I do that ? It's only a piece of garbage . Why should you care ? ", ' Because this is a public place , and I want to spend my time here without having to look at your garbage . ', " Listen , I really don't know why you're making this into such a big issue . It's only a small piece of garbage in a large space . It's not like there's garbage everywhere . Besides , someone will come along to clean it up at some time or another . ", " It's not the cleaner's responsibility to pick up after lazy people . It's part of your responsibility to make sure that the place is neat for other people . If everyone thought like you , there'd be garbage everywhere ! The cleaners can't be everywhere ! ", " Ok , whatever . See , I'm putting it in the garbage can . ", " Hold on , that's an item . You should put that in the recycle bin next to the trashcan . "]
['What are you doing this weekend ? ', " I don't have any plans . "]
['If ever you ’ re in Chicago , please do look me up . ', ' Well , yes , I ’ d like to , if it ’ s not too much trouble . ', ' No trouble at all . I think maybe you will meet some of my friends here as well . ', ' That ’ d be fine . ']
['How do you feel about wearing name logos or slogans on your clothing ? ', " I've never really thought about it before . I guess it doesn't bother me . ", " Do you think advertising has an influence on the choices you make when you're shopping ? ", ' I guess so . I usually buy name-brand clothing , shoes , and electronic goods . How about you ? ', " I actually try to avoid name-brand items . I can't stand it when big companies advertise their products all over the place ! ", ' I know that advertisers are experts at persuading people to spend their money , I think brilliant items are usually higher quality than ~ grounds . ', " I think is sensible to buy products that is high quality than others when you want to buy something that's going to last a long time , but I don't think it always makes sense . ", ' Do you have a brand preference for anything ? ', " I do for shower items like shower gel and shampoo , but I don't for higher-end items . ", ' What do you think about the " impossible is nothing " billboard on the high street ? ', " It's just a slogan for a famous company ; there's nothing really special about it . ", " I think it's a brilliant advert ! It really grabs my attention ! ", ' To each their own ! ']
['Did you see the fashion awards last night ? ', ' I sat through about half of it but they lost me after that . ', ' Not interested ? ', ' Not really , to be honest . Some of what they call fashion looks terrible to me . ', ' But they are showing what will be all the rage next year . ', ' All the rage with whom ? I never see anyone wearing these designs on the street . ', ' Did you know that fashion is cyclical ? ', ' What , it keeps coming back ? ', ' Precisely ! For example , Flares were popular for a while , then went out of fashion . Now we can start to see them coming back in again . ', ' Flares ? ', " They're also known as bell-bottoms . They are a type of trousers . ", " It's too complicated . I'll just stick to the plain clothes . ", " That's fine , but then you'll always look plain . "]
['Our national economy is increasing hand over fist . ', ' That ’ s really a good phenomenon to see . ', ' I hope it ’ ll continue for a long time . ']
['Betty was in hospital . ', ' I know that . I met her last week , and she looked as pale as death . ', ' She suffers from cancer . ', ' That ’ s too bad . She ’ s been so kind to us all . ']
['Do you have any plan on your mind ? ', ' I want to see all places of renown in Suzhou . ', ' How are we going there , by bike or by bus ? ', " By bike , of course.You don't want to miss the beautiful scenery , do you ? "]
['Maybe we all will be all things to all men . ', ' How terrible ! ', " But for the life , we'll be changed by this society . ", " I really don't want to go into the world , I feel afraid of it . ", " Don't be silly . We have reached the age to take the responsibility by ourselves . ", ' I know . ']
["You're late . ", " I know I'm late . I'm sorry . I tried to call you to tell you , but your phone seems to be disconnected . ", ' My phone ? ', ' Yes . An automatic message says your phone is not in service . ', " Really ? I had no idea . Let me check.Yes , it's dead . There's no dial tone . ", " So I couldn't get through . I knew I'd be late because my car wouldn't start.It was too cold I had to warm it up in the garage with a heater . That's why I'm late . ", " But this is terrible . I'm expecting important calls . ", ' About what ? ', " You know what.The theater guild is supposed to call me and discuss a contract for my play.They are supposed to call me this evening.If I don't have a phone . Oh , what can I do ? ", ' Well , the only thing you can do is tell the phone company and hope they fix it fast . ', ' Do you have a cell phone ? ', " No . I hate cell phones.But you could go to a neighbor's house and use their phone . ", " Can you drive me ? I will go to Ann's house . It isn't far . I can call the theater guild from there and give them her number.She will let us wait in her living room . ", " Yes , of course I can drive you.So you don't want to get your phone fixed right away ? ", " Yes , I do.At Ann's house I will call the phone company and have them check my line.If they can fix it right away without coming to my house , then we'll just return here.But if not , I need to wait at Ann's house to talk with the theater guild.It ' s very important to me . ", " Alright , let's go . ", " Yes , let's go . "]
['Would you like to go to a concert tonight ? ', " I'd like to very much . ", ' All right , then.There is one at the new concert hall . ', " Who's playing ? ", " It's the Powell orchestra . ", ' Do you know what they are playing ? ', " They're doing a seventeenth-century program . ", ' And who is directing ? ', " Well , I'm not sure of his name , but I know it's going to be his farewell performance . "]
['I am unsure how to add a class and need help . ', ' I have an opening . Do you have an add sheet for me to sign ? ', ' Yes , I have an add sheet . ', ' After I sign it , you must take it to the Admissions and Records Office to add the class . Do you know where that is ? ', " No , I'm not sure . ", ' When you cross the quad , the office is right in front of you . Go inside and follow the signs to the correct line . ', ' Thanks . I understand what to do now . ', ' It should be easy to find . After you add the class , check with me in a few weeks to make sure that you are on my roll sheet . ', ' That sounds good . ', ' Good , just make sure that you do the same thing if you ever need to drop a class . Good luck ! ']
["I found out when Jim's birthday is . It's this Friday . ", " Let's plan a surprise party for him ! ", ' Can you spread the word and ask everyone to bring some kind of snack food ? ', " That's easy . Anything else ? ", ' Will you call his wife and let her know so that if she is available , she can come too ? ', " Won't he be surprised ! ", " I don't know how old he is though . ", " That's O . K . Maybe his wife will spill the beans ! "]
['In spring , people are feeling refreshed . They take off their heavy winter clothes and walk with a straight back and light steps . They feel they are full of spirits and energy . ', ' Women in particular . They are anxious to get rid of those thick and clumsy winter suits and put on their new fashionable spring dress . ', ' Well , when summer comes , the weather is hot and the leaves turn darkgreen ; the sun is blazing and the air is threatening . No one would like to stay in the open air for long . ', " That's true . In summer , the first place people want to go is a spacious room with air-conditioning or a quiet river or swimming pool . ", ' I myself like very much to listen to the singing of some of the insects , especially the singing of cicadas . ', ' In autumn , almost all fruits are ripe and all crops are waiting to be harvested . ', ' And you can hear singing and laughing everywhere ! People are happy in autumn because autumn brings them harvest and richness and prosperity ! ', ' Well , winter is a season for relaxation , do you agree with me ? ', " Well , it's hard to say . For the fields and rivers , winter is a relaxing season , but for farmers , I think they might take a rest physically , but mentally they are still busy thinking , planning and calculating for the working of the next year . ", ' Maybe you are right . ']
['Hey Sarah , are you all right ? You look upset . ', " As a matter of fact , I am a bit upset . I just came out of a meeting and it didn't go very well . ", ' What happened ? ', ' No one would listen to any of my suggestions . Instead , they just kept arguing with each other . ', ' Who was chairing the meeting ? ', ' Bob . ', ' Well , I can tell you from experience that Bob might come off a little strong sometimes . ', " That's exactly what happened ! He kept interrupting everyone with his own suggestions and did not want to hear what others had to say . Then he expected everyone to agree with him . ", ' What was the meeting about ? ', " We were trying to come up with ideas to streamline the office's workflow to make it more efficient . ", " It's ironic that the meeting was anything but efficient . ", " Exactly . I had tons of ideas that I wanted to share , but they just wouldn't let me finish . What should I have done to get my point across ? ", ' You have to keep things short and sweet . When you get a chance to speak , try not to get into too many unnecessary details . ', ' Short and sweet ? But what if I have to explain something complicated ? ', ' You can always bring up the main points during the meeting and speak to those who are directly involved after the meeting . Not everyone needs to know all that information . ', " That's a good idea , I think I will try that at the next meeting . "]
["Let's go to the cinema tonight , shall we ? ", ' Good idea . Is there a good movie on ? ', " What about ' Farewell My Concubine ' ? I've been wanting to see it for a long time . ", " All right . But it'll be difficult to buy tickets I suppose . ", ' My brother has offered me two tickets for this evening . ', ' What time does it begin ? ', ' At eight thirty . ', " I'll come for you at about eight . ", " OK , I'll be waiting . "]
['I ’ d love to have my own farm . ', ' It would be very hard work . Are you sure ? ', ' I wouldn ’ t mind getting up early morning and the physical work would make me fit and healthy . ', ' Running a farm would be totally different to you current job . ', ' That ’ s one reason I ’ d like to try it . I ’ d really like to get away from working 9 to 5 in an office . ', ' You ’ d need a lot of training before becoming a farmer . It ’ s not something you can just walk into . ', ' My uncle owns a farm and I ’ Ve spent some time working with him . I love being in the countryside with farm animals and green fields . ', ' Well , I ‘ d certainly come and visit you . It would be great to take a working holiday on a farm . I ’ d love to get away from hustle and bustle of the city for a while . ']
['Good afternoon , everyone . The experiment is to start at 3 . Have you gone through the instructions ? ', ' Yes , sir . ', ' Ok , now some points for attention . First of all , pay attention to safety ... Now , sign your names on the lab record , and after that you can start . If there is any question , just let me know . ', " Excuse me , sir . This air compressor doesn't work . ", ' Have you turned it on ? ', ' Yes , I have . ', ' Ok , I will get you another one . ', ' Thank you . ']
['Guess what ? Paul and Susan are engaged . ', ' Really ? When did that happen ? ', ' A week ago ? They met last summer and now just sink . They will be married soon . ', ' Have they set a date for the wedding ? ', ' No , not yet . But Susan says they ’ d like to get married in November or December . Then they ’ ll go to Hawaii for their honeymoon . ']
['Oh man ! I ’ Ve been starving myself for days now and I haven ’ t lost an ounce ! ', ' Are you trying to lose weight ? ', ' Yeah , my friend is getting married next month and I ’ m supposed to be a bridesmaid . I have to fit into my dress and look nice for her wedding , but I haven ’ t lost any weight ! Look at these love handles . ', ' You don ’ t have to starve yourself to lose weight . I think that ’ s where you ’ re going wrong . ', ' Why ? If I eat less , then my body will start eating away at my fat reserves , right ? ', ' Not really . You should try to not eat foods high in calories , salts or saturated fats . Stay away from oily food and artificial flavors . ', ' So you are saying that I should eat , but I should just watch what I eat ? ', ' Yes ! You can also try to reduce your intake of carbohydrates and foods that are high in cholesterol . You can have steamed veggies or increase your protein intake found in chicken or fish . ', ' If I do all this do you think I can lose twenty pounds in four weeks ? ', ' Don ’ t count on it . ']
['Do you know that song ? ', ' Which song ? ', ' The song you hear now . ', " No , I've never heard of this song before . It's beautiful ! Who sing it ? ", " Elvis Presley . Don't you recognize his voice ? ", ' No . How about going to karaoke tonight ? ', ' Good idea . ']
['How are you ? ', ' Fine . ', ' I haven ’ t seen you for several days . ', ' Oh , I have been with my uncle for a week . ', ' What ’ s he doing ? ', ' He is an accountant . I have been helping him for a week . ', ' He must be happy . ', ' Yeah . How are you these days ? ', ' Fine too . ']
['What did you do this weekend , Kate ? ', ' Oh , Diane and I went for a drive in the country on Saturday . ', ' That sounds nice . Where did you go ? ', ' We drove to the lake and had a picnic . We had a great time ! How about you ? Did you do anything special ? ', ' Not really . I just worked on my car all day . ', " That old thing ! Why don't you just buy a new one ? ", ' But then what would I do every weekend ? ']
['I ’ d better be going . ', ' So soon . Why don ’ t you stay a little longer ? ', ' I wish I could , but It ’ s already late . ', ' Oh . It ’ s pity you have to leave . ', ' thank you for wonderful meat . ', " I'm glad you enjoy it . "]
['Did you remember to bring back that software I lent to you ? ', ' Oh , I ’ m sorry . It completely slipped my mind . ', ' That ’ s ok . If you could just bring it in tomorrow , I would appreciate it . ', ' Definitely , I ’ m really sorry . ']
["Well , known , Jim , I'm ... I'm pretty much in favour of computers , I think computers teach kids to think , because they require logical thought . ", " But I ... I don't agree with that , because computers weaken kids ' ability to think , because kids don't learn basic skills . ", ' What do you mean ? ', " They can't spell , they can't add , they can't subtract , they even don't remember any more.that ' s because they rely on gadgets . ", " That's not the gadgets.Creating programmes is stimulate thoughts . "]
['All right . But these are black and I don ’ t like black shoes . They ’ re dull . ', ' Well , black is a better color than pink . Pink ’ s for girls . ', ' Then why are you wearing black shoes ? ', ' Because ... oh , all right . You win . Let ’ s pay for them and go . ', ' Hey , thanks , mum . ']
['Hey , Mike . Can I ask you something ? ', " Sure , what's up ? ", " I'm going to gamble on the world cup tonight . Who do you think will win ? ", ' Good question . I have to think about it . ', ' My husband is betting on France . ', ' France ? Is he crazy ? ', ' What do you mean ? ', ' Well , how do I put this ? France is a terrible team . ']
['How do you do . I ’ m Mark Rancor . ', ' Nice to meet you . ', ' May I know your name , please ? ', ' I ’ m Rose Teller . I think I ’ Ve seen you somewhere before ? ', ' Ah , yes . I remember now . Were you Mr . John ’ s dinner partner last month ? ', ' Yes , I was . You work for 3M , right ? ', ' I did but now I ’ m for Microsoft . How are things with you ? ', ' Good . ', ' May I know what you do ? ', ' I ’ m a fashion designer . Next month , I have a fashion show . I ’ d love it if come . I can get you a couple of tickets . So you can bring a friend if you like . ', ' Sure . That would be great . Good luck . ', ' Thank you . ']
["What's the name of the series just showed ? ", ' Doctor Butcher . ', ' What a horrible name ! Is it full of suspense ? ', " No , not at all.it ' s about how to keep fit . "]
['What ’ s “ pi ” ? ', ' That ’ s the ratio of the circumference of a circle to its diameter , I think . ', ' I see . What is that ratio exactly ? ', ' It ’ s approximately 3.14 , but the number continues forever . What ’ s the diameter of your circle ? ', ' It ’ s 10 centimeters , so the circumference should be 31.4 centimeters . ', ' Ok . My next problem is to convert 10000 british pounds into us dollars . What ’ s the exchange rate at the moment ? ', ' According to the newspaper , the exchange rate is 1.85 dollars to the pound . ', ' That means that 10.000 pounds will buy me 18.500 dollars . ', ' What ’ s the next question . ', ' Fractions . What ’ s a quarter and an eighth ? That ’ s three-eights . Easy . The next question is “ what are prime numbers ? ” . ', ' I can help you there . Those are numbers that cannot be created by multiplying two whole numbers , apart from the number itself and 1 , together . ', ' So , 1,2 and 3 are prime numbers , but 4 isn ’ t because 2 * 2 = 4 . ', ' Exactly . Anything else ? ', ' How many seconds in an hour ? 60 seconds multiplied by 60 minutes equals 3600 seconds altogether . ', ' You ’ ll be a mathematician one day . ']
["How's your new car ? ", " Perfect . Couldn't be better ! ", ' You made a good choice , then ? ', " It's just what I wanted . ", ' No regrets ? ', " I'm really pleased with it . Thanks . ", " I'm glad you're so happy . ", " It's super . "]
["Thank you.Steven.That was the most magnificent meal I've had abroad.You ' ll have to let me reciprocate the next time you're in Beijing . ", " Don't worry about it , Lin.That ' s no big deal.You know , Americans appreciate China's rich culinary culture . Just excuse me for a second while I check the number here and figure out how much to give the waiter.Hmm , by the way , what do you do about tipping in China ? ", " We don't . ", " No tipping ? Now that's what I call a civilized system . ", " At hotels and some restaurants they add a service charge to the bill , but other than that , tipping isn't customary . ", ' What about cab drivers and porters ? ', " In a cab you just pay what it says on the meter . I generally tip hotel porters 10 yuan per bag , but in first-class hotels they're instructed not to accept gratuities . ", " You'd have a revolution on your hands if you tried to introduce that sort of system here . "]
["Morning , Mary . I haven't seen you in a long time . What's up ? ", ' Oh , I took up a new hobby . ', " So you don't travel a lot now ? ", " No , Frank . I'm much more interested in collecting stamps now . ", " It's certainly a popular hobby . I know a lot of people love stamps . ", " It certainly is . It's so much fun . ", ' I believe collecting stamps has something similar to traveling right ? ', ' Absolutely . Through all kinds of stamps I am able to learn about the world . ', ' Well , every stamp has a story to tell . ', " You're right . And I also meet many new friends while collecting stamps . ", ' Good . ', ' Sometimes we even spend hours discussing our collections . ', " There's a lot to share when you have a common interest . ", " Yes , it's really amazing . I got to go now . I'm meeting with some other collectors . ", ' Ok , good luck . See you ', ' See you , Frank . ']
['I am in hot water now , all the things seem to be blown up . ', " Don't be scared.Bite the bullet and everything will be right again . ", ' Thank you for encouraging me . There are problems cropping up here and there . But I will over come them one by one . ']
['What a beautiful view , my sweetheart ! ', ' It sure is.The Grand Canyon is truly masterpiece . No man could ever make anything like this . ', ' What is that below ? ', ' It is the Colorado River . You will go down the river in a boat if you wish . ', ' No , thank you.It looks a bit too dangerous for me . ', ' There is a beautiful state park here . I can see why so many people come out here to camp . ', ' Yes , there is this beautiful view . you may go fishing , camping and also enjoy this beautiful clean air . ', ' It definitely is a nice change from the polluted and crowded city . ', ' You are so romantic , my sweetheart . ']
['Our neighbour ’ s tape recorder is so loud that it annoys us to death . I ’ Ve made up my mind to cut the electricity off . ', ' What ? That would be to cut off your nose to spite your face . ', ' Then what shall I do ? ', ' Call the police . ']
["David , what's new with you ? You are not in the mood . Can you tell me ? ", " After six months , my college life will come to the end . The following trouble will be the job-hunting . That's really a headache . ", ' Do not take things so seriously , my pal ! Every one of us will face the trouble and job-hunting is inevitable . Take it easy ! Believe in yourself and some day you will be successful . ', ' It sounds reasonable . Maybe I should look on the bright side . ']
["What's the matter ? You don't look well . ", ' I am worried . ', ' What about ? ', ' My exam . ', ' Oh , is that all ? ', ' I feel very nervous about it . ', " Don't worry about it . Try to look on the bright sight of things . "]
["What's wrong , Frank ? ", " I didn't make the soccer team . ", " Cheer up ! It's not the end of the world . "]
["Jenny , you look terrible . What's eating you ? ", " Don't brother me ! ", " Hey , Chillon , I'm just trying to help . ", " Sorry , Sally , it's not your fault . ", " So , what's the problem ? ", ' I drew a blank on ~ about the test . ', " No kidding ! Didn't you study for it ? ", ' Yeah , but nothing was clear during the test . ', " That's too bad , anyway , I'm sure things will turn around next master . ", " I'm thinking of dropping out . ", " You can't do that , Jenny ! ", " I'm dead serious about this , Sally . ", " Come on , let's talk about it . "]
["She's pretty and meek . ", " No , I can't agree with you . She's one but not the other . ", ' What makes you think so ? ', " She's my wife , you know . "]
['Hey , did you hear the news ? ', " No , what's up ? ", " Miss Yang is dating the manager who's married . ", " You're joking ! ", " No joke ! That's why she hasn't married yet . "]
['David , why didn ’ t you clean the room ? ', ' I ’ m not in the mood . ', ' Why are you feeling depressed ? ', ' I was told my girlfriend was speaking ill of me . That ’ s a real let-down . ', ' I don ’ t think she will do such a thing . ', ' But she did and made me disappointed . ', ' Oh , cheer up . A girlfriend is not everything . ', ' But she means a lot to me . ', ' Then forgive her mistake . ', ' Oh . I just can ’ t forget it . ']
["Betty , would you please read this letter of application I've just written ? I'd like to have your opinion . ", " I'd be glad to tell you what I think . ", " Good ! I'm interested in your advice . ", ' If I were you , I would change the beginning . You should write about your education first because we like to judge a man by his abilities . ', ' Good idea , Betty . What would you think about the second part ? ', " I think it's too short . You'd better say something about your work experience . ", " You're right , I'll change it . How about the last part ? ", ' Very good . But you should talk about your family , too . ', ' I agree . I appreciate your helping me . ']
['Well , everything is packed and ready to go . ', " It's hard to believe that we're really leaving . The past two weeks was like a dream . ", ' Yes . Just think the blue sky , sunshine , mouth-watering food , centuries-old castles - - ', ' And the people were so friendly ! ', ' Yeah , we would have been lost without the help of the locals . ', ' Do you still remember the small restaurant at the corner of the street ? ', " Of course . That was the best pasta I've ever had . ", " I ate so much that I wasn't hungry until afternoon the next day . ", ' If only we could eat there once more ! ', ' Maybe we can come here again next summer . ', ' Hope the restaurant is still there . ', " Hey , what's the time ? ", ' Oh , my god ! Only two hours left before the plane takes off . We need to be at the airport now . ', " Don't worry . We can call a cab . It'll be alright . "]
['Do you live with your parents ? ', ' No , they live in Shanghai , my hometown . ', ' How often do you go back to visit them ? ', ' Once a year . ']
['Did you watch the live telecast of the World Cup last night ? ', ' I missed it . I watch a live show of a concert . ', " What's the band called ? ", ' Love Music Woman ']
['Here comes the birthday cake . ', ' Wow , what a lovely cake . ', ' Be sure to blow out all the candles in one puff . ', ' Oh , they all went out ! Did you make a wish ? ', " Yes , but I doubt if I get it . I've never get it . ", ' Better luck this time . ']
['Lisa , I ’ Ve been thinking of something . ', ' What is it ? ', ' Well . I ’ Ve done a lot of business for my company . And now I feel like going into business for myself . ', ' Do you mean you want to sell up your company of your own ? ', ' There ’ s a possibility . What do you say ? ', ' That ’ s not a bad idea . Bet after all you should get some sound financial guarantee . ']
['What are the seasons like in your city ? ', ' Summers is hot and usually lasts a long time . Winters are short , but cold , wet , and windy . I love the summers in my city , but I hate the wintertime . ', ' Does it ever rain in summer ? ', ' We usually get a big thunderstorm every two weeks , but apart from that , summers are dry . Thunderstorms make the air fresh again , so most people don ’ t mind then . ', ' What are spring and autumn like ? ', ' I like spring because flowers bloom and trees grow leaves again . In spring , the weather is very changeable-sometimes cold , sometimes warm . It ’ s usually windy with some rain . Autumn is usually sunny an ', ' Well , I live in the southern hemisphere , so our summertime is your wintertime , and vice versa . We get some rain in every season , but most is in winter . In winter , it sometimes gets cold , but our wine ', ' Do you usually go on a summer holiday ? ', ' No , I don ’ t . I go on a winter holiday instead . I go somewhere warm . ', ' I usually go on holiday during the spring or the autumn . I try to go somewhere where the weather is more reliable than in my city . ']
["I have some good news for you . We've decided we'd like to send you to Shanghai on a business trip this weekend . ", ' oh . ', " don't you think that it'd be a good thing for you to get out of the office for a couple of days ? ", ' sure . ', " I thought you'd be a bit more excited about this . Everything will be paid for and I'll send my assistant with you to take care of everything for you . All you have to do it get on the train tonight a ", ' the train ? Will I be flying back then ? ', " oh , no . We've brought your return ticket for you . I think you'll find it comfortable . ", ' will the train be very crowded ? ', " oh no . the train hasn't been crowded at all recently . Besides , you're in first-class , so you'll be fine . ", ' when is the first meeting then ? ', " they've scheduled the negotiation meeting for 9:00 tomorrow morning . That should give you enough time to have a quick shower . ", ' where will I be staying ? ', " we've booked you a room in the same hotel as your meetings , so you won't need to deal much with the transportation system . ", " that's very sensible . Would it be alright if I left early today to prepare for the trip ? ", " that's not a problem . Have a nap if you can . You don't know how tight the schedule is for this business trip . "]
['what ? How could you forget to reserve the concert tickets ? ', " I'm sorry . I forget all about it . ", ' How could you ? I reminded you just this morning . ', " It's leap my mind . I really feel terrible about it . ", ' I have been looking forward to this performance all month . ', " I'm really sorry I let you down . I'll make it up to you somehow . "]
['Say , Jim , how about going for a few beers after dinner ? ', ' You know that is tempting but is really not good for our fitness . ', ' What do you mean ? It will help us to relax . ', " Do you really think so ? I don't . It will just make us fat and act silly . Remember last time ? ", " I guess you are right . But what shall we do ? I don't feel like sitting at home . ", ' I suggest a walk over to the gym where we can play singsong and meet some of our friends . ', " That's a good idea . I hear Mary and Sally often go there to play singsong . Perhaps we can make a foursome with them . ", ' Sounds great to me ! If they are willing , we could ask them to go dancing with us . That is excellent exercise and fun , too . ', " Good . Let's go now . ", ' All right . ']
["Have you heard anything about Markweed Inc . ? They have called me back for interview , and I'm considering taking a job with them . ", ' Well , to start with , Markweed Inc . has a reputation for being one of the best employers in the field . ', ' The best ... huh ? With so many companies out there , how did they establish themselves in such a solid position on top ? ', ' First of all , they have an excellent benefits package for all employees , even the maintenance staff have health and dental coverage . ', ' Really ? What about the pay rate ? Are the wages pretty high ? ', ' From what I hear , they are very reasonable . A lot of the prestige the company has built is because they have attacked some high profile employees with their incentives . ', ' Well , what about the work environment ? Not every one is motivated solely by money . ', " It's a great place to work . They give you fair pay and benefits , and a lot of room to grow . I think if they off you a job , you should definitely take it . "]
["Terrible . How about people's lives ? ", ' Fortunately , there is no person died . ', " That's great . It seems that Typhoon is not as bad as earthquake . ", ' Yeah . Earthquake is one of the most badly natural disasters in the world . ', " That's why many people died in the earthquake . ", " Well , China is located on the Eurasia plate , where earthquakes happen frequently due to the earth's plates knocking against each other . ", ' Oh , China does have been plagued by numerous destructive earthquakes during its long history . ', " Yeah , we've experienced the 8.0 magnitude earthquake in Wenchman . ", " We're all familiar with natural disasters . but we still feel weak when we face Wenchman earthquake . ", ' Right . But people at that time only know two words , " save " and " assistance " , they will never don\'t lift a finger . Life is the most important compared with anything else . ', " That's the point . Love among human beings is not limited by geography . "]
['Do I have to take these books here if I want to renew them ? ', ' You can renew the books over the computer . ', " That's so convenient . "]
['I always feel I ’ m left high and dry with nobody to rely on . ', ' Don ’ t be fool . I ’ ll always side with you . ', ' I appreciate your kindness . ']
['Did you play football yesterday ? ', ' Yes , I played with Tony and John . ', " What did you do after you'd played football ? ", ' We all went swimming . ', ' Are you going swimming again this afternoon ? ', " No , we aren't . We're going to help Mr Smith to plant some flowers . ", ' Are you helping him all afternoon ? ', ' Yes , we are . We can neither play football nor do our homework today . ', " You're , going to be very busy . ", " Yes , we certainly are . But Mr Smith is going to pay us for all the work we'll do . "]
['Welcome , Ron , come on in ! ', ' Hi , Malia ! What a nice home ! ', ' We enjoy it too ! ', ' How long have you lived here ? ', ' About four years now . ', ' Well , it is very beautiful . ', " Ron , have a seat and I'll get us something to drink . ", ' Good ! I am really thirsty . You know it really is hot outside ! ', ' I have lemonade , iced tea , and mango juice . ', ' Mango juice would be perfect . Thank you ! ']
['Is there a lot of oil and coal in your country ? ', ' There is some , but my country is not amongst the leading producers . The oil and coal deposits are in the north of my country . Your country is a big oil producer , isn ’ t it ? ', ' Yes , it is . My country is famous for having that natural resources . We also have a lot of natural gas . ', ' We have some too . Do you have a lot of coal ? ', ' No coal has been discovered in my country , but there may be undiscovered deposits . We don ’ t have many metal deposits . ', ' There are a few in my country . We have deposit of gold , but they are very small . ', ' When I traveled around your country , I bought some jewellery made from gold from your country . The jewellery told me that there are few gold mines in your country . The gold was found in mountain steams . ', ' That ’ s right . A few people go panning for gold in rivers . ', ' You have many trees in your country . That ’ s another natural resources . ', ' It ’ s a natural resources that we hardly use . Government policy is to conserve those forests . ', ' I see . That ’ s probably a good idea . Too many forest are being destroyed . ', ' Is your country ’ s environment being damaged by the oil industry ? ', ' We have some inspections , but it is very hard to avoid pollution when extracting oil . There has been some damage , but it is under control . ']
["Don't you have too much to do with him . ", ' Why not ? ', ' His father is a prisoner . ', ' So what ? His father is in prison , not he . ']
['ORG ! It must be so late where you are . What time is it ? ', ' just after 2 am . ', " what's wrong ? Can't sleep ? ", ' nope , actually I was waiting for you . I have something big to tell you . ', ' really ? What is it ? ', ' I have an offer to work for a company in your city today ? ', " I can't believe it ! Is it real ? You're moving here ? ", " I haven't accepted the position yet and with the upcoming holiday I think it's the perfect chance to visit the city and take a good look at the company before deciding . If you have time I think we c ", " just give me the dates and I'll make sure I'm free . You know after all these chatting online , it will be great to meet you in real life . I look forward to seeing you soon ! ", ' me too . But I think I am going to bed now . my head is getting heavy . Have a nice day there ! ', ' thanks . This is so exciting . Sleep tight and sweet dreams ! ', ' talk to you later . ']
['You really should stop smoking , you know . ', ' I know . I know . I don ’ t smoke too much , though . ', ' How many cigarettes do you smoke a day ? ', ' About a pack , more if I drink . ', ' Wow . You ’ re really a heavy smoker . ', ' No , I ’ m not . My father smoked two packs a day for forty years . ', ' He died of lung cancer , right ? ', ' Yeah ... you ’ re right . I really should stop smoking . ']
['Why are you so rude to your wife ? ', " I didn't like her butting in where I didn't want her . She's a chatter box . ", ' But she means to help you , not to trouble you . ', " I know . But I just can't stand her butting in when I was trying to emphasize a point . "]
['OK , Hello ! ', ' Hello ! ', " Hi , what's your name ? ", ' Yeah , my name is Nandu . ', ' Nandu . Nandu , how do you spell you name ? ', ' Yeah , my name is like N-A-N-J-U . ', " Oh , OK . That's a nice name , Nandu . And where are you from ? ", " I'm from Madras . "]
['Be quiet , Will you ? ', " I'm sorry . "]
['I have to miss school next week . ', " Isn't there some way you could work your schedule out to be here ? ", ' Unfortunately , this is what I have to do . ', ' How are you going to catch up ? ', " I've got it all covered . ", ' If you miss this class , you will have used up your quota for the semester . ', " Don't worry , this will be the last class I miss . ", ' Make sure to remind me right before you are absent . ', " I'll remember . ", " Enjoy your day off and don't forget to study ! "]
['There will be a party in my company ; what shall I wear ? ', ' Is it formal or informal ? ', ' I guess it is a formal one because the general director will give a speech there , and most of the staff will take part in . ', ' In that case , formal suit with a nice tie will be better . ', ' You are right . What about shoes ? ', ' The brown leather shoes are OK . ', ' Thanks a lot . ', ' Don ’ t mention it . ']
['How do you think about our boss ? ', " He's the nicest boss I've had . ", " Yes , I think he's the most relaxing person in management . ", " What's more , he said I was the hardest working person in the office ! ", " That's good . Maybe you'll get promoted . ", ' I hope so . ']
['Well , no one could survive without water , but you see pollution has been making more and more water unable for drinking . ', ' Yeah . Water pollution has for a long time been a major concern among the environmental issues . ', ' But what are the sources of water pollution ? ', ' They could generally be divided into two categories , direct and indirect contaminant sources . ', ' Well , direct ones are the pollution directly from factories , refineries waste treatment plants etc . , aren ’ t they ? ', ' Yeah . They are emitted directly into urban water supplies . ', ' But what about the indirect ones ? ', ' Indirect sources include contaminants that enter the water supply from soils or groundwater systems and from the atmosphere via rainwater . ', ' I see . For the sake of us all , we should be an active participator in the prevention of it . ', " Sure . It's an issue asking for everyone's participation . "]
["I'm tired of dancing . ", " But to me it's really enjoyable . ", " Maybe it's because you always have pretty girls as your partners . ", ' Maybe so . ']
['I ’ m sick of my job , I always have to work late at night , and the company keeps me working in the office . ', ' Why don ’ t you find a new career where you can do what you enjoy , being outside working during the day ? ', ' What do you suggest ? I can ’ t afford to quit my job until I get a new one . ', ' Maybe you have two choices . You could attend school during the day , or you could get a position that provides training . ']
['I just dropped in to say good-bye . ', ' What time are you leaving ? ', " I'm going to try to leave by ten . ", ' Take care and give my best to your parents . ', ' Good-bye . Hope to see you soon again next year . ', " Don't forget to call us if you're in Tokyo . "]
['David , recently I established a travelling forum , and now I want to make a plan to hold the first activity . Where can we go for this time ? ', ' How many members are there in your forum ? ', ' a dozen . ', ' I think we can visit West Lake . The landscapes are attractive . It is said that just as there is paradise in heaven , there are Su Thou and Hang Thou on earth . ', " It's surely worth going to . There are ten famous spots there . ", ' What can we do next after locating the place ? ', ' Inform my members to prepare for the travelling . And then we can discuss about the travelling costs . ']
['My mom is three years older than my dad , and they are like night and day.My mom is 5 footsweet and very nice , and very caring , and very cute , everybody tells her how young she looks , and how she resembles my sister , perhaps.My father is very much completely opposite that.He is a very bi 4 , on a good day , 5 foot 2 , I think in real life , and she is very nice . ', ' When is the last time you talked to you parents ? ', ' I talked to them probably about two weeks ago . Yeah , everything is going well . ', ' Are you going to see them soon ? ', " I am going to go home after the holidays and we're going to have a Christmas kind of in January or February . Yeah , depending on when my brother can come in . ", ' OK . And who are you more like , your mother or your father ? ', ' I think I have traits of both , actually . I look more like my mother . ']
['We have to pick up Conrad before the party . ', ' Alright , no problem . ', " We're supposed to meet him at Cal's Bar at 10 ", " Wait a minute . Cal's bar ? ", ' Yes . ', " That's a gay bar . ", " Yes , it is . Conrad is gay . Didn't you know ? ", " I thought he was maybe gay , but I wasn't sure.Anyhow , you don't expect me to go into a gay bar , do you ? ", " Why not ? We're supposed to meet him there . ", " Why doesn't he meet us outside ? ", " Why should he do that ? It isn't illegal for us to go in . ", " Yeah , but who wants to go in ? I'm not gay , you know . Why should I go in a gay bar ? ", " You sound like you're afraid . ", " I just wouldn't be comfortable . ", " You've never been in a gay bar before ? ", ' No , never . ', " But it's just a bar . There's no danger.You shouldn't be so homophobic . ", ' Well ... ', " Listen . If you refuse to go in , Conrad will be offended.You don't hate gay people , do you ? ", " No , I don't . But I never went into a gay bar before . ", " Don't worry about it . There is nothing strange about it.If Conrad's there , we'll leave for the party.If he's not , we'll sit down and have a drink . ", " Okay . I will try it . I suppose it isn't reasonable for me to refuse to go in.After all , gay people aren't afraid to go into normal bars . ", " I'm glad you feel that way.We ' ll leave in about ten minutes , alright ? ", ' Fine . ']
['Are these your triplets ? They ’ re beautiful ! I ’ Ve seen other babies who were nothing but skin and bones at their age . You know , they ’ re absolutely identical of you and John ! Are you planning on having any more ? ', ' Bite your tongue ! I ’ m already at the end of my rope . Some nights I don ’ t sleep at all . John manages to sleep like a log even when the babies are screaming at the top of their lungs . ', ' Well , tell me . How was the labor and delivery ? ', ' I wouldn ’ t say that I had the time of my life but at least everything went without a hitch . ', ' Well , hang in there . In twenty years , you ’ ll fell it was well worth it ! ']
['Is everything ready for the big family barbecue tomorrow ? ', ' Yep . The steaks and chicken are marinated and I also bought hamburger buns . ', ' We should also cook a couple dozen hot dogs and kebabs . ', ' Yeah , good idea.We can put some lawn furniture outside next to the grill . I also set up the tent outside so we can hide from the sun if it gets too hot . ', ' Great ! I asked Grace to bring cups and serviettes as she is also bringing two big coolers for the beers . ', ' This is gonna be a great barbecue ! ']
['How is Rose now ? ', ' It ’ s still touch and go . We don ’ t see how she can make it . ', ' I ’ m sorry to hear about that . ']
["It's a fine day today , isn't it ? ", " Yes , it is.It ' s wonderful after the downpour . ", ' How nice seeing the sun back again ! The air is so fresh . ', ' I hope it stays nice like this for a long period of time . ', ' Well , the weather is so unpredictable this time of year . ', " You're right.We don't know what is going to be like tomorrow . ", ' Look ! It looks as if it is going to rain . ', ' The weatherman predicts a fine day today . ', ' The weather is often quite different from the weather forecast . ']
['Good morning . Mrs.Smith . ', " Good morning ! Can you help me , please ? I'm looking for some books for my mother . ", ' Well , what kind of books does she like ? ', " She's very fond of detective stories ? ", ' I see . Has she read any detective stories ? ', ' Oh , yes ! ', " Do you know if she's read this one ? ", " I'm not sure , but she probably won't remember if she has ! She's very forgetful ! ", ' Ah ! She has a bad memory . How old is she ? ', " She's eighty-seven . ", " I suggest you take this book . It's very exciting . ", " Thank you . That's a good idea.she likes exciting books . Can you suggest another one ? "]
['Do I have to write the invitation cards ? ', ' No , you don ’ t have to . But I think you ought to . ', ' Oh , well . If I must , I must . ']
['How many people are in your family ? ', ' As you know , China has a single-child policy . Therefore , there ’ s just my husband , my daughter and I . What about in your family ? ', ' I have one daughter and one son . Then there ’ s my husband and I . What about your parents ? Do they live with your family ? ', ' Not anymore . They live with my brother now . and yours ? ', ' My parents live by themselves now . when they get older , they ’ ll probably go to a retirement home . Do you just have one brother ? ', ' No , I have two older brothers and one younger sister . What about you ? ', ' I also grew up in a big family . I have one older brother and three younger sisters . ', ' How long have you been married ? ', ' About seven years now . and you ? ', " I've been married for about five years . What do you think about divorce ? ", ' It ’ s becoming more and more common . However , I don ’ t ever want to get divorced myself ! What about you ? ', ' If my husband cheated on me or treated me badly , I would get a divorce . ', ' If that happens , maybe you could marry my brother and we could become in-laws ! ', ' ( ha ha ) I ’ ll keep that in mind , but don ’ t tell my husband . ', ' Of course not ! ']
['I hear that you are going to participate in the dinner party tonight.Seen from what you are dressing , you really look like a fox . ', ' Yeah , I think it will be wonderful . ']
['I was just watching a documentary on tv about people use dogs for various purpose . It was very interesting . ', ' I love dogs . They have been used as guards for centuries . Nowadays , they are often used to find illegal drugs and bombs by the police and customs officers . ', ' The documentary also pointed out that they are used by shepherds to round up sheep and by rescue workers to find people trapped under rubble or snow . ', ' Horses are useful to people too . We use them for sports and recreation . ', ' Don ’ t forget that horses are still used in many countries to pull ploughs and carts . ', ' Can you ride a horse ? ', ' Yes , I can . I don ’ t ride regularly though . How about you ? ', ' I can ride too . Perhaps we could go horse riding together at the weekend ? ', ' What a good idea ! ']
["How's it going ? ", " I'm in a good mood today , actually . How about you ? ", " To be honest , I'm a bit fed up . ", " What's wrong ? ", " There's a girl in my company that I really like but I always get shy when she is around . ", ' I see ! Do you want to ask her out ? ', ' Sure , but how ? ', ' You can ask her out for drink after work . ', " But for what reasons ? She doesn't even know who I am . ", " Then you've got a lot of homework to do . You need to get her notice first . ", ' Easier said than done . ', ' You can start by meeting her at the bus stop and saying hello to her . ', ' But I always get tongue-tied when I see her . ', " That's something you need to overcome . Men should make the first move as most of girls prefer being chased . ", " I see . I'll try . ", ' Good luck . ']
["It's too hot to read . ", " We'd better go out for a walk . ", ' Which season do you like best ? ', ' Spring . ', ' How about summer ? ', ' I dislike it most . ', ' Why ? ', ' Because the hottest season is summer in a year . ', ' But sometimes summer is more charming than the other seasons . ']
['Where did you go yesterday ? ', ' I went to Croydon . ', ' Did you go shopping ? ', ' No , I went for an interview . ', ' Oh , did you get a job ? ', ' Yes , I got a job as a Management Trainee . ', ' Fantastic . ']
["John hasn't got married up to now . ", " Don't you know that he has been carrying a torch for Mary for years ? ", ' Really ? Does Mary know that ? ', ' Of course not . ', ' How silly John is . ']
['Mom , you know that Andrea and I sometimes worry about you . ', ' Really ? Why would you worry about me ? I ’ m just fine . ', ' You ’ re almost 70 years old , Mom ! Don ’ t you think it would be better for you if you moved in with us ? ', ' No way ! I like my apartment , and I like to be independent . ', ' Do you ever get lonely living alone ? ', ' Not at all . I see you and your family twice a week , and I enjoy seeing my own friends . I ’ m too busy to feel lonely ! ']
["Tom , you look thoughtful and unhappy recently . What's wrong with you ? ", ' Lily broke up with me last week . In fact , she dumped me . ', ' Why ? I mean , why did she part company with you after seven years together ? ', ' She said it was because we had very different ideas about life . ', ' Do you believe her excuse ? ', ' Of course not . I knew she had fallen in love with another guy . It is difficult to see her move on so quickly . ', ' Come on , buddy , cheer up . Why not do some sports with me ? Violent exercise might help to shake you out of your disappointment in love . ', ' Thank you , Steven . You are really a good friend . ']
['Do you like singing ? ', ' Yes , I do . ', " Let's go to a ETV tonight . ", " But I can't sing it well . ", " It doesn't matter . No one will laugh at you . ", " OK , I'Il go with you . When shall we go ? ", ' What about six ? ', " It's too early . Let's make it seven , OK ? ", " OK . Let's make it . "]
["You're being childish . Your nose will heal . And so will your pride , if you let it . ", " I'll have us ready for Stars.com by the end of next week . After that , I don't know . ", " Don't know what ? ", " Let's just say there could be some big changes around here . ", ' Is that right ? Like what kind of changes ? ', " You'll see . Oh , yeah , you'll see . ", ' Come on , grow up . Have you seen Vince around ? ']
['It ’ s really terrible ! ', ' What are you talking about ? ', ' Don ’ t you see many parents are forcing there children ’ s hands to learn something they think important to their children . But the children are not interested in it at all . ', ' You said it . Many parents just don ’ t understand know how to educate their children . ']
['Hello , this is Helen speaking . ', ' Hello , Helen . This is John . How are you ? ', ' Fine , thank you . And you ? ', ' Fine , thanks . I ’ ll have a party next Sunday at home . I ’ m calling to ask whether you can come or not . ', ' Oh , how wonderful . I ’ ll be glad to . ', ' Okay , now you are a famous star . ', ' Hum , don ’ t say that . Maybe you can do something useful for me . ', ' What ’ s wrong with you ? ', ' I ’ ll tell you at the party . ', ' Okay . ']
["Don't you think we ' d leave for the concert now ? ", ' What time dose it start ? ', ' In about 25 minutes . ', " Then we'd better get started . "]
['This is my admission card , and these are the books . ', ' OK , a moment , please . ', ' By the way , can I renew the borrowing ? ', ' For which one ? ', ' Sense and Sensibility , English version . ', ' Yes , of course . ', ' Can I just do it here ? ', ' Sorry . No . You should go to the other counter . ', ' OK , thanks . ', ' Sorry , this biography is over the deadline . You should pay extra for it . ', ' I was thinking of buying this from the bookstore when my father got this from the library ... anyway , how much should I pay ? ', ' 3 Yuan , please . ', ' Here you are . Thanks . ', ' You are welcome . See you next time . ']
['Hi , Mary , it ’ s been a long time ', ' Hello , my old friend . Long time no see . How are you doing ? ', ' Well , I ’ m doing okay . And how about yourself ? ', ' Not so well . To be honest with you , I broke up with Tom . ', ' Oh . I ’ m sorry to hear that . What happened ? ']
['hi , come on in . Can I take your coat ? ', ' sure , thanks . I brought you a bottle of wine as well . ', " you're the first guest to arrive . I'll just put your coat away and then I'll get you something to drink . ", ' should I take my shoes off ? ', ' whatever you prefer . ', ' this is a very nice place . How long have you been living here now ? ', ' just over three weeks . Would you like a drink ? ', ' sure , what do you have ? ', " I've got white wine , red wine , gin and tonics , ginger ale , lemonade , orange juice , and sprite . ", " I'll have a glass of red wine please . ", ' one glass of red wine coming up ! ', ' so how many people are coming for the dinner tonight ? ', " there's just going to be 6 of us tonight . ", " oh , I thought there were going to be eight . who isn't coming ? ", " Marcia and Paul called to cancel at the last moment . Paul was running late and Marcia wasn't feeling well . ", " that's too bad.They ' re such good company . ", " I think there's someone at the door . ", ' excuse me while I go and get that . ']
['Do you mind if I come over to use your computer ? ', ' No , but I have to type my paper tonight . ', " Does that mean I can't use it tonight ? ", ' You got it ! ']
['Do you like plum blossoms ? ', ' Certainly . I prefer the winter and I love plum blossoms much more . ', " It's snowing heavily . What about taking a walk ? ", " Seeking plum blossoms with stepping on the snow ? That's a good idea . Let's go ! ", ' What a heavy snow ! ', " Take care ! Don't slip down to the ground . ", " I've got it . I like the sound of stepping on the snow very much . ", ' Yes . Very wonderful . ', ' Do you smell the sweet scent ? ', ' Yes . It should be the fragrance of plum blossoms . ', ' The fragrance of plum blossoms comes from the hard coldness . ']
['I hate working on Christmas Eve ! Whoa ! Get a load of this guy ! Come in central , I think we ’ Ve got ourselves a situation here . ', ' License and registration please . Have you been drinking tonight , sir ? ', ' I had one or two glasses of eggnog , but nothing else . ', ' Step out of the vehicle , please . Sir , what do you have in the back ? ', ' Just a few Christmas gifts , ’ tis the season , after all ! ', ' Don ’ t take that tone with me . Do you have an invoice for these items ? ', ' Umm ... no ... I make these in my workshop in the North Pole ! ', ' You are under arrest , sir . You have the right to remain silent . You better not pout , you better not cry . Anything you say can and will be used against you . You have the right to an attorney . if you cannot afford one , the state will appoint one for you.do you understand the arrest to you ? ', ' You can ’ t take me to jail ! What about my sleigh ? It ’ s Christmas Eve ! I have presents to deliver ! Rudolph ! Prancer ! Dancer ! Get help ! ']
["I hear you're going to Tainan to visit your uncle . ", " That's correct . ", ' Well , say hello to him for me . ']
['What would you reckon the taxing increases ? ', ' Well , the state will benefit a lot , I suppose . ', ' But what do most people think about it ? ', ' Ah , it ’ s hard to say . ']
["How's your father been ? ", " He's been out of work for a couple of days . ", " What's wrong with him ? ", ' He has a bad cold . ', ' Well , tell him to take it easy and that I hope he feels better . ', " Thanks . I'll tell him . "]
['Can you help me buy my textbooks ? ', ' There will probably be a book list in the bookstore . Do you have your class schedule handy ? ', " No , I don't have that . ", ' To get started , take that list over to the bookstore . Do you know where the bookstore is ? ', ' I am not sure where the bookstore is . ', " When you pass the gym , it'll be the first door on the left . Do you know how to sell your old textbooks for money ? ", ' Yes , I knew I could do that . Exactly how do I go about selling them ? ', ' If you give your used textbooks to the person at the booth outside the door , he will reimburse you . Can you go over there today ? ', ' I think maybe I could be there . ', ' I am free at 1 ', ' Maybe that would work . ', " I'll catch you later then . Have a wonderful morning . "]
['Hey , John . Nice car . ', ' Thanks . I finally got rid of that old Nissan that got me through college . ', ' What is this , the new Ford ? ', ' No , it ’ s last year ’ s model . ', ' True . How much did you pay ? ', ' $ 14,500 . It only has 10,000 miles on it , so it ’ s like a new car . ', ' Does that mean you ’ re not going to take the train to work anymore ? ', ' Well , sometimes , I think it ’ ll be nice to drive to work instead . We ’ ll see . Want to go for a ride ? ', ' Yeah , sure . ', ' Come on . ']
['What are your plans for this weekend ? ', " I'd like to hire a bike . I think it would be a good idea to do some cycling on Sunday . ", " If the weather's fine . ", " I am sure it will be . It's been good so far this weekend . ", ' I know a good place to hire bikes if you want . ', ' Thanks . That would be really helpful . ', ' But remember , be careful when you ride a bike . The traffic in Beijing can be dangerous . ']
["I wish the teacher wouldn't make us read this book . ", " Yeah . It's boring . I'd rather read something more exciting . "]
['Mr . Brown is in hospital again . ', ' Is he ? He ’ s never been healthy . ', ' When I went to see him yesterday , he looked rather pale . ', ' I ’ m afraid he won ’ t make old bones . ']
['Someone ’ s told me behind closed door that he is very hot-tempered . ', ' I ’ m afraid what you were told is not quite right , if you could meet him in person , and you ’ ll know he ’ s very agreeable and capable . ', ' Really ? I hope to meet him soon . ']
['Do you like playing tennis ? ', " I don't find it very exciting . ", " Maybe you haven't found the magic . ", " I can't wait ! "]
['How old are you ? ', " Nine ... but I'll be ten on May 1st.When is your birthday ? ", " I'm older than you ! I'll be ten on April 14th . ", ' Are you going to have a birthday party ? ', " Maybe . I'll have to ask my mother . "]
['Come in , come in , what can I do for you ? ', ' Professor Donald , are you giving your advanced geology course again next semester ? ', ' Yes , I am applying on it . ', " I wonder if I could enroll in it . I know it is a graduate course and I ' m a junior , but ... ", " Aren't you a bit young ? I have a lot of qualified seniors to take the course and they usually have a hard time keeping up . ", ' I know , but geology of the American west is my major interest and I have done a large reading in the field . ', " Well , if you think you are ready , I'll let you enroll . ", ' Oh , thanks , professor Donald.this is very nice of you . ']
['Good evening , John . ', ' Good evening , Mary . ', ' How are you doing ? ', " I'm doing fine , thanks.What ' s new with you ? ", ' Nothing special . ', " I'm wondering whether you could come over for a pizza sometime next week ? ", " Sounds good.Sorry , here comes my bus.You call me , or I'll call you to make a date . ", " I'll call you . ", ' All right.Gotta go , bye , keep in touch . ', ' Have a great day , take care , bye . ']
["How'd you like to go on a bungee jump this weekend ? ", " I'm not sure . I promised to help my sister move Saturday . ", ' How about Sunday , then ? We could start in the morning . ', " I might be able to do that . But I don't think I can do it well . ", " Don't worry . It is a test of physical endurance , intelligence . Just to finish it is considered a victory for most . ", " OK . I'll talk to you later . "]
['I must apologize for having delayed the work . ', ' No , that ’ s not all your fault . ', ' But you will miss your good chance . I ’ m So sorry ', ' There ’ s no need to apologize.Forget about it . ']
['Oh dear , my weight has gone up again . ', ' I am not surprised , you eat too much . ', " And I suppose sitting at the desk all day in the office doesn't help . ", " No , I wouldn't think so . ", ' I do wish I could lose weight . ', " Well , why don't you go on the diet ? ", " I've tried diets before but they've never worked . ", " Perhaps you should excercise more . Why don't you go to an exercise class . ", ' Yes , maybe I should . ']
['Hi , Larry , how was your weekend ? ', " Not bad . We had a get-together with friends from college . I haven't seen many of them since graduation . How about you ? ", ' Great . I hung out with Jo all day shopping , and the went out for dinner together . ', ' Sounds a good weekend . You know it always amazes me that two people as different as you and Jo can become such close friends . ', " Yeah , I never thought we could be good friends either . We have our differences . She's more outgoing and active while I am more quiet and reversed , but we still get along extremely well . We can talk for hours about anything . ", " That's great . I know people who can't stand each other for even five minutes . ", " When Jo and I are together , we argue a lot , but that's also part of the fun . Besides , I know she will always be there for me when I need her , and she knows I'll be there for her . ", ' It seems you two bring out the best of one another . ', " Exactly . Having Jo as my friend is one of the best things that's ever happened to me . ", ' Yeah , you are so lucky to have found each other . ', ' Thanks , I think so too . ']
['What ’ s the matter , Sally ? You look so unhappy . ', ' I had a bad day yesterday . ', ' What happened ? ', ' I went to the library and lost my bag . ', ' Your bag ? Did you get it back ? ', ' I went back for it . But it was already gone . ', ' That ’ s too bad . I ’ m sorry to hear that . ']
['Are you free this evening , Li ? ', ' I ’ m afraid I ’ m busy tonight . I ’ m having dinner with friends . ', ' What a pity . I wanted to go for a drink with you . ', ' What about tomorrow ? Are you doing anything tomorrow ? ', ' No , I haven ’ t got any plans . ', ' Shall we go out tomorrow then ? ', ' Why not ? Sounds good to me . ']
['Do you like a package tour or to travel alone ? ', " I prefer a package tour , and we don't have to worry about accommodation , meals or that sort of trivial demanding things . ", " I prefer travel alone . I'll have a lot of time lingering at one place . "]
['Here , Let me get the door for you . ', ' Thanks . ', ' Do you need a hand with that ? ', ' Actually , I could you some help . Thank you so much . ', " Don't worry about it . "]
['Sam , what shall I do with my stocks ? Will I lose money ? ', ' There ’ s a possibility . ', ' What do you mean by that ? ', ' I mean if you don ’ t sell your shares now , it ’ s quite likely that you ’ ll end up losing your shirt . ', ' Is that so ? ', ' Absolutely . Take my word for it . ']
['You should have seen the line at the housing office.It took me an hour to make my dormitory deposit for next year . Have you made yours yet ? ', ' No , I ’ m not sure I ’ m going to . ', ' Why not ? There ’ s not much time left . Are you short of cash ? ', ' No , thanks . I am okay . ', ' You ’ d better hurry up if you wanna a dorm room next September ... ', ' Well , actually , I am thinking about living off campus . ', ' Do you have any idea how much that would cost ? ', ' I know it would be more expensive . I think I could handle it though . It ’ s that this dorm is so noisy that I can ’ t get anything done . ', ' You should study in the library the way I do . Think of the money you ’ d save . ', ' I ’ Ve got to think it over some more . ', ' I hope you will have second thoughts . ']
['What a wonderful party ! I had a good time . How about you ? ', ' I enjoyed myself , too . ', ' Shall I give you a ride home ? ', " Yes , if it's not too much of a trouble . ", " It's no trouble at all because your house is on the way to my place . ", " That's great . Let's go ! "]
["Hello , my name is Xu Hua . I'm from Beijing . ", " Hello , Xu Hua . I'm Paula . I'm American . ", ' Welcome to China , Paula . ', ' Thank you . ']
['Have you heard that Mel Gibson was arrested by the police last week ? ', ' No , not yet . Why ? ', ' For suspicion of driving under influence . ', ' Oh . I am not his fan . ']
["You've met her before , haven't you ? ", " I don't recall . "]
['Excuse me , Sir , do you know what time it is ? ', ' Oh , it ’ s almost eleven twenty . ', ' Thank you . ', ' You ’ re welcome . The rain is quite heavy , isn ’ t it ? ', ' Yeah . I was in a hurry and I forgot my umbrella today . ', ' I have one . We could share it . Which way are you going ? ', ' Oh , that ’ s very kind of you . I am going to the Garden Hotel . ', ' I am going there , too . We can walk together . ', ' Sure . ']
["We'd like to invite you over for dinner this Friday evening . Can you come ? ", ' This Friday evening ? ', " Yes . We hope you'll be able to join us . ", " Thank you for the invitation . I'll be very happy to go . ", ' Good ! ', ' What time should I arrive ? ', ' How about 6:00 ? ', ' Fine . See you then . ']
["Isn't this lovely weather ? Will you help me water the flowers , Jack ? ", ' Well , do you think I have to ? ', " I do.We haven't watered them for quite a few days . ", " Please look at the sky.Don ' t you see the dark clouds ? It's going to rain soon . ", " Good.So we don't have to work.How nice ! ", " But I don't think it's so nice . ", ' Why ? ', " The weather report says it's going to rain for a whole week . ", " Oh , I'm afraid all the flowers will die in the rain . "]
['Can you speak English ? ', ' Yes I can . I speak it very well . ', ' Where did you learn it ? ', ' I lived in England when I was a child . ', ' What else can you speak ? ', ' Well , I know a little Italian . ']
['What ’ s the difference between football and rugby ? ', ' Those tow games are quite different . First , there ’ s the size of the teams . In football , a team has 11 players . In rugby there are 15 players on each team . The biggest difference is that in football , only the goalkeeper can use his hands . In rugby , the ball is usually carried forward by players , though kicking is permitted . ', ' In rugby , players pass the ball by throwing it to team mates , don ’ t they ? ', ' That ’ s right . However , players can only pass the ball backwards . They cannot pass the ball forwards to their team mates . That ’ s a foul . ', ' I know how goals are scored in football , but how about in rugby ? ', ' If a team carries the ball over the goal line , they score points . A team can also score points by kicking the ball between two tall posts at each end of the pitch . ', ' There ’ s a lot more physical contact in rugby , isn ’ t there ? ', ' Yes . Players usually need to bring a player down to stop him from moving forward with the ball . This is called ” tackling ” , as in football . ', ' The ball is a different shape in rugby , isn ’ t it ? ', ' Yes . It ’ s not perfectly round like a football . A rugby ball is oval in shape . There ’ s a match on TV this afternoon . Why don ’ t you watch it with me ? I ’ ll try to explain the rules and tactics while we ’ re watching . ', ' Ok . ']
['What do you say to eating out , Maggie ? ', " Yeah , why not ? We haven't been out for dinner for quite a long time . A new French restaurant has just opened in our neighborhood . We can go there . ", ' Do we need to book a table in advance ? ', " No need for that . It's not usually busy on weekdays . ", ' What time shall we go ? ', " Why not now ? I'm hungry . "]
['How do you like other films starring Charlie Chaplin ? ', " Well , I like others very much , but I really don't think much of this one . ", " You don't like the performance , do you ? ", " Yes , but I don't like the story . "]
["Who's that striking woman over there ? ", " Hm ? Oh , that's Alice . She's totally mad . Don't get yourself in a room alone with her . ", ' Really ? Why not ? She looks great . ', " Yes , I know , but she's dangerous . ", ' Really ? Tell me more . ', " Well , I'm not one to gossip , as you know , but rumor has it that she sued her former boss for sexual harassment . ", ' Wow , crikey . So what happened ? ', ' Well , this is just between ourselves , of course , but he was her lover and he wanted to leave her , so she got revenge . I heard him say she was a dangerous woman . ', ' Wow . ', " Oh , while we're on the subject , what happened to you and your secretary ? ", " I have no idea what you're talking about . ", ' Oh , come on . Everybody knows . ', ' Could you excuse me a moment ? I have to make a phone call ', ' Oh , sure . ']
['What is the movie you saw last night ? ', " It is a new film , ' Transformer ' . ", ' How do you like it ? ', ' I expected too high from that movie , but I was a bit disappointed about it . ', ' But I heard the box office rose up to 15 million in the first week . ', " Box office can't explain everything . I do not think it is cheerful or well-made . The plot is old and the female character is not pretty . ", " My sister has given me two tickets for tonight . It is called ' The life of Rose ' , a French movie . ", " What's it about ? ", ' It tells the lifetime of a lady singer from a beggar in the street to a famous singer in the world . It is a kind of tragedy . ', ' I prefer the tragedy . It is moving and makes me ponder about my life . ', " Let's go . The time is coming . ", ' We can buy the popcorn before entering the cinema . ']
['Hi ! Peter . How are you ? ', ' Fine ! How about you ? ', ' Pretty good . ']
['I cannot ignore her suggestion . In fact I always value her suggestion . ', ' I know . Maybe you will get the air if you go against her . ', ' Well , it takes two to to make a happy marriage . ', ' And it takes two to make an agreement too . You have no guts , I am afraid . ']
['Who ’ s that ? ', ' It ’ me . Susan Taylor ', ' Oh , please come in . nice to see you . ', ' On , what ’ re you doing ? You look as busy as a bee . ', ' Yeah , I ’ m trying to decorate my house . ', ' Really , that ’ s cool . Let me see what you ’ Ve done . ', ' But actually it ’ s not done yet . I ’ m going to get a special pendent lamp . ', ' That ’ s all right . Let me see , oh , that lace looks so unique , and it ’ s so creative to make a picture display here . How did you get that idea ? ', ' It ’ s just a simple decorating . I just want to add my personality to my living space . ']
['Do you like music ? ', ' Well , it depends . ', ' Do you think the music is well-matched ? ', ' No , I think the music is too fast . ', ' How about the words of the song ? ', ' It sounds nice . ', ' I like it . Naturally it can arouse your feelings . ', " Yes , I think so . It's very emotional . ", ' Of course , and I also like the rhythms . ', ' Full of energy and hope . ', " Really . It's worth listening to and enjoying . ", " Certainly it is . It's worth an Academy Award . "]
['Hey , Wen ! Welcome to D . C . ! Glad you came out to visit ! ', " Thanks for inviting me . Actually , I've never been anywhere with so many black people before . It's different . ", " Howard is eighty percent black . But there are whites , and even Asians here . Thankfully , it's also coed . ", ' Great ! Is your , too ? ', " Sorry , nope . But the Alpha Phi Alpha's are throwing a party tonight . ", " That's a black fraternity , right ? So we should see some dancing ! "]
['How could you handle living in such a big family ? Does everyone get along ? ', ' Sure . We love each other and take care of each other . ', " In such a big family , there must be a head . Who's the head of your family ? ", ' My grandpa . He has the final word about almost everything . My grandpa is “ President , ” and Grandma is “ Vice-President . ” My parents , uncles and aunts try to arrive at a consensus on important questions . ', ' Is a family like yours common in South Korea ? ', ' No . Not anymore.Mine is highly educated but traditional family . Most South Korea families today are a lot smaller . In traditional families , the old people are well respected and taken good care of . Ho ', " My family setup is a bit different . In New York city , there're only three people , my mother , my stepfather and me . During this summertime , I fly out to California and live with my dad . Dad's getting ", " Of course there'll be a room for you ! ", " To be blunt , maybe I won't be able to get along with his new wife or her kids . ", " Yours is a modern family . I'm sure your dad loves you and would want you to stay for the summer . You just need to try your best to get along with your new stepmother and her boys . ", ' But four boys ! ', ' It will be a new experience , and you might as well learn to adjust to changes . ', " You are right , I guess.The world keeps changing , and so do families . But I like a small-sized or medium-sized family where everybody is equal to everybody else . That's what I want . ", " It is good to have goals in life . If California doesn't work out , come and visit me in Korea , OK ? ", " That's a great idea ! ", ' We could share a room ! It would be fun . And we could do some traveling around Korea . You could see for yourself what life in a big family is like ! ', ' That sounds like an excellent offer . I might take you up on that . Thank you for the wonderful invitation . ']
['Hello , Kate . ', " Hi , Peter . I didn't see you last night . Where did you go ? ", ' I was almost on line the whole night . ', ' Did you play network games the whole night ? ', ' No , I listened to the music , too . ', ' What are you going to do now ? ', " I'm tired . I need a rest . "]
["I'm going to have some people over for dinner Saturday night.Would you like to join us ? ", " Oh , I'm afraid I'll be busy tomorrow evening . ", ' Some other time then ? ', ' OK.Thanks for asking me . ']
["Ma , I really don't know how to thank you . ", " I'm glad I was able to help . ", " It's most kind of you . ", " Don't mention it . It was the least I could do . ", " If there's ever anything I can do for you , Don't hesitate to let me know . ", ' Thank you . ', " I'm most grateful . ", ' It was a pleasure . ']
["You're acting weird tonight . ", " I'm just in the mood to act goofy . ", ' What brought this on ? ', " I guess I'm glad exams are over . "]
['Hey , Mary , can you cut that out ? ', ' Cut what out I ’ m not doing anything . ', ' The tapping of your pen on your desk . It ’ s driving me crazy . ', ' Fine ! By the way would you mind not slurping your coffee every time you have a cup ! ', ' I don ’ t slurp my coffee . And plus , how can you hear it when you ’ re shouting into your phone all the time ? ', ' You ’ Ve got to be kidding me ! You ’ re complaining about me talking on the phone when you go out for a cigarette break ten times a day to shoot the breeze ? ', ' Look , we have a lot of accumulated anger from working in these conditions , and it ’ s probably okay to let off steam once in a while . But , it ’ s probably not a good idea to keep it up I ’ m willing to forgive and forget and if you are . ', " Fine . Let's call a truce . I'll try to more considerate and to keep the noise down . ", ' Yeah , I ’ ll try to do the same.So , I was wondering you wanna go out to dinner Friday night ? ']
['what do you think about all the different diets people go on ? ', " I don't think dieting is good for you . It's much better to eat a balanced diet and to never get overweight to begin with ! ", ' but what do you think about people who are obese ? What should they do to lose weight ? ', " they need to eat healthy foods , but they also have to increase the amount of exercise they do every day . They don't have to cut out fattening foods altogether , though . ", " so you think it's ok for people who are dieting to eat chocolate ? ", " sure , they can eat some chocolate . As long as they are exercising and eating mostly healthy foods , there's nothing wrong with having a small desert . ", ' how about drinking soda ? ', " many people gain weight by drinking far too much soda . Soda should be a treat ; there's simply no nutritional value in it whatsoever . If you want to lose weight and you can't stop drinking soda , try ", " that's good advice . Have you ever tried taking vitamins ? ", " my mother used to make me take vitamins every day , but I don't take them anymore . Vitamins are good as a supplement , but they don't do much good if you don't have a well-balanced diet to start . ", ' how do you know so much about food and dieting ? ', ' you might not believe this , but I used to be twice the size than I am now ! ']
['Bill , I have received the admission letter from Cambridge University ! ', ' Congratulations ! ', ' How about you ? Have you got any news from university ? ', ' No . But I am going to apply for some vocational schools . I like fashion design and want to study it . ', ' I am glad you can study something you really like ! ']
["John , if you don't mind , I'd like to ask you a personal question . ", " I don't mind at all . ", ' All right . Are you married ? ', " To tell you the truth , I'm not married . I'm still single . ", ' Then , when do you plan to get married ? ', " I don't know . It's still up in the air . "]
['Bob , put on your shoes , your feet are really smelly . ', ' No foot gives out scent . ', " But don't forget you are in a cafe . ", ' Never mind , the odour of my feet will quicken their eating speed . ', " I simply can't bear your barbaric behavior . ", ' Don ’ t pretend you are a good God . ', ' You should feel shameful for your behavior . ', " I've never experienced such a kind of feeling . ", " I'm really sick of you . "]
['What are you doing over the weekend , Sara ? ', " I'm planing to go bowling tonight . Tomorrow I was hoping to see a movie . What about you ? ", " I want to go camping , you know , just get a way for the weekend . I'm not sure I'll be able to , though . ", ' Why not ? ', " Well , I have a lot of work . I'll see how it goes . "]
["She is kind of player who never hides how she's feeling . Once look at her and you know if she's winning or losing . ", ' She wears her heart on her sleeve . ']
['Good afternoon , Johnson . ', " Good afternoon , Mary . How's business ? ", ' Not bad , thanks . ']
['hey Ayden , I was wondering if you could do me a favor . ', ' that depends . What is it ? ', " it's kind of a big favor . I'm absolutely flat broke , and I owe my landlady $ 200 . she's given me until Friday to give it to her , but I don't get paid until next Monday . Do you think you could loans ", " I'd love to help you out , but I'm a bit short on cash this month as well . I had to get a new engine put into my car , and that ate up my savings . ", " if you can't give me the full amount , a fraction of it would still help . I'll pay you back on Monday . I promise . ", " let's see , I've got about $ 50 to get me through the weekend . I can only spare about $ 20 . I would give you more if I had it , I just don't have much money to my name right now . ", " thanks a lot Ayden . Every little bit will help . Tell you what , if you aren't doing anything tonight , why don't you come over and have dinner at my place . ", " that'd be great . Thanks ! What time should I come over ? ", ' how about at 6 pm ? ', ' see you then ! ']
["You don't have to play that record so loud , do you ? ", " I'm sorry . Has it been bothering you ? ", ' Yes . And please ask me the next time you want to use something . ', " I'm sorry . I meant to ask you . "]
["I'm going over to the gym . I want to do some running . ", " Why don't you run outside ? ", ' Are you kidding ? Do you know how cold it is today ? ', " Yeah , I suppose . I guess it isn't healthy to run in this weather . ", " No , it's not . Not at all . I'd probably freeze my lungs . ", " Wait for me a minute . I'll go over to the gym too . ", ' You ? ', ' Yes , why not ? Just let me get my gym clothes together . ', " I didn't know you could exercise . ", ' What do you mean by that ? Everyone can exercise ! ', ' Yeah , I know . But you ? I always thought you were only good at lifting beer bottles to your mouth . ', " No , not at all . I was on the swimming team in high school.And I'd like to do some weight training . They have decent equipment at that gym . ", " You're going to lift weights ? Hah ! ", ' Are you laughing at me ? ', " I'm sorry . I just can't imagine you lifting weights . ", ' Maybe not . But I want to start . I need to get in shape . I feel these past couple months that my energy is low . ', " It's true . If a person doesn't exercise , they get sluggish.That ' s why I keep running . Even in the winter . ", ' So I need to do something too . ', " But lifting weights isn't the best thing.You should do some kind of aerobic exercise . ", " I know . But I want to start today with a little weight lifting.Then I'm going to buy a new swimming suit and goggles , and every other day I'm going to go swim laps in the pool . How does that sound ? ", " It sounds like a good plan to me . I'm still ... I mean ... ", ' What ? ', " I'm still just surprised you really want to do it.It doesn't seem to go with your character . "]
['The boss is mad at you . ', ' Who cares ? ']
['Bob , what are you thinking about ? ', " I'm looking forward to going to America . ", ' When do you go ? ', ' Next week . ']
['I have never seen so many flavors of ice cream in one place ! ', ' There certainly are a lot . Can you choose a favorite ? ', ' Vanilla with toppings is my favorite . ', ' Is there anything as good as a hot fudge sundae ? ', " No way ! Do you have a flavors you don't like ? ", " I don't like ice cream with too many different flavors in it . ", " I agree with that , it just doesn't work for me . ", ' I saw garlic ice cream on the menu once . ', ' I think that would be horrible ! ', " I think I'll stick with a more traditional choice today ! "]
['I heard that ben is forming his own band . ', ' it will be a rock and roll band probably . He ’ s a very good guitarist . ', ' can you play a musical instrument ? If you can , he might ask you to join the band . ', ' I can play drums , but I haven ’ t played for a while . I ’ m not sure I ’ d be good enough to play in a band . ', ' I wish I could play a musical instrument . I love music . ', ' nowadays , you can be a DJ . You can mix dance music . You don ’ t need to be able to play musical instrument or sing . ', " I'd love to try it.but the equipment is expensive and it was still take a lot of practice . ", ' you know , you could probably get a computer program that would help you . You already have a computer , so you could use that to help you mix some music . ', ' that ’ s a great idea . I ’ ll search for some information on the internet . If it ’ s possible to do , the internet will have some information about it . ']
['Hey , Frank , there is that Janet Check . ', ' Wow , what a great burd ! ', ' She sure knows how to strut her stuff . ', " She's a real turn-on our rights . ", " And look out she's dressed . ", ' Yeah , I noticed . She must be really loaded . ', ' No way . Her old man is rich . He buys her anything she wants . ', ' Lucky her . Anyway , I think that is just as beautiful . ', " I think you've lost it . ", " Well , that's my opinion . ", ' I admit that she is much prettier than Kate . ', ' Oh , there is no comparison . Now we are talking but ugly . ', " At least we agree on that . Let's go and get a drink . "]
["I'm going to America . ", " Any idea when you'll leave ? ", ' I hope before the end of the month . ', ' Let me know when you find out . ']
['Who is Cindy ’ s husband ? ', ' Cindy ’ s husband is Ron . ', ' How many children do Cindy and Ron have ? ', ' They have two children-one son and one daughter-as well as one daughter-in-law and one son-in-law . ', ' Do they have any grandchildren ? ', ' Yes , they have three grandchildren-one girl and two boys . ', ' Does their daughters get along well with her in-laws ? ', ' Yes , she gets along with them quite well . ', ' Do they have a large family ? ', ' Their family is very similar to Cindy and Ron ’ s family . ']
['What do you think of doctor Thompson ? ', " I feel confident of his ability to cure my daughter's disease . ", ' How can you be so sure ? ', ' I can tell from the way he spoke to us . ', ' Never believe his words . ']
['Where do you live , Kim ? ', ' I live in an apartment downtown . ', " Oh , that's convenient , but ... how much crime is there ? ", " Not much . But there is a lot of traffic . I can't stand the noise sometimes ! Where do you live ? ", ' . I have a house in the suburbs . ', " Oh , I bet it's really quiet . But is there much to do there ? ", " No , not much . In fact , nothing ever really happens . That's the trouble . ", " Hey . Let's trade places one weekend ! ", ' OK . Great idea ! ']
['I must be going now . ', ' Really ? Can ’ t you stay a little longer ? ', ' No , I really must go now . My family are expecting me home soon . ', ' Be seeing you then . ', ' See you . ']
["Good morning , Jerry . How's everything ? ", ' Fine , just fine . Thanks . ', ' Doing anything for lunch ? ', " Well , as a matter of fact , I've got a lunch date with Bob Thomas . "]
["It's awfully hot . ", ' You can say that again . ']
['It seems a glorious day today . ', ' I agree ... ', " It's beginning to spot . ", ' Just now we both thought it would be fine . ']
["I don't think I'm getting better . ", ' Believe me , you really look much better than before . ', " I'm still not sure whether I can recover from it . "]
['did you get my email ? ', ' I certainly did . Do you want to come in and give me some feedback about your weekend ? ', ' sure . ', ' how did the business trip go ? ', ' well , to be honest , nothing is more stressful than going on a business trip with our boss . ', " I understand . The last time I went on a business trip with the boss , I didn't even have enough to eat ! ", ' I also think the company is pretty cheap with travel expenses . I spent half of the weekend on a train ! Surely they could have afforded to buy a few plane tickets ! ', ' our company is quite conscious of the environmental problems that frequent flying causes . ', ' I see . Well , then perhaps they could give me a few days off after a business trip . It was really tiring for me . ', ' I can ask the boss about giving you the day off today . ', " thank you . I can't imagine getting much done today . I'm just too exhausted ! ", ' no problem . Did you bring any gifts back for your department ? ', ' no , should I have ? ']
['Hello ! ', ' Is that the box-office ? ', ' Yes . ', " I'd like to book two tickets for the film ' Jane Eyre ' for this evening , please . ", " Just a minute please . Oh , I'm sorry , all the tickets for tonight have been sold out . ", ' What a pity ! How about tomorrow evening ? ', " Oh , you're lucky , there are just two tickets left . Do you want to take them ? ", " Wonderful , I'll take them . ", ' OK , your name and telephone number please . ', ' Wang Min . Telephone number is 13811658 . Can I pick the tickets this afternoon ? ', ' Yes , of course . ', ' Thank you very much . ']
['I really like the book you lent me the other day . ', " I'm glad you like it . ", ' And thank you very much for letting me keep it so long . ', ' Not at all . ', " Everyone in our class enjoyed it too.It ' s very interesting . ", " Oh , I'm glad . ", ' Would you mind me keeping it for another three days ? ', ' No problem . ']
["I've got to go home and study . ", ' For what ? ', ' The test tomorrow . ', " If you don't know it by now , you might as well not bother studying . "]
['How did you first meet ? ', ' My roommate invited both of us to dinner . ', ' Was it love at first sight ? Did you fall in love with her the first time you met her ? ', ' Yes ! The first time I saw her I knew we would fall in love . ']
['What is the correct time , please ? ', ' It ’ s exactly twelve minutes past seven . ', ' When will you lecture begin ? ', ' Begin at 9 o ’ clock sharp . ']
['You ’ re a wonderful person , Kathleen . ', ' So you are . ', ' And I ’ m so honored that you would want to be with me because you would never be with anyone who wasn ’ t truly worthy . ', ' I feel exactly the same way with you . ', ' Don ’ t , don ’ t , don ’ t , don ’ t say that . That , that makes it worse . ', ' What ? You don ’ t love me ? Me , either . ', ' You don ’ t love me ? ', ' No . ', ' But we ’ re so right for each other . ', ' I know , I know . Well , is there some , is there someone else ? Oh , that woman on television , Sydney Ann . ']
['Mary , can you help me set the table ? ', ' Sure . ', ' This is usually my chore . ', " I don't mind helping . ", ' We need to set the table for four . ', " So that's four plates , four forks , four knives , and four spoons ? ", " That's right . Mom didn't know where to buy chopsticks for you . ", " Don't be silly ! I know how to use knives and forks . "]
['Excuse me . would you lend me some wreckers ', ' Until when ? ', ' Until Monday or Tuesday next week . ', ' No problem . ']
['Shall we go to cinema this evening ? The new blockbuster starring mel gibson is showing . It ’ s supposed to be really good . ', ' What kind of movie is it ? I don ’ t like many of his movies , actually . ', ' It ’ s a thriller . It has Julia Roberts playing the female lead . ', ' I like thrillers and I like Julia Roberts , so it might be interesting . I read a review today and the critic didn ’ t seem to be very impressed . ', ' What did the critic say ? ', ' He didn ’ t say it was bad , but he said that it wasn ’ t as good as it could have been , particularly as there were some good actors and actresses in it . ', ' The movie starts at eight o ’ clock , so we have plenty of time to eat and get ready . ', ' Good . Dinner is nearly ready and I ’ d like to watch the news before we go . The Oscars were last night and I want to see the results . ', ' I won ’ t spoil your enjoyment by telling you who won . There were a few surprises . ']
['Do you have the five dollars I lent you yesterday ? ', " Oh I forgot ! I'll run home real quickly and bring you the money . ", " You don't have to go right away . ", " I'd hate for you to think I was lazy in returning your money . "]
['What are your hobbies , Mr . Green ? ', ' I like collecting stamps . ', " But it's an expensive hobby , isn't it ? ", " Yes , you're right . What do you like to do in your spare time ? ", ' I usually play chess with my friends . But I like playing basketball best . ', ' Do you play basketball well ? ', " No , I'm not very good at it . I play just for the fun of it . ", ' Shall we have a game together some day ? ', " OK , that'd be very nice . "]
['Are you satisfied with the dishes ? ', ' Great , the lamb stew tastes incredible . ', " I like it , too . I like the fish especially . It's so fresh , and the flavoury is kind of like for a fresh water fish . ", ' Yes , the food here deserves its reputation . Chinese food is one of my favorites 。 ', " If you like , I'll take you to a new restaurant next time , I just heard about it from my friend , and he was just raving about it . It's such a great Sichuan cuisine . Would you like to try that ? ", " Sure , I'd love to . I heard Sichuan cuisine is very hot , I think I definitely love it . ", ' Great , I love hot food too . ', " Well , let's finish this great dinner first . ", ' You said it . ']
['Hey Michelle . Good to see you . Are you at lunch ? ', ' Oh hi Jim . No I just got back . I thought you were on vacation now . ', ' No , I wish I was ! I just got back from Spain actually . ', ' Oh wonderful ! Have you been there before or was it your first time ? ', " My first time . I've traveled around Europe a lot , but this was my first time to Spain . It was amazing , and the weather was just beautiful ! No rain , and just sun , sun , sun ... ", " I'm so jealous of you . I've never been anywhere in Europe . I've always dreamed of traveling around and seeing the sights . ", " Well , I really recommend Spain . You really should go . Anyway , it's been great to catch up , but I must be going , this is my floor . Speak again soon I hope . "]
['That looks like an interesting book . ', ' It is . It ’ s got pictures of interesting building from all over the world , with brief descriptions of how they were build , their purpose , and so on . ', ' There are the pymeids . It ’ s easy to see how they got that name ! they don ’ t have smooth sides though . ', ' They don ’ t now , but most of them did originally . There ’ s picture of the pentagon in the United States . It ’ s very distinctive with its five sides . ', ' Look at that cylindrical office building . I ’ Ve never been seen one that shape before . ', ' Yes . Usually only towers are cylindrical in shape . ', ' Tv towers are usually thicker at the bottom than at the top . They ’ re not perfectly cylindrical . ', ' This is the world ’ s largest sports stadium . It ’ s a massive oval . ', ' What sports do they play there ? ', ' It says here that it ’ s mainly used for big football matches and athletics meetings . ', ' Is that building a perfect cube ? ', ' According to the book , it is . I ’ Ve never seen a building that is a perfect cube . Look at the building . From the air , it looks like a square with a semi-circle attached to each of its four sides . What kind of building is it ? ', ' Is says here that it ’ s a war memorial . Now , there ’ s a distinctive structure-the stomium in Brussels . See ? It consists of several connected by cylinders . I believe you can go up and down inside it . ']
['Yes , sir ? ', ' I hate to complain , but this soup is too salty . ', " I'm very sorry.sir . I'll ask the manager to take care of this . "]
['Are the galaxies in the universe moving through space ? ', ' No , the galaxies sit more or less passively in the space around them . But not too much . As the space between galaxies expands , it carries the galaxies further apart - like raisins in an expanding dough . ', ' But I heard that our Milky way galaxy may one day collide with a neighboring galaxy . If galaxies are moving apart from each other , how can they collide ? ', ' Well , the universe is a chaotic place , and the gravity from one galaxy , or from a group of galaxies , may disturb the motion of its near neighbors , causing them to collide . However , on average , when you compare two large enough chunks of space , the galaxies in one are moving away from the galaxies in the other . ', " Wow , you're really informative . Thanks a lot . ", " You're welcome . "]
['Isn ’ t he the best instructor ? I think * he ’ s so hot . Wow ! I really feel energized , don ’ t you ? ', ' I swear , I ’ m going to kill you for this . ', ' What ’ s wrong ? Didn ’ t you think it was fun ? ! ', ' Oh , yeah ! I had a blast ! I love sweating like a pig with a bunch of pot bellies who all smell bad . Sorry , I ’ m just not into this health kick . ', ' Oh , no , get off it . It wasn ’ t such a killer class . You just have to get into it . Like they say , no pain , no gain . ', ' I am wiped out . Thank you . ', ' Look , next time get yourself some comfy shoes . You ’ re gonna come back again with me , aren ’ t you ? ', ' Never ! But thank you for inviting me . ', ' Come on . You ’ ll feel better after we hit the showers . ']
['I like the design of the coat . ', ' But I like its color . ', " Anyway , it's my ideal coat . I'll take it . ", " I'll take one , too . "]
['Do you have any hobbies ? ', ' Yes . I like gardening . ', " Oh , that's interesting . Do you have a garden ? ", ' Yes , follow me . Here it is . ', ' Your garden is really lovely . ', ' Thank you . ', ' Do you take care of them everyday ? ', ' Yes , I do . ', " Don't you feel dull ? ", " I don't . I like the work . "]
['What ? You golden watch is lost ? ', " Yeah . I just can't find it anywhere . ", " It's an open book that it was stolen by the man in black . ", " Let's get it back . "]
['Good morning , Miss . ', ' Morning . Can I help you ? ', " Yes . I'd like to know how to use the library . You know , I'm a new student here . ", ' All you need is your student identification card to check out books . ']
['Do you have much experience with kids ? ', ' Yes . I have three sons . Actually I also have a grandson . ', ' To tell you the truth , sometimes I regret having a baby so early . I have been making so many sacrifices just because my husband insisted on keeping the baby . ', ' I understand . I was in your position before . At that time I couldn ’ t depend on anyone taking care of the children for me . My husband seldom stayed at home . ', ' What about your mother ? Did she help you ? ', ' Yes , she did a little . But you see , Americans are different from Chinese . You can ’ t depend on your own mother to be a full-time babysitter . She could baby-sit only once or twice a week . That ’ s it . I had to care for them most of the time . ', ' I see . So if my little family goes to America , I would end up taking care of my child all the time . My husband would have to make the bread for us . I just don ’ t know how I would get some education and be able to get a job some day . ', ' Don ’ t worry . You can take night classes . I did that when I had kids . And soon your child will be old enough to attend kindergarten . Then you could find a job and work . ', ' Sounds not so easy to me . When that happens , I will be too old to learn . ', ' No . You see , I went back to school to get my Master ’ s Degree when I was in my thirties . You won ’ t be older than that . ']
["Hey , Daniel , how's it going ? ", ' Hey , Daddy , today I had really a fantastic history class . ', " Wow , it's so strange for you to say things like that . What had happened ? ", " We've learnt the story of Zheg He Sailing to West Ocean . He is a real great navigator . ", ' Did your teacher tell you the route he took ? ', ' Yeah , he , with his fleet , came across the Indian Ocean , and arrived at the east coast of Africa . ', ' Great , do you still remember when he started his voyage ? ', ' Of course , that is from 1405 to 1433 , which is in Ming dynasty . ', " Good , by the way , do you finish reading the book Robinson Crusoe I've bought for you ? ", ' Not yet , you know I have a lot of homework to do . ', ' You should speed up , because the story of Robinson can give you a better understanding about what you learned today . ', " OK , great Daddy , after supper , I'll embark on it . ", " That's my boy ! Wait , Daniel , when is Pirates of the Caribbean on ? ", ' Is it about Captain Jack Sparrow , who wants to find the treasure on the sea ? ', ' Exactly , now , tell me the time . ', " I won't tell you , unless you promise to let me watch it with you . "]
['Most of our customers are foreigners . How many foreign languages can you speak , Elizabeth ? ', ' Two . French and Spanish . ', ' And how well can you speak them ? ', ' Well , French was my best subject at school . I can read and write it pretty well . ', ' And how about your Spanish ? ', " Well , it's not as good as my French . I can speak it reasonably well , but my written Spanish isn't very good . ", " I see . Well , we have a lot of Spanish customers , but you wouldn't need to write any Spanish here . ", " In that case , I'm fit for the position I think . "]
['This historian is famous in the field of Tang Dynasty . ', ' So he always sits above the salt when there is a seminar about it . ', ' Right , to be famous to be respectable in some way . ', ' You got it . ']
['He has lots of hobbies . ', ' And he ’ s always busy with his pictures and roses . ', ' He ’ s won a dozen prizes for his pictures and roses . ', ' But as for his business in the city ... ', ' He lets his cousins look after his business . ', ' He sounds more like an artist than a businessman . ']
['Good morning , Miss Li . ', ' Morning , Mike . ', ' I ’ m sorry that I was absent yesterday . ', ' I ’ Ve already got your certificate for sick-leave . How do you feel today ? ', ' I feel much better now . ', ' Have you received the reading material handed out yesterday ? ', ' I ’ Ve already got it . Thanks . ', ' I will explain it in detail in the next class . Could you preview it ? ', ' I will . ']
["We'd better leave now . ", ' I beg your pardon ? ']
['Where are we headed now ? ', " To a historic coffeehouse . It's got a little Mafia story to it . ", ' Awesome . Was someone killed there ? ', ' Oh , yeah , while he was eating , and he was a pretty famous Don . ', ' Cool ! Is it safe for us to eat there though ? ', " Sure . In fact , nowadays , you'll see more tourists there than Italians . There are Mafia tours nowadays that go there to eat . "]
['How is everything going with your girlfriend ? ', " Didn't I tell you ? It's over ! ", " Oh , I am sorry to hear that . I did't know that you had split up . What happened ? ", ' It was a few things . The first thing that happened was that we were supposed to go out for a romantic dinner for our one year anniversary , but she stood me up ! ', " Really ! Did she tell you why she didn't show up ? ", ' No , but I ended up finding out later that night when I saw her drinking with another man at a club near my home ! ', ' What was she thinking ? Did you confront her about it when you saw her ? ', " I wanted to , but I knew that if I spoke to her , I'd just blow up at her , so I decided to just go home . I called her later that the night , but she didn't answer the phone . ", " I can't believe she would do that to you . It's so dishonest-and rude ! ", " I know . I still haven't heard from her . The good thing is that I'm so angry with her that I don't feel sad about not having her around . ", " I bet you that she regrets what she's done . You are such a good catch ! She really lost out , didn't she ? ", ' I guess so . ', " So I don't think you'll have a problem finding another girlfriend . There are plenty of fish in the sea ! "]
['How do you usually spend your leisure time ? I mean , do you have any special interests out of your job ? ', ' Of course . You see , almost everyone has some kind of hobby . ', ' Yeah , you ’ re quite right and what ’ s your hobby ? ', ' I like taking photos out of doors . ', ' Oh , photography , It ’ s really a good hobby . ', ' Yes , I usually develop and print all my own photos . ', ' You yourself have a photo studio ? ', ' Yes , simple as it is . It does work . ']
['Have we handed out all the water ? ', ' Yes . So what else to do now ? ', ' Nothing . The teacher said the only thing left was to get back all the disposable cups later . ', ' I see . How do you like the game ? ', " Terrific . There is one girl said , It is the best game I've ever watched . ", ' Who do you think do better ? ', ' Clive was really outstanding . Not only he put on a big show himself , but also he inspired the whole team . ', ' Exactly . He is unbelievable . ', " On the other hand , I think the other team won everyone's respect . The leader said they could have crumpled at the beginning , but they just carried on and never lost their cool . ", ' They were really tough . ', ' The thing I like most about them is that they did not play with a heavy heart even though at that time the odds seemed to be against them . ', " I can't agree more . Okay , time is up . Let's do the last thing . "]
["I'd like to reserve two seats for tomorrow night . ", ' Would you like orchestra seats ? ', " Isn't there anything less expensive ? ", ' Not unless you want the matinee . ']
["Let's do something different today . ", ' Like how ? ', ' I would like you to give me a different hair style . ', ' What did you have in mind ? ', ' Give me a short haircut . ', ' Do you know how short you want your hair to be ? ', ' I want you to cut it to a few inches long . ', " That's pretty short . Are you sure about this ? ", " I've had this idea for some time now . ", " I'm going to do it , but you have to be sure you really want me to . ", ' This is what I want . ', " Fine then . Let's get started . "]
["We can go to the cinema or say at home watching TV , what's it to be ? ", " As far as I'm concerned , staying at home is more comfortable than going to the movies . ", " Thanks , dear . I feel so tired after a whole day's work . "]
['I am thinking about resigning from my current job . ', ' Have you thought about it seriously ? ', ' Yes , I have been thinking about it for quite a while . Now I finally make up my mind to leave . I have given my resignation letter to our boss last Friday . ', ' Ok , did you find a new company ? ', ' Yes , I will move on to XYZ Company . ', ' Good for you , but your leaving will be a great loss to us . It is so nice to work with you . ', ' Thanks . I had learned so much from you and our colleagues . ']
['Hi , Francis . ', ' Oh , Mike . How are you doing ? ', ' Not bad . It seems you are super yogurt lover . You have so many in your cart . ', ' Well , I prefer yogurt to all the other drinks . Have you ever tried a kind of yogurt with old milk in it ? It tastes great and very healthy too . ', ' Oh , I haven ’ t noticed that before . Maybe I will try next time . ', ' Why don ’ t you go ahead of me ? I have more items than you . ', ' Thank you . In fact , I am in a hurry . My wife is waiting for me at the parking lot . ', ' You ’ re welcome . It was good seeing you again . ', ' Me too . Have a great day . ']
['Hi ! What are you watching ? ', ' It ’ s a program about islam . It ’ s very interesting . ', ' Wow ! So many people ! Where are they and what are they doing ? ', ' They are muslims on a pilgrimage to mecca . Muslims call this pilgrimage “ haj ” . ', ' Why do they go there ? ', ' Muslims believe that every man who is able should go on a haj at least once in his life . Mecca is the spiritual centre of the muslim faith . ', ' When muslims pray , they face towards mecca . ', ' That ’ s right . Unfortunately , so many people go on the haj each year that there are often stamped and people get killed . ', ' I heard about that . The pilgrims must walk around a large , sacred black stone . ', ' That ’ s right . That ’ s when accidents often happen . The Saudi government tries to limit the number of pilgrims , to reduce the chances of accidents . ', ' Pilgrimages are common in many faiths . ', ' Yes . In England , Christian pilgrims might go to Canterbury and many Christians go to the Vatican on pilgrimages . ', ' Isn ’ t there a place in france where people go to get healed ? ', ' I think that place is Lourdes . There are many stories of people being healed after visiting there . ', ' Do you think that there is something magical about that place ? ', ' Personally . I think that people believe they will be healed and that faith causes a change in their mind that cures them . I don ’ t think place is magical in any way . ']
['Why do you want to go to the U . S . ? ', ' I want to enrich my knowledge in management . The United States is an ideal place for me . ', ' What will you do when you come home ? ', " Before I work in the office , I was a teacher . So if possible , I'd like to come back to some school to pass on my new knowledge to more people . ", ' Do you feel your English is good enough for the course ? ', ' Yes . You know , English is my present working language . Besides , I scored very high in TOEFL . ', ' Who will be your supporter during your stay in the States ? ', ' I will support myself . In recent years , I have saved enough money for my study in the U . S . ', ' How long do you expect to stay there ? ', ' I will be there for three years . ']
["I don't know what to say . This can't be happening . Here's the obituary . ", " It's really there ? This all seems so surreal-like it's all one big nightmare . ", " But it explains why Taylor isn't answering and Femi took time off from work . ", " Poor Femi . Taylor's death must have made her realize that she still cared for him . ", ' This says the viewing is at Myers Funeral Home today until five . ', " It's already half past four . We should go and pay our respects . Taylor's family will be there . "]
['Dear Anna . I really love you . ', ' I love you , too . ', ' I want to take care of you forever . Will you marry me ? ', ' Oh . My God ! Are you serious ? ', " Am I too abrupt ? Did I scare you ? Or you don't want ... ", " No ! I have been expecting this moment for a long time . I mean my answer is ' yes ' . ", " Oh , I'm so happy . I will try my best to love you and protect you . I promise . ", " I trust you . We'll be happy . ", ' Let me wear you this diamond ring . ', " It's so beautiful . "]
['Balista , pull me a ristretto . ', " What ? You're suddenly some kind of coffee snob now ? What's a ristretto anyway ? ", " It's basically a very strong espresso . Half the water pulled through the same amount of beans . Pure coffee essence . ", ' Sounds like it must be just full of caffeine . I want one of those instead ! ', " You fiend . It's about the flavor , not the fix . Why don't you just crush some caffeine pills and start doing lines ? "]
['The Spring Festival is drawing close . By then we will have five days off . I am expecting it . ', ' Can you tell me something about the Spring Festival ? ', " Just like you celebrate Christmas , we celebrate our lunar New Year's Day , the Spring Festival . It is a time for the family members and relatives to have a get-together . ", ' Christmas is also a special time for us to have the family reunion and to express our best wishes to those we love and those who love us in the coming new year . ', " Christmas has more religious nature , while our Spring Festival is a more traditional holiday . On the New Year's Eve , we have a big dinner called ' Family Reunion Dinner ' . One of the traditional food to eat at the dinner is dumplings . After that , the adults usually sit chatting , watching TV , or playing cards . ", ' What are the children doing ? ', ' They usually go outside to play firecrackers and fireworks . ', ' I heard one of the purposes to do it is to frighten the devils so they will not come to do any harm to people in the next year . ', " Perhaps it is like what people told you . At 24 hours midnight , the time when the New Year really comes , we exchange ' Happy New Year ' to each other , and parents and grandparents will take out small packages wrapped with red paper , in them are some what we call ' Lucky Money . ", ' Who will get the money ? ', ' Of course the children . ']
['We ’ re going to the movies . Will you join us ? ', ' I ’ m very sorry I can ’ t . ', ' Why not ? ', ' I ’ m afraid I have some business to attend to . ', ' Then would you like to have lunch with us ? ', ' I ’ d love to but I have to help John with his math problems right now . ', ' Would you like me to give you a lift ? ', ' No , thanks . His home is not far and I can walk there . ', ' Come on . It ’ s no trouble at all . ', ' Ok , thank you . ']
["Bob refused all his classmates ' invitation . ", " I really couldn't understand him . ", ' He is surely a hard nut , nobody likes approaching him . ', " We'd better leave him alone . "]
['Are your ready to go to the supermarket ? ', ' Yes , are you ? ', " I've got my money and my keys , so I'm ready . ", " You do know that it's absolutely freezing out , don't you ? I'd put a coat on if I were you . ", " It wasn't cold out this morning . ", " Well , it's started raining since then . Look out the window ! It's pouring rain out there ! ", " Well , I guess we'd better grab our umbrellas then , as well . ", ' Have a look outside for me . Does that look like hail to you ? ', ' It does , actually . Maybe we should wait for it to clear up before we go shopping . ', " That's a good idea . But maybe we should move the car so that the hail doesn't dent it . ", " Ok . I'll go move the car if you turn the heat on . It's a bit chilly in here . ", ' How long do you think this hailstorm is supposed to last ? ', " I don't know . The weatherman didn't say anything about this in his weather report last night . ", " Maybe we should turn on the news in case it's supposed to get worse . ", " I don't think we have anything to worry about . Do you want to put on a cup of tea as well ? ", ' Good idea . That will help us to warm up . ', " If I'm not back in ten minutes , come and find me . ", " Alright . I'll have a cup of tea waiting for you . "]
['At the Beijing Olympics , all four table tennis events were all-Chinese finals . A clean sweep again ! ', ' Yes . All international ping-pong tournaments have become a demonstration of Chinese supremacy in the sport . ', " Do you know any secrets to China's success ? ", ' In the first place , I think the whole nation is just fond of the game . It is well grounded with the mass . With huge numbers of people playing ping-pong , we can always spot a handful of potential world champions . ', ' So , the national ping-pong team must be a highly competitive membership . ', ' Sure . There is a careful mechanism for selecting players from provincial teams , and those lucky dogs have to observe strict rules . ', ' For example ? ', ' They are subject to hard training . And you know what , for a player on the national team , personal affairs are supposed to take a back seat to training and competitions . They are not even allowed to talk relationships with each other . ', " Oh , dear ! It's an encroachment on individual rights ! ", " Well , ping-pong is our national sport , and we just have to keep winning one honor after another . That's why many people think such rules acceptable . After all , they are funded out of taxpayers'money . "]
['I can ’ t believe my English teacher is making me read pride and prejudice ! ', ' Why not ! It ’ s a classic . In fact , it ’ s one of my favorite novels . ', ' But it ’ s so old . ', ' Don ’ t judge a book by its cover . Do you Kwon what it ’ s about ? ', ' No , not at all . ', ' First of all , it ’ s a romance novel , set in the early 19th century . ', ' I didn ’ t realize it was a romance novel . What ’ s the main storyline ? ', ' It ’ s basically about a father who tried to marry off one of his five girls . ', ' Why does he want to do that ? ', ' Since he doesn ’ t have a son , he hopes that one of the girls will marry a wealthy man . That way , all of his daughters will be cared for . ', ' Won ’ t they get his inheritance ? ', ' No , that ’ s the problem . Though they are well-off , once he dies , his house will go to his cousin . So , when he dies , the girls will have nothing . ', ' I see . This sounds interesting ! Maybe my teacher isn ’ t so horrible after all . ', ' So , are you going to read the novel or watch the movie ? ', ' There ’ s movie ? My teacher didn ’ t tell me that ! ', ' That ’ s probably because she wants you to read the book first . ', ' It would take a lot less time ... ', ' How about this . When you finish the book . I ’ ll get the movie and watch it with you . ', ' Ok . That sounds like a deal . ']
['Hello ! ', " Hi , Jenny ! Jason here . It's great to hear your voice again . ", " Hi , Jason ! Long time no see . How's the hotel ? ", " It's pretty nice , but I'm going to start looking for an apartment soon . Hotel living is not for me . ", ' I know what you mean . ', ' How about you ? When are you leaving for Berkeley ? ', ' I am leaving in two weeks . ', " So soon ! Well , I'd really like to see you again before you leave . Would you like to go out with me on Friday ? I'd like to take you to dinner and maybe a movie or something afterwards . ", " Oh , I am sorry , Jason . I've already got plans for Friday evening . How about Saturday ? ", " Saturday is fine . I'll make dinner reservations for 7 o ’ clock . Is that ok ? ", ' 7 is fine with me . ', " Great . I'll pick you up at six thirty . ", " I'll be waiting . "]
['When do you want to have the open house party ? ', ' How about next Friday ? ', ' Friday sounds good . ', ' How do you feel about hiring that clown to come and entertain the kids ? ', ' I like that . Then the adults will be more free to mingle and relax . ', " That's what I was thinking . ", " I'm so excited . Finally , a yard of my own . ", ' Do you feel like a king in your castle ? ']
["Dad , I'm scared . ", " Take it easy , honey . It's just raining cats and dogs . ", " But , dad , it's stormy outside . ", " Honey , it's just windy and raining outside . ", ' Ar ! Dad , the power went out . ']
["I'm so glad that the spring festival is near at hand . ", ' me . too i like the festival best of all . ', ' Think of the big face down the eve , hmm . ', ' And special TV programs , fire crackers and the games to play . ', ' Hey , do you know any mystery belief serve the festival ? ', ' Such as ... ', ' You know why fire crackers are set off in festival . ', ' Why ? to welcome the new year of course . ', ' And also to frighten away evil spirits . ', ' Really ? ', ' And my parents say the whole year will be as good or as bad as new year day itself and bad or rude words on the day will bring a bad year . ', " Oh , that's why my parents never scold me that day . they always try to avoid tears and quarrels . "]
['Mary likes mountain climbing . ', ' What ? No kidding ! ', " Yes , she's a professional climber . ", " I can't believe it ! "]
['You must be feeling terrible for Mary . ', " Yes , she's been like this for two weeks . ", " I'm worried that she can't catch up with her class . ", " So am I.The doctor says she'll get over in a month . "]
["You wouldn't believe what I got in the mail today ! ", " what's that ? ", " it's a letter from Ray and Sue in Shanghai ! ", ' have you read it yet ? ', " no , I thought I'd wait until you got home . ", ' go on , read it out loud . ', ' ok . It says , " Dear Jessica . It was so good to receive you letter . I sounds like you and Riley are settling into your new home with ease ... " ', ' when did you send her a letter ? ', ' just a few weeks ago . Sue and I send letters to each other often . ', " I didn't know anyone did that any more . Ok , go on . ", " ok ... I'm going to have to skip over this section . It's girl-talk . ", " that's fine with me . ", " oh . It's actually all rather personal . ", ' well , skip over all of that and read me the rest . ', ' ok , it just says , ball , blah , blah ... " Ray and I look forward to seeing you in June . Write soon . With love , Sue . " ', ' are we going to see them in June or are they coming to see us ? ', " didn't I tell you ? We're going to Shanghai to stay with them in June . ", ' oh , I guess I missed that . ', ' men ! ']
['Jack , what do you think about the election ? ', ' I think the campaign is a blockbuster . ', ' How many people have flung their hats into the ring ? ', ' Finally 100 candidates ran for one seat . ', ' Who do you think will be elected ? ', " It's hard to say . They all had an active campaign to round up the votes . ", ' I think Mr . White would be elected , you know he has spent millions in this campaign and he blasted the opposition in his campaign speech . ', ' Maybe . Who knows ? ']
["May doesn't get along very well with her mother-in-law . ", " Yeah . That's just what is troubling John . ", ' Poor John ! He is bettering bother sides of this bread . ', " This situation isn't easy to handle . "]
["Can you tell me the time ? I've got an appointment at 8: 30 . ", " It's 8 sharp by my watch . ", " Gee ! There's only thirty minutes to go . "]
['Holly , I just heard some terrible news . ', ' Me , too . I overheard someone say Taylor has a brain tumor . ', ' What ? No , I heard that he has stomach cancer . His ex-girlfriend said it . ', " That could explain all his stomachaches . He's trying to hide it from us . ", " Maybe that's why he didn't show up at the potluck . Have you seen him ? ", " No , but someone said he was in the men's room puking . Follow me ! "]
['Hi , Kate . ', ' Hi , Don . What a surprise ! ', ' Yeah , I saw someone walking like you , but I wasn ’ t sure . We haven ’ t seen each other for how long ? Almost three months ? But you look quite different now . ', ' Have you noticed what has changed ? ', ' Oh , you look quite slender and more vivacious . What have you been taking ? Are you on a diet ? ', ' Yes . I ’ m on a diet , but I ’ Ve not taken anything . I just eat less and exercise more . And it really worked in the past three months . I ’ Ve lost twelve pounds . ', ' Wow ! That ’ s great . I sincerely want to achieve my weight loss goals , but it ’ s difficult for me to keep up the exercise . Also you know , old habits are hard to break . ', ' What kind of exercise do you think I do ? I just go to dance everyday after work . I ’ m taking an amateur dance class . I dance two hours everyday . ', ' Dance ? You only go dancing ? That ’ s not hard . I can do that . ', ' Sure . Join my class next week . ']
['What food do you fancy ? ', ' I feel like something good to eat . ', " How about going to Joe's Restaurant . ", ' Hey , that sounds a good idea . ']
["Hello , Jack.It ' s good of you to come . ", ' The pleasure is mine.Happy birthday and many happy returns of the day ! ', " Thank you , Jack.To be frank , I'd rather forget my birthday . ", " Don't be silly . "]
['Sam , we are hard up for the everyday expenses . When can you find a job . ', " I'm looking for it , but you see , the market is hard up for jobs , too . ", " You liar , I saw you again in the inn . I bet you don't want to work at all . "]
["I'm sorry , but I can't find the book you lent me . I guess I have lost it . ", " Don't worry about it . ", ' I really feel bad about it . Let me buy you a new one . ', " No . Don't be silly . I wouldn't dream of letting you do that . "]
["What's your favorite magazine ? ", " Off hand , I'd say the Reader's Digests is my favorite . ", ' What kind of magazine is it ? ', " It's instructive and inspiring . ", " Really ? It is a weekly , isn't it ? ", " No , it's a semimonthly . ", ' Does it enjoy popularity among the young generation ? ', " Yes , it's so popular that it's sold out as soon as it reaches the bookstores . ", ' Oh , I think I should try to read one . ']
['Hello ? Is that Mark ? ', " How are you ? I haven't heard from you in ages . ", " I've been overseas , So have you been busy lately ? ", ' Pretty busy.So are you back for good ? ', " Yes , I was just wondering when you'd have time to go fishing . ", " Well , I'm not working on the weekend , so we could grab some beer , ice and our fishing rods , and head out to the river . ", " That sounds good . I've missed you my friend . ", ' Same here . ']
['Thanks for inviting me to your friend ’ s wedding . I was surprised to hear the bride and groom talking to each other that way during the marriage ceremony . Is that common ? ', ' Well , some people use a standard set of words , but many couples today write their own wedding vows . ', " Your tradition of throwing rice as they got into their car was interesting , but it didn't look like real rice to me . ", " It wasn't . It was birdseed . We don't throw rice anymore because someone discovered that birds come along and eat the rice and have trouble digesting it . ", " Oh , I didn't think of that . Well , this reception reminds me of weddingparties back in China . Plenty of food and drink , music and dancing , and interesting traditions . ", " Wait until you see what happens next ! The bride is getting ready to throw her bouquet . Let's go over and watch . ", ' She ’ s got quite a crowd around her . Oh , look ! That little girl caught it ! ', ' She ’ s my friend ’ s ten-year-old niece . I guess there won ’ t be another wedding in this family for a long time . ']
["We are doing ' Secret Santa ' at the office again this year . ", ' Whose name did you pick ? ', ' I got Jacob . Any ideas what to get him ? ', ' Booze ! ', ' Yeah , you ’ re right . Can ’ t go wrong with that . ']
['So , Monica , what do you feel like doing this afternoon ? ', ' Actually , I had a perfect plan for this afternoon , but it is totally ruined by the sand storm . I woke up this morning and found it was sunny . So I called Lucy and asked her to go shopping with me . We were going to look for a new purse . Now it turned out to be like this . Neither of us wants to go to outside anymore . ', ' That ’ s too bad . I hate sand storms too . It can be worse than any kind of bad weather . ', ' What ’ s wrong with climate ? Anyway , I think the sand storm happens more frequently these days than the years before . Can ’ t people do something to stop it ? ', ' It is not an easy job . The government is working on it . Lots of trees have been planted in the north of the capital . Also , methods of generating rain are being used by the government to fight against the drought . But of course , it will not work overnight . So , have you come out with a new plan for today ? ', ' My new plan is to wait for the end of the sand storm and clean my apartment . ']
["Hey ! What's up ? ", " Hi , John ! I haven't seen you for ages . ", " Yeah , I've been out of town . ", ' So how have you been ? ', " Great ! Work is really busy now , but it's fun . "]
["Bob refused all his classmates ' invitations . ", " I really couldn't understand him . ", ' He is surely a hard nut , nobody likes approaching him . ', " We'd better also leave him alone . "]
['Hey , Paul , why the long face ? ', " It's difficult to explain . ", ' Try me . ', " Well , I had a terrible day of work , I'm thinking of quiting my job . ", ' Take it easy , maybe tomorrow will be different . ', " I don't know , I can't stand my job these days . ", " Cheer up , I hope you'll feel better soon . "]
["I give up ! I simply can't learn French ! ", " Why do you say that ? I think you're making a lot of progress . ", " No , I'm not . I try and try and I still can't speak it very well . ", " Learning any language takes a lot of effort . But don't give up . Why don't we practise those dialogues together ? ", ' Good idea . That might help . ']
['Would you like to go to a party tonight ? ', ' That sounds like a good idea . ', ' Would 7:00 be OK ? ', " That's fine . I'm looking forward to it . "]
["Hello , I'm Jack . Are you Christina ? ", ' Yes I am . Nice to meet you , Jack . ', ' Are you from Italy , Christina ? ', ' No , I am German . I live in Munich . ', ' Really , I went to Munich last week . ', ' And did you like it ? ', ' Oh , yes . It is a fantastic city . And I like German food as well . ', ' And where are you from , Jack ? ', ' I am from California in the United States . But I am now studying in England . ', ' What are you studying ? ', ' I am studying languages . This year I am doing German and Italian . ', " Oh , excellent . Why don't we talk in German for a while then ? "]
['hi , Charlie ! What are you reading ? ', ' hi , bob . I ’ m reading a biography ? ', ' who ’ s it about ? ', ' it ’ s about bob Dylan . ', ' who is he ? ', ' he ’ s a famous American musician . ', ' who ’ s the author ? ', ' it was written by Howard sounds . ', ' what do you think about it ? ', ' it ’ s great ! I ’ Ve learned a lot form reading it . ', ' can I read it when you ’ re done ? ', ' sure , bob ! I ’ m on chapter 12 now , so I ’ m almost finished . ', ' how many chapters does the book have ? ', ' there are 15 chapters in total . ', ' when do you think you ’ ll have finished reading it ? ', ' I should be done by Friday . I ’ ll give it to you in class then . ', ' thanks . Charlie ! ', ' no problem . Bob . ']
['Whip me if I get below 80 marks out of 100 ! ', " Take it easy , Jim . Your mother didn't mean it ! Need any help ? ", " Yes . Can you help me remember how to spell ' beautiful ' ? "]
['Where are you planning on transferring to ? ', ' I can ’ t seem to make a decision . ', ' Where do you want to go ? ', ' I honestly have no idea . ', ' You haven ’ t thought about it ? ', ' I like it here at PCC . ', ' Why don ’ t you just continue going to PCC ? ', ' I like that idea . ', ' It ’ s a great school . ', ' I completely agree . ', ' So , have you made your decision yet ? ', ' I ’ m staying right where I ’ m at . ']
['Any plans tonight ? ', ' Not really , do you ? ', ' Well , I am wondering if we took a hang-out for a drink or something . You know , I just came back from a really tough interview . I was quite nervous during the interview . I really want to have the job . Right now , I am still a little on the edge . I am not sure if I could convince them during the interview . ', ' Take it easy . It is all over now . How was it going , anyway ? ', ' I don ’ t know . I think I did well in the paper exams . I was prepared to answer a lot of questions , but they didn ’ t ask those as I expected . To my surprise , the manager tried to talk about the Chinese poesy with me . ', ' That ’ s strange . But probably , it is the new interview technique they call it “ Getting to know you more personally ” . What about your answers ? ', ' Just did my best . ']
['Mary , how was your date with john ? ', " It's ok . It seems we have a lot in common . ", ' Oh , really . That is great news . What does he look like ? ', ' He is tall and slim , fair-haired . ', ' Sounds like he is pretty cute . What do you think of him ? ', ' He is a nice guy and very considerate . I was impressed with how smart he was and he has a great sense of humor . ', " Oh , it's love at first sight . When will you see each other again ? ", " He didn't say , but he said he would call me . ", ' Maybe he is busy with his work . Just wait and try not to think about it too much ! ', " Oh , steve . Stop it ! I am a bit nervous ! What if he doesn't call ? ", " Come on , Mary , you're a total catch . I bet he will call you . Don't worry . ", " Thank you , Steve . You're always so encouraging . ", " That's what friends are for . "]
['In my opinions , someone else has caused the fire of this house . ', ' Who do you think that has the motive ? ', ' I ’ m not sure now . In any case , let ’ s first make some careful investigations . ', ' OK , murder will out ! ', ' Yeah . ']
['So Dick , how about getting some coffee for tonight ? ', ' Coffee ? I don ’ t honestly like that kind of stuff . ', ' Come on , you can at least try a little , besides your cigarette . ', ' What ’ s wrong with that ? Cigarette is the thing I go crazy for . ', ' Not for me , Dick . ']
['Thank you for your hospitality , Leon . I had a wonderful time ! ', " You're welcome , Diane . I hope you can visit us again soon . "]
['David , why didn ’ t you clean the room ? ', ' I ’ m not in the mood . ', ' Why are you feeling depressed ? ', ' I was told my girlfriend was speaking ill of me . That ’ s a real let-down . ', ' I don ’ t think she will do such a thing . ', ' But she did and made me disappointed . ', ' Oh , cheer up . A girlfriend is not everything . ', ' But she means a lot to me . ', ' Then forgive her mistake . ', ' Oh . I just can ’ t forget it . ']
['Which university did you graduate from ? ', ' I graduated from Songhua University . ', ' When did you graduate ? ', ' I graduated from it in 2002 . ']
['You are friend of Janet , right ? I am Andrew , Andrew Smith . ', " Nice to meet you , Andrew . I am Noirin , Noirin O'Neil . ", " I'm sorry , I didn't quite catch that . ", " Noirin , N-O-I-R-I-N , it's an Irish name . "]
['Would you like a cigarette ? ', " No , thanks . I've decided to give up smoking . ", ' Really ? Why ? ', " Well , it's just that I think if you don't enjoy doing something any more , you should stop doing it . ", " I see . You mean you don't enjoy smoking any more ? ", " That's right . You should give it up , too . It's bad for your health . ", " Stop talking like my mother . That's what she keeps saying . ", " But it's true . It's a nasty habit . I can't think why I ever started . Anyway , it's obviously got you in its grip ! ", ' What do you mean ? What are you talking about ? ', " I mean you couldn't give it up ! ", " Who ? Me ? Could't give up smoking ? Nonsense ! Of course I could ! I know I could ! ", ' How do you know ? ', " Because I've already proved it . Smoking's the easiest thing in the world to give up . I've done it hundreds of times ! "]
['Do you think Mr . Johnson is a good worker ? ', " Just between you and me , I think he's lazy . ", " Haven't you ever seen him working late ? ", " No , I haven't . "]
['What do you think of smoking ? ', ' It ’ s harmful not only for yourself but for others . ', ' What in your opinion can be done to stop smoking ? ', ' Stop producing cigarettes . ', ' But that ’ ll affect the national economy . ', ' That ’ s right . But I don ’ t think there are better ways . ', ' How about painting a warning on each cigarette packet ? ', ' Maybe it can take effect . ']
["I'm here to express my congratulations to you on your birthday . And I wish you many happy returns of the day . Here is a birthday present for you . ", ' Many thanks for your presence . ']
['How did you spend the weekend ? ', ' I went to a movie with my boyfriend . ', ' Really ? How was it ? ', ' It was great . The director took a lot of care while framing . They say be has good chance at winning the Oscar for best director . Also I like the actors , some really great new young actors . ', " Oh , yeah ? What's it about ? ", " Well , it's the classic love story between two people from conflicting backgrounds . But besides a beautiful story , the cinematography is great . There is some really dramatic footage . It's really quite a visual feast . And the soundtrack is moving . ", ' Sounds pretty good . Is it a tragedy ? ', " The ending is a bit of a surprise . I don't want to ruin it for you . ", ' Oh , I like movies with surprise endings , although , sometimes they can be frustrating . Maybe I should invite my girlfriend to go next weekend . ', " It would be a really good choice . The movie is very suitable for lovers to see together . I'm sure you won't regret it . "]
['Would you like to come out with me tonight ? ', ' Sorry , I can ’ t . ', ' Tomorrow night , then ? ', ' I ’ d like to . But I ’ m afraid I can ’ t . ', ' I ’ m wondering if you like to go to the theatre then . ', ' That ’ s sounds great . ', ' Ok . How about give me a ring , then ? ', ' No . I ’ d better not . ', ' Why not ? ', ' Because I don ’ t think my husband would like it . Thank you for inviting me anyway . ']
['My goodness ! You ’ re kidding ! ', ' No . I ’ m serious . I ’ m going to quit my job . ', ' That ’ s amazing ! You got a good pay here , didn ’ t you ? ', ' It ’ s true . But I can ’ t show my abilities . ', ' Come on ! Don ’ t be silly ! ', ' Your present job is something better . Why do you change ? ', ' Well . How do you know ? ']
["All of my friends are going out to the lake tonight and I'm going too ! ", ' Over my dead body you are ! ']
['Hello , Anna speaking ! ', ' Hey , Anna , this is Jason . ', " Jason , where have you been hiding lately ? You know it's been a long time since your last call . Have you been good ? ", ' Yes . How are you , Anna ? ', ' I am fine . What have you been doing ? ', " Working . I've been really busy these days . I got a promotion . ", " That's great , congratulations ! ", ' Thanks . I am feeling pretty good about myself too . You know , bigger office , a raise and even an assistant . ', " That's good . So I guess I'll have to make an appointment to see you . ", ' You are kidding . ', ' How long have you been working there ? ', ' A bit over two years . This is a fast-moving company , and seniority isn ’ t the only factor in deciding promotions . ', ' How do you like your new boss ? ', ' She is very nice and open-minded . ', ' Much better than the last one , huh ? ', ' Yeah . He was a real slave driver . He probably would have loved it if we were robots . ', " Forget about him . Come over to my house tonight . Let's get drunk . ", " Good . Tonight 8 o'clock . ", ' 8 it is . See you then . ', ' Bye . ']
['Shall we go to a movie tonight ? ', " That's a good idea.What ' s on ? ", ' Gone with the Wind . ', " What's it about ? ", " Sorry , I've no idea . "]
['I never understand why these shops have so much liquor . ', " What do you mean ? It's because it's much cheaper to buy liquor duty-free . ", " But why ? Why don't people like to buy shirts duty-free ? Or shoes ? I just don't understand why it's always liquor . ", " Well , it's because in most countries liquor has a higher tax on it . ", ' You mean liquor has a higher tax than other things ? ', " Yes , of course . Didn't you know that ? ", " No , I didn't . How high is the tax ? ", " Well , it is different in different countries.But it's because of the high tax that buying liquor duty-free is such a good deal . ", ' Why would the government want to tax liquor so much ? ', " Liquor is considered a luxury item.And also , it is considered as something that isn't very healthy.So if people want to buy it , the government thinks it has the right to tax it . ", " That's why a lot of people buy cigarettes here too , isn't it ? ", ' Of course . Cigarettes are also taxed very heavily . ']
['What do you plan to do on Sunday morning ? ', ' Nothing special . ', ' How about going to English corner with me ? ', " Oh , I'd rather not . ", ' Why not ? ', ' You know , I am poor at English , especially spoken English . ', " That's why you should go there , If you don't dare to speak English owing to the fact that you are afraid of making mistakes , you simply will never learn English . "]
['Why are you walking to and fro in the room ? ', ' I ’ m worrying about the children . After all this is the first time they have been out without us . ', ' Don ’ t worry . They are grown-ups . ', ' I know . But I couldn ’ t help . ']
["Mary , why don't you come to my house this Saturday ? ", " I don't know . I'll have to ask my host mom . ", ' Come on , Mary . This is America . You make your own decisions here . ', ' But I still have to tell her . ', ' Of course . ', ' Tell you what , give me your phone number . ', " It's 555-4321 . ", " Got it . I'll call you later tonight and we can talk about what to do on Saturday . "]
['They must be your parents , what do they do ? ', ' My mother is a professor and my father is a manager . ', ' Do they often take you out ? ', " No , usually they're very busy . "]
['I went to the doctor yesterday . ', ' I beg your pardon ? ', ' I said I had been to the doctor the day before . ', ' What did he say ? ', " He said I ' d got the flu . ", ' Oh dear ! What did he tell you to do ? ', ' He told me to stay in bed for ten days . ', ' Ten days ? Would you please repeat it again ? ', ' Yes , ten days . ']
['Have a nice weekend . ', ' Same to you . ']
['It seems to be clearing up . ', " It's such a nice change . ", " I really don't think this weather will last . ", " Let's just hope it doesn't get cold again . "]
["There's a new play tonight . ", " What's its name ? ", " ' Romeo and Juliet ' . ", ' What is it about ? ', " It's about their great love . ", ' Sounds interesting . ', ' Of course . Do you want to see it ? ', ' Yes , do you have tickets ? ', " No , I don't . ", " Let's go to the theater and buy two tickets now , shall we ? ", " Good idea . Let's goa ", " OK . Let's go . "]
['Wow ! What happened to you ? You look sad . ', ' I just lost my job . My boss just told me . ', " That's unbelievable . Why did this happen ? ", " I don't understand of myself . It seems they have to save money . ", " I cant't believe it . You've worked here for years . "]
['Your father looks much younger in the picture . ', ' He was 20 years old then . ', ' How old is he now ? ', " He's over sixty . "]
['Hello ! Let me introduce myself . My name is Nancy . ', " Nice to meet you , I'am Simon . I don't think I ' Ve seen you around before . ", ' No , I just started working here at IBM , I am in the sale department . ', ' What do you do there ? ', ' I main market reasearch , and you ? ', " I ' Ve beaning worked IBM for years . I am vested personnel file system , He is the after sale survise director . he such a nice boss , I like working for him . ", " Really ? I don't believe I would met him , is he here now ? ", " Yes , That's him over there - the taller , handsome one . Would you let me introduce you ? ", " Thanks , that's would be lovely.You ' r right , he is kind and nice looking . "]
['Hey John , did you register for classes yet ? ', ' I register this Friday . ', ' What classes do you plan on taking ? ', " I really want to take the communication class , but I don't know if it will be available . ", ' Is that class really that popular ? ', ' Yeah . I tried to get in last semester , but it was full by the time I registered . ', ' What other classes are you going to take ? ', " I still need to take English 201 , but I really don't like writing . ", " I took that class already . There is a lot of writing , but it's not that bad . ", ' Oh really ? Who was the instructor ? There are like 4 different instructors to choose from . ', ' I had Professor Mahoney . ', ' Is he an easy grader ? ', " I'm not sure if he is or not , but I thought he was definitely fair . ", ' Do you mind if I ask you what you got ? ', ' Not at all . I got a 3.8 . ', ' Well , what did you get in English 101 last year ? ', ' I got a 4.0 in that class . ', " Well , I can't compare to you . I got a 3.1 in English 101 . That means if you got a lower grade in English 201 , it must be harder . ", " It's not what it appears . I actually tried harder in the 101 class . If I put as much effort into the 201 class , I would have received the same grade . ", ' Oh . That helps . Thanks . ']
['Mr . Smith is really a thorough drag . ', ' What is it ? ', " He's endless talking about stocks almost bores me to death . ", " Don't you like to know anything about stocks ? ", " I'm not at all keen on this subject . "]
['Hello , Green here . ', " Oh , Mr Green , my name is Jianshan . You don't know me , but I'm a friend of David Smith . ", ' Oh , yes . ', ' When I told David I was coming here to live , he give me your number , and suggest that I give your a ring . I was wondering if you could give me some advices . ', " I'll be please to if I can . What can I do for you ? ", " Well , I'm looking for a place to live . David thought as you are a @ agent . you might know something is suitable . ", ' Yes , I think I can help you . Why not you come around and see me ? Do you know my office ? ', " Yes , I've got the address . ", ' Good , where are you now ? ', " I'm at the post office . ", " oh , well , that's just a few minutes walk to my office , come around and see me now . ", ' Thank you very much , Mr Green . ', ' Not at all . ']
['Like to come over to our fancy dress party ? ', ' Oh shame ! I have a class tomorrow . ', ' Well , then join us some other time . ', ' Yeah . Thanks . And have fun ! ']
['What are your plans for today ? ', ' Nothing special . ', ' Would you like to have dinner with me at King Hotel at 7pm ? ', " I'd like to . See you then . "]
['Could you do me a favour ? I don ’ t understand this French document . ', ' Oh , this is over my head . It ’ s too professional . ']
['School has added several new courses to our grade this semester . I have more homework to do now . ', " What's your favorite course , Daniel ? ", ' I like science most . ', " Science ? That's a surprise . ", ' Surprise ? ', ' I thought you would like PE . ', ' I do like PE , but I am interested in science . ', " Are you interested in science ? I can't believe it . ", ' Through this course , I can learn more about the world around us clearly . ', ' Your parents would be happy if they knew that . Because you are always a naughty boy . ', " Naughty ? I'm naughty ? I'm just clever . So I only do the things I am interested in . ", ' Hope so . ']
['Hi , Tony . Haven ’ t seen you for a long time . How have you been ? ', " OK , I ’ Ve been looking for a job for days , and I haven ’ t found one yet . It's so hard finding work these days . Have you had any luck ? ", " Yes , I've got a job , a waiter's job in a restaurant . ", ' Are you well paid ? ', ' Well , $ 10 per hour , but I can keep the tips . That comes to roughly $ 80 every evening ', ' Not bad . ', " Actually , there's still another opening . If you are interested , you ’ ll surely get it . ", ' That ’ s great ! I ’ ll go there right now and speak with the boss . ', ' There ’ s no rush . You can see him tomorrow . I ’ Ve told him about you . He promised to give you the job . ', ' That was nice of you , Susan . Thanks a lot . ', ' Think nothing of it , Tony . I ’ m sure you ’ d do the same for me . ', " Could you tell me a bit more about the work there ? I mean , those dos and don'ts . I am a green hand , you know . ", " First of all , you must be punctual . You should be there before 6 p . m . so that you will have half an hour for preparation changing clothes and things like that . Then , remember you should smile . Smile to your customers all the time . Never pull a long face even If you feel awful that day . Anything else ? Oh , yes . Never argue with your boss . Learn to say ' Yes , sir . ' ", ' Be a yes-man , you mean ? ', ' You may put it that way if you like . Don ’ t worry . You ’ ll have no problem . ', ' I hope not . ']
['Hi , Tim , any news about your job interview ? ', " Yeah , I didn't get the job in the end . ", ' Oh , what a pity ! ', " It's ok , that's life . "]
['Hello , Kith , can you and Alice come around this evening ? We prefer your coming . ', ' I think we would be able to make it.What time shall we come ? ', " About 7 o'clock . ", ' Shall we bring any thing ? Some wine ? ', ' No , not really.Just bring yourselves . We would like to your presence . ']
['Tom , I married Julia last month . Have you already known it ? ', " No , I haven't . I'm so surprised at the news . ", ' Indeed , we got married too soon . ', ' Congratulations . But have you heard the proverb that if one gets married too hurriedly one may regret it for a long time ? ', ' Yes . However , I believe that marriage comes by destiny . I knew I would marry Julia when I met her at the first time . ', " How's your married life ? ", " We're happy together now . ", " I have to say you're a well-matched couple . ", ' Thank you ! ']
['What did you learn at the workshop you went to yesterday ? Do you think it was worth the investment to go ? ', ' Yeah , I really got a lot of the session . The workshop topic was resolving personal problems . It was led by a professional human resources director . The teacher had a lot of experience , and I think we were all given a really good base to start with . ', ' The workshop was only one afternoon long , do you really think you can learn that much in only a couple of hours ? ', ' It depends on the topic , the teacher , and the way the course is set up . Yesterday , even though we only had a short time to discuss the issues , the workshop got us all thinking . We learned some very basic , but very useful methods of dealing with personnel issues . ', ' Sounds like you really learned a lot . ', ' I did ... I just hope I can implement all these great ideas that we shared . ']
['Every teacher likes him . ', ' They say he can sum up like winking . ', ' How he manages to do that is always a mystery to me . ', " Maybe he's gifted in that . "]
["There's just one catch . Zina asked me to let you know . ", ' What ? ', " She promised that we'd be ready to start tracking the Stars.com web site by the end of next week . ", " What ! ? It'll be a miracle if we're ready by the end of the month ! Is she crazy ? ", ' Yes , I think she is just a little bit crazy . ', ' Crazy is too kind . Insane is more like it . Nuts ! Wacko ! Psycho ! ']
['Would you like to have some more wine ? ', ' Sure.thanks . ', ' Say when . ']
['I ’ m terribly sorry to cause you so much trouble . ', ' That ’ s alright . ']
['Do you know where Helen is ? ', " She's gone to a flower shop . Today is her husband's birthday . ", ' That reminds me . My wedding anniversary is tomorrow . ']
['What sport do you like the most ? ', ' I like baseball the best . ', ' Me too . Did you play when you were a kid ? ', ' Yeah . I played until I graduated from high school . ', ' What position did you play ? ', ' I think I tried every position , but the last few years , I played third base . ', " I hate third base . It's scary when the ball is coming at you so fast . ", " It was scary at first , but after awhile , I got used to it . If you have fast reflexes , then it's not really a problem . What position did you play ? ", ' I played outfield . I hated the infield because I never figured out all the bounces . ', " I wish I could play again , but there isn't much opportunities around here . ", " I'm on a softball league . It's not fast pitch , but it's still fun . You wanna join our group ? ", ' When do you guys play ? ', ' We play either Tuesdays or Thursdays . ', " Sounds pretty fun . I'll come out and join you next time . "]
["Jane's mother always wants her to marry a big shot . J ", " That is just wishful thinking . The cost of higher education has increased in recent years , faster than the cost of living . So she wants Jane's brother to go on studying and earn his doctorate by means of it . ", " But it's unfair for Jane . "]
["I'm back . ", ' What have you done ? ', ' Going shopping . It tires me too much . ', " Why don't you go shopping online ? ", ' Can I ? ', ' Why not ? Let me recommend a website . ', ' OK . What does it sell ? ', ' It sells almost everything you can see in the department . ', " That's great . "]
['Hey Nick , what are you up to ? ', ' Not much , just heading over to the shooting range . You wanna come ? ', ' Seriously ? You mean to fire a real weapon ? I don ’ t know man . ', ' Yeah , it will be fun ! I have a 9mm pistol that is really easy to shoot . I also have a revolver that ’ s really fun too ! They have big targets at the range that we could use to practice and improve you ', ' Yeah that would be cool ! Maybe I can also have a try at other weapons like a machine gun or a shotgun ! Maybe even a rocket launcher or an anti tank missile ! Or what about a flame thrower ! ', ' Whoa , take it easy there Rambo . Don ’ t get carried away . These weapons are not toys , and you must first learn how to handle them properly . There are basic rules that you must abide by in order to be ', ' Wow , I didn ’ t know ! It always looks so cool and easy in the movies ! ', ' The reality is different you know , running and firing a weapon is a lot harder than in the movies ! So are you ready ? ', ' Let ’ s do it ! ']
['I went out with Leo last night . It was really exciting . ', ' Really ? You are a lucky dog . You know , many girls dream of dating him . ', " Yes , I know . He's really on the A-list . "]
['What kind of note are you taking there . That looks like doodle to me . ', " It's picture association of the concept that the professor taught today . ", ' Does that actually work for you ? ', " I don't really know for sure yet . I'll tell you after the test on Friday . ", ' I like to use shorthand note taking . ', ' I was told once that the more time you spend writing , the less you are paying attention and so you miss stuff . ', ' Hmm . I never thought about it that way . ', ' One time I tried just listening , no notes , no pictures . I think I really learned more that day . ']
['I heard that ben is forming his own band . ', ' It will be a rock and roll band probably . He ’ s a very good guitarist . ', ' Can you play a musical instrument ? If you can , he might ask you to join the band . ', ' I can play drums , but I haven ’ t played for a while . I ’ m not sure I ’ d be good enough to play in a band . ', ' I wish I could play a musical instrument . I love music . ', " Nowadays , you can be a DJ . You can mix dance music . You don't need to be able to play music instrument or thing . ", ' I love to try it , but the instrument is expensive and it was still need to take a lot of practice . ', ' You know , you could probably get a computer program that would help you . You already have a computer , so you could use that to help you mix some music . ', ' That ’ s a great idea . I ’ ll search for some information on the internet . If it ’ s possible to do , the internet will have some information about it . ']
["It's one of the highlights of the match . ", ' What ? ', ' The wonderful passing Melaena did . ', ' Too bad I missed it . ']
['Susan has been down recently . I saw her this morning , she looked terrible ! ', ' You have any idea why ? ', ' She broke up with her boyfriend . ', ' I heard her boyfriend is married . ', " She still loves him . That's why she feels upset . Her love is always hard and confusing ... ", ' Then what about you ? How are you getting on with your boyfriend ? ', ' He sometimes really drives me crazy . ']
['Your tree looks beautiful . Do you decorate it this way every year ? ', " Yes , it's a family tradition dating back to my childhood . We use the same lights and ornaments , but of course we have a new tree each year.The children made some of these decorations . Here , you can hang this on one of those high branches . ", ' Well , everything seems to be just about ready . Now all we need is snow.Do you exchange the presents in the morning ? ', ' Oh , yes . The kids are too excited to wait . After we clean up the mess all the empty boxes and the wrapping paper we have a big breakfast . Then the kids have the whole day to play with their new toys . ', " And we'll have a great turkey dinner at around four o'clock . My brother and his family will be joining us . I look forward to meeting them . Well , it's late , so I'll say good night . I'll see you early tomorrow , so I can share your Christmas morning.Good night ! "]
['Has your family lived here for long ? ', ' Five and a half years . We moved here on the first of November . ', ' You have a fantastic view . ', ' Yes . I love living here . ', ' Look ! You can see the village way down in the valley . ', ' Yes . It ’ s a lovely view . ']
["Hi , Mary . I haven't seen you in ages ! I heard that you and Daniel are getting married on August 8th , the opening day of the 2008 Olympic Games . Is it true ? ", " yes , it is . We've been dating for over 7 years . We have decided to get married on a special day and we think August 8th , 2008 is a red-letter day . ", " good for you ! It sounds like you've done a lot of planning in a very short time . ", ' yes , there is a lot of to be taken care of---wedding photos , wedding dress , catering , transport , hotel , etc ... ', ' is everything ready now ? ', " almost . The only thing that isn't ready is the hotel . As a lot of people have chosen that day to get married , it is hard to find a hotel that isn't too expensive . ", ' have you tried The Peninsula Palace Beijing ? My wedding reception was held there and they did an excellent job . ', " yes , we called , but it is booked up . The only choice is the Regent Beijing but we haven't made up our minds yet . ", " it's an excellent hotel . A friend of mine had her wedding reception there and said it was perfect , though very expensive . ", " that's why we want to have a look at other hotels . We don ’ t want to spend too much on an extravagant wedding reception . ", " I guess you're right . I can help you ask other hotels . I am sure there are probably some available . ", ' thank you . ', ' my pleasure . ']
['Are you doing something on Saturday evening ? If not , welcome to my new apartment . ', ' You moved to a new place ? ', ' Yes , I have been busy emptying the packing boxes and cleaning up the mats . Right now , it looks like a home . I would like to have a small celebration party . Please do come . ', ' Thank you for inviting me . Sounds lovely ! I would like to come . Where is your new apartment ? ', ' It is in the DX community , Room 306 , No . 2 building . It is very easy to find . Just ask the guard at the entrance . ', ' Who else will come ? ', ' I invited all the colleagues in our department and also my former neighbor , Paul . He is a very good person . You should meet him . ', ' Ok , I will be there around 6 . Is that ok for you ? ', ' Yes , great . I am happy you are coming . ']
['What are you doing over the weekend , Sara ? ', " I'm planing to go balling tonight . Tomorrow I was hoping to see a movie . What about you ? ", " I want to go camping , you know , just get a way for the weekend . I'm not sure I'll be able to , though . ", ' Why not ? ', " Well , I have a lot of work . I'll see how to goes . "]
['What brings you to Beijing ? ', " I'm here on business . "]
["I've heard that you've made a new strange friend recently , Sophie . ", ' Yes . He is an old man with a great sense of humour . Not only can he play the piano , he also draws pictures very well . ', ' So you can learn a lot from him . ', ' Yeah , he has no children , so he sometimes feel s very lonely . I often go to his house to play and talk with him . That makes him feel very happy . ']
['Happy new year ! ', ' Thank you . Same to you . ', ' Have you got any plans ? ', " I've been invited over to a friend's , and you ? ", " My roommate's having a party . "]
["I can't wait to go skiing tomorrow . ", " I know . It's going to be so much fun . ", ' I always get excited the day before . ', " I used to be like that . But I go skiing so often that I don't get excited anymore . ", " I only go skiing twice a year , so it's a real treat for me . ", ' That makes sense . ', ' What things make you excited ? ', ' Whenever I go to Vegas , I get really excited . ', ' Oh ... that makes me excited too ! ', ' Looks like anything fun makes you excited . ']
['I heard you are busy with your new house now ? ', ' Yeah , I want my own house very much , so I decide to buy one . ', ' Let meet this right — — do you want to buy the house ? ', ' Yeah . This is a big house with a garden . I like it very much . ', ' But it is far from downtown . Living here is very inconvenient . ', ' It is very quiet and peaceful . This is what I want . ']
['What can I do for you ? ', ' I was looking for a book , but I couldn ’ t find it . ', ' Did you check our database to see if it was on the shelf ? ', ' I already did . ', ' Is it on the shelf ? ', ' I didn ’ t see it . ', ' Apparently somebody took that book out of the library . ', ' Will you ever get another copy ? ', ' We will definitely be getting another . ', ' Could you please reserve it for me ? ', ' That won ’ t be a problem . ', ' Thanks . I really appreciate that . ']
['When can we expect you and your daughter for dinner ? Next Saturday ? ', ' Next Saturday ? I ’ m sorry . I ’ Ve promised to go to a Chinese Opera with my daughter . ', ' How about Sunday then ? ', ' Yes , Sunday sounds fine . What time ? ', ' Does six thirty suit you ? ', ' It suits us fine . We ’ ll see you then . ', ' Thanks , goodbye . ']
['Do you mind helping me ? ', ' What can I help you with ? ', " I'm not sure how to find my next class . ", " Do you know what building that it's in ? ", ' The C building , I think . ', " Well , that's not far away . ", ' Could you point me in that direction ? ', ' Do you know what the room number is ? ', " It's C261 . ", ' My next class is around there . ', ' Can you show it to me ? ', " Sure , let's go . "]
['Could we go over some things , because I think my test score is wrong . ', ' What do you think is wrong , the math or the way your answer was scored ? ', ' Both . ', ' I am willing to take a second look because teachers make mistakes , too . Will that work for you ? ', " Yeah , I'm ready . ", ' Check your answers against the ones on the answer sheet and let me know where you see the mistake . ', ' These look strange . ', " Yes , I agree ; let's move on to the calculating of the score . Would that be OK ? ", " OK , let's do the calculation . ", ' We add all of these up and divide by this and that gives us this percentage . ', ' I see . ', ' Anytime you have a question , please feel free to ask ! ']
['How can I live without Helen ? ', " Get a hold of yourself , Bruce . You'll get over her eventually . "]
['Did you hear peter just retired ? ', " Are you sure ? He is quite young , isn't he ? ", " He is not young as he looks . I think he's almost sixty . ", ' Really ? He looks so young . ']
['Lodge , You must come around sometime , You have to check out my mew stereo . ', ' Sure , When is good time for you ? ', ' Can you make it on Tuesday ? ', ' What time do you want me there ? ', ' Anytime after six will be fine . ', " All right , It's a date . "]
['How long have you been living in New York ? ', ' Oh , about two years now . ', ' Where do your parents live ? ', ' They still live in Shanghai where I was born . ', ' Do you write or call them very much ? ', ' Yes , I try to keep in touch with them . ']
["I don't dare ask Jane for a date . ", " You've got no guts ! "]
["Excuse me , what's your name ? ", " My name is Jessica . What's yours ? ", ' John . ', ' You speak English very well . ', ' Thank you . ', ' Do you know what time it is ? ', " Sure . It's 5:10 PM . ", ' What did you say ? ', " I said it's 5:10 PM . ", ' Thanks . ', " You're welcome . "]
['Japanese is easy to learn . ', " You're mistaken about it . As a matter of fact , it's very hard . ", " I don't think so.There ' re so many familiar characters and they sound just like Chinese . ", " You're quite right.But many Japanese learners begin with smiles on their faces and end up with tears in their eyes . "]
['Today people are hearing about information superhighways and the intermet . ', ' Is this change going to be beneficial for theindividuals like you and me . ', ' Yes , I think so . My friend once used it mostly to play chess , but now he has learnt how to do other things on the Internet . ', " There's no doubt the Internet will be a powerful commercial medium . It'll connect hundreds of millions of customers and open up huge markets for all kinds of products and services . ", " That's true . I can imagine companies sending advertisements directly to customers over the net . Customers , in turn , can examine and compare whatever goods they want to buy and tell their computers to find them at the best price offered . ", " Yeah . It'll be a shoppers heaven . That's the use of net in E-commerce . "]
['What ’ s the problem ? Things are getting out of hand . You keep sticking your nose where it doesn ’ t belong . ', ' What do you mean ? ', ' Now , I am responsible for training new staff , but you keep overriding my authority by trying to pose your methods . I know you are a hotshot college graduate with something to prove . But I don ’ t like your way . ']
['How was your holiday to Cyprus ? ', ' It was so fantastic I didn ’ t really want to come home . ', ' Did you happen to meet someone ? ', ' How did you know ? ', ' You always act like this when you ’ Ve fallen in love . Who is he ? How did you meet ? ', ' His name is Tony and we met my first night in Pathos . He works with my sister who lives there . ', ' Was it love at first sight ? ', ' Not really . I wasn ’ t looking for a holiday romance , but my sister told me that she had promised him that she ’ d set him up on blind date with me . I didn ’ t think I ’ d have anything to lose , so I went . ', ' And ? ', ' Let ’ s just say that by the third date , we both realized that we had fallen in love . ', ' That happened quickly ! Are you going to see him again ? ', ' Luckily , his company has a position available here , so he ’ s going to see if he can get relocated . ', ' It sounds like he is madly in love with you . Are you ready for such a serious relationship ? ', ' Well , I ’ m not really a spring chicken anymore . We don ’ t know what will happen . ']
['Are you a smoker ? ', ' Yes , I ’ m afraid I am . My husband is a smoker too . ', ' Would you describe yourself as being a heavy smoker ? ', ' No . But my husband smokes 20 or more a day . ', ' When did you begin to smoke ? ', ' I had my first cigarette when I was 17 . ', ' Might I ask if you have tried to give up smoking ? ', ' Yes . Twice . ']
['what do you hope to do when you finish university ? ', ' I ’ d like to go into management . I ’ Ve applied for several jobs already and I ’ m hopeful that I ’ ll get some job offers . How about you ? ', ' after I graduate , I have to do some more studies to pass exams to become a lawyer . I think I ’ Ve got a good chance of passing . There ’ s a possibility of getting a job with a law firm in London , provide ', ' we both have to overcome several obstacles if we are to achieve our ambitions . ', ' if life were easy , then we ’ d achieve our ambition quickly and then get bored . ', ' unfortunately , it ’ s inevitable that some people are going to work hard yet not succeed . ', ' that ’ s why ambition need to be realistic . You can ’ t achieve something that ’ s totally unrealistic . ', ' as long as you plan carefully , most thing are possible . It ’ s always good to have a backup plan in case things go wrong . ', ' I think it ’ s important to be successful in a field you are truly interested in , not something that other people force you to be interested it . ', ' my father wanted me to become a doctor , but I knew it would be impossible for me to be successful in that field . ', ' I hope my parents don ’ t try to interfere in my choice of career . ']
['Hey , Susie , what health club do you belong to ? ', ' Total Fitness , why ? ', ' Well , I ’ Ve been going to Athletic Express , but I don ’ t like it there . ', ' Really ? Why not ? I hear it ’ s pretty good . ', ' The people don ’ t really work out there . They just stand around and talk all the time . ', ' Oh , it ’ s one of those places . ', ' Yeah , is your club different ? ', ' Well , they have different rooms . I lift weights by the pool where there aren ’ t so many people . ', ' Do they have a lot of equipment ? ', ' Yeah , they have all the machines , a pool , and a steam room and sauna . ', ' Sounds nice . What about classes ? ', ' The usual . Aerobics , kickboxing , yoga . They just started a Tai Chi class too . ', ' Wow , that sounds great . ', ' Well , I have a guest pass . Why don ’ t you come with me tonight ? ', ' Really ? Thanks . I ’ ll stop by when I get off work . ', ' Perfect . See you later . ', ' O . K . , see you . ']
['Do you like traveling ? ', " Yes , I've just come back from Scotland . ", ' Where did you visit ? ', ' I only had time to visit Edinburgh . ', ' How did you like it ? ', " It's fantastic . ", ' Why did you go there ? ', ' I went there on business . ', ' And do you have friends there ? ', ' Yes , a lot of friends . ', ' You must have enjoyed yourself . ', ' Yes , and I look many pictures . ']
['Susan , Did you know the four ugliest women in ancient China ? ', ' No , I only know four great beauties of China . ', ' There were some famous ugly women in history . ', ' Yeah ? Were they famous because of the ugliness ? ', ' Though they were ugly , they had great virtue . ', ' Then who were they ? ', ' Mo Mu , Thong Lichen , Meng Gang and Ran Nv . They were well respected . ', ' It seems that the inner beauty is also important . ', ' Sometimes the inner beauty is more beautiful . ']
['I wonder how Sarah and Mat are . ', " Don't you know they've already broken up ? ", " I'm not surprised . She's a plain Jane . ", " And he's so handsome . "]
["What's up ? You look depressed . ", ' I just had a quarrel with him . ', ' Would you rather I taught him a lesson for you ? ', ' No , thanks . ']
['Nowadays , ships and boats are no longer so important in transportation as they used to be . ', ' True . With the extension of railways and highways , and the improvement of safety and capacity of airplanes , ships and boats have been giving place to trains , planes and automobiles . ', ' I read in the newspapers that the passenger liners from Shanghai to Ningpo and Dalian have been out of business ; and the liners up and down the Yangtze River have been reduced by 70 % . ', " The pace of life of people is now getting faster and faster , so the speed of ships and boats seems to be so slow . I think it may be the reason why people don't like to travel by boat . ", ' But the most of the transoceanic cargo transportation is still carried by boat . ']
['I always think everybody looks down on me ', " Don't be that negative . ", ' How can you be optimistic ? You can see it in their eyes . ', ' I find it there is no meaning in living this world . ', " Don't be that negative . ", ' Really , life is so boring . ']
['Good afternoon , sir . May I help you ? ', ' I booked a table yesterday . ', " What's your name , please ? ", ' Smith . ', ' A minute , please . ... Yes , this way , please . ']
["I'm so glad that the Spring Festival is near at hand . ", ' Me too . I like the festival best of all . ', ' Think of the big face down the eve , hmm . ', ' And special TV programs , fire crackers and the games to play . ', ' Hey , do you know any mystery belief serve the festival ? ', ' Such as ? ', ' You know why fire crackers are set off in festival . ', ' Why ? To welcome the new year of course ? ', ' And also to frighten away evil spirits . ', ' Really ? ', ' And my parents say the whole year will be as good or as bad as new year day itself and bad or rude words on the day will bring a bad year . ', " Oh , that's why my parents never scold me that day . They always try to avoid tears and quarrels . "]
['Mom , did you feel the earthquake this afternoon ? ', ' Oh , that scared me . ', ' The breaking news just reported some houses were destroyed by the earthquake . ', ' Oh , dear ! How ruthless ! ', ' Do you think we can donate some clothes and food for the victims ? ', " Why not ? That's a good idea to help them . "]
["It's really late but I'm starving . ", " Hey , that coffee shop's lights are still on . ", ' Maybe they have some good pie . ', ' I would love a really sticky cinnamon bun . ', ' There was a coffee shop by my house when I was a kid that served cinnamon hot chocolate . ', ' Mmmm . That sounds like something I had in Mexico once . ', ' Good stuff ... Oh , no . The door is locked . ', ' Ohhhhh ! And I just got all my juices going ! ']
['How have you been ? ', ' Fine , thank you . ', ' And how ’ s everyone in your family ? ', ' Very well , thank you . I ’ m meeting my wife and daughter for lunch at 12:00 , would you care to join us ? ', ' I ’ d love to but I ’ m afraid I can ’ t . I ’ Ve already got a lunch engagement . ']
['How was your first date , David ? Are you satisfied with Jane ? ', ' It was all right . She , tall and attractive , has stable job and source of income . ', ' Yes , so I think she is suitable for you . ', ' But , well ... what I want to say is ... ', ' Stop acting like this . Say away ! ', ' Her standard for selecting life partner is a little higher . I can not accept that . ', ' What did she say ? ', ' She said she want a man with large house , luxurious car and healthy parents . ', ' Give her up . ']
["I wonder what he looks like . Oh , I can't wait to see him ! His email said he'd be wearing a white hat . ( looking around for him ) oh , there he is . ", ' hey , Isabelle ... ', " Logan ! Why on earth are you hiding here ? White hat ! Come on ! Don't tell me you're the guy ! It can't be true . ", ' yes , I am the guy . ', ' what a bummer ! You set me up ? ', " let me explain . I didn't mean to hurt you ... ", ' how dare you ! ', ' hang on a second . Hear me out , just this once , Isabella ! ', ' why did you lie to me in the email ? ', " I didn't lie . You just didn't ask me my real name . ", ' I should have known it was you . No wonder all the 20 questions were answered correctly . I thought I might have found the one for me . ', " I'm sorry . It was cruel of me . But I promise it will never happen again ? Look , there's a nice restaurant . Let me take you to dinner and we can talk things over . "]
['How beautiful the flower is ! ', " Really , it's so beautiful . ", " You like it . Well , I'll gather in for you . ", " You mustn't pick it in this place . ", ' Where it is ? ', " It's a private garden . "]
['I love that vase . ', ' Do you really like it ? ', ' Yes , it looks perfect . ', " It wasn't very expensive either . ", " That's amazing ! "]
["In my country , we go to school from 8 o'clock in the morning until five in the afternoon . ", ' Five days a week , too ? ', ' Actually , five and a half . On Saturday , we have classes only in the morning . ', ' Gosh ! ', " That's too much for us really . ", ' Where are you going now ? ', " I'm going to try to find out where the school is located . ", ' When do you start school ? ', " I'm going to register right now . ", " That's good . "]
['Which is more interesting to you , flying kites or going roller-skating ? ', ' Well , flying kites is more fun to me . ', " I've got no kite . Do you have one ? ", " Let's go and buy one . "]
['I heard that Ann had divorced . ', " I suspect it's unavoidable . ", ' Poor Ann . She did not love her husband at all . ', " Yeah . She married him at her mother's bidding . "]
['how do you usually spend your day , now that you ’ Ve retired ? ', ' well , I nearly always get up at dawn . I don ’ t like sleeping in late . The days are longer in summer that in winter , so I get up in summer . I usually do some exercise when I get up . ', ' what do you have for breakfast ? ', ' I usually have cereal , but sometimes I cook a traditional English breakfast . ', ' that sounds nice . How do you spend your mornings ? ', ' I usually do housework in mornings . I go shopping occasionally . I like to do all my shopping in one bag trip to the supermarket . I always drive to the big supermarket in the city center . It takes about ', ' how do you spend your afternoons ? ', ' I usually meet some friends and we play sports together or I might spend some time alone on my hobbies . I spend winter evening watching tv , but I spend summer evening at cultural events if I have time ']
['Hi , my name is Ted , what ’ s yours ? ', ' What ? ', ' I said , I ’ m Ted , who are you ? ', ' Huh ? Oh , my name is Laura . ', ' Do you somewhere often , Laura ? ', ' Huh ? I can ’ t hear you , the music ’ s too loud . ', ' Let ’ s go outside and talk . So Laura , do you come here often ? ', ' Hold on , my ears are still ringing from the music ... what was it you asked me ? ', ' I asked if you come here often . ', ' Sometimes , usually once every few weeks . Do you ? ', ' No , this is my first time here . ', ' I usually come with a group of friends . We dance a little , have a few drinks , and just have a good time . ', ' Yeah , that ’ s why I ’ m here . My friends dragged me here , because they think I spend too much time studying . ', ' That ’ s good . It ’ s good to hit the books , but you need to get out once in a while . ', ' I guess so . But the music is too loud . I don ’ t mind getting out and meeting people , but next time I ’ ll do it in a park . ']
['People are funny . ', ' They sure are . ', ' Did you hear about the pilot ? ', ' The one that stole a small plane ? ', ' Yes , he stole a plane in Canada and flew into the U . S . ', ' Did they catch him ? ', ' Yes . After two U . S . fighter jets followed him for an hour , he landed on a highway . ', ' Did he crash ? ', ' No , he just landed the plane and walked to a restaurant . ', ' Did the cops find out why he flew into the U . S . ? ', ' His life sucked . He was hoping a fighter jet would shoot him down . ', ' Poor guy . ']
['When he told me I had to work overtime , that was it . ', ' The last straw , huh ? ', " Yes , he's really pushed me too far . ", ' I know what you mean . ']
["You're going to Shanghai tomorrow , are you ? ", " That's right . Do you think it'll be cold ? ", " It might be . You'd better take a heavy sweater with you.The nights are usually quite cold at this time of year . ", " Do you think I'll need a cotton coat ? ", " Not for now , I think , But I believe there'll be rain , so take your raincoat with you . "]
['Did you watch the Premiership last night ? ', ' Yes , I watched United play Chelsea . What a fierce battle ! allay were engaged in intensive pressing and tackling in midfield . Well , it was not like a normal English League match . ', " No , it wasn't . Rather , it looked like a Bundesliga match , where physical contact is so frequent . English League teams are apt to pass the midfield quickly with long passes . It seems to me English soccer players are very gentlemanly . As Diego Maradona spoke teasingly , they often knew only chasing hard after the ball , but forgot to steal it . ", " Haha . That's probably why slide tackle and fouls are less common , and offsides more frequent in English League matches than those on the Continent . And the ball is often kept flying overhead , drawing beautiful curves in the sky . Such games are quite pleasing to the eye . ", ' Which team do you back then ? ', " I'm a firm United supporter . I like their playing style . The Reds always have several excellent wing-backs , Like Riggs , Peckham and Gary Neville . They often make wonderful crosses when they assist in attacking . ", ' But the Reds keep a weak midfield . I think Juventas of Italian Series A have always maintained a very formidable midfield . It is the main source of its strength . ']
["I'd like to purchase a parking permit for next semester . ", ' Are you a daytime student or do you just come in the evenings ? ', ' I am a daytime student . ', ' Will you be driving a motorcycle or a car ? ', ' I will be driving my car . ', ' OK , that will be twenty-five dollars . How would you like to pay for it ? ', " I'll pay for it with a check . ", ' Would you like to pay for any extra permits for another vehicle ? ', " No , thanks ; I'm fine . ", ' Here you go then . Have a great school year ! ']
["What's your major in college ? ", ' I take architecture as my major . ', ' What research are you dealing with now ? ', ' I am dealing with the study of the architecture style of ancient Chinese buildings . ']
['Would you like to go to a concert with me ? ', " I'd love to . "]
['Good morning , Miss Li . ', ' Morning , Mike . ', " I'm sorry that I was absent yesterday . ", " I've already got your certificate for sick leave . How do you feel today ? ", ' I feel much better now . ', ' Have you received the reading material handed out yesterday ? ', " I've already got it . Thanks . ", ' I will explain it in detail in the next class , could you preview it ? ', ' I will . ']
['They promised us a sea view . ', ' Well , you can just see the sea . Between the factory chimneys . ', " Isn't it awful ? I can't bear to look at it . I don't think I can stand this place for two weeks . ", " Well , it can't be helped . We'll just have to put up with it . "]
['You are saying he will be promoted to the general manager ? ', ' Yeah . ', ' Are you sure ? ', ' Yes . I bet my bottom dollar that he will get promoted . ', ' Just because he gets on well with everybody ? ', " Partly , and he's also a hard working man . "]
["What's Beijing like ? ", ' It ’ s big and exciting but noisy . ', ' What can I see in Beijing ? ', ' You can see the Forbidden City . ', ' What ’ s it like ? ', ' It ’ s beautiful but crowded . ']
["Would you talk to me about taking one of Dr . Miller's classes ? ", ' Yes . Have you ever been in one of his classes ? ', " I'm thinking about taking his class next semester . ", ' He was a very easy teacher . Are you thinking of taking a class with him ? ', " I'm not sure because I really need to learn something , but I also worry about grades . ", " Grades are important , but don't you think that gaining the knowledge is important , too ? ", ' I really need to learn this stuff . ', ' He made everything so interesting that the time just flew by . Do you know what I mean ? ', ' Yes , that sounds right for me . ', ' Did you know that he came here last year after 10 years in the military ? ', ' Yeah , I already knew that . That could be a good thing . ', ' I think you know that you have to make the best decision for you . Enjoy your year ! ']
['How was my singing ? ', ' Not bad at all . ']
['Hello . I was wondering if Taylor Smith has checked out yet ? ', " Just one moment . I'll check with the cancer ward desk . ", " The cancer ward ! ? Oh , my . It's worse than we thought . ", " Ma'am , I'm sorry . The cancer ward said Mr . Smith passed away two days ago . ", " That's impossible ! I'm talking about Mister Taylor Smith . ", " Yes , ma'am . He died from complications of stomach cancer . I'm very sorry . ", " I'm really sick ! "]
['I have something really cool to tell you about ! Do you know anything about online auctions ? ', ' Not really . ', " They're awesome ! I was browsing through the eBay auction today , and I found the cutest fat little copper Buddha ! It's over a hundred years old . ", " Please don't tell me you bought it . ", ' Why not ? ', ' If you did , you probably got ripped off . ']
['Excuse me . May I ask you some questions ? ', ' Sure . What do you want to know ? ', " Could you please tell me how many credits would be required for a bachelor's degree ? ", ' Well , you have to get 166 credits , including required courses and optional courses . ', " OK . And how long does it take to get a bachelor's degree ? ", ' It can be completed in four years normally . ', ' I see . Thank you very much . ', " You're welcome . "]
['I have failed in my final examination . What can I do now ? ', ' You have asked me several times about it . You are driving me up the wall . ']
['Would you like to go to a concert tonight ? ', " I'd like to very much . ", ' All right , then.There is one at the new concert hall . ', " Who's playing ? ", " It's the Powell orchestra . ", ' Do you know what they are playing ? ', " They're doing a seventeenth-century program . ", ' And who is directing ? ', " Well , I'm not sure of his name , but I know it's going to be his farewell performance . "]
['Your 3.5 percent share is going to be worth at least a million . ', ' I need to be motivated , Vince.Multi - motivated . As in multi-million . ', ' What if I said no ? ', ' Ever hear of WebTracker ? ', " You wouldn't ! If you leave , you'll make nothing . ", ' I might make nothing even if I stay . For that kind of risk , I want to get rich . ', " OK . If you sign the Stars.com account before WebTracker does , we'll talk next week . "]
['Shall I get you another cup of coffee ? ', ' Yes , please . That is very kind of you . ', ' Shall I make more sandwiches ? ', ' No , thanks . I ’ Ve had plenty . ']
["We're in big trouble , Jason . Nick is beating us by a long shot . ", " Impossible ! Well , I'm not giving up yet . It's not over till the fat lady sings ! ", " OK , comeback kid . Here's you last question.How many times did Robin Williams win the Oscar for Best Actor ? ", " Hmm . Let's see ... there was Good Morning , Vietnam , Dead Poet's Society , The Fisher King ... Three , right ? ", ' Nope , sorry ! Actually , Robin Williams has never won an Oscar for Best Actor--only for Best Supporting Actor ! ']
["I'm so busy . I don't know how will get this done . ", " You're not the only one with a lot to do . We are all in the same boat . "]
['Helen , did you hear I ’ m having a party ? Next Saturday in my place . ', ' I may have something on that day , but thanks for inviting me . ', ' Well , drop by if you can . ', ' I will , do you want me to bring anything ? ', ' No , just bring yourself . I hope to see you there . ']
["Please help yourself to whatever you like , don't be shy . ", ' Yes , thank you . I ’ Ve already been helping myself . ', ' This dish tastes terrific . Would you like to try a little ? It is a little hot , but very good . ', ' I like hot food , especially Sichuan cuisine . ', ' Would you like another beer ? ', " I'II have another cup of beer insist . I know I don't like to drink alone , especially there are someone sitting there next to me . ", " Come on , it's the weekend . Let's taste and enjoy this meal . Cheers ! ", " Bottom's up , and you're right . This meal is incredible . I wish I had known this restaurant before . Thanks for bringing me here . I know I'll be back soon . "]
['Hi , Bob , everything okay ? ', " more or less . There's just one thing bothering me . ", " oh ? What's that ? ", " well , you know I have some students studying for their master's degree . One of them tried to give me a gift that kind made me uneasy . ", ' what gift ? ', " it's an Egyptian carpet . The student came to my office the other day and brought the carpet to show his gratitude . Seeing what gift was , I was really uncomfortable . I mean it's too expensive a gift ", " you refused the gift ? That's terrible . ", " I know , but I really can't accept such an expensive gift . I explained to him why , but he seemed really upset about it . I think he might have taken it the wrong way . ", ' perhaps . He probably thinks you considered the gift a bribe for a higher grade . ', " that's what I am worried about . I do understand the respect attached with the gift and I am honored . But I really don't think it's proper for a student to spend a fortune on a gift for a professor . "]
['It is so quiet here . I like the place . ', ' Me too . ', " I can't stand the loud noise in the city . ", ' Yes , sometimes I can hardly get asleep at night . ', ' I hope I can stay here longer . ', ' When will your vacation end ? ', ' The day after tomorrow . ', ' You will go back tomorrow , right ? ', ' Yes , you are right . ']
['Who do you think is going to get the Oscar for best actor ? ', " I have no idea . To be honest , I couldn't care less . "]
['I finally went out to dinner with him last night . ', ' Just the two of you ? ', ' Yup . ', ' Where did you go ? ', ' True , a sea food restaurant . ', ' True ? The food is terrible . ', " I didn't notice . I don't really even know what I ate . ", ' Really ? ']
['( Before Christmas Party ) Are you ready for the Christmas party tonight ', " Almost . I have to get dressed . It's a formal party and I have special party make up ! ", ' Use this lipstick and it will make your lips shine ! ', " Great ! Uh , remember that there's a gift exchange , too . We all have to bring a gift . ", " I've already got mine . ", " ( At the Party ) It's Christmas Eve ! Time to open presents ! ", ' Here ! Open mine first . ', " Wow ! It's just what I wanted ! ", " Hey ! Why don't I have any presents ! "]
['Hi , Mike , what gives ? ', ' Hi , Bill , this is my new car . ', ' Hey , great set of wheels . ', ' You like it , huh ? ', " Who wouldn't ? Wow , that's out of this world . ", " It is special , isn't it ? ", ' Yeah , too cool . How much did they sold you for ? ', " Lots . Looks like I'll have to moonlight for the next two years . ", ' I can imagine . ', " Hey , let's go for a spin . You can try it out . ", " I'd love to . ", " Ok , let's go . "]
['Good afternoon . ', ' My goodness ! It ’ s the afternoon ? Doesn ’ t the time fly ! Do come in and sit down . ', ' Thank you . ', ' What ’ s the time ? My watch has stopped . ', ' It ’ s half past twelve . ', ' When do you have lunch ? ', ' From one to two . ', ' What do you normally eat ? ', ' We usually go to the cafeteria . ', ' Oh , it ’ s time to have lunch now . ', ' let ’ s go together . ']
['Thank you for coming to see me off . ', ' Not at all . ', ' If I have time , I will come again . ', ' You are welcome at any time . ', ' Thank you for your hospitality . I hope I didn ’ t cause you too much trouble during my stay . ', ' You are most welcome . ', ' I ’ m afraid I have to go now . The plane will take off soon . ', ' Call us as soon as you got home . ']
['We have mild wines and strong liquors . Which kind do you prefer ? ', " I've no idea . I'd like to listen to your suggestion . ", " It's my pleasure . Actually , it's really hard to say as individual tastes are different . As for myself , I'd like to recommend gin and tonic . ", " Well , I'll try gin and tonic . "]
["We'll get a big bonus this year , won't we ? ", " Don't count on it . "]
["My Buddha ! ! It's beautiful ! But I thought you were afraid ? ", ' Actually , I was watching your auction all along . I saw you drop out at $ 250 . ', ' You sneak ! ', ' I watched Buddha buyer go up to $ 315 . I waited until the very last minute and then I jumped in at $ 325 ! I sniped him ! ', " But that's a lot of money ! Honey ! "]
['Do you mind if I borrow the notes from last week ? ', ' Were you here last week ? ', ' I was unable to make it . ', ' How come ? ', " I was sick that day , and couldn't make it . ", ' Well , here are the notes . ', ' Are there any more ? ', ' Sorry , here you go . ', ' Thanks a lot . ', ' No problem . ']
['Do you have any habits such as smoking ? ', " No , I rarely smoke . I don't drink , either . I only drink with my family on celebrations or with close friends . ", ' What kind of winter sport do you like best ? ', ' My favorite winter sport is skiing . In addition , I am keen on basketball . ', ' What do you like doing in your spare time ? ', " I like doing aerobics in my spare time . It's good for my health . ", ' Do you have any hobbies ? ', ' Yes , I have . I collect stamps , Chinese stamps as well as those from other countries . ']
['I wonder if it is possible that we organize a dinner party for all the colleagues in our departments . They are working very hard these days . Maybe it is time for everybody to relax a little . ', ' That is a good idea , I love it . What time do you think is convenient ? ', ' Well , what about this Thursday evening after we finish the weekly meeting ? ', ' Ok , I will inform everybody when they come back from lunch . It has been a long time since we had the department dinner last time . I am sure they don ’ t want to miss it . ', ' I hope so . Let me know how many will come . Then I will book the restaurant . ']
['You must be new . ', ' As a matter of fact , I am . ', ' Have you just started college ? ', ' No . I transferred here from a different school . ', ' What school ? ', ' I transferred here from PCC . ', ' Do you like it here ? ', ' I really like it here so far . ', ' Do you like it better here or at PCC ? ', ' I like PCC better . ', ' If that ’ s the case , then why did you leave ? ', " I graduated and I'am working towards my next degree . "]
['Are you coming or not ? ', " I haven't decided yet . ", ' Well , make up your mind . We need to know . ', ' Ok , count me in . ']
["Hey , Bob . Are you getting the feeling you've been here before ? ", " Yes , I'm sure I've been here before . ", " Maybe we're walking in circles . ", " Yes , there's that bar we passed an hour ago . "]
['I am thinking about inviting you to a dinner . When would you have time ? And what kind of food do you fancy ? ', ' That would be great . I am really in the mood for a spicy hotpot . Any special reason for the invitation ? ', ' To thank you for helping me at work last week . If you would not have been so kind , I would not have been able to pick my parents from the airport . You really did me a big favor . Thank you so much . ', ' It was my pleasure . How about this evening ? I feel very hungry now . ', ' Fine , I know a good hotpot place in the downtown area , food there is pretty spicy too . Shall we try that one ? ', ' Ok with me . You are the boss . I will meet you downstairs after work . ']
['I have been working 70 hours this week . I am totally maxed out . ', ' 70 hours ? I would be dead if I worked hard like that . ']
['What a beautiful day ! ', ' It is really gorgeous out today . I remembered the weatherman said it is supposed to rain . ', " I heard that it's supposed to get up to 90 degrees Fahrenheit today . ", " Really ? That's unusual for October , isn't it ? ", ' Well , you could never tell about the weather here in New York . ', " Yes , that's true . Still , it's hard to believe . Yesterday our high was only 50 degrees Fahrenheit . "]
['I have no idea about what to do next . ', ' Maybe you can pick Mary ’ s brains now . She knows a lot about stocks . ', ' Let me have a try . ']
["Hello , is it necessary to do warm-up exercise ? I can't wait to dive into the water . ", " I'm sorry . Every customer coming here must do the warm-up exercise before getting down to swimming . That's out regulation . ", ' Yeah , I see . You are just doing your job . But I wanna know what the advantages it has . ', ' OK , lovely boy . Try to be patient . Do you know the danger of swimming without warm-up ? ', ' As far as I know , people will be weak if they swim too long . ', " That's right . But the most dangerous thing is that their legs may spasm out of control when swimming . ", " Is it very dangerous ? I'm a little scared . Do you offer the lifebuoy for us ? ", ' Yes , besides that , we also provide our customers with goggles , swimming suit and something like that . ', ' Do you have the workers to save me if anything should happen ? ', ' Of course , all the workers here are able to swim , and they will come to your aid quickly . ']
['Do you feel better ? ', ' Much better . My heart sank when Mary told me that she wanted to leave me . ', ' Don ’ t be sad . Everything will be fine . ', ' Thanks a lot . You are so kind . ']
['Do you have the time ? ', " It's ten thirty . "]
["It's a perfect day for swimming . ", ' I am going to the beech . How about coming with me ? ', ' Great ! I love swimming . Besides , I need a tan for Hill ’ s party .. ', " Don't forget the sun block lotion . You don't want a sunburn , do you ? ", ' No . Thanks for reminding me . ']
['Can you vouch for me that I was with you yesterday ? ', ' Why do I need to do that ? ', " My character is in question . Someone was robbed at work and unless I have an alibi , I'm a suspect . ", ' Oh , my goodness . Who do I need to talk to ? ', ' My employer . Can you come in to the office tomorrow ? ', ' Absolutely . I think I still have the boarding passes from our flight here somewhere . ', " That would be the real proof . Didn't we have to show ID to get on the plane ? ", ' Since 911 I think every airline requires that the passengers show ID to board . ']
['Which team has won ? ', ' Neither.The game ended in two all . ', " But I still think AC milan's defence seems better organized . ", ' But the Brazilian is tougher . ']
['What dances do you like ? ', ' I love to dance the fast music . ', ' Then you must be interested in disco . ', " Yes , it's my favorite . ", " Oh , it's a disco . Let's dance . ", " You're a good dancer . ", ' Thank you . Now they are playing a rumba . Would you have a try ? ', ' Sorry . I feel like sitting out the next dance . ', " OK . Let's get something to drink . ", ' Good idea . ']
['What day is today ? Tuesday ? ', " Yeah . I bet you did forget everything . What's the date today , do you know ? ", " I bet it's May 5th . "]
['I heard that Kevin got divorced . Is that true ? ', ' Not so bad , but Kevin does have problems with his wife . ', ' What ? ', " His wife always complained that Kevin's salary was too low and got no promotion . ", ' Poor Kevin , we should do something for him . He is a nice guy and does his job well . ', ' Yeah , I agree with you . But you know , it ’ s just one of those things . ']
['Good morning , Miss Wu ! Can I ask you something ? ', ' Certainly . You are more welcome to do . What is it ? ', " Tomorrow is my wife's birthday . We both love spicy Chinese dishes . I am wondering if you could recommend a good local restaurant where I can find some good spicy dishes . ", ' Well , if spicy local dishes are what you are looking for , In Hua Restaurant is the best place to go . The restaurant serves very good and spicy local dishes . You might want to try there . ', ' How far is it from here ? ', " It is near the university . Five minutes ' walk from your flat , I think . ", " Great . We'll go and have a try . Thank you very much . ", " You're welcome . May you have a good time . Please give my regards to your wife . I wish her a happy birthday tomorrow . ", ' Thank you . The same to you . ']
['Is this seat taken ? ', ' No . Have a seat . ']
['Why don ’ t we go the cinema tonight ? ', ' That sounds good but I don ’ t know what ’ s on . ', ' I think there ’ s a very romantic new film starring Hugh Grant . Let ’ s go and see that . ', ' Ok , that ’ s a good idea . Where shall we meet ? ', ' Well how about meeting at my place ? ', ' That sounds good . I ’ ll call you once I arrive . ']
['Show us our itineraries , please . ', " We'll first go to Mount Tai , then we'll go to Sichuan by air , after that we'll be leaving for Tibet . ", ' How long will the trip take ? ', ' At least 20 days . ']
['Tom , aren ’ t you a little too old to be trick-or-treating ? ', ' What are you talking about ? Where is your Halloween spirit ? Didn ’ t you ever dress up in a costume and go around the neighborhood trick-or-treating with your friends ? ', ' Of course , I did , but when I was ten ! Trick - or-treating is for kids , plus , I ’ m sure people will think you ’ re a kidnapper or something , running around with kids NCP at night . ', ' Whatever , I ’ m going next door I heard Mrs . Robinson is giving out big bags of M & Ms ! ']
['I really want to switch things up . ', ' What were you thinking ? ', ' I think I want to try a new style . ', ' What would you like me to do ? ', ' I want you to cut my hair shorter . ', ' How short ? ', ' I want my hair to be only a few inches long . ', ' Do you really want it that short ? ', " Yes , I've been wanting it short for a while now . ", " If you really want me to , then I'll do it . ", " I'm absolutely sure that this is what I want . ", " Let's do it . "]
['I hear you and James are engaged at last . ', ' Yes , we are . ', ' When are you getting married ? ', ' In the spring . ', " Oh , lovely.Where ' s the wedding going to be ? ", " Well .. we're not sure yet , probably in St.Albans . ", " Oh , yes , your parents live there , don't they ? ", " Yes , that's right . ", " Where are you going to live after you're married ? ", " We're going to buy a flat or a small house somewhere in South London . ", ' Are you going to give up your job ? ', " Yes , probably but I may look for another one when we're settled in . "]
['Welcome , Li Mei . Please give me your coat and hat . ', ' Thank you , Peter . ', " Oh , let's come in and enjoy yourself . ", " Happy birthday , Peter , and many happy returns of the day . Here's a present for you . ", " Thank you , Li Mei . Come into the dining room . I'm going to cut the cake soon . ", ' What wish do you make ? ', " It's a secret . "]
['Which service offered by your bank do you use most ? ', ' I use several services . Of course , I deposit and withdraw money quite often . I often use my ATM card to take money out of my current account . I use my bank to exchange money from once currency to another . I often travel abroad , you see . ', ' Do you ever ask you bank for traveller ’ s cheques ? They are much safer than carrying lots of cash around . ', ' I sometimes use traveller ’ s cheques , but sometimes I travel to countries where they are hard to exchange for cash . ', ' Do you use your bank to pay your utility bills ? I use direct debit . ', ' Yes , I do . It save me a lot of time . I also have standing orders for my subscriptions to magazines . ', ' That ’ s good idea . You don ’ t need to worry about missing an issue of a magazine if you do that . I suppose you have a mortgage too . ', ' Yes . My bank offers very good terms and conditions on mortgage . There ’ s a lot of competition between banks nowadays . Each one is trying to offer better conditions and services than the others . ', ' I have a deposit account with my bank . There are some restrictions on withdrawing money , but the interest rate is much higher . ', ' I don ’ t have one . I prefer to buy shares . My bank also provides a share trading service . It ’ s cheap and easy to use . ', ' That ’ s great . But I prefer to put my money somewhere where the returns are more certain . ']
['I am not sure what to do during the holidays , any suggestions ? ', ' Well , going to a cinema , visiting the galleries , exhibitions and museums , finding and meeting old friends , exercising in the health club or mountain biking . There are so many good choices . ', ' The problem is that I find all of them are full of fun . I just don ’ t know what to do first . ', ' Why not start with the most interesting one ? ', ' Actually , I ’ m interested in all of them . The more choices we have , the harder to make a decision . ', ' Toss a coin to decide then . ']
['You know John ? ', ' Which John ? Mr.Turnbow ’ s son ? ', ' Yes . I ’ Ve read news about him in today ’ s paper . ', ' And he ’ s bright and intelligent . I ’ m sure he can pass the university entrance exam . ', ' I wish he could too . ', ' How ’ s your boy , Jack ? ', ' He ’ s a bit tired , you know . It often takes him a couple of hours to brush up . ', ' Poor boys ! They work harder at school nowadays , don ’ t they ? ', ' Good luck to them . ']
["You're from New York , aren't you ? ", " Yes , that's right . ", ' What do you suggest I should see in New York ? ', ' Well , how about the Museum of Modern Art ? ', " No , I don't like museums.They ' re boring . ", " Why don't you go to see the Empire State Building ? ", ' Ah ! That sounds interesting . ']
['So , Jack , do you believe in ghosts ? ', ' No , not really . Why do you ask ? ', ' Because I want to tell you about the time that I saw a ghost . ', ' You saw a ghost ? When ? ', ' It was many years ago , when I was a little child . It was the middle of the night , and I went to get a drink of water from the kitchen . I walked out of my room and was at the top of the stairs , when ... ', " So that's where you saw the ghost ? In your house ? What did it look like ? Was it hideous ? ", ' It was a big , green thing that looked like a person . It was in the kitchen , and it slowly moved towards the stairs ... ', ' So what did you do ? ', " I hid so that it couldn't see me . Slowly it got closer and closer , until ... ", ' Until what ? What happened ? Did you see it clearly ? Did it attack you ? ', ' It moved slowly up the stairs , step by step , and I could hear its approaching footsteps . When it finally got to the top of the stairs , I realized that it was my father in his green pajamas . He had gone to get a late night snack . ']
['Are you getting overtime ? ', " Yes , but it's not so appetizing . ", ' Have you thought about another job ? ', " That's what's hanging on my mind recently . "]
['I bought it . I got a watch , too . The company that sells this car has a car club . ', ' Where you can buy lots of paraphernalia ? ', ' Yeah , and meet other drivers of the same car ! ', ' Cool ! ', " I know girls love this kind of car . Look , it's got a sunroof ! Imagine ... a cool , starry night ... ", " So , you're going to use Sarah's car to go cruising for chicks ? ", ' No . I borrowed it to go shopping . ']
['Quite a few people are laid off these days . ', ' Yeah . It is not easy for them to find another job . ', ' University graduates have difficulty finding a job too . There seems to be more and more competition in the job market ', ' It is strange that some people are quitting their jobs in order to find a better one . What do you think ? Do you want to quit your job ? ', " No . Not now . I think I'll try to keep this one . "]
['Hello , Ms . Barkley . How are you ? ', ' Fine , thank you , sir . It ’ s nice to see you again . ', ' Good to see you again , too . How ’ s you family ? ', ' Very well , thank you , Mr . Parker . ']
["Mike's really angry . ", ' I wonder Why . ']
["Oh my god ! It's 10:00 pm . I have to go . ", ' Can ’ t you stay a little longer ? ', ' I am afraid not . ', ' Say hi to your parents for me . I hope to see them soon . ', ' Thank you . Well , if you ever pass my home , please drop in . ', ' Yes , I will . Take care , then . ', ' Yes , sure . Have a sweet dream ! ']
["Why you are so crazy about Beijing Opera ? It's so boring . ", " But I think it's fantastic and charming . Well , you have your opinion and I have mine . ", " Maybe you're right . But I just still can't understand ... ", " Come on . I don't see any point in arguing about this . Everyone has a right to his own opinion . "]
['Your garden is looking very beautiful this summer . The flowers are really colorful . ', ' Thank you . I have roses , tulips , and daffodils . Do you like the rockery with the smaller flowers ? ', ' Yes , I do . Those are violets , aren ’ t they ? ', ' Yes , they are . This afternoon , I ’ m going to prune the hedge . ', ' The lower branches on that tree are hanging very low . Would you like me to cut them off for you ? ', ' Thank you ! That would be very kind of you . I have a saw in the garden shed . ', ' When the lower branches are removed , you ’ ll be able to sit under the tree . ', ' Tomorrow , I ’ ll cut the grass . Then the garden will look perfect . ', ' Just make sure children don ’ t play in the flower beds and destroy the flowers . ']
['Listen to this . Mary got married . ', ' Is she really ? I can ’ t believe it ! ', ' Yes . Yesterday . ', ' Good gracious . That ’ s incredible ! ', ' She married Jerrod . ', ' You ’ re kidding . ', ' She ’ s going to live in Paris . ', ' Really ? I ’ m surprised . ']
["I've been accepted by the university , and they've offered me a position on the basketball team ! ", " That's wonderful ! Icing on the cake . "]
['Do you feel all right ? You look Pale . ', ' All my joints seem to hurt and I have a terrible headache . ', ' Have you taken your temperature ? ', ' No , not yet , but I do feel a little feverish . ', ' How long have you been feeling this way ? ', ' Only since this morning . ', " Oh , probably you've been working too hard . ", ' Maybe you are right . ']
['What a terrible house ! ', " I'm sick of it , too . ", " The door bell doesn't work , there's no hot water , and the building is falling apart . ", " It's no use complaining . If we had got enough money , we couldn't put up with it , and would have moved out . ", ' Sure . ']
['What kind of jobs are becoming popular in your country ? ', ' As in many countries , there ’ s been a big growth in anything related to computers . Young people are attracted to that field in particular . There ’ s also been a big growth in education . ', ' There ’ s been a growth in that field in my country too . A lot of people want to learn practical and professional skills . ', ' The interesting thing is that many of the teachers are not actually trained teachers . They are usually professionals who are taking a break from their jobs to pass on skills to others . ', ' I noticed that too . What are the people learning ? ', ' In my country , they are usually studying something business-related , such as marketing , management techniques , and human resource management . ', ' I think that jobs in the leisure industry will become more popular in the future . ', ' That trend has already begun in my country . In particular , there ’ s a big demand for people to work in fitness centers . Which kinds of jobs are less in demand ? ', ' Those in traditional fields , such as agriculture and heavy industry . Younger people are not interested in doing those jobs and other countries have industries that can produce things much cheaper . ', ' Yes . My country is certainly expanding in the service and hi-tech sectors , but contracting in the heavy industry and primary industry sectors . However , our car and aircraft manufacturers are doing very well . ', ' They are well known for high quality , that ’ s why . ']
["Hi , Ben . Here are the top ten of this week's top chart . ", ' Oh , great ! ', ' Which is your favorite in this ten ? ', ' I like No . 4 . ', ' You mean Sweet Heart . ', " Yes . In fact , I think it's much better than this week's No . 1 . ", ' What do you think about Cold Wind ? ', " I like it as well , but I don't think it's as good as Sweet Heart . ", " So No . 4 is your favorite . Which one don't you like ? ", " Well . I don't like Your Lips very much . ", ' Why ? ', " I think it's too slow makes me sleepy . In fact , it's the worst in this week ’ s top ten , if you ask me . ", " Really ? But it's my favorite . "]
['are you good at making decisions ? ', ' not really . Sometimes , I even let other people make key decision for me . ', ' what kinds of decisions do you leave to other people ? ', ' there are basic decisions like which restaurant to go to . I can never seem to choose . I let my parents make big decisions for me . They chose my university and my course . I ended up studying something ', ' your parents will be choosing your girlfriend if you aren ’ t careful ! Why don ’ t you try being more decisive ? Start with some basic ones . When your friends are discussing which restaurant to eat at , mak ', ' that ’ s a good idea . You ’ re very decisive , I ’ Ve noticed . So , which bar are we going to this evening ? ', ' I can ’ t make a decision . You ’ ll have to put forward an idea . ', ' ok , i choose luckies . ', ' you see ? You ’ re becoming more decisive already ! ']
['Old Dyson looks as if he maybe kick the bucket any day . ', ' Why do you say that ? ', ' I ’ Ve ever seen a living being looked so thin . ', ' Really ? In my eyes it ’ s normal , as an old man , to be thin is better than to be fat . ', ' Maybe you are right . ']
["I've got to put together a sales pitch to give to our clients in the morning . You always give such amazing presentations , I was hoping you could give me some advice about how to win them over tomorrow . ", " Sure , it's easy . First of all , the secret to a successful oral presentation is to keep things simple . People are listening and they usually don't have a long attention spans . Stick to about three or four points , give an overview of the points , then present them one by one , and then summarize at the end . Be straightforward and organized and you're sure to be remembered . ", ' What kind of visuals should I use to support the presentation ? Do you think I should use PowerPoint ? ', " You should consider the size and interests of your audience . In other words , who is listening , and what do they want to hear ... you can put together a PPT with some graphics and animations that will catch people's attention , but be careful not to go overboard . ", " I think I can put something together , no problem . But when it comes to tomorrow , I'll just be a bundle of nerves ! How can I get over my fear of speaking in public ? ", ' You know , stage fright is very normal , most people get nervous before they have to speak in front of large groups . Just prepare well , rehearse beforehand , and trust that you will be great ... and you will be ! ']
['Hey , Shirley ! Want to join me for lunch ... my treat ! ', ' Wow ! Sure ! ', ' I must confess I have an ulterior motive for asking you to lunch . ', " Oh ... that's OK ... as long as you're buying ! ", " I really want to pick your brain about something I've been thinking a lot about . ", " I'd love to help if I can . ", " Well , as you know , I have a Bachelor's degree in English literature and that's served me well so far , but I've always wanted to do some post-graduate work ... maybe even get a Doctorate ! ", ' Wow ! Just the idea of going back to school fills my head with pain . ', " But you have a Master's degree ... hasn't that helped your career ? ", " Yeah , I'd have to say it has . But I'm still paying for it , you know . ", " I know education is expensive , but it's been my lifelong dream . Call me crazy , but I've always wanted to have that PhD at the end of my name . ", ' Well , getting a Doctorate degree would mean close to a decade of school . Can you afford that ? Can you survive that ? ', " I certainly can't afford it , but I'm sure I could find some good student loans . ", " I think you need to separate the dream of having a PhD from the reality of years of more schooling . It's not as romantic as you might think . ", " Yeah ... I keep thinking about what I'll do with a Master's or Doctorate . I love language but I don't think there are a lot of well-paying jobs out there for experts on Shakespeare . ", " Uh huh , that's for sure . You might find that your only career choice is teaching other graduate students . "]
['Do you mind if we call on you this evening ? ', " Of course not , we'd be happy if you could come.What time will you be able to come ? ", " How about seven o'clock ? ", " Fine.We ' ll be expecting you . "]
['Hey , May , how are you doing ? ', " Oh , I'm a little busy these days . ", ' Why is that ? ', ' Don ’ t you know Christmas is coming ? I have a lot of things to get ready . ', ' But you ’ re in China . Are you planning on going home for Christmas ? ', ' Yeah , so I have to buy presents for everyone before I leave . ', ' Why not just give them money in red envelopes ? That would be much easier . ', ' Americans don ’ t like giving money , they prefer presents you buy for them . So I have to figure out what to buy for all of my family and friends . ', " I've got it . I won ’ t bother you any more . You ’ d better hurry to do it , Christmas is just around the corner . ", ' I will . Merry Christmas . ']
['Peter really is a remarkable expert ! There is very little he doesn ’ t know . ', ' I have exactly the same feeling . This afternoon he explained the ins and outs of the stock market to me . He knows a lot about investments . ']
['How big is your family ? ', ' My family is not big , there are only 3 of us-my parents and I . ', ' Who supports the family ? ', ' My father supports the family , and he is the sole breadwinner . My mother is a housewife . ', ' Do you live with your family ? ', ' Yes , we live a happy life together . ']
['This is the good life ! We have it good don ’ t you think ? ', ' Yeah of course ! Although , don ’ t you ever wonder what “ could have been ” ? ', ' What do you mean ? ', ' Well , sometimes I think of how things could have turned out if I had done things a little differently . ', ' For example ? ', ' Like for example , if I hadn ’ t studied architecture , I would have become an artist like I wanted to . ', ' I see . Yeah now that I think of it , I wouldn ’ t have gotten married if I hadn ’ t moved to this town and met Sally . ', ' You see ! Everything happens for a reason ! We wouldn ’ t even have met if I hadn ’ t been in that car accident ten years ago ! ', ' Well , I have no regrets ! ', ' I ’ ll drink to that ! ']
["Excuse me ? I didn't hear what you said . ", ' I asked you if you wanted some help . ', ' I am new to this school and not familiar with this library . Can you help me ? ', " Certainly . What's your topic ? ", " I'm looking for information on tropical fish . ", " All right . You can use the computer over there , enter ' tropical fish'under subject . If you know the title of the book , enter it under ' title ' ", ' Great , thank you . ', ' You are welcome . ']
["I hate landing in the sand trap ! Now I'm probably going to waste strokes getting it out . ", " At least you haven't landed in the water yet . I've done that on the last two holes . ", " Could you hand me my wedge ? I'll try ... ", " Here you go . I'll wait for you to get on the green before I putt . ", " No . you go ahead and putt it out . Then I'Il go . ", " No way , Mary . I'm going to let you go first . I don't want the pressure of putting first . "]
['excuse me , is this the way to the Greta Wall ? ', ' oh , it is really far from here . You ’ re going in the wrong direction actually . ', ' I must have taken a wrong turn . ', ' it doesn ’ t matter . Go back the way you came . After about five kilometers , you ’ ll see a hotel on the side of the road . It ’ s a big one . You can ’ t miss it . ', ' and then ? ', ' take the next right . Drive about one click further , and you ’ ll see the entrance of the highway to the Great Wall . ', ' thanks a lot . ', ' you ’ re welcome . ', ' by the way , how long does it take ? ', ' without traffic , it takes about an hour . ', ' I heard the Great Wall closes early in the afternoon . Do you think I can make it before closing ? ', ' yes , I think so . It doesn ’ t close until 5 o ’ clock . You still have plenty of time . ', ' great ! Thank you ! ', ' my pleasure , and have a good time ! ']
['Hello , Deva , how are you ? ', " Can't complain . What about you ? ", ' Not bad . Have you heard Wendy divorced her husband ? ', " I've heard . She looks quite depressed . ", ' Yes . They used to be joined at the hip . ', ' I heard they were just married for 5 months . ', " Yes , she said they couldn't communicate well with each other and they often argued over trivial things . ", ' Yeah . Mixed marriage is tempting but crisis-ridden . ', ' You said it . You know , they fall in love at first sight and quickly jumped into marriage . ', ' Maybe they were just attracted to each other but too different to be married . ', ' Yeah . We Chinese have quite different lifestyles and values from foreigners . ', " Definitely . That's why many cross-cultural marriages end in divorce . ", " We've heard so much about Chinese film stars divorcing foreigners . ", " That's true.Just hope Wendy can recover from the pain of divorce soon . "]
['hi , betty ! ', ' hi , Andy , how are you finding your new job ? ', ' pretty good . My colleagues seem alright . So far everything is great . ', " that's nice . What do they have you doing over there ? ", ' well , I work in the marketing department . The corporate culture is totally different from my last employer . Before , when I was assigned a task , I was totally on my own but here most of the work is don ', " that ' s really good . It's very important to feel like you are part of the team at work . ", " indeed . Team work is highly valued in this new company . I like our boss too . He is easy to get along with treats everybody with respect and appreciation . He's highly respected by all his employees . ", " that's great , that's good for a positive work environment and helps motivate employees . I wish my boss was like that . ", ' true , take my former supervisor as an example . He was extremely controlling and overbearing . He always had to micromanage everything . ', " well , now you don't have to worry about that . This new place sounds really good . ", ' yeah it is . ']
["I heard you're getting married , James . Congratulations ! ", " Thank you , Wendy . I hope you'll be able to make it to the wedding . ", " I'm looking forward to it . "]
['What lovely weather ! ', " It's so pleasant after the bad weather we've been having . ", " Let's go out and enjoy the fresh air . ", " All right.Let ' s go . "]
['Do you keep any pets , such as cats , dogs ? ', " No , I'm scared of cats . ", ' Oh , but why ? ', " I feel they're dirty . "]
['I would love to be famous and have thousands of adoring fans . ', ' Really ? I ’ m not sure that I would like all the attention . There have been numerous cases of paparazzi interfering with star ’ s private live in recent years . ', ' I love being photographed ! If I were famous , I ’ d do interviews for all the top magazines , like cosmo and elle . ', ' I wouldn ’ t mind having my photo taken a few times or being interviewed once or twice , but it would get tedious after a while . Imagine the things the gossip columnists would write about you . ', ' No-one really believes gossip columnists . ', ' I think you ’ ll find that many people believe what they read in gossip columns . You ’ d also have to be very careful about every word you said . If you appeared on a chat show and said something silly , it ', ' I think you ’ re right about that . I ’ d need a good manager to be my spokesperson . I could do a lot of charity work , which would help a lot of people . ', ' That ’ s a great idea . Which charities would you support ? ', ' I love children , as you know , so probably a children ’ s charity . ', ' You ’ d have to remember that anything you said or did might reflect on the charity , so you ’ d really need to be very careful . Anyway , I ’ d be the first to buy your posters and I ’ d attend your first book - ', ' Thanks , but actually I was hoping I could ask you to write my biography . ']
["It's terrible how things have changed.You remember there used to be trees on all these hills . ", " Really ? There aren't many left now . ", " No , they've all been cut down and now all the soil is washing away . ", ' Were there any animals in the forest ? ', " Yes , I can remember it very well that there used to be all sorts of animals and birds.But nowadays you just don't see the birds that you used to see around here . "]
['Henry , do you know how much we spent this month ? ', " No , I'm not clear . ", " we've spent $ 1,000 . ", " Don't make a fuss.The price is rising "]
['Where are you living ? ', ' I live in the southern part of this city . I rent a house . ', ' Do you move a lot ? ', " No , I don't . "]
["Hey , Gucci . I didn't know it would be a charity show . You can see there are many collecting boxes at the entrance . ", ' Oh , I forgot to tell you this . The show is to collect money for children in need . And all the money from ticket selling will go to the Red Cross . ', " That's really a good thing . Let's do our part . ", ' Good idea . ', ' Who will sing in the show ? ', ' A lot of stars , including Andy , Justin , Mendy ... ', ' Mendy ? Are you sure ? I love her songs ! ', ' Me too . She is so young and talented . She is not only a singer but also a great composer herself . ', ' Yeah . Though she was so popular , I heard she managed to maintain a low profile . ', ' She is a real star . Not a onetime thing . ', " But I also heard some people didn't like her music . I don't understand why . She is so amazing ! ", ' Well , I suppose people have different tastes on music . Moreover , here stuff is really strong and creative . It takes time for people to accept new things . ', ' You are right . Anyway , things will be different as the days go on . She can get it . I have faith in her . ', ' Sure . That makes a good fan . Do you know what songs she is gonna sing tonight ? ', ' Here is the programme . Check it out yourself ! ', ' OK . ']
["What's your hobby ? ", ' Photograph . ', " What's the make of your camera ? ", ' Olympus . ', ' Do you own your own darkroom ? ', ' No , usually I get my films developed at a photo studio , but I make my own enlargements . ', ' Why ? ', " Because I can make many different kinds of pictures from one negative . That's more , but that saves money . "]
['Lester , you are really fantastic at automobile repair . ', ' Thanks , June . But I think I need to be certified as a mechanic 5 before I ’ m allowed to repair cars for a living . ', ' That ’ s not a big problem . There are many small schools for adults like you who can study to be certified . ', ' I guess I never thought of that before . ', ' And you can easily get a student loan from a vocational school , or from the government . ', ' Wow , you ’ Ve inspired me to do something ! ']
['How is the college search going ? ', " It's a huge headache . I have no idea what I want to do . ", " But don't you want to study music ? Shouldn't it be easy ? ", ' It should be , but there are too many options . My grades are good enough that I have a lot of choices , but after that ... ', ' I know . You have to decide if you want to attend a school in a city or in the country , a big school or a small school , a public or private school ... ', ' Yup , you understand . And my parents are trying to pressure me into going to a Catholic college . They both attended one and think that it combines a good education with good discipline . And the tuition is usually pretty low . ', " I see . Well , don't forget to talk to the college counselor at the school . He usually gives good advice and can help point you in the right direction . He gave me some information , and next week I'm going to take a look at some of the colleges he recommended . ", ' Thanks for the information . And good luck in your college search . ']
['I seldom heard the quarreling of her children . ', ' Why do you say that ? ', ' Because her children have been the age when they seem to quarrel all day long . ', ' Oh , I see . She told me that she had learned very quickly how to pour oil on troubled waters , but not to pour oil on the flame . ', ' She is a clever mother . ']
["I haven't met you at the gym for a long time . ", " yeah , I quit my job , and started working from home . Recently I've got a project to deal with and don't have much time to work out . ", " why ? You have a decent salary , lots of promotion opportunities and a regular life of going to the office at 9 o ' clock and coming back home at 5 in the evening . ", " it's not about pay raise or promotion . You know , I hate getting up early in the morning and coming back home late at night . ", ' then SOHO is your ideal work style . ', ' yeah , as long as I have a computer and internet access , I can start working . I recently enjoy working in my own place and at my own pace . ', " and you don't have to work under that much pressure and control . ", ' absolutely . I can decide when and what to do all by myself . ', ' sounds great . Are there many business opportunity ? ', ' yeah , I can find enough online . ', " it's good to have business around . But you should also do some exercise to keep fit . ", " thank you for reminding me . I'll continue to exercise as soon as I finish this project . "]
['What did you say when she told you the news ? ', ' I calmed up . And finally , I asked her to chew the cud for such an important decision . I could not have the heart to disappoint her with a blunt refusal . ', ' But I put my foot down and insisted on her forgetting that . ', ' How could have the heart to do that ? She needs warmth and help . ']
['Can I borrow some money from you ? ', ' No way ! ']
['How do your spend your time after work or in vacation ? ', ' In my spare time , I am fond of traveling and I always take a trip with my family . ', " But traveling is an expensive hobby , isn't it ? ", ' You are deadly right . ']
['I really have a good time here.Thank you very much . ', ' Keep in touch ! ', ' I promise . ']
['Where is Pamela ? ', ' Is she coming ? ', " She told me she'd be here . ", " They are announcing your flight . You'd better board the plane . ", ' Are you rushing me ? ', " I am just reminding you about the time . You don't want to miss the plane , do you ? ", " I know what I am doing . Don't worry . Can you do me a favor ? ", " Name it and I'll do it for you . ", " Take care of Pamela when I am away . She is a nice girl . I don't want her to get hurt or anything . ", " I've got it . ", ' Thank you . Now I see that you are my true friend . Most of my so-called friends left me at the moment my company went bankrupt . You are the only one who has stood by me the whole time . ', ' I am just doing what I think I should do . ', ' Thank you for being a friend of mine . ', " This isn't like you ... Well , I hope you will have a nice flight and a successful start in business . ", " Thank you . I have to leave now . If you see Pamela , tell her I'll write to her . "]
["What's the weather today ? ", " It's fine today . ", ' What was the weather like yesterday ? ', ' It rained all day yesterday . The weather was awful last week . ', ' What will the weather be like tomorrow ? ', " It's going to be sunny tomorrow . "]
["Tom's new business will do well . ", " I don't think so . There's too much competition . "]
['Hi , Charlie ! What are you reading ? ', ' Hi , bob . I ’ m reading a biography ? ', ' Who ’ s it about ? ', ' It ’ s about Bob Dylan . ', ' Who is he ? ', ' He ’ s a famous American musician . ', ' Who ’ s the author ? ', ' It was written by Howard Sounds . ', ' What do you think about it ? ', ' It ’ s great ! I ’ Ve learned a lot from reading it . ', ' Can I read it when you ’ re done ? ', ' Sure , bob ! I ’ m on chapter 12 now , so I ’ m almost finished . ', ' How many chapters does the book have ? ', ' There are 15 chapters in total . ', ' When do you think you ’ ll have finished reading it ? ', ' I should be done by Friday . I ’ ll give it to you in class then . ', ' Thanks . Charlie ! ', ' No problem . Bob . ']
['How are you getting along with your wife now ? ', ' What can you expect ? Not that good . ', ' What are you going to do then ? ', ' Just let it go . ', ' How are your work now ? ', ' Not bad , just let it go . ']
["I've been thinking about getting my hair cut . ", ' I thought you were going to let it grow out long . ', " I said that , didn't I ? But I just don't know what to do with it . ", " You're in one of those in-between stages , aren't you . ", " Yes , it's not short enough to be wash-and-go and not long enough to do anything fancy . ", ' Have you thought about wearing a hat ? ', ' Everywhere I go ? ', " Well , it's one way to get through the in-betweens if you really want to grow it out ! "]
["Didn't you say you were planning a trip to China ? I heard the northwest and north of China are experiencing severe sandstorms ! ", " I was planning to go to Beijing first and then go to northwest China ! Looks like I'm in trouble . ", ' Definitely . I heard Beijing was experiencing seven degree strong winds ! That is nearly a record high ! ', " No way ! I don't think I've ever encountered winds that strong ! Are the storms affecting land and air transportation ? ", " Absolutely ! I don't think any planes are going anywhere . The sand being blown around has cut visibility in Beijing to less than 100 meters . But inseems Gansu Province is being hit the hardest . ", " That's exactly where I was planning to go ! ", ' Well , this storm originated in the plateaus in northwest China . At the moment , that area is calmer . ']
['Hey , Jenny . Would you like to go to dinner with me ? ', " I don't know . You know what they say about office romances . ", " No , I don't . What do they say about office romances ? ", " They say you shouldn't mix love and work . ", " That's silly . What I do on my own time is no one else ’ s business . Besides , it's pretty hard to meet people outside of the office when we spend long hours here . ", ' You ’ Ve got a point . Once I dated one of my supervisors and all of my co-workers accused him of favoritism . Then when the relationship went bad , he fired me . ', " People fall in love with people they work with . That's a fact . ", " That may be true , but I don't want an inter-office relationship to affect my productivity . ", ' If it does , it will only make you more productive , because we can support each other . ', ' You are sounding like we are already married . ', ' Good grief . All I did was ask you out . I am sorry . ', " Well , I don't feel right about it . ", ' I am talking about dinner tonight , not a lifetime . ', " Most starts with dinner , but then it gets out of hand . Besides , haven't you asked out every woman in the entire office ? ", ' I like company . ', ' Company ? I heard about you from Linda . She said you were an octopus ! ', ' What can I say ? I am a passionate guy . ', ' Well , I hope you can find something else to be passionate about . ', ' You want to go out with me and you know it . ', " In your dreams . Now if you don't mind , I've got some work to do . ", ' Ok , I get the message . Hey , do you have any sisters ? ']
['I ’ m looking forward to relaxing this coming weekend . ', ' I hope that I can finally find free time too . I ’ Ve been so busy at work recently . ', ' How might you spend the weekend . ', ' I hope to do a little gardening . I find it very relaxing . ', ' I might do that too . I hope the weather is nice . I could go and play some golf . ', ' I heard that the weather should be good . There ’ s a possibility of a shower , but it ’ s not very likely . ', ' Hopefully , we ’ ll both have relaxing weekends . ', ' Of course , something could come up and stop that wish coming true . ', ' Unfortunately , there ’ s always the possibility of some urgent work requiring our attention . ']
['Do you drink the Robust Milk every day ? ', ' Not every day , but occasionally . ', ' It will make you as fit as a fiddle . ', " I don't believe ads.What ' s more , I'm already in perfect health . "]
["In my country , we go to school from 8 o'clock in the morning until five in the afternoon . ", ' Five days a week , too ? ', ' Actually , five and a half.On Saturday , we have classes only in the morning . ', ' Gosh ! ', " That's too much for us really . ", ' Where are you going now ? ', " I'm going to try to find out where the school is located . ", ' When do you start school ? ', " I'm going to register right now . ", " That's good . "]
["Well , what about it ? As it happens I've got two tickets for next thursday evening . I thought perhaps . ", " Well , thanks all the same , Denise . But no I don't think.Sorry , I'm sure you would enjoy it . I'd like to Denise , but I'm busy on friday this week and next week too . ", ' But I said thursday.The tickets are for thursday evening . ', ' Thursday ? Oh , sorry . I meant thursday too . I mean I busy then too . ', ' I see.Oh , well some other time perhaps . ', ' Yes . some other time perhaps.Thanks again . ']
['Where were you last night , at exactly nine twenty PM ? ', " nine twenty pm , I couldn't say . I cann't remember . ", " Are you sure you cann't remember ? ", " I've absolutely certain . ", ' Were you in or out ? Can you remember that ? ', " I'm not quite positive . I think I went out at about half pass nine . ", ' Did you see anyone come into the block flats ? ', " No , I didn't . ", ' Sure ? ', ' Quite sure . ']
['Jim is a genius . He gets along well with everybody and he can always get the work done . ', ' A boss likes him a lot . He says Jim is a good team player . ', ' Everybody would like to have Jim on their team . Because he is funny and helpful and he can contribute a lot to the team he belongs to . ', ' Maybe we all should learn something from him . ', ' Right . ']
["John , my father isn't there at all . Are you kidding ? ", " Poor , fellow , what's the date today , buddy ? ", " It's ... oh it's the 1st April , April Fool's Day . ", " You forgot all of about it , didn't you ? "]
['Happy birthday ! Many happy returns ( of the day ) . ', ' Thanks . ']
['Hey , Joe ! Where have you been these past few days ? ', ' I ’ Ve been busy with a first aid course that I started about a week ago at the Red Cross . ', ' Cool ! I ’ Ve always wanted to do something like that ! Have you learned anything useful ? ', ' For sure ! I mean we ’ Ve learned how to apply pressure to stop bleeding , how to check for a pulse , and even how to apply CPR ! ', ' Have you treated any real emergencies ? ', ' Well , they took us along with some paramedics.There was this guy who fell off his motorcycle and suffered a concussion as well as a couple of compound fractures . His wounds were pretty serious so they had to rush him to the hospital . It was intense ! ', ' I can imagine ! I tend to faint when I see blood , so I think I won ’ t be taking up a course like that anytime soon ! ']
['Hello ? ', ' Good morning , Nathaniel . This is Leah calling from the International Student Office . ', ' Good morning . ', " The reason I'm calling is because Ms . Collins will not be able to call you back until next week . ", ' Oh . I had hoped she would have called me back yesterday . ', " She's terribly sorry about that . She had to leave the office suddenly and won't be able to return until next week . She hopes you understand . ", ' Is there someone else I can talk to ? ', ' She asked me to call you to book an appointment with someone else today . When are you free today ? ', ' Any time after 2 pm today would be good for me . ', ' Mr . Liu is available at 2:15 today . Will that work for you ? ', " I'd prefer to speak with Ms . Fonda . ", " I'm afraid she isn't available this afternoon . She has an opening at 11:30 this morning . Will that work for you ? ", ' That will be fine . ', " Ok , we'll be expecting you at 11:30 then . See you then . "]
['I work so hard that I do not have the energy to exercise . ', ' That is just an excuse . You can always find some time to exercise . ', ' But I work hard all the time for long hours . Often I have no time for lunch . Yet , I am still getting fatter . ', ' Bill , you know that work is not the same as exercise as it is stressful but not relaxing . And skipping meals will not help you lose weight . In fact your body will only store fat if you miss meals . ', " I know you're right , but what can I do ? ", ' How about going for a walk instead of sitting on the sofa reading the newspaper after dinner every night ? ', " But I'll miss the news . It's important in my business to keep up with events in China . ", ' I know , I know . Have you got a portable radio ? You can listen to the news and get healthy at the same time . ', " That's a good idea ! "]
["I'll always remember my college days . ", ' Oh yeah ? ', ' It was one of the best times in my life . It was tough , but I made it . I became a college graduate . ', ' How did you feel when you graduated ? ', " It was a round day for me . My family attend the graduation ceremony . I was so nervous . I couldn't find my cap and gown , but all worked out in the end . ", ' What did you do after graduation ? ', ' I was planning to attend gradate school , but then I was offered a good job doing marketing , so I changed my mind . ', " Sounds like you're happy with your decision . ", ' I sure am . So what about you ? How did you feel when you graduated ? ', ' It was also a proud day for me , but I also felt like a kind of loss that day . ', ' How could it be ? ', " While seeing others going to work or continue their study , I didn't know what I would do . ", " You didn't have an offer ? ", " I had one , but I didn't like the job very much . I wanted to attend graduate school , but I was afraid it would be too tough . ", " I think you lack in the power of decision . Once you make your decision , don't be overtaken by misgivings and fear . Just go full steam ahead ! "]
["John's father got married again . ", ' Married whom ? ', ' If I tell you . , you must be completely taken aback . ', ' Come on . Tell me what happened . ', ' He married a girl who is only eighteen ! ', " Is that true ? But anyhow , it's none of our business , isn't it ? "]
['Have a nice weekend ! ', ' Thanks.You too ! ', ' Do you have any plans ? ', " Well , my family's away and I can't afford to do much.What about you ? ", " Oh , I haven't decided what I'm going to do yet . "]
['How many languages can you speak ? ', ' I can speak French and German . ', ' How well can you speak them ? ', " I can speak German quite well , but I can't speak French very well . ", ' Can you help me to translate these sentences into German now ? ', " No , but I'll be able to tomorrow . "]
['There are so many record players here.That is hard to choose . ', ' Look at this one.It has a radio and cassette player and built in speakers . ', " I'd rather get one with separated speakers.They give a clear sound . ", " Yes , but we shouldn't get any thing too big.Remember it has to fit in with our living room furniture . ", " That's right.Now this one looks alright ? It's a detached or do you prefer this one ? It's Sony . ", " Let's have the salesmen for a demonstration . "]
['Can ’ t you remember the days when you had the hots for me ? ', ' You tried to seduce me . I fell for you . ', ' By the way , are you going to the concert tomorrow ? ', ' I am just thinking of it . Maybe I ’ ll go . ']
['I think that show biz stars have a really easy life . They have lots of money , so they can buy almost anything they want . They ’ re famous , so everyone loves them . ', ' I think they must have horrible lives . All the paparazzi take photos of them wherever they go and whatever they do . They must get sick of it . ', ' I bet they love it really . Sure , they complain about it , but that just gets them more publicity , doesn ’ t it ? ', ' I think that few of the show biz stars want any publicity for themselves . They only want it for their films . ', ' No way ! They want publicity for themselves , so that they get invited to make more films , go to lots of cocktail parties , and even make albums ! They have such an easy life . They don ’ t even pay for Drin ', ' Show biz stars have plenty of expenses . That ’ s why they need so much money . They need million of dollars to buy big , seclude houses and wonderful dresses . I bet most show biz stars would prefer to Wea ', ' I don ’ t understand how you can have any sympathy for show biz stars . They ’ re overpaid , over-ambitious , and over-adored . ', ' I think you should give them some credit . They ’ re very talented people and they deserve all the money they earn . They even donate money to charity to help people who are less fortunate than themselves ', ' Come on ! They only do that to get even more publicity for their films and themselves . ']
["What's the matter , Lisa ? You don't look too good . ", ' I just found out that my husband is cheating on me . ', ' You mean Mark ? He seems like such an honest guy . ', " That's what I thought . It seems that he's been seeing someone else for about two months . ", ' Two months ? How did you find out ? ', ' I asked for leave and was at home when the telephone rang . I picked it up and a girl asked to talk to Mark . She then asked if I was his sister , and I said no , I was his wife . She hung up immediately . ', ' So you asked him about the girl who called ? ', ' Yeah , he first said it was someone from work . He gave me a lame excuse , and so I pressed him on it . ', " What'd he do ? ", ' He kept trying to make stupid excuses , and then broke down and admitted to a small indiscretion . ', ' Indiscretion ? How can an indiscretion last two months ? I mean , you two have been married for two years ! How can he do that to you ? ', ' I told him I would divorce him if he wouldn ’ t tell me the truth or end the relationship with her . ', ' Good . I totally agree with what you did . ']
['So do you believe in palmistry ? ', ' Palmistry ? What is that ? ', " It's when someone takes a look at another person's palm to tell the future . ", " Oh , you mean palm reading . I've seen that before , but I don't believe in it . ", " Are you sure ? I've read a lot about palmistry and I've been able to tell a lot of accurate things about a person from his palm . Do you want me to take a look at your hand ? ", " Really ? You've read books about it ? Ok , then . But only if you want to . ", " Ok , let's see , well , you've got a long life line , which is good , and the love line is strong ... ", ' What else do you see ? Will I be successful ? Will I make a lot of money ? ', ' Hmm , hard to say , wait , yes , it looks like you will do well in business , and your ambition will help you a lot , but ... ', " What ? What is it ? What's the matter ? ", " You seem to have a large gullibility line . You believe everything that you're told . "]
['Welcome back movie lovers to another Premier Movie Review . My name is Richard Clarke and I am joined today by the very erudite DavidWatson . ', ' Thank you Dick . Today we are going to talk about the movie Lion King . Tell me Dave , what is your impression of this film ? ', ' Well , I think this film is simply a fable , depicting man ’ s eternal greed for power , and in my opinion , it ’ s a very fine film . Even despite the accusations of plagiarism traditional folk tales from other countries.The musical score was amazing , the animation was very well done , and the story was simply enchanting . ', ' I think otherwise . Even though the animation was technically strong , and as you say , the score and songs performed by Elton John were great , the film lacks a certain originality ; it lacked heart . And I would dare to say , it was too predictable . ', ' Predictable ! How ! Come on Dick , It ’ s a G-rated movie ! It ’ s for the kids ! It ’ s not a thriller ! ', ' Well , that ’ s just it . It did have some very dramatic and intense scenes For example when Mufasal dies , or the dark , grim portrayal of Scar . Even so , the film is linear . Mufasal dies , Simba runs away thinking it ’ s his fault . Falls in love and returns to retake what is rightfully his . It ’ s just too cliche . ', ' How can it be cliche ? It ’ s a fable ! It ’ s telling a time-honoured story ! The movie make a point of how the hunger for power leads to corruption , and teaches children the value of respect , life and love . ', ' You have always been so soft , Dave ! ', ' Open your heart Dick . Don ’ t shut us out . ', ' Anyway ... That ’ s all for today folks ! Join us next time as we talk about & quot , How to lose a guy in 10 days & quot , I ’ m sure you ’ ll love that one Dave ! ']
['Hi , Walter ! ', ' Hi , Sterling ! ', ' What do you think of our new teacher ? ', " Professor Wood ? I think he's a brilliant scientist . ", " You're got a point there . But do you think he's a little absent-minded ? ", ' I guess so . ']
['It gives me great pleasure to introduce Mr ... eh Mr ... ', ' Miss ! ', ' Yeah ! May I introduce Mis ... eh ... Miss ... ', ' My name is Jane Brown ! ', ' Oh yeah ! Would you please welcome ... Miss Jan Brown . ']
['I stayed online chatting with friends all night . It was great fun . ', " I don't understand . You don't even know the ' friends ' you are ' talking ' to ! ", " It is better I don't know them . So I can say anything I want . ", ' Do you believe what they say ? ', " Who cares ? It's just online . It's not real . Do you want to join me tonight ? ", " Thanks , but I'm a lousy typist . "]
['We scored six goals . ', " I don't believe it . ", ' And I score three of them . ', ' You are not serious ? ', ' We had extra time of course . ', ' I can believe that . ']
['This is tough to say , Jordan , but I think we should break up . ', ' Are you serious ? ', ' Yes , I mean it . ', ' But why ? Did I do anything wrong ? ', ' No , we are just too different . This isn ’ t working . ', ' Hey , come on . It ’ s too early to say that . We can fix things . ', ' I have thought about it for a while . I think it ’ s time to move on for both of us . ', ' But I still love you . ', ' I ’ m sorry . ', ' I knew this would happen some day ... ', ' Then why didn ’ t you talk to me ? ', ' Well . It ’ s not all my fault , Anna ... ', " I don't want to argue with you anymore . This is going to be tough , but Let ’ s try and be friends . ", ' I would like that Anna , but I think I ’ ll need a little space for a bit . ', ' I think we ’ ll be better off if we are apart . ', ' Shall we keep pur friendship ? ', ' Sure , let ’ s just be friends . ']
["Who's that ? ", " Saint Jude-he's the saint of lost causes . Like my cousin , Anna , who can't stop getting pregnant . She's a lost cause . ", ' Is that your cousin in the back ? ', " Yep . She's always got a bun in the oven . She was pregnant before marriage-a real sin in the Catholic Church . ", " What about birth control pills ? Don't they work on Italians ? ", ' Ha-ha . Birth control and abortion are four-letter words in my family . ', ' And I heard that Italian men have very active libidos . ']
["Hi , Lander . What's wrong ? ", ' I can hardly make ends meet these days . ', " Same here . I have't brought any new clothes for three months . ", ' My income remains the same but prices just continue to rise . ', ' True . The news says that there is a general increase in the price of daily necessities . ', ' Definitely . I have to spend 300 yuan more on food every month . ']
["You look a bit dull today . What's up ? ", ' Well , my mum lost her job yesterday . ', " I'm sorry to hear that . Well , I heard that registered urban unemployment rate reached 4 percent this year , with more than half being women . ", ' The supply outstrips the demand in the job market and women are in a disadvantageous position as a whole . ', " Yeah , it's true . What is she going to do ? ", ' Well , she is thinking of doing some household cleaning or baby sitting in the community . ', " That's not bad . It could be a short-term alternative . Your mum can look for another one when the market improves . Things will work out eventually . ", " Thank you . I just hope she won't feel pressed . "]
["You don't look too well . What's going on ? ", " I just lost my job . I'm just worried about how I'm going to pay the bills . ", " I'm sorry to hear that . Have you been looking for another job ? ", " I just started , but the job market is very bad right now . I'm not optimistic about it . ", " That's tough . What does your wife think about this ? ", " She's trying to be supportive , but I can tell she is very worried about our financial situation as well . ", " I have some friends who might be able to help you find a job . I'll see what they can do . ", ' I really appreciate your help . ', " No problem . In the meantime , don't try to worry so much . You'll get through this . "]
['Let me tell you what happened to my homework . ', ' OK , go ahead--what is the excuse THIS time ? ', ' Actually , I did it , but then it got lost . ', ' Could you have gotten it done at another time ? ', ' Yes , I could . ', ' You have never missed an assignment before--when will you be making this one up ? ', " I'll make it up early next week . ", " That would work , but don't let it happen again . ", " I'll try . ", " That will solve it then . Let's work hard to not let it happen again . "]
['Do you want to try your hand at tennis ? ', ' Certainly I do . ', " It seems you're very fond of it . ", " I'd be happy to do something new . "]
['This is how a holiday should be . Relaxing on the beach with a nice cool drink . ', ' Isn ’ t it wonderful here ? The kids are enjoying themselves in the swimming pool . I hope it ’ s safe . ', ' Don ’ t worry about them . They ’ re very responsible . Besides , there are many people there and there ’ s lifeguard employed by the hotel . Waiter ! Could I have another drink pleas ? Thank you . So , what shall we do this evening ? ', ' The kids said that they wanted to go to a party at the hotel . There ’ s a special one just for kids . ', ' So , we could try that restaurant that was recommended in the guidebook . Then we could go to a club . We haven ’ t been to one for ages . ', ' That ’ s a great idea . We can really enjoy ourselves without worrying about the kids . ', ' Now , how about going for a swim in the sea ? We shouldn ’ t sunbathe all day . ']
['Hi , Nancy.How are you doing ? ', ' Hi , Tom.Want a cup of coffee ? ', " Not right now . I've got to get another car and my old one is blown up . ", ' Oh , hey , did you look in the classified ads ? ', ' You mean used car ? ', ' No , Ah ... single sellers . ', " Well , yeah , but I'd be getting somebody else's problem . ", " Uh huh.How about a used car ? They've got good ones now . ", " It's the same kind of deal though , you know , you never know what you're going to get . ", " Oh , hey , how about a new car ? They've got easy loans now.You ' d feel so good driving a new car . ", " Let's look at them all.Have you got a paper there ? "]
["Oh my God ! I can't find my first period American literature class . ", ' You look lost . Can I help you ? ', " Aren't you the guy who sat in front of me in our homeroom ? ", " Yeah . I'm Brad . ", " I'm Mary . I can't find my American literature class . ", ' What room is it ? ', " It's 112 . ", " It's on the first floor by the nurse's office . ", " Thanks a lot , Brad . I've got to go before the bell rings . "]
['I heard that Ann had divorced . ', " I suspect it's unavoidable . ", ' Poor Ann . She did not love her husband at all . ', " Yeah . She married him at her mother's bidding . "]
['Awful ! My cell phone is out of service again . Fred , can you lend me some money ? ', ' How much do you want ? ', ' 200yuan . I bought a computer online , so I have to pay the mortgage . ', ' I am so sorry to hear that . Is that enough ? ', " It's so nice of you . You really make my day . ", ' Forget it ! We seemingly need to gather money little by little . ', ' What you said is absolutely right . I will pay you back as soon as I get back on my feet . ', ' No rush . You can give it back whenever you have it . ']
['How do Mark and Jones compare , in your opinion ? ', " Generally speaking , Mark's personality is much more agreeable than Jones ", " May I venture to ask if you've decided to employ Mark ? ", ' Possibly . ']
['Mary , today is a great day for you . ', ' How nice of you to remember ! ', " Oh , here's a little token of my affection . ", " You're so thoughtful.Thank you . "]
["I am sorry , but I can't stay until the end of class . ", ' Where do you need to be that is more important than school ? ', ' I have an appointment . ', ' Do you have a plan to make up your missed work ? ', " No , but I'll make sure someone helps me out this week with my missed work . ", ' Are you going to go right away ? ', ' I am leaving right now . ', ' All right , but please remember that it is your responsibility to catch up . ', " Thanks , Professor . I'll make sure everything gets taken care of . ", ' Goodbye , and try not to miss any more school . ']
["An interesting meeting , isn't it ? ", ' Yes , very . I thought the last speaker was especially good . ', " Let me introduce myself , by the way . My name's Thomas Bradley . ", " How do you do ? I'm Ted Nugent . ", ' Sorry , what was your last name again ? ', " It's Nugent , N-U-G-E-N-T , but just call me Ted . ", " Ok , I'm Tom . ", ' Glad to meet you . ', ' And what do you do , Ted ? ', " Me ? I'm in the car business . ", ' Salesman ? ', " Yes , that's right . And how about you ? ", ' I work for American Airlines . ', ' Oh , really ? What do you do there exactly ? ', " I'm in the Personnel Department . "]
["It's terrible how things have changed . You remember there used to be trees on all these hills . ", " Really ? There aren't many left now . ", " No , they've all been cut down and now all the soil is washing away . ", ' Were there any animals in the forest ? ', " Yes , I can remember it very well that there used to be all sorts of animals and birds . But nowadays you just don't see the birds that you used to see around here . "]
['My son is alway complaining that I dump on him . He was very rude and told me to mind my own business . I cannot put up with that . ', ' What does his dad say ? ', ' John is a peacemaker . He simply doesn ’ t bother . He says he should give him a free hand . ']
['You are married to a foreigner , huh ? So what ’ s it like ? ', ' Well , the first year of our marriage , we had great difficulty getting along . The things that are important to me are not important to him . We had a lot of conflicts . ', ' Yeah , I know what you mean . The first year of any marriage is difficult for all couples , not to mention two people from different cultures . ', ' And now we have a two-year-old boy . We ’ re very happy that he ’ s healthy and smart . ', ' Oh , so he ’ s half Chinese and half American . That ’ s unusual . What languages does he speak , then ? ', ' Right now he speaks mostly Chinese , and he can say a few English words . But he will learn . ', ' What does he look like ? Can people tell ? ', ' Yes , people surely can . He ’ s whiter than the Chinese kids , and his hair is a little blonde . My husband says his eyes are very Chinese though . ']
['Would you like to go to a concert tonight ? ', " I'd like to very much . ", ' All right , then.There is one at the new concert hall . ', " Who's playing ? ", " It's the Powell orchestra . ", ' Do you know what they are playing ? ', " They're doing a seventeenth-century program . ", ' And who is directing ? ', " Well , I'm not sure of his name , but I know it's going to be his farewell performance . "]
['Here ’ s your hot dog and beer . What happened ? Did I miss anything ? ', ' Yeah , Cal Ripen just hit a home run . ', ' What ’ s the score ? ', ' Well it was 3 to 4 , but Ripen ’ s home run made it 5 to 4 since another player was on first base . ', ' So Baltimore is winning ? ', ' Right . ', ' This is a really great place to watch a baseball game . ', ' Yeah , there isn ’ t a bad seat in the place . ', ' The fans are great here , too . Not like in Philadelphia . ', ' It was a great idea to spend a day watching a game . ', ' Yeah , it reminds you why they say baseball is America ’ s favorite pastime . ']
['Well , it ’ s really too late . I have to go now . ', ' Could you stay a little longer ? ', ' Sorry , I can ’ t.My mother doesn ’ t want me to be late . I really have to go . ', ' In that case , I won ’ t keep you.Remember to give me a call . ', ' Thank you for your delicious meal . ']
['Tell me why you saw the movie twice . ', " I think it's the most successful film in scene-setting and music . ", ' You bet it . ']
['Did you get a nice tree ? ', " Sure did . It's a beauty . Where do you want it ? ", " Let's put it over there . ", " Let's go to work . We want to have the tree ready to light up by evening . ", " Let's string the lights first.Then we won't have to mess up the decorations . ", " Hand me some globes and paper flowers , I'll put them on these top branches . ", " There , ... we're about done . ", " Let's switch the lights on . ", ' OK . Here goes . ', " Well , I guess we're all set for another merry Christmas . "]
['Have the aerobic classes any effect on you ? ', ' Sure , great effect.My weight has dropped from 150 pounds to 120 . ', " Congratulations ! That's really something beyond my imagination . "]
['Our house is too small . We had better have a big one . ', ' How could we ever manage to buy a big house when we are always living beyond our means ? ', ' Shut up . You should think how to make fortunes , not look for a squabble . ']
['Can we have dinner together sometime this weekend ? ', ' Ok , you name the day . ', ' How about the second of March ? ', ' What day is that ? ', " It's Friday . ", ' Good . Where shall we meet ? ']
['I cannot stay here any more minutes . ', ' What is wrong with you ? ', ' Tom is making so much noise . I have not a bit of peace and quiet all evening . ', ' You can talk with him . ']
['What does she do ? ', ' She works as a teller in a bank . ', ' Does she go to night school ? ', ' Yes . She goes three times a week . ', ' Why ? What does she want to be ? ', ' She wants to be a manager . ', ' What classes does she take ? ', ' She takes classes in accounting and business . ']
["You must be Wily . It's nice to meet you . ", ' Nice to meet you , Mr . Wilson . ', ' Tim , please . Please be seated . ', ' Thank you . ', ' So , Wily , you have been with IBM for two years ready for change ? ', " Well , I think I'm ready for new challenges . "]
['What about you , Emily ? Have you dated anyone recently ? ', " I started to date someone recently , but it didn't work out . ", " That's too bad . What happened ? ", " Well ... that's a long story . "]
["Daniel , you can't spit the gum everywhere . ", ' Come on , just a little piece . ', ' Do you know how many people chew gum everyday ? ', ' I have no idea . ', ' Just in Beijing , people consume 300,000 pieces of gum every day . ', " That's amazing . ", ' If all the people spit out the gum like you , the whole world would become a big trash can . ', ' Come on , you are making too big deal out of this . ', ' I just want to remind you to behave yourself . ', ' OK , dear sister , I see . This kind of thing will not happen again . ']
['Is my hair done yet ? ', ' Yeah , I just need to make the final touches . ', " How long until you're finished ? ", " I'm finished . What do you think ? ", ' I like my hair so much . ', ' Do you really ? ', " It's beautiful . ", ' Well , thank you very much . ', ' How much is it for my hair ? ', ' You owe me $ 55 . ', ' Thanks for everything . ', ' You are very welcome . Come back again . ']
["Listen , Karen , I need your help . I don't know anyone here yet . ", " I'm glad to help you . What's wrong ? ", ' My mother-in-law just went into the hospital in L.A.Hank and I will be flying there tonight . ', " I'm sorry to hear it . What's wrong with her ? ", " Doctors aren't sure yet.But the real problem is Suzy . She has a bad cold , and we don't want to take her with us . But we don't know who can stay with her . ", ' You need a babysitter . ', " Yes , I'd ask Jill , the girl I've had before , but I need someone overnight.Maybe even for two nights . ", ' I could have Suzy stay at my place . ', " I don't want to do that to you , Karen . ", ' Why not ? ', " Your own kids would get Suzy's cold . I think it would be better to have a good babysitter here . But I don't know who to ask . I need someone more mature than Jill . It might even be for two or three days . ", ' I know who we can ask . There is a girl I know , Sara Ralston.She is 17 , and she will usually take this kind of job . I know her from my church , and I trust her completely . ', " I'd like to talk with her.This is short notice , I know . But Hank and I are leaving tonight . ", " I'll get you her number . I hope she can do it . She is very responsible . ", " I'm glad you know someone . I knew you would be the best person to ask about this . I don't want to insult Jill or her mother . I think Jill maybe could do it.But I'd rather have someone a little older . ", " I'll go home and get Sara's number . I'll call her first myself . ", " Great . Then call me and let me know if she's free . "]
['Did you hear what happened in the Scott case ? Some of the sensitive material were leaked to the press . Now every newspapers is all over it . ', ' Oh ... I bet the firm is fuming . Do they know who spilled the beans ? ', " I'm sure they have their suspicions ; there were only a few of the senior level layers who were privy to the case details . ", ' What kind of repercussions will there be for the people who are held responsible ? ', " I'm sure there'll be canned ! And there also might be some legal consequences . ", ' Why would the person who told have problems with the law ? ', ' Because whoever let the cat out of the bag was breaking client confidentiality . ', " I didn't think about that . That's pretty serious . Are there investigators working on finding out who it was ? ", " I'm sure management is on top of it . "]
['You are not being a good sport about this . ', " That's because you cheated . ", ' I never cheat . ', ' Yes , you do . ']
["Hi , I'm Lucas , I just moved in next door . ", " Oh , hi Lucas , come on in . I'm Barbara . Nice to meet you . ", ' Nice to meet you too . ', " Would you like something to drink ? I've got tea and some grape juice . ", ' Thanks . Some tea would be nice . Chinese tea is great . I really like your tea set . Where did you get it ? ', ' Oh , there is a supermarket not far from here . But there is also a tea house around the corner , where you can get tea , taste tea and get a tea set as well . ', " Oh yeah , I saw the tea house the other day . I think I might go and have a look sometime . It's a nice neighborhood here . ", " You are right about that . It's quiet and very convenient . You can get to the bus and the subway stations within ten minutes ' walk . There's a grocery store , a book store , a gym , and many restaurants along the street . ", " There's a gym nearby ? That's exciting ! I really want to start to go to gym as soon as possible . I've been lazy this summer holiday and have put on some weight . ", ' Well , if you want we can go together sometime . Actually I was thinking of going this afternoon , if you like , you can join me and I can show you the neighborhood along the way . ', ' That would be wonderful . Thanks ! ']
['What ’ s your favourite ball sport ? ', ' I like basketball . I really enjoy watching the NBA games on TV . ', ' Who ’ s your favourite player ? ', ' I don ’ t really have one but I support Huston . ', ' Do they have a good team ? ', ' I think they do , but I ’ m biased . They have a good manager and a great coach . ', ' I can ’ t keep up with the game . The players play so quickly that I can hardly see what they are doing . ', ' I have the same problem . The players are really very skilful . I wish I could play that well . ', ' You play for an amateur team , don ’ t you ? ', ' Yes , I do . We ’ re doing pretty well this season . We ’ Ve won most of our games , but we ’ re not top of the league table . ', ' How many more games are there this season ? ', ' We ’ Ve got four more games . I hope we can win all of them . ']
["I'm sorry , but I can't go . ", ' Why not ? ', ' I have to see my daughter . ', ' When poyou have to see her ? ', ' I have an appointment at one fifteen . ']
["I like the kid.He ' s so lovely . ", ' How old is he ? ', " Twelve.He ' s very sensible for his age . "]
['Time flies ! ', " You're telling me . "]
['How are you , Kim ? I haven ’ t seen you around for a few days . ', ' Oh , I was out sick most of last week . I ’ m still not completely over it . You ’ d better not get too close ! ', ' I ’ m sorry to hear about that . Why don ’ t you join me for a hot cup of tea ? It ’ ll be good for you ! ', ' Sure , why not ? I could use a rest . ']
['Hello , Mr . Brown , long time no see . Where have you been ? ', ' Oh , I went on a holiday in the city of Chende . ', ' Great . What do you think of it ? ', ' The city is small , not very modern , but there are many mountains with lots of trees around the city , so the air there is pretty fresh . ', ' Did you go to the Summer Mountain Resort ? ', " Certainly ! The most attractive place is that , it's very large ; it is 8 times the size of Forbidden City and 16 times the size of Summer Palace . The art of gardens is perfectly represented in it . ", ' It sounds great , and is it really cool there ? ', ' Yes , I think the reason is that there is a big lake , and many trees in the Resort . ', ' What is the special local product ? ', ' The main product of Chende is various kinds of ferine mushroom and the almond . The mushroom tastes really good , and it is very different from the common mushrooms , and the snack made of almond is delicious . ', ' I hope to go there someday . ']
['Gino , do you really need to go ? ', " Yeah , it's must for me . ", " But don't forget to give me a ring . ", " I won't , mom . ", ' Take care of yourself . ', ' I will . Bye , mom . ', ' Bye , my boy . ']
['John got a heart attack last night . ', ' Oh really ? Is he all right ? ', ' Not so good , though his nephew took him to hospital in time . ', ' Poor old John ! I am ever so sorry . ']
['Why are you always staring at Melissa ? Do you like her or something ? ', ' Mind your own business . ']
['Have you heard about the new iPhone ? ', " yes , I heard it's supposed to come out in June . Are you thinking about getting one ? ", " I'd like to . It's a cell phone , camera , PAD and mp3 player all in one . ", " if I had enough money , I'd buy one , but I don't even have enough to buy one of their shuffle spods . ", ' how big is a shuffle iPod ? ', ' the first generation iPod shuffle is about the size of a park of gum and the second generation iPod shuffle is about half the size of the first . ', ' how many gigs of music can it hold ? ', " I think it's either one or two gigs . I can't remember . ", ' how much do they cost ? ', " not much at all . I think it's about 100 dollars . ", " you're right , that's not bad at all . ", ' do you have an iPod ? ', ' I got one for my birthday when they first came out , but after the battery died out , I never brought another one . ', " why didn't you just buy another battery for it so you could use it ? ", " that's one of the problems with having an iPod . Though an iPod might have an above average battery life , once the battery is dead , so is your iPod . "]
["You seem to like her very much , don't you ? ", " I can't deny that . She is so beautiful that I fell in love with her at the first sight . I wish I knew more about her . ", ' But I heard that she had a three-year-old girl . ', ' I can not belive that . It must be cooked up by someone . ']
['Do you need help with something ? ', ' I ’ m looking for this book . ', ' Is there something wrong ? ', ' I don ’ t see it on the shelf . ', ' Did you check the computer ? ', ' I already looked . ', ' Did it say anything ? ', ' It said that the book is on the shelf , but it isn ’ t . ', ' I ’ m sure I can get it from another library . ', ' Could you do that ? ', ' I ’ ll let you know when I get the book in . ', ' That ’ s great . Thank you so much . ']
["Hello Bill , what's new ? ", ' Bob and Mary are back together . ', " I'm glad to hear it . ", " Me too , they're such a nice couple . "]
['Hey , Robert , what are you doing this weekend ? ', " I didn't have any big plans . ", ' We are putting together a birthday party for Mary . ', ' That sounds like fun . Where will it be ? ', " We thought it would be fun to have a pool party at Jay's house . ", ' Oh good ! Can I bring anything ? ', ' We will be providing hot dogs , hamburgers , and cake , but people can bring side dishes . ', ' I am assuming that the dress is casual . ', ' Dress casually and bring your bathing suit ! ', " Wonderful . Just e-mail me the time and date and I'll be there . "]
["Jessica is going back to Holland next week . I've been thinking a lot about what to give her as a parting gift , but I still have no clue . ", ' Is that the girl you spent almost every weekend with ? ', " Yeah , that's her . We had a lot of wonderful times together . She is really a special friend , and I want to get her something meaningful . ", " I am not good at picking gifts . Maybe you can ask if there's anything she needs to make it easier ? ", " I don't think so . That way it would lose all the charm . I want it to be a surprise . I want to show her that I care about her and I hope our friendship will last . ", " Yeah , that's nice . ", " Hmm , I think I've got an idea . Maybe I can get her an ever-green plant to take back home . ", " A plant ? That's creative . I'm sure ever time she waters it she'll think of you . But there is a problem . Do you think it'll be able to get through the customs ? ", " I hope so . I'll make sure to get a small one so she can put it into her suitcase . I hope it won't cause her trouble at the border . ", " I don't know . I think the idea of a plant going across borders with a friend is really exciting but maybe seeds would be safer . You don't want to get her in trouble . "]
['Do you have any hobbies ? ', ' Yes , I like collecting things . ', ' Oh , that ’ s interesting , and but what kind of things ? ', ' Several things , for example , Various coins , stamps , stones and so on . ', ' Stones ? I know many people collecting coins and stamps but stones ? ', ' Yes , stones . ', ' well , I can ’ t just image it . ']
["We're going dancing tonight . ", ' Count me out . ']
['Good morning Mike ! ', " Morning Sally ! What's up ? you seem in a hurry ! ", " I am having an exam at nine , It's already eight thirty . ", " Don't worry , I'll drive you . ", ' Thank you very much ! ', ' How are your cases coming along ? ', " Very well , thanks , I will probably finish next week , but this is still a lot of work , I have been worked on in for six months , and i ' m so closed to end . I can feel it . ", " Wow , Good for you.It sounds like a lot of work . I'm proud of you ! Is this the right building ? ", " Yes , It's only eight forty . Thanks so much ! ", " You're welcome.Good luck , bye ! ", ' Have a nice day , bye ! ']
["Oh , Mary , come in , please . I'm so happy to see you . ", " Happy birthday , George . Many happy returns of the day . Here's a present for you . ", " Oh , thank you , Mary . You're so nice . ", ' I hope you like it . Oh , have the other guys arrived ? ', " They're all waiting for you . Let's join them . I'm going to cut the cake soon . ", " Let's go . "]
['When shooting a gun , accuracy is very important . ', ' You only need to tell me that once . ']
['John , why don ’ t you go and do some gardening ? The lawn needs weeding . ', ' Because I ’ m not in the mood , that ’ s why . ', ' Well , don ’ t just sit there , do something . Come and help me in the kitchen . ', ' Help you in the kitchen , I don ’ t feel like it . ', ' Would you like to clear the table then ? ', ' Really ? Do I have to do it ? ', ' Not , if you don ’ t want to . ', ' Well , isn ’ t there anything you want ? ', ' Yes , I want to go out . Would you like to come ? ', ' No , why should I ? I don ’ t feel like it . Besides , I ’ m in such a bad mood . ']
['I just heard that you won the long-distance race . Congratulations on your victory . ', ' Thank you . ', " So it is really worth your great effort . And hope you can keep the record you've made today . ", ' I will try my best . ']
['Oh , what a beautiful garden ! ', ' These are my roses . The roses have been in flower for a week . ', ' The garden looks lovely when the roses are in bloom . You must have a lot of pleasure in planting flowers . ', ' Yes , you are right . I love flowers and hence have taken to growing them . I take care of my flowers every day as if they are my good friends . ', ' You did a good job . But I got tired of working in the garden . ', " Oh , I see . People who don't understand the nature of flowers won't be able to grow them well . I can help you learn more if you want to plant flowers one day . In this way you need not be afraid of your own sweet flower-garden's being neglected . ", ' Yes . Thanks . ']
['Julia , why have you prepared a candlelight dinner ? Anything special to celebrate ? Did you get a promotion ? ', " Honey , don't tell me that you forgot our anniversary , did you ? ", ' Oh , my dear , how can I forget such an important day ? I was just kidding . Look at this box . ', " What's in it ? ", ' Have a guess . ', ' A necklace ? ', ' No . ', ' I have no idea . ', ' Open it now . ', " Oh , my god . A diamond brooch . It's so beautiful . You're so kind to me , A . Thank you ! ", " You're welcome , honey . I hope we will celebrate our golden wedding anniversary in future . "]
['What do you say we stop in at that Burger King over there and grab a bite ? ', ' Forget it ! If you think I ’ d ever set foot that inferior restaurant again , you gotta be nuts . Last time I ate that food , almost vomited . The service in there is terrible . It was the first time I ever stiffed a waiter ', ' Yeah , not seeing a single person anywhere informed me . Hey ! How about that one over there ? ', ' Oh , give me a break ! That place is too lavish for us . ', ' Easy . It ’ s on me . ', ' In that case , I ’ m right behind you . ']
['what did you do over the weekend ? ', ' I went a global warming rally in London . It was fantastic to be around so many people who care about the environment . ', " do you think there's anything we can do to reverse the damage that's been done already ? ", " it might not be possible to fix the problems that we've created for ourselves , but there are lots of things we can do to prevent more damages from happening . ", ' like what ? ', ' well , we can use public transport instead of taking our cars for a start . ', ' what else can we do to protect the environment ? ', ' if you do have to drive , you should make sure that your car runs on unleaded petrol . Also , your home should use sources of renewable energy . ', ' how about recycling ? Does that actually help ? ', ' yes . You should take your glass , paper , plastic , cardboard , and tin cans to a recycling center . ', ' what do you think is the biggest worry for our future ? ', ' I think that the issue of greatest concern is having enough sources of clean water for everyone . ', ' I had no idea you were such as environmentalist before ! ', " to be honest , in order for the earth to continue to be a habitable place , we're all going to have to become more interested in the environment . "]
['Why are you going out with Andy ? ', ' Because I like him . ', ' Me , too . I think he ’ s really a shoulder to cry on . ']
["Hi , Mikel . What's with you ? You look angry . ", " No , I just check my weight , I'm getting fatter . ", " True , you are getting a really pot belly , aren't you ? ", " I'll get you for that comments , George . ", " Just kidding , Mikel . Why don't you come work out with me ? ", " ah , I don't know a fit works . Last time , all I saw the gym were bunch of lidos , like me . ", " It works if you keep at it . Come on , let's go ! ", " All right . But so help me it's a better work . ", " This feels great . I'm all reed up . I can keep going all night . ", " Not me . I'm too hot and I'm too tired . ", ' Exercise has no benefit unless you sweat like a pig . ', " Well , that's not for me . ", ' Thanks for coming , it was a real blessed . ', " It wasn't as good as you think . ", " You'll get used to it , Mikel , trust me . "]
['Good morning , Miss Wang . How beautiful you look today ! ', " Thank you . I'm wearing make-up . ", ' Who taught you to put on make-up ? ', " It's me . I have studied make-up at a beauty shop . ", ' Can you teach me how to do make-up ? ', ' Of course . First , use eye shadow to heighten your eyes . ', ' What eye shadow do you think is the most fit for me ? ', ' I think pink eye shadow is popular among Chinese girls . ', ' How do you protect yourself from chapped lips ? ', ' I suggest you use lipstick , which also accentuates your lips . ', ' How did you grow such long nails ? ', ' You have to pay attention to trimming them from time to time . ']
['Oh Gush ! The first day of my career is over . I can not breathe now after dealing with so many documents . But I heard the notice that our company will hold two-week staff training . ', ' Stop fussing ! It is said that the training is important for our newcomers . And my company also informs me to attend the training next week . ', ' But for me , the training is waste of my precious time . ', " I disagree with you . Companies usually make a workable and reasonable plan for the trainings , so as to improve new comers ' understanding of the company and its rules in short time . Through the training , we get to know many things , such as the corporate culture and spirit . Our newcomers can really grasp the essence of the company "]
['You look like being on cloud nine . ', ' I am . ', ' What has made you so happy ? ', " I think I'm in love . ", " Are you ? Who's the lucky girl ? ", ' Her name is Jenny . ', ' How did you meet her ? ', ' We are in the same math class . Our teacher sat us next to each other . ', ' What do you like best about her ? ', " She's very funny . She makes me laugh all the time . ", ' I guess it was fate working to bring you together . ', " Whatever brought us together , I'm happy . "]
['How will you spend this lovely weekend ? ', ' I have no idea , any suggestions ? ', " We haven't played chess for a long time . How about playing chess ? ", " It must be fun . But you know , I am not good at chess . I never won since I've learnt to play chess . ", ' Don ’ t worry , I will teach you how to win . ', ' OK , settled then . ', ' See you tomorrow . ', ' See you ! ']
['Alright everyone settle down . Let ’ s get started.As you know , an important aspect of becoming a good citizen is understanding the genesis of our legal system . It is not enough to simply memorize our laws , it is necessary that we comprehend why and how they were formed . This brings me to our topic for today . Does anyone know what we celebrate on May first ? ', ' Cinct de mayo ? ', ' No , that ’ s May fifth in Spanish , James , no wonder you are failing my Spanish class . No , May first is International Workers ’ Day . ', ' Do we get a day off from school then ? ', ' No ! It is not considered to be a national holiday here in the US , but in other countries it is . ', ' Www , man ! ', ' In the nineteenth century , working conditions were appalling , with workers being forced to work ten , twelve , and fourteen hours a day . Support for the eight-hour work day movement was growing rapidly , despite the indifference and hostility of many union leaders , and by April 1886 , 250,000 workers were involved in the May Day movement.Previous legislative attempts to improve working conditions had failed , so labor organizers took drastic measures . They passed a resolution stating that eight hours would constitute a legal day ’ s work . And , on May First 1886 , the resolution took effect . ', ' Cool ! Is that why we only work eight hours now ? ', ' Yes ! But the happy ending came at a high price.On May third , 1886 , police fired into a crowd of strikers at the McCormick Reaper Works Factory , killing four and wounding many . A mass meeting was called for the next day to protest the brutality . ', ' And then what happened ? ', ' Well , as we say , the rest is history ... ']
["What's that book you have under your arm ? ", " It's the best seller everyone's been talking about for the last six months . ", " How in the world did you get a copy ? I've put a hold on it at the public library for weeks and I'm still waiting my turn . ", ' I checked it out of the rental library . It only costs five cents a day . ', ' Is it really worth paying for ? ', " I can't tell yet . I haven't got beyond the first chapter . ", " If it's any good , I'll buy a copy when it comes out in the pocket edition . "]
['Hey Lucas , how was your trip to Paris ? ', ' It was wonderful , but I was so tired . ', ' Did you go to the top of the Eiffel Tower . ', ' Yes , that was the first thing we did . We went all the way to the top . There were visitorsfrom all over the world taking photos there . ', ' What else did you see ? ', " Art galleries , cathedrals , statues , fountains , palaces , bistros , there's really too much to say . ", ' You must have had a great time . ', ' Yes , at the beginning we were all excited and had lots of fun . However , on the third day of travelling in the city , I felt sick I think I had something bad to eat but it passed by the evening . ', " Yes . you need to be careful with what you eat when you're abroad.sometimes new food might disagree with you . ", ' On the fourth day , we went to taste the French cuisine . That was really fantastic . And no stomach problems . ', ' That is great . Everyone says French food is wonderful . ', " You'll have to try for yourself some day . "]
['You have your ducks in a row . ', ' Thank you very much . I will devote all my efforts to my work . ']
['Were you born in the U . S . , Melissa ? ', " No , I wasn't . I came here in 1992 . ", ' How old were you ? ', ' I was seventeen . ', ' So , did you go to college right away ? ', " No , because my English wasn't very good . I studied English for two years first . ", ' Wow , your English is really fluent now . ', ' Thanks . Your English is pretty good , too . ', ' Yeah , but I was born here ! ! ']
['Can I help you ? ', " Yes , would you like to tell me what's playing for tonight ? ", ' Sure . There is a folk concert tonight . ', ' Are there any good seats left ? ', ' Sorry . There are only some seats in the back . ', ' Well , what time does it begin ? ', ' It begins at 7 p . m .. ', ' OK . I see . ', ' How many tickets do you want ? ', ' Just two . ', ' OK . Fifty yuan for each . ', ' Here is the money . ']
['We have a live show of a football match this Friday night . ', " What're the teams ? ", ' Brazilian against AC Millan . ', ' I bet AC Milan will lose . ']
["How time flies ! Why I always feel haven't enough time to work and study ? ", " Yes , I also felt that . I'm always busy , and have no time for rest . I don ’ t know how to make use of time . ", ' Maybe we should make a plan and list what we should do next , and follow it . ', " That's a good idea . And in this way we will know how we spend our time and spare a lot of time to do other things . ", ' You are right . Let ’ s stop idling around and do something . ', ' Yeah , time is money . We really need to make good use of it . ']
["Hi dude , you look upset , what's up ? ", " haven't been sleeping well recently . ", " what's the problem ? ", " every night my roommates watch the Korean soap operas till mid-night . I am not a big fan of Korean shows and I don't know how to tell them to stop without hurting their feelings . ", ' well , you can simply tell them you want to sleep , or make an arrangement for a time when the room should quiet down . ', " yeah , I know , but I find these sorts of things hard to say . They won't like it if I tell them to turn off the TV . Now I just hope the show will end soon . ", ' I understand . I used to live in a dorm with four people . I was great in some aspects . We always went out and and had fun together . But on the other hand , when I wanted some quiet time , and people kept ', ' yeah , I crave my own space . i just so tired of having people around me all time . ']
["I'd better be going . ", " So soon ? Why don't you stay a little longer ? ", " I wish I could , but it's already late . ", " Oh , it's a pity that you have to leave . ", ' Thank you for a wonderful meal . ', " I'm glad you enjoyed it . "]
['Are you an American ? ', ' Yeah . ', " Why don't you speak English ? ", ' Oh , my mother is a German , so I can speak German . ', ' Oh , do you like Chinese ? ', " Yeah , I'm eager to learn Chinese , but it is too difficult for me . ", ' I want to study German . Can we exchange lessons ? ', " Very Good . I'd like to do that . ", ' When will we begin ? ', ' How about tomorrow night ? ', " That's all right . "]
["You seem depressed these days . What's the matter ? ", " I went bankrupt and I'm flat broke now . ", " If I can do anything for you , don't hesitate to let me know . ", ' Thank you . ']
['You ’ re all set now ? ', ' Oh , thank you so much . ', ' Really , it was nothing . ', ' I really appreciated it . ', ' I was happy to help . ', ' It was so kind of you . ', ' Don ’ t mention it . ', ' You ’ re a real friend in need . ']
["Haven't seen you for a long time ", " I've been away on a vacation . ", ' I bet you had a wonderful time ', ' Yeah , beautiful sunshine , pleasant scenery and many new friends ', ' Sounds great ']
['I hear you have just shown your hand first to Lin Ping . ', ' Yes . ', " If I were in your position , I wouldn't give up an inch . ", " I regret to say I can't accept your suggestion . "]
['Have any plans for the weekend , Tom ? ', ' Yes . I am going for a hike around the Qinghai Lake . ', ' Oh , do you go hiking often ? ', ' I go as much as I can . I love hiking , because you can really get in touch with nature . ', ' It would be nice to get out of the city . Do you want some company ? ', ' Sure . But it will be a long hike 30 miles in three days . Have you been hiking before ? ', ' Yeah , I go a lot too . I saw a bear and a lion on my last hike . ', ' Wow . You must have been pretty far away from the city . ', ' Yeah , my friend and I hiked in a very wild part of the national forest . ', ' Well , bring him along to . We will have a great time this weekend . ', ' Thanks . I will ask him . ']
['Has the game started yet ? ', ' Yeah , about 5 minutes ago . ', " Who's winning ? ", ' The Bulls , of course ! ', " What ! That wasn't a foul ! C ’ mon , ref ! ", ' Don ’ t worry , Shan always screws up free throws . ', ' You were right ! He didn ’ t make the shot ! ', ' That was a great shot ! A three pointer , yeah ! ', ' Did you see that ? He traveled and the ref didn ’ t call it ! ', ' This ref needs glasses . Hey ref , open your eyes ! I can ’ t believe he didn ’ t see that ! ', ' Okay ... end of the first quarter ... Alright , I ’ m gonna make a beer run . ']
['I heard that Kevin got divorced . Is that true ? ', ' Not so bad , but Kevin does have problems with his wife . ', ' What ? ', " His wife always complained that Kevin's salary was too low and got no promotion . ", ' Poor Kevin , we should do something for him . He is a nice guy and does his job well . ', " Yeah , I agree with you . But you know , it's just one of those things . "]
['Honey , do you know what color the carrot is ? ', " Mom , it's orange ? ", ' Wow , my son is so clever . ', " Mom , that's a stupid question . ", ' Really ? ', ' I am not a child at all . I know more . ', ' Oh , my son looks like a grown-up . ', ' Sure . Mom , I can take care of you . ', " No kidding . So tell me what's your favorite color ? ", " I like blue . You see , that's the color of the sky . I wanna be a superman . ", ' Why ? ', ' I hope I can fly to any place like superman . So I can touch the sky . ', ' OK , superman . Put on your cape , we are going to fly home . ']
['Thanks for inviting me to work out with you , Joan . ', " Don't mention it , let's go in . ", " Yeah , this place looks great . Wow , look at her , she can certainly get down , can't she ? ", ' She sure can . Are you jealous , Leslie ? ', ' A little , I wish I could do that . ', ' You can ! With a little practice . ', " Look at him , he's buff . ", " I think he's hot too . ", ' How do they all get in such tiptop shape ? ', ' Exercised over and over . Exercise is a key . ', " That's it . I decided to turn over a new leaf . I'm going to exercise every single day . ", ' Good for you , Leslie ! ']
['wow , it that your sports car ? ', ' yes , do you like it ? ', ' I love it ! I used to always want to drive a green jaguar . Is it in good condition ? ', ' it looks good on the outside , but the inside is a different story . It needs a lot of servicing before it can go out on the roads again . ', " what's wrong with it ? ", ' well , first of all , it needs a new engine , which is extremely expensive . ', " when's the last time you had it serviced ? ", ' it must have been a few years ago now . ', ' I thought all cars needed regular servicing on a yearly basis . ', " they do . Once my son was born , there was no reason to drive this car anymore . It's only a two-seater , you know ! ", ' what else is wrong with it ? ', " the heating controls don't work anymore , so it always feels like it's about 100 degrees in the car — even in the summer ! ", ' anything else ? ', " the brakes don't really work that well anymore either . ", " why don't you get it all fixed ? ", ' it costs more than you think to run a car , especially when there are so many things wrong with it ! ', ' well , let me know when you can get it fixed . I ’ d love to go for a ride in it ! ']
['Hello , Kith , can you and Alice come around this evening ? We prefer your coming . ', ' I think we would be able to make it . What time shall we come ? ', " About 7 o'clock . ", ' Shall we bring any thing ? Some wine ? ', ' No , not really . Just bring yourselves . We would like to your presence . ']
['Hello . May I speak to Mary , please ? ', " Speaking . Who's calling , please ? ", ' Hi , Mary . This is Tom . ', " Oh , hi , Tom . How've you been ? ", " Just fine . I say . Aren't you busy tomorrow evening ? ", " Let me see . Uh-huh ... no , I guess I'll be free . ", ' Well , uh ... why not dine out together and go to the movies ? ', ' Sounds like a good idea . ', " Okay . I'll pick you up at 6:00 . ", ' Thank you for inviting me . See you then . Bye , Tom . ']
['Well , my particular interest is collecting stamps , especially the rare ones . What about you ? ', ' I ’ m afraid that ’ s not my cup of tea . I just find skin-diving attracting . ', ' So have you ever been to the stamp display of the town ? ']
['There are so many flavors of ice cream to choose from ! ', ' Yes , there must be about a hundred . Do you have a favorite ? ', ' I love fruit flavored ices the best . ', ' I know , fresh fruit flavored is the best ever . ', ' What is your least favorite ice cream ? ', " I don't like peppermint ice cream . ", ' Yeah , I know what you mean . ', ' One time , I tried garlic ice cream . ', ' That could be interesting . ', " That doesn't sound like a good choice for today though . Let's order ! "]
["I don't want to do the damn dishes . ", " Watch your language or you'll be spending the weekend in your room . "]
['Good morning , Paul ! ', ' Hi , good morning , you are so early today . ', " Yes , traffic wasn't much today , so I made it to the office earlier . ", ' I see . How long does it take you to reach the office every day ? ', ' Well , about an hour or so . ', ' Wow , that ’ s quite a long journey . Do you drive a car ? ', " No . I take public transportation . It's safer . ", ' You are right ! But I get up a little late . That gives me no other option but to travel by motorcycle . ', ' Well , both have advantages and disadvantages . ']
['I usually get a lot of information on the computer and use E-mail to send messages to my friends . ', " Me too.Recently , I'm fascinated with net-chat . I've made many friends on the net.Every day I talk to them and share many interesting things with them . I really enjoy it . ", " Don't you think it ' s a sheer waste of both time and money ? ", " I'm afraid not . Every coin has two sides . I think using internet has a great deal to do with human interaction . "]
["Do you believe in UFO's ? ", ' Sure . A UFO is just a space vehicle from another planet . If you think about it , our space shuttles are UFOs . ', " I've never thought about it like that before . ", " I've seen photos of UFOs in America before , but they've all looked doctored up . ", " Do you think that there's life on other planets ? ", ' I think there must be . ', ' Why is that ? ', " I don't't think it would make sense if we were the only beings in this whole world . The world is just far too big for that . ", " Do you think that there's intelligent life trying to contact us ? ", " No , but we're trying to contact them . ", " I suppose you're right . ", ' I think that countries are working hard to find a planet that we can live on in the future so that when global warming destroys this planet , humankind will not become extinct . ', ' Do you really think that global warming Wil destroy Earth some day ? ', " There's a lot of evidence that suggest it will , but I don't think it's going to happen any time soon . "]
['What do you think of shopping ? ', " I don't mind shopping for food and other daily needs . ", ' What do you think of big department store ? ', " It's fun walking around them , but their displays are so good I'm tempted to buy things I don't really need . "]
['Nice and warm again , isn ’ t it ? ', ' Oh , it ’ s lovely . Think of the nasty weather we had last week . ', ' How are you these days ? ', ' Fine , thank you . And you ? ', ' Fine today , though a bit under the weather last week . ']
["Martha . What's wrong ? Why are you crying ? ", ' Jake just broke up with me . ', " I'm sorry . When did this happen ? ", " Yesterday . I didn't even know it was coming . He just told me he found someone else . ", " What a jerk . He doesn't deserve you . ", ' But it still hurts . I thought I loved him . ', " He didn't treat you that well either . Maybe you don't want to hear this , but I think you can do better . ", " Better or worse , it doesn't matter . I had a lot of feelings for him . I really liked him ", ' It must be really painful . I remember when Josh and I broke up . I was crying for a week . ', " I know . I'll get over him . My first break up was painful because I was naive . ", " Exactly . You'll find someone again . You should get your mind off of this . Let's go shopping . ", " Maybe tomorrow . I don't feel like it tonight . ", ' How about coffee down the street ? ', ' Sure . ']
['I got a ninety-five on my test . ', ' So what ? I got a ninety-nine . ']
['How can you keep in touch with your aunt in America ? ', ' Oh , I make a phone call once a month . ', " It's very expensive , right ? ", ' Yeah . ', ' Why not send E-mail through the Internet ? ', ' Is it convenient and cheap ? ', ' Sure . You can send E-mail to each other every day through the internet . In addition , you can make a phone call through the internet , too . ', " Really ? I'm so glad to hear that.But I don't know how to get access to the Internet.Could you show me ? ", " No problem . I'll tell you . ", " I'll appreciate it very much . "]
['Can I help you ? ', ' Yes , I need to apply for a parking permit . ', ' Are you a professor ? ', " What ? Are you kidding ? I'm only 22 years old ! ", " Yes , I am kidding.But don't you know only professors and students with disabilitiescan apply for parking permits ? ", " Yes , I know . I have a disability.My hip was broken last year . And I can't walk well . ", " Oh , I'm sorry . I didn't know . ", " It's alright . You didn't see me walk to the desk . ", ' Here is the application form . I also need to see your student ID and your permission letter from the university . ', ' My permission letter ? ', ' Yes , the letter that certifies you have a disability.And it must certify your disability entitles you to a parking place . ', ' I was told I should have the letter sent directly to your office . ', ' Yes . Or you can bring it yourself . ', ' But I asked them to send it to you directly . ', ' Let me look in the file then . Maybe we received it . ', ' My name is Derek Schneider , S - C - H - N - E - I - D - E - R . ', ' Yes , here it is.Alright . Then I just need your completed application form , and I will be able to process your request . ', ' Good . I will sit over there and fill out the form . I will give it to you in a few minutes.Oh , by the way , can I apply for any parking lot I want ? ', ' The form has a map on the back . You may specify your top four choices.We will give a spot in the lot that has an opening . ', ' I see . Thank you . ', " You're very welcome . "]
["It's too hot to read . ", " We'd better go out for a walk . ", ' Which season do you like best ? ', ' Spring . ', ' How about summer ? ', ' I dislike it most . ', ' Why ? ', ' Because the hottest season is summer in a year . ', ' But sometimes summer is more charming than the other seasons . ']
['Will you be at the family reunion next year ? ', " Yes , we'll be there , come hell or high water ! "]
['I watched a very interesting documentary about plants yesterday evening . It was called “ unusual plants ” and looked at several species of plants from around the world which have unusual features . ', ' Really ? Tell me about some of the plants they showed . ', ' Well . There was one type of plant that catches insects and eats them . ', ' Is that type of plant found in this country ? ', ' No , it isn ’ t . it ’ s a pity , because I ’ d like to see it in action . ', ' So would I . what other unusual plants did they show ? ', ' They showed flowers that only provide their nectar to one type of butterfly or bee . The insect has to be the exact size to get the nectar . Other insects cannot get it . Of course , when the insect collects the nectar , it also takes some pollen from one flower to another . ', ' That ’ s very specialized . So , the insects and the flowers rely on each other . If one became extinct , the other would too . ', ' That ’ s right . That ’ s one reason why it ’ s so important to protect every species . ', ' I see . The plants that fascinate me most are cacti . I find it amazing that they can survive in such dry desert conditions . ', ' According to the documentary , they have an incredible ability to find water supplies , however small , and then store them without losing much through evaporation . ', ' That ’ s why they often have long roots to find water spines instead of leaves , to reduce water loss . ']
['I have some good news for you . ', " What's that ? ", ' Jenny is getting married . ', " Great ! Who's the bridegroom ? ", ' Tom , that lucky guy . ', ' The guy always hands the girls in a line . When did he propose ? ', " Last week , It said that he fell in love with Jenny at Mrs.Whit ' s party last Monday as soon as he saw her . ", " My gosh ! How romantic ! When's the big day ? ", ' July 4 , the National Holiday . ', ' Will it be a church wedding or a civil ceremony ? ', ' Jenny plans to hold it in church . ', ' Who is the best man ? ', ' Guess ! ', ' Nobody is OK , but you ! ', ' You know , Tom is my best friend and he asked me to be his best man . ', ' Did you promise him ? ', ' Yes , I did . ']
['Ben , what are you doing ? ', ' Well , I would say that I ’ m just drifting - - here , in the pool . ', ' Why ? ', ' Well , it ’ s very comfortable just to drift here . ', ' Have you thought about graduate school ? ', ' No . ', ' Would you mind telling me then — what were those four years of college for ? What was the point of all that hard work ? ', ' You got me . ', ' Now listen , Ben . Look , I think it ’ s a very good thing that a young man — after he ’ s done some very good work — should have a chance to relax and enjoy himself , and lie around , and drink beer and so on . But after a few weeks I believe that person should want to take some stock in himself and his situation and start to think about getting off his ass . ']
['Peter , have you finished your English composition ? ', ' No . But I ’ m working on it . ', ' Class starts in twenty minutes . You have to turn it in at the beginning of class today . ', ' I know . I know ! ', ' Do you think you can finish it on time ? ', ' Don ’ t worry . I ’ ll get it done very soon . I ’ m almost finished . ', ' You ’ d better hurry ! ', ' Well , it would be a lot easier to finish if you stopped talking to me . ', ' Sorry ! ']
["How many orders do we still need to pack , Gale ? We've been packing all day . ", ' We still have to do about ten more . ', " Well . I am really tired from packing all of the stuff all day . And it's about time to clock out . ", ' I know . Maybe we can finish it tomorrow . ', ' Why not ! These orders are not urgent . We could do it first thing tomorrow morning ', " All right . Let's call it quits and go home . ", ' See . Great minds think alike . ']
['Tom , did you see the film last night ? ', ' Yes , I did , I thought it was a failure . ', " Do you really think so ? I don't think so . It wasn't that bad film at all . Didn't you hear the applause of the audience ? ", ' Well , maybe so . But I still think everyone has their rights of their own opinion . ', " Well , I don't see the point of arguing this . "]
['Are you OK ? ', ' Yeah . Why not ? ', ' Because ... I heard John got married yesterday . ', ' Oh , you went to the wedding ? ', " No , he didn't tell me about it . Don't feel bad . ", " I'm OK . I promise . Maybe you don't know that I have done with him for a long time . "]
['How do I apply to an American university ? ', ' You should go to the library to find some information about American universities , and write to the Admission Office . Then the Admission Office will send you application forms and other related materials . From experience , many applicants write to several universities instead of just one . ', ' I was told that it took a lot of time and effort to apply . ', " That is true . I'll list for you the requirements of almost all the universities . First of all , you need official transcripts of your undergraduate work , three letters of recommendation from your professors who know your competence , and the official TOEFL ( Test of English as a Foreign Language ) score ( It's usually 550 ) . Then you need a financial guarantee , and an application fee of 25 dollars . ", " What's to come next ? ", ' If they agree to enroll you , they will send you a TAP - 66 Form . With TAP - 66 , you can apply for a passport from our government , and then apply for a visa from the US Embassy in Beijing . ', ' How long will it take to go over all the procedures ? ', ' From 3 to 6 months if everything goes well . ', ' Thank you . I appreciate all your help . ', ' You are welcome . Please feel free to ask if you have any more questions . ']
['Well , speak of the devil . ', ' What do you mean ? ', ' I was just thinking about you the other day . ', ' You were ? ']
['Mom , you know that Andrea and I sometimes worry about you . ', ' Really ? Why would you worry about me ? I ’ m just fine . ', ' You ’ re almost 70 years old , Mom ! Don ’ t you think it would be better for you if you moved in with us ? ', ' No way ! I like my apartment , and I like to be independent . ', ' Do you ever get lonely living alone ? ', ' Not at all . I see you and your family twice a week , and I enjoy seeing my own friends . I ’ m too busy to feel lonely ! ']
['Do you have any plans for Veteran ’ s Day ? ', ' You mean Armistice Day . ', ' Well , as you know , on November 11th the allies signed a peace treaty with the Germans , also known as the Armistice Treaty . This marked the end of WWI and many countries around the world commemorate this date under names such as Remembers ’ Day . In Poland it ’ s their independence day ! There ’ s a lot going on around the world on this day . ', ' Wow , I didn ’ t know ! Probably because I flunked history in school . ']
['Are you sure you heard right ? ', ' Yes , he is running for class president . ', " I don't believe you . ", ' Take my word for it . ']
["These days my son has turned his computer into an electronic playground . He plays football , rides horses , drives racing cars , and does a whole bunch of other things on the computer . The funny thing about it is that , no matter what he plays , he always wins first place . I wonder if he'll be able to cope with a defeat in real life . ", " Don't worry . He'll cross that bridge when he comes to it . My son reads a lot on his computer and uses e-mail to send messages to his friends almost every day . He's really absorbed by the discussions . ", " That's exactly like my wife . She spends at least two hours a day on the computers discussing things ranging from stock prices to soft-ware standards . ", ' I guess using a computer has a great deal to do with human interaction . Getting in touch with each other must be more fun to your wife and my son than the coolest computer games or the hottest information . ']
["I'll participate in a quiz about the 29th Olympic Games in Beijing . It will be held tonight . Will you come ? ", ' Sure . What do you know about the Olympic Games on the past ? For example , do you know where and when the first Olympic Games were held in the ancient times ? ', ' It was held in 776 B . C . at Olympia . It also has a long history of more than 2700 years . ', " Haven't the Olympics been stopped for a long time ? ", ' Yes , there were no games in 1916 , 1940 and 1944 , because of World War I and World War II . ', " I see . Look , do you know what that emblem means ? I've seen it so many times , but I don't know what it stands for . ", " Oh , it's the Beijing 2008 Olympics ' Emblem . It's a Chinese seal , meaning that Chinese people warmly welcome the friends from all over the world . ", ' I see . I believe there will be lots of foreigners coming to Beijing to watch the Games . ', ' Sure . ']
['I plan to buy a car this year . ', ' How do you pay for it ? ', " I'm going to work in holidays and pay by installments . ", ' Tell me if you need help . ']
["What's your favorite season ? ", ' I like the freedom of summer with no school . ', ' Yeah , and all those fun summer sports and activities . ', ' And I like the festivities of winter with Thanksgiving , Christmas and New Year . ', ' Oh , me too ! All the family getting together ... ', ' And I really like the smells and colors of spring . ', ' I like the feeling then that school is almost over ! ', ' But I must say , if it were only for the weather , I like autumn most ! ']
['One of my students told me she was very depressed today . ', ' Why ? ', ' Her father is dying . ', ' Oh , that ’ s very sad . ', ' Yeah , she ’ s broken up about it , poor kid . ', ' What did you do ? ', ' I talked to her for a while , but she ’ s really depressed . So , I made an appointment with the school counselor for her . ', ' That ’ s a good idea . The counselor is a psychologist . He ’ s better trained to handle these sorts of things . ', ' Yeah , that ’ s what I told her . I ’ m glad she ’ s reaching out for help , instead of trying to deal with this on her own . ', ' Yeah , me too . ']
['It ’ s rather cold . Isn ’ t it ', ' Oh . Yes . It is ', ' Shall I light the stove ? ', ' That ’ s a good idea ', ' Well . What ’ s the climate like in your country ? ', ' It ’ s mild . but it ’ s not always pleasant . ', ' Which season do you like best ? ', ' I like spring . The days are long and the nights are short . The flowers in blew . We go on picnics ']
['Good afternoon , Sam . ', ' Good afternoon , Tina . ', ' What are you going to do tomorrow ? ', " I'm not sure yet . And you ? ", ' I would like to go skating . Feel like going with me ? ', ' Is skating interesting ? ', " I think so . Fresh air , white snow . It's so comfortable . ", " But I can't skate well . ", " It doesn't matter , I can teach you . ", " It's very kind of you . "]
['Can you play tennis ? ', ' Yes , I can . ', " It is interesting , isn't it ? ", " Yes , it's very interesting . ", ' Can you teach me ? ', ' Sure . Take the tennis racket . Now , throw the ball up , and hit it with the racket . Like this . ', ' Let me try . Oh , I missed ! ', ' Throw the ball up high . ', ' High ? ', ' Yes , very high . Over your head . Then you will have time to hit the ball . ', ' Oh ! I hit it . ', ' Well done ! ', ' Thank you . I think I like playing it . ']
['What was the party like last night , Jean ? ', " Not bad at all , thanks . There were one or two interesting people there.Why couldn't you come ? ", " Well , I couldn't get away from work early . And when . I got home I had a headache , so I had to go straight to bed . But I was over-tired , because I wasn't able to get to sleep for hours . ", " What a shame . Why didn't you take a sleeping pill ? ", " I don't like them . I used to take them when I had to work overtime , you know . ", ' How many did you use to take ? ', ' Three every night . ', ' Good heavens . Why did you take so many ? ', " Because I was under a terrible strain . The doctor saidthey weren't very strong . Anyway , I used to feel awful the next morning . ", " I'm sure you did . ", ' The doctor said I had to be careful . ', ' He was quite right . ', ' So I stopped drinking coffee late at night instead . ']
['What a beautiful view . ', ' It sure is . The Grand Canyon is truly a masterpiece . No man could ever make anything like this . ', ' What is that below ? ', ' It is the Colorado River . You can go down the river in a boat if you wish . ', ' No . Thank you . It looks a bit too dangerous for me . ', ' There is a beautiful state park here . I can see why so many people come out here to camp . ', ' Yes , there is beautiful view . You can go fishing , camping and also enjoy this beautiful clean air . ', ' It definitely is a nice change from the polluted and crowded city . ', " That's true . "]
["I would like you to meet my family . Can you come to dinner next week at my parents ' place ? ", ' Yeuks ! Do they know anything about me ? ', " Actually , I've told them a lot about you . They are excited to meet you . ", " I'm a little nervous ! ", " I think you'll like them . My family is pretty laid back . ", ' How Ay people will be there at dinner ? ', " Let's see . there's my mom and dad and my two brothers and one of my sisters . ", " That's good , I'm usually more comfortable in bigger families . "]
['Are you studying any languages here ? ', " Yes , I'm studying in the Foreign Languages Department . ", ' What are you majoring in ? ', " I'm majoring in English . ", ' Is it difficult to learn ? ', " Yes.The language is hard to learn , but it's interesting . ", ' Do you know anything about Britain and America ? ', " I'm reading a lot of books about the two countries . I like the culture . ", " Right.It ' s important to learn the culture of a nation if you want to learn the language well . ", " You're right . "]
['Judy , your husband has a really nice car . ', " Thanks . It's a lot better than mine , and it's new . ", ' Where are you going ? ', " We're going to visit my sister in the city . ", " I didn't know your sister lives in the city , when did she move there ? ", ' About a year ago . She lives in an apartment on 3rd street , across from the public library . ', " I see . It's almost 5:00 PM now , don't you think there will be a lot of traffic ? ", " Oh , we're not driving . We're going to take the subway . The subway only takes about 20 minutes . ", ' Yes , but it can be very crowded around this time . I always feel uncomfortable taking the subway . ', " I take the subway to work everyday , so I'm used to it now . ", " Doesn't your mother live in the city ? ", " Yes , she's lived there for about ten years . ", ' I remember when she moved there . Apartments were a lot cheaper then . ', " I know what you mean . It's hard to find anything that's reasonable now . ", " Have a good time . Next time you're free , give me a call and we'll go play poker . ", ' See you later . ']
['The time has come to say goodbye . ', ' So soon . It seems as if you just got here . ', ' I feel that way , too . But all good things must come to an end , as they say . ', ' It certainly has been a pleasure seeing you again and renewing old memories . ', " I've had a great time and thank you for your spending so much time showing me around . ", ' It was fun for me , too . It gave me a chance to get away from my routine . ', " You'll be out to see me next year , as you promised ? ", ' Oh , yes . I should be there some time next spring . ', " I'll be expecting you then . "]
["I don't think the lecture is very interesting . ", ' The lecturer is dull , too . ', " I feel he's like a talking machine . ", ' I feel the same way . ']
["And lightweight , too . It'll play for 20 hours on two AA batteries ! ", ' Cool ! The sound is great . These earphones are awesome ! ', " And they're really safe . They'll protect your ear from sound damage . ", ' You certainly need that . You always pump the volume up way too high . ', ' I know . And you can also hear outside noises while you listen to music . ', " You're right ! So I can listen to music while riding my motorbike ! "]
["You're spending a very long time on my hair . ", " I'm almost done . ", ' I needed you to be done and finished an hour ago . ', " I'm all done now . ", " Are you sure you're finished ? ", " I don't understand . ", ' You did a horrible job on my hair . ', " What's wrong with it ? ", " I don't like anything about it . ", ' I apologize . ', " That's fine , but I'm not paying for it . ", " Excuse me ? Let's try to work this out , okay ? "]
['Excuse me . Have you got the time ? ', ' My watch says half past five . ', ' Does your watch keep good time ? ', ' Oh yeah . It loses only a few seconds in the whole month . ', ' Thanks a lot . ']
['Do you think discrimination against women in the work force is still prevalent even today ? ', ' From my own experience as a career woman , I would have to say that while things are getting better now than they used to be , it is still a widespread problem . Society is changing , but there is still a glass ceiling for women in many career tracks . ', ' do you think the glass ceiling phenomena is because of traditional social customs ? Or are there more issues coming into play ? ', " I think it's a very complicated issue . A part of the difficulties women have advancing in the work force are due to few opportunities and many male managers . Don't underestimate the good ole ' boy system . Men have power , so it's easier for them to stay in power . ", " What about affirmative action ? Hasn't legislation changed a lot of the make hierarchy ? ", " Affirmative action has given us management quotas and bans sexual discrimination , but it's still a man's world . "]
['Emily , what kind of report is this ? ', ' What do you mean , Mr . Smith ? You said to make it brief . ', " Don't get smart with me . Here , do it again , but do it right this time . "]
['Would you like some more rice ? ', " No , thanks . I'm full . "]
['He has to deliver letters every day . ', ' Poor man , he must be terribly fed up with it . ', ' Oh , no , he likes the job . ', ' Oh , Really ? ']
['Good morning golf aficionados ! My name is Rick Fields , and you guessed it , I am here with my main man , Bob Copeland . ', ' Thank you , Rick ! As you can see , ladies and gentleman , we are here in beautiful Pebble Beach where the top golfers in the world are trying to win the grand prize of one million dollars ! ', ' Whoa , that ’ s a lot of cash ! Let ’ s go to the course and see how Tiger Woods is doing . ', ' All right , we are here at the eighth hole . It ’ s a par four , and has some very difficult hazards which many golfers find difficult to avoid . Although , I did see Jack Nicklaus hit a hole in one on this very same hole ! ', ' Tiger Woods is about to tee off , and let ’ s see if he has the same luck as Jack . Tiger is asking his caddie for his driver and , he seems to be very nervous . ', ' Oh no ! Not a good swing at all ! It ’ s definitely not his day today . On the seventh hole he got a bogey and before that he barely made par . He will definitely not get a birdie on this shot . ', ' It seems that his ball has flown somewhere deep in the trees . He is having a hard time finding it and even his caddie has climbed a tree to try and spot it . ', ' Oh no ! A bear ! Run , Tiger , run ! Somebody call animal control ! ']
["I haven't seen Bill lately . How is he ? ", " He's still pretty sick . ", " That's too bad . What does he have ? ", " We don't know , but he's going to the doctor tomorrow . ", " Let me know if there's anything I can do . ", " Thanks a lot . I'll tell him . "]
["Professor , I'm concerned about my grades . Do you have a minute ? ", ' Of course , how can I help you ? ', ' I want to know if I am doing OK . ', " Let's pull out your scores so far . Do you think you are doing OK ? ", ' I am afraid that I might not be doing all that well . ', " I'm seeing that you are doing OK in some areas , but not so well in others . ", ' I think I could take better notes and read a little more . ', ' You can greatly improve your grades by always reflecting on what you can improve on . ', " I'm working on it ! ", ' Just do your best and I am sure that you will see improvement . ']
['Lisa , I am told you did very well in your exam . ', ' I was the only one who got a strait A in my class . ', ' Congratulations on your success . ', ' Thank you . ']
["Good morning , madam . I'd like to apply for a library card . Can you help me ? ", ' Yes . Please give me your ID card , a photo . ', ' OK . Here you are . ', ' Then you have to give me 15 dollars for the deposit . The library card is free . ', ' OK . Here is the money . And If I return the card , can I get the refund ? ', ' Of course , as long as the card is well kept . ', ' OK . I see . Thank you . ', ' You are welcome . ']
["Mr . Clinton , it's nice to see you again . ", " Nice to see you again , too . Peter . How's your family ? ", " Very well . How's Mrs . Clinton ? ", " Not bad . But she's as busy as before . "]
['how did your interview go ? ', " pretty well . I don't know if I'll get the promotion or not , but I feel good about it . ", ' if you get the promotion , what will your new title be ? ', ' if I get the promotion , I will be a senior engineer instead of an assistant engineer . ', ' will you get a pay-raise , too ? ', ' whenever you are given added responsibilities , you should get a promotion . ', ' that makes sense . Who interviewed you ? ', ' my boss . ', ' what kinds of questions did she ask you ? ', ' she asked me about my ability to work in a team and what I thought a good boss should be . ', ' the second one sounds rather difficult to answer . What did you tell her ? ', " I told her that I'm an excellent team player and that a good boss should treat male and female employees equally . ", ' those are good answers . How did she react ? ', " she told me that even when I become a senior engineer , I'll have to work with the assistant engineers as a team . ", ' what do you think about her as a boss ? ', " she's pretty easy to get along with . She listens to her employees and treats everyone equally . ", " you're lucky . Not everyone has such a great boss ! ", " that's true . She's highly esteemed among everyone at my company . ", ' when you find out you get the promotion or not , let me know . ', ' I will do . ']
['Has the game started yet ? ', ' Yeah , about 5 minutes ago . ', " Who's winning ? ", ' The Bulls , of course ! ', " What ! That wasn't a foul ! C ’ mon , ref ! ", ' Don ’ t worry , Shan always screws up free throws . ', ' You were right ! He didn ’ t make the shot ! ', ' That was a great shot ! A three pointer , yeah ! ', ' Did you see that ? He traveled and the ref didn ’ t call it ! ', ' This ref needs glasses . Hey ref , open your eyes ! I can ’ t believe he didn ’ t see that ! ', ' Okay ... end of the first quarter ... Alright , I ’ m gonna make a beer run . ']
['Are you ready to go shopping ? ', " Not yet . I'm not finished with my research yet . ", ' What research ? ', ' Reading my fashion magazines ! How do you think I know so much about all the latest trends ? ', " But they're just ads ... ", " Duh ... That's the point . The people in the ads are wearing what's in . Plus , there are articles on new trends ... "]
['I hear that Tom got divorced , and I don ’ t know how he is now . ', ' Out of sight , out of mind . ', ' Who do you mean ? ', ' Don ’ t you know they have had little affection for each other ? ']
["What's the name of the singer who sings this song ? ", " I can't remember . ", " It's on the tip of my tongue . I think it starts with a ' B ' . "]
['Hi , Bill . Are you going to the commencement ? ', ' Yes . Do you want to go with me ? ', " OK . ( Several minutes later . ) Let's go into the school auditorium . ", ' Now that take this seat . Do you see those piles of red diplomas on the desks on the stage ? ', ' Yes . I find my heart is now rising and falling like waves , all sorts of feelings welling up in my heart . ', " That's true . Four years ' trails and hardships , joys and sorrows of life are gushing out to my mind all together . I can hardly tell whether I am joyful or gloomy at the moment when I am about to leave the campus and to start a new stage of my life . ", ' How time flies . Look , the president of the college has come onto the stage . ', " He's going to make the opening speech . "]
["Hi , I'm Benjamin . Nice to meet you here . You look great . ", " Thank you . Nice to meet you too . I'm John . Is this your first time to take a long-distance trip on plane . ", ' No , this is the second time . But I also feel bad because of the lower pressure and the jet lag . ', ' Oh , I am sorry to hear that . Take it easy . It will be OK soon . You see , I take this long-hour plane frequently , but the jet lag still makes me uneasy . ', " Oh , that's too bad . Do you get a good knowledge of China ? ", " Yes , whenever I think about China , I'd see the Tian'an Men Square . China is a very beautiful country . And I've seen many landmarks in China but I like the Great Wall most . ", ' All of the Chinese are proud of the Great Wall . And it was built before the In dynasty near Shan Haiguan-the First Pass in the World . ', ' Was it built before the In dynasty ? I thought it was in the Ming dynasty . ', ' No , before the In dynasty . ', ' Oh , yeah . Thought I am an American , I know quite a lot about China and I like Chinese tea very well . ', ' Both the green tea and the black tea are good for our health . And I usually refresh myself with a cup of tea . ']
['Oh . Have you finished listing your study preferences ? ', ' Yes , I have . ', ' Good . So , which is your top choice ? ', ' Medicine . In my country , that certainly has great prestige . ', ' I see . Which subject did you put last then ? ', ' Oh.history . ', " That's interesting . Could you give any reasons for your choice ? Can you explainwhy do you put medicine first ? ", " Well , doctors are such an important job . I mean your health is the most imponent thing you've got , isn't it ? I want to be important and help people . ", ' Yes . I suppose so . ']
["Hello , Mr . Black , I'm calling to say goodbye . ", " You're leaving so soon ? I wish you stayed a little longer . ", ' I wish I could stay a little longer , but a lot of things to do back home . ', ' Have you got the ticket ? ', ' Yes , I did . ', ' What time are you going ? ', " At 11:00 o'clock . ", " I'll pick you up by nine o'clock and take you straight to the airport . ", " No , I'll go by myself , thanks . ", ' OK , goodbye . ']
['Mark is parade his knowledge again . ', ' Yeah ! He ’ s very good at showing off his knowledge . ', ' A well-learned person never does that . ']
['They are professors and government officials . ', ' Where are they from ? ', ' Most of them are from America and Europe . ', ' What are they doing in Beijing ? ', ' They are attending an international conference here . ', ' Which hotel are they staying at ? ', ' They are staying at the Hilton Hotel . ']
['Do you need a ticket ? ', " Surely , I do . It's hard to come by , isn't it ? ", ' Yes , it is . ', ' Can you get it ? ', ' You can be assured of it . ']
['Where to , miss ? ', ' Hi ! Crenshaw and Hawthorne , at the Holiday Inn that is on that corner . ', ' Sure thing . So , where are you flying in from ? ', ' From China . ', ' Really ? You don ’ t look very Chinese to me , if you don ’ t mind me saying so . ', ' It ’ s fine . I am actually from Mexico . I was in China on a business trip , visiting some local companies that manufacture bathroom products . ', ' Wow sounds interesting ! Excuse me if I am being a bit nosy but , how old are you ? ', ' Don ’ t you know it ’ s rude to ask a lady her age ? ', ' Don ’ t get me wrong ! It ’ s just that you seem so young and already doing business overseas ! ', ' Well thank you ! In that case , I am 26 years old , and what about yourself ? ', ' I am 40 years old and was born and raised here in the good old U . S of A , although I have some Colombian heritage . ', ' Really ? That ’ s great ! Do you speak some Spanish ? ', ' Uh ... yeah .. of course ! ']
['Did you see that ? ', ' No , I missed it . ', ' How could you miss that ? ', ' Someone was in the way . ']
['Hello , Is this EYE computers ? ', ' Yeas , It is.Sewen Jes speaking.How can I help ? ', " Actually , I'm calling to complain about your service . The computer I bought last week is faulty . ", " Oh , I'm sorry to hear that , sir.What exactly is problem ? ", " Well , easily , It doesn't work . It doesn't even start probably . ", " Oh , dear ! I'll do well I can . "]
["Look what you've done ! ", " I'm very sorry , sir . I'll bring you a cloth immediately . ", ' Yes , and hurry up ! ', " I'd like to apologize for my carelessness . May I clean it up for you ? ", " No , I'll do it myself . ", ' Here is my card , sir . Could you send me the cleaning bill and I will refund the cost to you ? ', ' I should think so , too ! ', " I'm very sorry to have caused you this trouble . ", ' Yes , and please be more careful in the future ! ', " I will , sir . I'm really very sorry . ", " That's OK . "]
['Did you tell others that we are getting married soon ? You have such a big mouth ! ', ' I am so sorry about that . It was just a slip of the tongue . ']
["I really don't know how to break this to you , but it ’ s eating me alive ! ", ' Just tell the truth . I won ’ t take it personally . ', ' Well ... hum . You are sure you won ’ t lose control of yourself ? ', " Sometimes it's wise to be direct with people . Come on , just tell me . Don't beat around the bush , please ! ", ' Well . Since you ’ d like an honest answer , I will tell you the truth . ', ' Alright . What is that you want to tell me ? ', ' We ’ Ve won two free tickets to Hawaii for a seven-day vacation ! ', ' What ? Are you serious ? Oh , my gosh ! There will be guys everywhere . ']
["I'm the coolest high-tech stud around ... ", ' Why ? Do you have a robot girlfriend ? ', ' Not yet ... I got an MP3 player and a set of stereo headphones . ', ' So you can download MP3 music from the Net and record it onto the MP3 chip ? ', ' Yep ! And take it with me anywhere ! And the music is free ! ', " Let me see it ! It's so small ! "]
["Don't you ever cheat on me . ", ' Why would I do that ? ', ' Because men like to cheat . ', ' Some men do , but not me . ', " I'm watching you . ", " I'm an open book . Watch me all you want . ", " If I catch you , you'll be sorry . ", " You won't catch me , because I love you . I'm not a cheater . ", ' I will poke your eyes out . ', " I don't want any other woman . ", ' I will chop your toes off , one by one . ', " Honey , please . You're the only woman for me , forever . I swear it . "]
['Hi , Lilly , it ’ s so nice to see you again . ', ' Hum , me too . This winter holiday was especially long . What have you done ? ', ' Nothing special . I had a get-together with some schoolmates at the high school , visited the Internet and read a couple of books which I had been longing for . How about yours ? ', ' You know , I like traveling . I made good use of this long vacation and enjoyed myself . ']
["Well now that I know what kind of movies you like , tell me , what's your least favorite kind of movie ? ", " I don't really like sci-fi movies because they're always really weird . ", " I know ! I don't get them at all . But wait , isn't ' Terminator ' a sci-fi movie ? ", " Hmm ... you're right . Well , I guess ' Terminator ' is an exception to the rule . "]
['There are advertisements everywhere here in hong kong . The city is so bright at night , with all the neon signs . ', ' I like it . It makes the city feel alive . I like all the different colors and I like the billboards with eye-catching pictures and slogans . ', ' I think that there are too many of them . I think that companies spend far too much money on advertising . They should have lower prices instead . Then they would see more . ', ' I see your point , but if companies didn ’ t spend money on advertising , no one would hear about their products . I agree that some form of advertising can be annoying . I don ’ t like it when people try to give you leaflets with information about products you have no intention of buying . ', ' I really hate receiving spam . I also dislike having to listen to advertisements and jingles when they are broadcast in stores or on the subway . ', ' Yes , that annoys me too . With billboards , you can look away , but with broadcasts , you can ’ t avoid them . I like the way that advertising agencies use comedy in their campaign . ', ' I like that too . I don ’ t like the way that advertising campaign often tell you if you don ’ t buy a certain product , you ’ re not cool or modern or efficient or something . ', ' That kind of advertising seems to be very common with brand name products . They are always trying to maintain brand loyalty . ']
['do you have any plans for Friday night ? ', " I don't think so . Why ? ", ' well , my hosue-mates and I are having a house-warming party . Would you like to come ? ', ' sure . Would it be alright if I brought a few friends ? ', ' the more , the merrier ! ', ' will there be a lot of people there ? ', " I sure hope so . We've each invited about 10 people . ", ' who else is going to be there ? ', " I'm inviting my friends from work , you , my sister , and a few friends from school . ", " I know your sister . She's very nice . ", " don't worry.You won't be sitting there by yourself . ", ' what time is it going to start ? ', " most people are working Friday night , so it's going to start around 9 pm . ", ' should I bring anything ? ', " we'll have beer and snacks , but if you want to bring a bottle of wine , that'd be great . ", " I could also bring some music if you want . I've got loads of songs on my new iPod . ", " that'd be great . I'll see you then ! "]
['So , Jack , do you believe in ghosts ? ', ' No , not really . Why do you ask ? ', ' Because I want to tell you about the time that I saw a ghost . ', ' You saw a ghost ? When ? ', ' It was many years ago , when I was a little child . It was the middle of the night , and I went to get a drink of water from the kitchen . I walked out of my room and was at the top of the stairs , when ... ', " So that's where you saw the ghost ? In your house ? What did it look like ? Was it hideous ? ", ' It was a big , green thing that looked like a person . It was in the kitchen , and it slowly moved towards the stairs ... ', ' So what did you do ? ', " I hid so that it couldn't see me . Slowly it got closer and closer , until ... ", ' Until what ? What happened ? Did you see it clearly ? Did it attack you ? ', ' It moved slowly up the stairs , step by step , and I could hear its approaching footsteps . When it finally got to the top of the stairs , I realized that it was my father in his green pajamas . He had gone to get a late night snack . ']
['What did the doctor say ? ', ' He said that I have been eating too much . ', ' Did he give you any advice ? ', ' Yes , he asked me to clean up my diet by cutting red meat . ', ' Yes , you must put yourself on a diet . ']
["I don't know about you , but I am famished . Are you interested in getting a bite to eat ? ", " That sounds great . I'm absolutely starving ! What kind of food are you in the mood for ? ", " I'd love something spicy . Maybe we could get some Sichuan hotpot . ", " You are a woman after my own heart . I don't know many people who can handle spicy food . Are you sure you are up for hot pot ? ", ' Sure . If I could , I would eat hot pot every day ! ', " Ok , you are really all eyes when it comes to talking about food , aren't you ? ", " Well , let's stop dragging our feet and find a Sichuan hot pot restaurant for dinner ! ", " Let me think about it for a minute . Let's see ... oh the name of the restaurant is on the tip of my tongue ! Give me a second and it'll come to me . ", ' Well ... ? Have you thought of it yet ? ', ' No ... ', " Never mind . There's an authentic tasting hot pot restaurant not far from the China World Trade Towers on Chang An Street . Have you been there ? ", " That's it ! That ’ s the one I was thinking of ! I told you I'd remember it ! ", " You really have a big head , don't you . "]
['Excuse me . Where is Q-Duck ? I remember it was around the second intersection of this street . ', ' Q-Duck ? Do you mean the famous roast-duck store ? ', ' Yes , definitely . ', ' They have moved to some other places long time ago . ', ' Wow , this place is quite different from ten years ago when I first came to China . ', ' Yeah , a lot of changes have happened here . ', ' This street used to have few stores . But now , you can see supermarkets , shopping malls and department stores everywhere . ', " Yeah , they are my wife's heaven , but not mine . I always get lost in the supermarket . ", ' Me too ! I was lost three times ten years ago . There were no English directions then . ', ' Is that better now ? ', ' Yeah , there are many English signs , and wrong spellings as many as them . ']
['You ’ re new here , right ? ', ' Yes , I am new . ', ' Is this your first semester ? ', ' I just transferred from another school . ', ' What school did you transfer from ? ', ' I came here from PCC . ', ' Do you like it here so far ? ', ' I am really enjoying it here so far . ', ' Which is better , here or PCC ? ', ' I think PCC is a lot better than here . ', ' Why didn ’ t you just stay at PCC ? ', ' I graduated and now want to get a BA . ']
['My hair stood on end when I saw the bloody scene . ', ' What scene ? ', ' A kitten being run over by a truck . ']
["Adam , I'm sorry ! ", " But where have you been , Alice ? You're over an hour late . ", " Yes , but I couldn't help it . I was late getting off work for a start , and then I missed the bus . The bus I did catch got caught in a traffic jam . It was one thing after another . ", " But why were you getting off work so late ? The office close at six , doesn't it ? ", " Yes , but there's a rush on at the moment , and my boss asked me to do some urgent letters . ", " But didn't you tell him you had an appointment ? ", " Well , no . I thought I'd finish in about five minutes , and I didn't want to be difficult about just a few minutes . If it hadn't been for missing the bus and the traffic , I wouldn't have been so late . I'm sorry . ", " Well , you're here . And that's the main thing . "]
['Remember that writing contest I entered ? Well , I won first prize . ', ' Great ! This calls for a celebration . ']
['Can you imagine having a million dollars ? ', " Yes , and I know a few things I'd spend the money on . ", ' Yeah , me too . ', ' A new car for a start . ']
['David , what do you want to do after graduation ? ', " I suppose I should choose one from the ' Best Career List ' , to be a public officer , what do you think ? ", ' That sounds like a hot job , right ? But in my opinion , you ought not to choose one career from that so-called list , and you need to take your interests , values , and skills into account . ', ' It beats me ! I never thought about it before and maybe I thought finding a career is a simple thing . ', " You'd better ask for suggestions from a career counselor , and then make a decision . "]
['The mosquitos are biting me ! ', ' Me , too , I can ’ t stop scratching . They are everywhere ! Sneaky little jerks . ', ' Do you have any bug spray ? ', ' No , I forgot to buy some . ', ' Then we ’ ll have to put up with it . ', ' We can cover ourselves with beer ! That way if they bite us , they ’ ll get drunk and fall asleep . ', ' That ’ s without a doubt , the best idea you ’ Ve had ! Let ’ s do it ! ', ' Run ! They are thirsty for more ! ']
["How come you're still up ? Shouldn't you be asleep by now ? ", " I've been having a hard time sleeping lately . ", ' As far as I know , insomnia is usually caused by stress . Are you stressed at all ? ', " Well , I'm really worried about my grades . I didn't think this course would be so stressful . ", " You're a good student . I'm sure you can do well . What you need to do is to relax . ", " You're probably right . I just wish it were that simple . How can I stop feeling so anxious all the time ? ", ' Taking a yoga class or learning some relaxation techniques can help you cope with your stress . ', " I don't really have time to learn anything new . I need to spend my time studying ! ", ' You need to take some breaks throughout the day . Studying all day isn ’ t very usually effective . ', ' You ’ re right . I usually end up staring at my computer or checking my email instead of doing my work for class . ', ' Besides , it ’ s not difficult to learn yoga . In fact , I can teach you a move that ’ s supposed to help you fall asleep ! You just have to sit down like this , bend over and breath in deeply . ', ' That ’ s fantastic . I ’ m going to go try that out in my room now . good night ! ', ' Good night , sleep tight ; don ’ t let the bed bugs bite ! ']
['Hey , Teresa , meet the new neighbors yet ? ', ' Actually , i popped in them last night . ', " OK , let's cut to the chase . what are they like ? ", " Well , they're really beautiful people . ", " I'll say , she is really stacked , isn't she ? ", ' Yeah , she is a neck-off for sure . ', ' And he looks like a typical jog . ', ' He is a professional football player . ', ' Ah-ha , I thought so . ', ' Anyway , that is not what I meant by beautiful . ', ' What did you mean ? ', " I meant that they're very simple , easy to talk to . ", " That's right . ", ' Yeah . I think things are worked out just fine . ']
['Did you get your grades yet ? ', ' Yeah . My whole GPA is screwed up now . ', ' Why ? What happened ? ', ' Well , I bombed my econ final and ended up with a 1.7 . ', ' Ouch . You must be very disappointed . ', " Well , it's my fault because I didn't study as much as I should have . ", " Why don't you re-take the class next year ? ", " That's what I plan on doing unless I keep screwing up . How did you do this semester ? ", " I didn't do that well either . I ended up with a 3.2 this semester . That drops my total GPA to 3.45 . ", ' My GPA is pretty similar to yours . I have a 3.1 now because of the stupid econ class . ', ' What was your GPA before this semester ? ', ' I was sitting happy with a 3.4 . ', ' Why did it go down so much ? ', " Let's just say I screwed up more than my econ class . ", ' What happened to you ? ', ' I started playing starcraft and ended up wasting a lot of time . ', ' You better stop slacking off . ', " You're right . I'm not going to play games during school anymore . "]
['So Emily , do you still want to see a movie together this weekend ? ', " Well , what do you want to see ? I don't think there are many good movies out right now . ", ' Mmmm ... I know ! We can go to a really bad sci-fi movie and sit in the back of the theater and make fun of it . What do you think ? ', " Now that's a great plan . It's a date ! "]
['Do you think that climate change is responsible for the recent floods ? ', ' It could be . There are floods in this country almost every year , but in recent years they have been more widespread and more frequent . ', ' It seems that the climate in this country is changing . ', ' The summers are hotter . The last three summers have been the hottest for the past 200 years . There have also been stronger winds . ', ' I think that the changing climate is a sign that we are causing too much damage to the environment . ', ' I think you ’ re right . Climate change naturally over time , but I think that human activities are speeding up the change . I wish that government would join together and try to resolve the problem . ', ' Me too . If we don ’ t do something soon , It might be too late . ']
['Are you almost finished with my hair ? ', " I'm almost finished . ", ' How much longer is it going to be ? ', " I'm done now . Do you like it ? ", ' I absolutely love it . ', ' You really like it ? ', ' Yes , I truly do . ', " I'm glad you like it . ", ' How much do I owe you ? ', " It's going to be $ 55 . ", ' Here you go , thanks for everything . ', ' Make sure and come back in a couple of weeks . ']
['Oh , hi , Lily . When did you get back from Canada ? ', ' Just last week . ', ' How was it ? ', ' Oh , I loved it . I only visited a couple of cities , you know . But I had a great time . ', ' Well , tell me . What are they like ? ', ' They ’ re nice . ']
['And lots of Dear Abby sob stories ... ', ' Hey ! I learn a lot from the psychologists who give advice in those columns ! ', " No wonder you're such a wacko ... ", ' Whatever ... Smell ! Perfume samples ! ', ' Nice . Hey , I like the layout of this page ... ', ' You mean , you like the pictures of the beautiful models ... Hello ? ']
["I'd be a basket case if you think of me that way . I need your understanding . ", ' I know , I know . But you always bat around without doing things useful . ', ' Can ’ t you be more considerate ? I need your encouragement . ', ' All right . Do what you can do now instead of twiddling your thumbs . ']
['Driving during the rush hours can be a bit of a bind . ', ' Yeah . I think so.You have to be patient and careful . ', " So I'd rather walk or run to work . ", ' You must be joking ! ']
['What do you think of smoking ? ', ' It ’ s harmful not only for yourself but for others . ', ' What in your opinion can be done to stop smoking ? ', ' Stop producing cigarettes . ', ' But that ’ ll affect the national economy . ', ' That ’ s right . But I don ’ t think there are better ways . ', ' How about painting a warning on each cigarette packet ? ', ' Maybe it can take effect . ']
["Hey Rachael , what's up ? How is your day ? ", ' Not bad.We have had a big meeting today , remember ? ', ' Oh , yea . I forgot.So how did it go ? ', ' Pretty well . I think the boss liked my ideas . ', ' Great , so what happens now ? ', " Well , I have to write the proposal . I'm pretty excited about it . "]
["Hello , Bobby , It seems that I can't arrive at your home by 12 o'clock . ", " What happened ? We're all expecting you , Hans , Dick , Archie ... ", " I'm so sorry , I've been held up by the damn traffic jam for half an hour . I'd have arrived but for that . ", ' I see . Where are you now , Li ? ', ' Thirty meters ahead is the Waterloo Bridge . ', " It's not far away from home , It's - let me see – about 20 minutes'walk , Can you walk here ? ", " I've thought of that , but what can I do with my car ? If only I had taken a taxi ! ", " That's too bad , But don't worry.We ' ll put off dinner till one o'clock . ", " I'm so terribly sorry to keep you waiting . ", " It doesn't matter.Bye . ", ' Bye . ']
["This is our first day of class.It ' s better for us to introduce ourselves to each other . Who would like to begin first ? Any volunteers ? ", " I'd like to introduce myself first . ", ' Yes , please . ', " My name is Gavin White . I was born and raised in London . After high school , I went to Edinburgh University . I worked for one year to pay for my tuition and then got my Bachelor ’ s degree there . Now I've come here to get my Master ’ s degree . I am glad to meet all of you and I hope we will become good friends . "]
['Sheila , what time should we meet tomorrow ? ', ' The usual time . Half past two in the afternoon . ', ' What place ? ', ' The usual place . In front of the treasure house . ', ' And what should I wear ? ', ' Your usual shirt and shoes . ', ' What are you going to wear ? ', ' Nothing unusual , I ’ m afraid . ', ' Sheila , how about that fashionable blue dress ? ', ' Good . That ’ s something unusual . ']
['What did you think of the movie ? ', " I didn't like it . Not a bit . I couldn't stand the music . Besides the story was so boring that it put me to sleep . ", " I noticed that , it was not exciting as I expected , but the music was great . I'm always found Jazz . And that movie had a lot of Jazz . ", " I know . However , Jazz always annoys me . I really don't enjoy music in a movie . ", " I'm sorry to hear that.What kind of movie do you like ? ", ' Anything with a lot of action , I like thrillers and chillers . ', ' Oh , I see . ', " Well , I enjoy the popcorn and being with you.You ' re more important than the movie . ", ' Thanks for the sweet words . ', ' Any time . ']
["Hi Amanda , how are you ? I've missed working with you and the whole gang since my transfer last week . ", " We've missed you too . The office just isn't the same without you . How is your new job ? ", " It's great . I really get to focus on what I like to do and everyone has been very nice and welcoming . However , I'm having a small problem with my new colleagues . ", ' What happened ? ', ' Well , three people are celebrating their birthdays this month and the policy here is for everyone to contribute ten dollars to a card and cake for each person . ', " Wow , so you'll be out thirty dollars on your first week at work ! ", " I know . It is a lot of money and I haven't gotten to know any of the people celebrating their birthdays well enough yet . At our old department , it was only three dollars for each birthday and there were only ten of us . ", " Well , every department is different . You wouldn't want your new co-workers to think you're a Grinch , right ? ", ' What is that ? ', ' A Grinch is a person who spoils the mood at a happy occasion by being selfish or unenthusiastic . You know - a party proper . ', " I definitely don't want to be that ! But , I still think it's unreasonable for them to ask me for such a big sum of money when we don't know each other very well . What should I do ? "]
['Then I must go-you have said it yourself . ', ' No , you must stay ! I swear it , and the oath shall be kept . ', ' I tell you I must go ! ', ' Where ? ', ' I have spoken my mind , and can go anywhere now . ', ' I ask you to pass through life at my side-to be my second self and best earthly companion . ', " I'll never again come to your side ; I am turn away now and can't return . "]
['Merry Christmas ! Mary ! ', ' Merry Christmas ! Mr Bean . ', ' Will you come to join us at dinner this evening ? My family will be happy to see you . And father misses you very much . ', ' Well , I would be glad to , but I have promised Tom to see his Christmas tree , and play the piano for his song tonight . ']
['Hello , Kate ! How are you doing ? ', ' Fine , thanks . How are you ? ', ' Fine . How are your term papers ? ', " Oh my lord . I haven't really started them . ", ' How could it be ? They are due two weeks later . ', ' I know but I was busy with my part-time job the last few days . ', " Kate , you know , I am thinking of getting a part-time job next year because I really need more money and I don't want to ask my parents for any more . But I'm so busy ! How am I going to work and study ? How do you do it ? Do you have some good tips on budgeting time ? ", " To be honest with you , Jason , I don't think I'm doing a very good job of balancing my schoolwork with my job . I'm always two steps behind . I've got to get back to the dorm and continue writing that paper . Say ! Why don ’ t you talk to your advisor ? And let me know ! ", ' My advisor ? ']
['Jack , I hear you got promoted.Is that true ? ', " Yes . I think I'm lucky . ", " Oh , Jack , you deserve it.You ' Ve been working so hard . ", ' Thank you for saying that . ']
['Why did she do that ? ', ' I have no idea . It was completely out of the blue . ']
['Hurry up ! Time is money ! ', " Don't build a fire under me . I know the importance of time . ", ' But you are too slow to follow them . ', " Don't you see I'm trying my best ? "]
['Why is little Billy crying ? ', ' He got a scolding . ']
["I'm going to work in a multi-national enterprise after graduation . ", ' but you said your dream was to be an entrepreneur , to be your own boss . ', " I'll do it someday . But it's not the right time now . I have to learn a lot by working as an employee . ", " it sounds like you've got a perfect plan . ", " you could say so . I'll work hard in that company and try to understand as much as possible about how to run an enterprise . ", ' it can save you lots of time and effort to simply copy a successful business model . ', ' yeah , the success stories of that company might be useful for me . And their customers may become the potential ones for my own company . ', " that's right . You should establish good relationships with them . what else are you planning to do while working for that company ? ", " well , I'll come up with a detailed business plan to attract the investors . ", " sounds perfect . I think with all that you have in mind , you'll become a successful businessman . By then , perhaps , I'll join in as a partner of your company . "]
['Rob lost his bike . ', ' What an idiot ! ']
["I heard Betty lost her tennis match this morning , so she's out of the tournament . ", ' Really ? What a shame ! I thought she was going to win this one . ', " Me , too . I'm sure she'll do better in the next tournament . "]
['Can you believe the headlines ? ', ' What are you reading ? ', ' I ’ m reading about Michael Milliken , the Bond King . ', ' Didn ’ t he sell worthless stocks to people or something ? He got arrested for that , didn ’ t he ? ', ' He got arrested all right . ', ' If I remember , he got off with a light sentence . Something like three years in a minimum-security prison . ', ' Yup , that ’ s him . He made millions of dollars selling bonds to people and ended up with a pile of cash when they became useless . ', ' I think the government fined him a small amount , and he kept the rest in his foreign bank accounts . He ’ s still a millionaire . ', ' That ’ s the kind of thing in America that gets me mad . Some guy pulls off a stock scheme and makes millions while spending the bare minimum sentence in jail . ', ' I know . And some poor guy that robs a liquor store makes $ 500 at most and ends up in jail for five to ten years . ']
["do you believe in UFO's ? ", ' sure . A UFO is just a space vehicle from another planet . If you think about it , our space shuttles are UFOs . ', " I've never thought about it like that before . ", " I've seen photos of UFOs in America before , but they've all looked doctored up . ", " do you think that there's life on other planets ? ", ' I think there must be . ', ' why is that ? ', " I don't't think it would make sense if we were the only beings in this whole world . The world is just far too big for that . ", " do you think that there's intelligent life trying to contact us ? ", " no , but we're trying to contact them . ", " I suppose you're right . ", ' I think that countries are working hard to find a planet that we can live on in the future so that when global warming destroys this planet , humankind will not become extinct . ', ' do you really think that global warming Wil destroy Earth some day ? ', " there's a lot of evidence that suggest it will , but I don't think it's going to happen any time soon . "]
["It's said you will go abroad to pursue your graduate studies . ", " Yes , I've been thinking about visiting you . I hope to get some advice from you . ", ' Which country do you want to go to ? ', ' My field is electronic engineering . Which country do you think I should go ? ', " Were I in your position , I'd go to America . ", ' Which university should I apply to ? ', ' There are many universities for you to choose from . Some famous universities such as Harvard , Yale , the University of Michigan , and Massachusetts Institute of Technology are really wonderful places to study , but they are very competitive and expensive . Some smaller universities or institutes are also very nice but much cheaper . ', ' Oh , I see . Thank you very much . ']
["It rumored that Jean is fooling around with another woman's husband . ", " You gossip ! What's the basis of your opinion ? ", ' Someone declared that he saw it . ', " I don't believe it . Jean is such a kind lady . How could she do this ? ", " Who knows ? You can't judge a book by its cover . ", ' Maybe ! ']
['Do you have cold medicine ? ', ' Yes , but do you have a prescription with you ? ', " No , I don't . ", " I'm afraid you can't buy any medicine without a prescription from a doctor . ", ' I have a headache . Is there anything I can buy without a prescription ? ', ' Then you can buy Aspirin . ', ' I will take the Aspirin then . And have you a small first-aid kit ? ', ' Yes , here this is . ', " I'll take it too . ", ' Thank you and take care . ']
["It's rather cold , isn't it ? ", ' Oh , yes , it is . ', ' Shall I light the stove ? ', " That's a good idea . ", " Well , what's the climate like in your country ? ", " It's mild , but it's not always pleasant . ", ' Which season do you like best ? ', ' I like spring . The days are long and the night are short . The flowers are in bloom.We go on picnics . ']
['Where do you work , Andrea ? ', ' I work for Thomas Cook Travel . ', ' Oh , really ? What do you do there ? ', " I'm a guide . I take people on tours to countries in South America , like Peru . ", ' That sounds interesting ! ', " Yes , it's a great job . I love it . And what do you do ? ", " I'm a student , and I have a part-time job , too . ", ' Oh ? Where do you work ? ', ' In a fast-food restaurant . ', ' Which restaurant ? ', ' Hamburger Heaven . ']
['Yeah . Just pull on this strip . Then peel off the back . ', ' You might make a few enemies this way . ', " If they don't think this is fun , they're not meant to be our friends . ", " You mean your friends . I think it's cruel . ", " Yeah . But it's fun . Look at those two ugly old ladies ... or are they men ? ", ' Hurry ! Get a shot ! ... Hand it over ! ', " I knew you'd come around ... "]
['When ’ re you getting married ? ', ' We planned our wedding for next May . ', ' Why so late ? Didn ’ t she want to get married this October ? ', ' Yeah , I did . But my fiancee has an important project . ', ' That ’ s really a shame . By the way , who will be the bridesmaid ? ', ' Julie ’ s friend , Mary . And John will be the best man . ', ' Wow ! I ’ m very excited about your ceremony . ']
["Hey ! Fred , you are five minutes earlier than me today . Usually , you don't . ", ' Hurry ! It is time for me to steal something . ', " What's your meaning ? ", ' I am stealing vegetables at the Happy Farm . ', ' You are a thief ? ', " No , no . I mean stealing vegetables on Internet is very popular now . Many white collars join in this game and have a lot of fun by stealing others ' vegetables . ", ' You mean it is a still virtual game . Your friends steal your vegetables time and time again , and you take theirs as well , right ? ', ' You got what I meant . Perhaps , what I steal are not vegetables , but loneliness . ', " Don't be addicted to the game . It's not good for your job . "]
['Bill , your work is too messy . ', " I'll pay attention to my handwriting next time . ", ' Is this a promise ? ', " Yes , I'm serious this time . "]
['Our maths teacher is rather humorous . ', " On the contrary , I think he's very serious . ", ' No , not at all.His examples are really interesting . ', " So they're easy to remember . ", ' Yeah , how about your maths teacher ? ', " He's an old antique , very serious . ", ' Bad luck , Anne . ', ' Hey ! How about your history teacher ? ', " She's another antique . ", " I'm sorry to hear that . "]
['Your family must be busy shopping for Christmas , now . ', ' Oh yeah and decorating the house too was colored paper and pictures . they will put a Christmas tree just inside the front door , pained toys and colored electric lights along the branches and plays all the gift packages under it . ', ' Woo , your home will beautiful on Christmas . ', ' Sure our thing . ', ' I do wish your christmas and happy new year . ', ' Thanks . ']
['Jenny , do you want to go to see a movie ? ', " What's on tonight ? ", " I want to see ' Click . ' ", ' Who is in this movie ? ', " I don't know . My friend told me it was a touching movie . "]
['How long have you been in Taiwan ? ', ' About 3 years , so I came here 2000 . ', ' So , where did you grow up ? ', ' Providence , Rhode Island . do you know it ? ', ' I am not sure , where exactly is it ? ', ' Well , not so far from New York . So what about you ? Did you grow up here ? ', ' No , I was born in Gaoxiong , I only moved to Taipei after I graduated . ']
['I am in hot water now , all the things seem to be blown up . ', " Don't be scared . Bite the bullet and everything will be right again . ", ' Thanks for encouraging me . There are problems cropping up here and there . But I will overcome them one by one . ']
["What's your schedule like this year ? ", ' Pretty busy . I have to pick up a lot of credits this year . ', " What's your major ? ", ' I ’ m majoring in French literature . ', " Oh , don't you have to take that class on 18th century poetry ? It's really difficult . I hear the students in that class have to write a paper a hundred pages long . ", " That's right . We got the assignment last week . ", ' When is it due ? ', ' Next Monday . ', ' Remind me never to sign up for that course . ']
["Did you check the internet for next week's weather forecast ? ", " I sure did . You're in luck ! It's supposed to snow all week in the mountains ! ", " Yes ! Somebody up there loves me ! I knew it wasn't too late for snow . ", ' It is kind of strange though , to have snow in April , and so much of it . ', " There have been so many dry winters lately that it's about time , don't you think ? ", " When you put it that way , I guess the skies can't hold out on us forever . ", " This will be the best ski trip I've ever taken . I can't wait to use my new hoard . ", ' It will be the best as long as the weatherman is right . ']
['Are you going to the beach this saturday afternoon ? ', ' It depends on the weather . ', " The radio says it'll be fine . ", " That'll be great . "]
['Are you studying here ? ', ' Yes , I am studying in Eastern Asian language department . ', ' What are you major in ? ', ' I major in Japanese . ', ' What do you think of the literature course . ', ' Its very helpful . The course has let me into a world of literature . I read so many great literatures . ']
['Did you say you saw lily alone ? ', ' Yes , nobody was with her . ', ' Where did you say she was ? ', ' In Thailand . ', ' I must say I think that is very odd . Are you absolutely certain it was her ? ', ' Yes . yes , I am sure . ', " Because I don't want any , er , do you understand ? But you are quite sure , are you ? ", ' Quite sure . I mean that hair of hers and the voice of hers . ']
["When I quarrel with my husband . He didn't even try to cool me out . ", ' It takes two to make a quarrel and it takes two to mend fences . ', ' I was so angry that I could not keep cool . What I need is just an apology . ']
['Is that you , Dave ? Oh , my gosh ! The backstabber who left us to work for the evil WebTracker ! ', ' Yeah , yeah , yeah . Hi , Mary . How are you ? ', " I'm filthy rich ! Haven't you heard about the MicroPower deal ? ", " Yeah , I guess I did . They're going to buy invoking ? ", " That's right . For seventy-five million . So how are you ? ", " I'm getting by OK . I heard MicroPower was going to make Zina president of their new invoking Internet division . "]
['The summer vacation is coming . Have you any plans ? ', " I haven't made up my mind . Maybe I will go to the US . What about you ? ", " I am going on a hiking trip . It's good exercise as well as fun . ", ' I think so . ', ' So why not come and join us ? Lee will come as well . ', " That's great . I will go hiking with you . "]
['It seems that something is praying heavy on you.What ’ s the matter ? ', ' I got my father ’ s goat last night . ', ' What did you do to get his goat ? ', ' When I asked him to treat me like he does to my sisters , he jumped down my throat . So I took it out on him by telling him what I thought . ']
['We need to elect club officials before the summer starts . ', ' I guess we should start with nominees first . ', " Let's make it the first item of business in our next meeting . ", ' We should probably let everyone know ahead of time so they will be prepared . ', ' Can you take care of sending out a bulletin by e-mail to all the club members ? ', ' Yes , I can do that this afternoon . ', " Let's schedule the actual election times the week after the nominations . Doesn't that seem logical ? ", ' Yes , let me put it on the calendar . ']
["How's business ? ", " Couldn't be better . "]
['are you looking for a course ? ', " yes , but I'm not sure which one to sign up for . ", ' what kind of program are you looking for ? Full-time or part-time ? ', ' I have to work during the day , so I want to find a part-time course that I can do in the evenings . ', ' what kind of course are you looking for ? ', ' I need to improve my English . ', ' do you want a one-to-one private tutor or a group class ? ', ' I think a one-to-one course will be too expensive for me , so a group class would be fine . ', ' have you ever considered taking one of our online courses ? ', ' I think I prefer face-to-face instruction better . ', " that's fine . If you want , you can sign up for a pre-sessional interview . ", " what's that for ? ", ' one of our qualified teachers will interview you so that they can find a class that suits you best . ', ' do you have a brochure about the course that I can take home to read ? ', " sure . Here's a brochure about out English classes that meet in the evenings . ", " thanks . I'll read through it tonight and get back to you tomorrow to sign up for a course . "]
['Hi , Mr . Zhang . What ’ s wrong ? You don ’ t look so happy . How was your date ? ', ' I was turned down again . It ’ s frustrating . I guess you ’ Ve got to teach me some skills . ', ' Me ? I ’ m even less experienced than you are . ', ' At least you know what American women generally like in a man . ', ' Believe it or not , I guess American women like a man in good shape , which Chinese women may not care about so much . That ’ s my honest opinion . I know you have been trying very hard . ', ' American men are naturally taller than Chinese men . So even if I exercise , there aren ’ t many chances . ', ' No , that ’ s not true . I ’ Ve met two American women who were married to Chinese . But those Chinese look very strong and healthy . So if you exercise more often , I bet it will surely be easier for you to date American girls . How old is Jacky Chan ? He ’ s small and short . But I bet he can have any American woman he wants . ', ' You know , that ’ s going to be a tremendous change for me . Because I never exercise . ', ' Why don ’ t you try then ? Even if it doesn ’ t help you find an American girl , you could still have a stronger and healthier body . You won ’ t lose anything by doing that . ']
['Who is it ? ', " Open the door . It's me . I can't find the key . ", " You're always so careless . ", ' Oh , thank you . I am exhausted . Will you bring me a cup of tea ? ', " Okay , but I haven't prepare supper . ", " So let's eat out . ", ' What do you want to eat ? ', ' Noodles . How about you ? ', ' Dumplings . ']
["Recently , there prevails ' Net Love ' ! ", " What's Net Love ? ", " Two people chat on the Net and step by step fall into love ! It's Net Love . ", " Ridiculous ! They haven't met ! Maybe they're the same sex ! ", " Maybe yesterday you've received a man's woos . He's called ' Beast ' ? ", ' How could you know ? ', ' I watched the screen display ! ', " Do you know ' He ' is Ms . Rebecca ! ", " It's typical Net Love , and a typical lesbians ' homosex ! HA ! ", ' Impossible ! ']
['What shall we do tonight ? ', ' How about the cinema ? ', " That's a good idea.We haven't been there for ages . ", ' What would you suggest to see ? ', " Oh , I don't know.It depends . "]
['I want to have Mexican food for dinner . ', " I'm tired of Mexican food . Besides , you picked the restaurant last week . ", ' OK , you win . You pick the restaurant this time . ']
["Tom's dating your sister . ", ' Are you sure ? ']
["It's almost 6:00 . I'd better be going . ", " Can you stay for dinner ? We'd love to have you join us . ", " It's really nice of you . Thanks ! "]
["I'm calling about our appointment . I can't call on you this evening.My wife is terribly ill . ", ' Sorry to hear that . ', ' How about next week ? ', " Fine , we'll be expecting you then . "]
['You honestly believe the world ’ s improving every year ? ', ' Yes , I do . I think that science is making us wiser . What do you think ? ', ' I don ’ t think you ’ re right there . ', ' I believe industry is making us wealthier . ', ' I don ’ t believe that . ', ' And in my opinion , medicine is making us healthier . ', ' I agree with you in the sense . But we ’ re all more miserable than ever , aren ’ t we ? ', ' I don ’ t agree with you . I maintain that we ’ re healthier , wealthier and wiser than we were a hundred years ago . ', ' That ’ s your opinion not mine . ']
['How was your date recently ? ', ' Not too bad . It is seemingly too hard for me to find a place for our date . ', ' I guess so . Going to watch a movie and having dinner at a restaurant are usual . ', ' She said she wanted to go Dutch in dating . ', ' Yes , now many girls want to be independent , so it is a little popular , especially among white collars . ', ' But I am still traditional , so I felt weird when she paid for herself . ', ' Forget about it ! ', ' Are you satisfied with your girlfriend ? ', ' It will be a long story . We have many differences , for example , she usually puts all her clothes into washing machine . That is the sort of thing I can not bear . ']
['You ’ re going to set up your own law office , aren ’ t you ? ', ' Yes . After so many years of hard work , I ’ d rather I had an office of my own . ', ' If you need help , don ’ t hesitate to ask me . ', ' I ’ ll be very glad if you would help . ', ' I ’ d like to wish you every success in your new venture . ', ' Thank you . I wish I would . ', ' Good luck to you . ']
['Do you know who Ammo Hung is ? ', ' Of course . He is now 50 years old . And he started out studying alembics , singing , dancing and martial arts at the age of nine , and has tarred in 140 kung fu films . He has also become an independent producer and director . ', ' You know only one aspect of him . Do you know what he would do in the kitchen ? ', ' I have no idea . Tell me . ', ' In the kitchen , with his wife by his side he still puts on quite a dinner time show . ', ' What does he do there ? ', " Imagine a chef chopping vegetables on fast forward . Picture a man making a stir-fry , tossing the mixture up in the air , and then catching it , every last bit , in his work . And his culinary motto is ' Enjoy the moment . ' If you want to know hey theycook , visit www.StudioClassroom.com.tw for the recipe . "]
["Wasn't that a great flick ? I was on the edge of my seat through the whole movie . ", ' I would say it was a typical run-of-the-mill Hollywood thriller . ', " Well , I'm no movie expert , but those special effects were impressive by any standards . ", " Special effects ? Baloney ! That movie was made on a shoestring budget . They've been using trick photography like that for years ", ' Okay . But you have to admit that it was an exciting story , especially with that surprise ending . ', ' You should read the book . The original story is much better and has a different twist at the end . ', ' Oh , really ? How does the book end ? ', ' Read it yourself and find out ! ']
['Do you know the highest mountain in the world ? ', ' Yes . It is Everest , also called Zhumulangma in China . It is 8,844 . 43 meters above the sea level . ', ' Wow ! That must be really awesome to stand on the top of the mountain to overlook the earth . ', ' Actually , it is impossible because the mountain is covered with snow all year around . And is has heavy fog for most of the time . ', ' Have people set foot on its peak ? ', ' Yes , it has been conquered by many people in history . ']
['I have been feeling sick for three days . ', " I'm most upset to hear that.Are you better now ? ", ' Not much better.Thank you . ']
["I'm feeling down . ", ' Come on . Cheer up ! ']
["Alice , I never knew you had such a lovely voice . You really can sing , can't you ? ", ' Thanks , Mark . I used to be a member of the school choir . ', ' No wonder you can control your voice so well . You are a professional singer . ', " Well , you are flattering me . I wouldn't say I am a professional , but I did receive some training at school . My music teacher used to be a professional singer . ", ' Well , a good teacher makes good students . ', ' You are quite right . ']
['Mr.Keller , may I call at your home sometime the week ? ', ' Oh , certainly.When would you like to come ? ', ' Well , when will it be convenient for you ? ', ' This weekend would be OK with me . ']
["I Don't know how they do it ! Our competitors have undercut us by 10 % percent on the price of our latest model . There is no way will be able to compete against that . We're barely breaking even with the present prices . ", " These price wars are disastrous for our bottom line . If they're charging 10 % less than we are , we've got to find a way to lower our price while keeping our profit . ", " Profits are almost nonexistent now , we can't beat their price . How do they keep their price so low ? ", ' We can try to lower our cost of production then . We need a price that we can compete with , something comparable with the competition . ', " You really think we can make it ? I don't have much faith in our ability to lower the price again . We're no match for them , the competition will beat us hands down . "]
['Did you know Carl is almost fifty ? ', " Are you sure ? He doesn't look that old . ", ' He told me so himself . ']
['The city has got a traffic problem . ', " That means it's developing very fast . ", ' You said it . ', ' Problems are inevitable . ']
['Well , you seem to enjoy speaking English . ', " You can't help learning when you're using it all day.You ' ll see . A few weeks ' study in the school will have a similar effect on you . ", " I hope so.You see , at the moment I find it difficult to get used to the teacher's speed and accent . I'm awfully worried , I can't reply as quickly as she seems to expect . ", " Oh , she likes keeping us on our toes by getting us use English throughout the class.She doesn't mind your making mistakes , though . ", ' You know , speaking in class is a very good chance to put your English to practical use . ']
['What ? You want to leave early ? ', ' Yes . Can I ? ', ' Do you really need to ? ', ' Yes . Is it OK with you ? ', ' Is it important ? ', ' Yes . Do you mind ? ', ' You really have to ? ', ' Yes . Will you let me ? ', ' I guess so . ']
['What sort of things do you grow in your garden ? ', ' I grow a variety of things , so that something is in bloom all year round . ', ' When is your garden at its best ? ', ' It looks best in spring , when the plum and cherry blossoms are out . ']
['Hi Kevin , how was your year at college ? ', ' It was great ! How was your year ? ', ' It was good . Do you have a girlfriend at school ? ', " Yes , I'm dating someone . Her name is Amanda . "]
['Your tie is handsome . ', ' Oh , thank you . Your skirt looks beautiful , too . ']
['Did you say that Ted was at your mercy ? ', ' Sort of yes . ', ' But he is not someone who can be led by the nose . ', ' But I am not that someone . I can easily talk him into doing whatever I want him to do . ']
["I failed the exam because I didn't study . ", ' Serves you right . ']
['Good morning . Sanyu Restaurant . May I help you ? ', ' What time do you open this evening ? ', ' We open at 6:30 , sir . ', " I see . I'd like to reserve a table for two . ", ' Yes , sir . What time would you like your table , sir ? ', " I'm not sure , perhaps around 8 pm . ", " Fine ! I'll reserve a table for two at 8 pm , sir . May I have your name , please ? ", ' Davis . ', ' Thank you , Mr . Davis . ', " Oh , any chance of a table by the window ? My wife loves the bird's eye view . As it's her birthday , I want it to be a celebration . ", " I see . We have already received many bookings and though I can't guarantee anything , please be assured that we'll try our best , Mr . Davis . I hope you'll understand . ", ' I do , but I would appreciate you , if it could be arranged . ', " We'll try our best . ", ' Thank you . ']
['Wow , this is drop-dead gorgeous . ', ' So no more regret now ? ', " Don't remind me of that . This would be the last time I cut any classes for a basketball game . ", " Come on . Don't be so hard on yourself . Enjoy your life . ", " I just can't help it . Oh , look at Clive , he is really a big hit . They are definitely gonna win . ", " It's only seven minutes into the game , too early to cheer up . ", ' Come on , 18 points already , they are never gonna catch up . ', " Who knows ! It's a long game . Look ! That was a really nice shot ! ", ' Thay are coming back to narrow the gap . ', ' Wait , that guy , I know him . He is just a bench warmer . ', " A secret weapon . They'd better set up the defense now . ", ' Clive is ready to explode . Keep your eyes open . ', " Oh , man ! I can't believe it . A slam dunk ! ", ' Good that he resembled his old , quick self . ']
['Look at that pretty girl . ', " Wow ! She's gorgeous . "]
['What are the seasons like in your city ? ', ' Summers are hot and usually lasts a long time . Winters are short , but cold , wet , and windy . I love the summers in my city , but I hate the wintertime . ', ' Does it ever rain in summer ? ', ' We usually get a big thunderstorm every two weeks , but apart from that , summers are dry . Thunderstorms make the air fresh again , so most people don ’ t mind then . ', ' What are spring and autumn like ? ', ' I like spring because flowers bloom and trees grow leaves again . In spring , the weather is very changeable-sometimes cold , sometimes warm . It ’ s usually windy with some rain . Autumn is usually sunny and dry , but it ’ s gradually gets colder as winter arrives . What are the seasons like in you city ? ', ' Well , I live in the southern hemisphere , so our summertime is your wintertime , and vice versa . We get some rain in every season , but most is in winter . In winter , it sometimes gets cold , but our winters are usually quite mild . Summers are warm , but not hot . Spring and autumn are both very short-sometimes just a few weeks each . The weather is very changeable then-just like spring in your city . ', ' Do you usually go on a summer holiday ? ', ' No , I don ’ t . I go on a winter holiday instead . I go somewhere warm . ', ' I usually go on holiday during the spring or the autumn . I try to go somewhere where the weather is more reliable than in my city . ']
['How do you think people get their personalities ? ', ' I think it ’ s mainly from the environment a person lives in . ', ' Don ’ t you think people get their personalities from their parents ? ', " No , but parents control a lot of the environment that kids grow up in , so they certainly influence their kids ' personalities a lot . ", ' So why do you think many kids have personalities that are so different from their parents . ', ' Maybe when they become teenagers , they want to be completely different to their parents . ', ' You might be right . I guess most parents want their kids to be like them , but kids today grow up in a different environment . You know , they know much more about the world from the internet , newspapers , and tv . ', ' Do you think that teenagers get a lot of their bad behaviour from tv and movies ? ', ' Maybe some of it . I think a lot of people blame TV and movies when the real problem is that the parents aren ’ t bringing their child up correctly . ', ' Parents have a difficult job . They have to bring up their children and usually have to work too . ', ' Yes , that ’ s true . Your son is doing well at school , isn ’ t he ? ', ' Yes , he is . He ’ s very hardworking when he ’ s at school . Then he comes home from school and does homework before dinner . After dinner , he goes out with his friends . ', ' So , he ’ s not a bookworm ? It ’ s good that he has an outgoing personality . Some kids are very quiet and introverted . You wonder they ’ ll survive in the real world without their parents to support them . ']
['Are you an art aficionado ? ', ' Not really . I like going to an art exhibition once or twice a year . I hardly know anything about art or sculpture . You are a true art lover , aren ’ t you ? ', ' I love going to art galleries , particularly when one is holding an exhibition of abstract art . ', ' I never understand the meaning of those painting . They are too abstract for me . I didn ’ t pay much attention in art class at school . ', ' Art isn ’ t for everyone . I ’ m going to an exhibition tomorrow at the national gallery . It ’ s an exhibition of greek and roman sculpture . ', ' I like sculpture , especially that form ancient rome or Greece . What time are you thinking of going ? I ’ d love to go with you . ', ' I thought I ’ d have an early lunch and go immediately afterwards . Does that sound ok to you ? Bus 51 goes directly there . ', ' That sounds fine . What time shall we meet at the bus stop ? ', ' Let ’ s meet at 12:30 . it will probably take us there or four hours to see all of the exhibits . ']
["your daughter will be back soon . I'm going to start making dinner . You can just watch some TV in TV room if you like . We just bought a new TV with a LCD screen . The remote control is on the coffee ta ", ' would you mind if I helped out in the kitchen instead ? I do enjoy cooking . ', " this is supposed to be your vacation ; we'd like you to just relax . ", ' cooking makes me feel relaxed . So , what are we cooking ? ', " ok , well , we're going to make a pan of lasagne , a salad , and some garlic bread . Here's the recipe . Do you want to get the ingredients we need out of the cupboard ? ", ' sure . We should probably pre-heat the oven right away , too . ', " that's a good idea . Can you set the oven to 200 degrees Celsius ? ", " that's a bit high for lasagne . I'll just set it at 180 degree and we can take it from there . ", " fine . I'll just get out the casserole dish , the saucepan , the salad bowl , and the baking sheet . ", " you know , I could do this myself . Why don't you go get the screwdriver and the pliers and go fix the vacuum cleaner so it works better ? ", " I don't think it's broken . ", " well , if it's not broken , then you need to learn how to vacuum better , because it doesn't look like you've vacuumed for ages ! ", " fine . I'll go vacuum . Let me know if you need any other help . "]
["It's very kind of you to come and see us off . ", ' My pleasure.What a pity you have to leave so soon ! ', " We would stay longer . but I've got to attend a meeting tomorrow morning . Thank you for your warm hospitality . ", " You're welcome . Maybe next time we'll come to see you . ", ' My wife and I will look forward to it . ', " I promise the next holiday I have we're coming to visit . Oh , what's your flight number ? ", " lt's Flight No . 302 , Northwest Orient Airlines . ", ' They just announced the boarding call . ', " Then we've got to get going . ", ' OK . Bon voyage and a safe landing . ', ' Thank you again for all your help . ', ' Bye . ']
['Labor is an abundant resource here . ', " One of many abundant resources , I'd like to point out . "]
["I'm afraid I've had a terrible row with my boss . What shall I do ? ", " I think you'd better apologize . ", " Oh , but I can't . It wasn't my fault . ", ' Maybe not , but I advice you to say it was your fault . ']
["What's the matter with you ? You look so upset and tired . ", ' My father failed in business . ', " Oh , that's really tough . ", ' Maybe it is the most difficult period of my family have experienced . ', ' I can understand . By the way , is there anyway I can help ? ', ' No , not now . I have found a part-time job.So perhaps I can help my family to come over the difficulties . ', " Oh , that's so great , bless you ! if you need me , I'll always be there . ", ' Thank you . ']
["Come in . It's nice to see you again . ", " It's nice to be here . ", ' Would you care for a drink ? ', ' Just a club soda for me , please . ']
['What can I do for you ? ', ' I want to check out these books . ', ' I need your library card . ', ' I have it right here . ', ' It seems you have late fees . ', ' Are you sure ? ', ' Yes , I ’ m sure . ', ' How much ? ', ' Your late fees come to $ 24.50 . ', ' I don ’ t have that right now . ', ' You have to pay it off before you can check out more books . ', ' I ’ ll do that soon . ']
['Hi Sarah , how are you ? ', ' Fine , how are you doing ? ', ' OK . ', ' What do you want to do ? ', " I'm hungry . I'd like to eat something . ", ' Where do you want to go ? ', " I'd like to go to an Italian restaurant . ", ' What kind of Italian food do you like ? ', ' I like spaghetti . Do you like spaghetti ? ', " No , I don't , but I like pizza . "]
['How was your date with Betty ? ', " Let's change the subject . "]
["The Johnson are on their way back . You remember them , don't you ? ", " Johnson ? I can't place them . ", ' We met them in Bermuda last May . ', " They've completely slipped my mind . ", ' The couple with the dogs-think back . ', " No , I don't recall a thing about them . ", " Well , I've invited them for brunch . ", ' Hmm , I must be getting absent-minded . ']
['Good to see you . Come on in . ', " Thank you . Here's a present for you . ", " Oh , you shouldn't . But thank you very much . "]
['I have never experienced a roller coaster . I want you to sit beside me . ', ' Wait a moment , I want to go to the toilet . ', ' You try to put on a brave face . ']
["It seems that you are an optimistic man who doesn't dismay easily . That is what a good salesman needs . Good luck . ", ' Thank you . ', " I guess we have covered all the stuff that we need to discuss and it's time to say goodbye . ", ' Yes , goodbye and keep in touch . ']
['What are you going to do for your year abroad , Tim ? ', ' Study study study ! I want to learn a lot . ', ' You ’ re going to take courses ? ', ' Yes , I ’ m going to take some university courses there . ', ' Sounds hard . ', ' Yes , but I think it ’ s probably for the best . ', ' Won ’ t you get lonely ? ', ' Hey , I ’ m a pretty cool guy ; I ’ ll make friends . And I ’ ll have a lot of extra-curricular activities too . You know , like fencing or theater or something . ']
["You're from New York , aren't you ? ", " Yes , that's right . ", ' What do you suggest I should see in New York ? ', ' Well , how about the Museum of Modern Art ? ', " No , I don't like museums.They ' re boring . ", " Why don't you go to see the Empire State Building ? ", ' Ah ! That sounds interesting . ']
['I ’ ll sing you a song . ', ' Yes , sing a song . But don ’ t sing a sad song . ', ' Most of my songs are sad , sorry . ', ' Well , please sing one that ’ s not sad . ', ' OK , I ’ ll sing San Francisco then . ']
["Is this Zhang Lin's home ? ", " Yes.Oh , it's you , Linda . I haven't seen you for a long time.Well , come in and sit down.How about something to drink ? ", " Yes , please . I'm a little thirsty , actually . ", ' Would you like tea or coffee ? ', ' Coffee , please . ', ' Here you are . ', ' Would you like to talk over a drink ? ', ' That sounds good . How are you doing , Linda ? ', ' Just fine.Are you busy now ? ', " No . I'm just killing time . ", ' Shall we visit our math teacher tomorrow ? ', " Yes . I haven't been in his house for several weeks.When shall we start ? ", " How about eight o'clock tomorrow morning ? ", ' All right . See you tomorrow . ']
['I am going to celebrate my birthday with you all in a night club this year , what do you say ? ', ' Fantastic ! I enjoy clubbing , especially those clubs with live bands . The only fly in the ointment is that the air is bad , full of smoke , and the music is too loud , so conversations are not really possible . Once I nearly got burnt by a cigarette . ', ' How did that happen ? ', ' A wild dancer dropped it on my left foot and said nothing about it . If I had drunk enough and I would have had the bold to punch him in the face . ', ' Sounds cool ! But that is not what a lady should do . People are easy to lose head in a night club and being drunk . ']
["How's your mother doing ? ", ' She is so pretty sick . ', " That's too bad . I wish your mother can recover soon . ", ' Thank you . ']
['The trouble is not that . It is that he may suddenly remember something I promised him a couple of weeks ago , out of a clear blue sky . Then he complains that I have gone back on my words . ', ' Does he do that with his Dad ? I mean , does he complain things to his father ? ', ' He never does , and in fact , he seldom communicates with him . ', ' But didn ’ t you say that his Dad takes him under his wings ? ', ' Yes , I did . He only takes side with him . He seldom asks what Dick is doing . ']
['Do you know where you want to transfer to ? ', ' I don ’ t have the slightest clue . ', ' What school would you like to go to ? ', ' I ’ m not sure . ', ' You honestly have no idea ? ', ' PCC is perfectly fine for me . ', ' You might as well stay here . ', ' That ’ s not a bad idea . ', ' PCC is a wonderful institution . ', ' You have a point . ', ' So , what are you going to do ? ', ' I ’ m just going to keep going to PCC . ']
['Hi , Walter ! ', ' Hi , Sterling ! ', ' What do you think of our new teacher ? ', " Professor Wood ? I think he's a brilliant scientist . ", " You're got a point there.But do you think he's a little absent-minded ? ", ' I guess so . ']
['Hello , Bob , this is Frank . ', " I know , we've met . ", " I didn't know you knew Frank . ", ' Yes , we met last year at a conference . ']
["Aren't you staying for the party ? ", " No . I'm tired and I've got to work tomorrow . ", " I don't blame you for getting some rest . ", ' Yeah . I need to . ']
['What ? ', ' What happened with that guy at the cafe ? ', ' nothing ', ' But you ’ re crazy about him ? ', ' Yes , I am . ', ' Why don ’ t you run off with him ? What are you waiting for ? ', ' I don ’ t actually know him . ', ' Really ? ', ' I only know him through the ... you are not gonna believe this . ', ' Oh , let me guess . Through the internet ? ', ' Yes . ', ' Hmm . You ’ Ve got mail . ']
['How do you like Tom ? ', ' I like him very much . He ’ s a gay dog . ', ' Are you ready to welcome him ? ', ' I am all set . He can come anytime . ']
['What kind of job have you ever had ? ', ' I used to work as a teacher . ', ' How did you like your job ? ', " Oh , if I hadn't moved here I would never thought of changing it . "]
['It ’ s a wonderful party , Joan , The food , the drink , the atmosphere ... Everyone is enjoying himself . ', ' Thanks to your help.To our friendship . ', ' Bottoms up ! By the way what kind of entertainment are we gonna have ? ', ' Dancing . The boys from the Campus Band have promised to play music for us . ', ' Oh , how wonderful ! Every girl on the campus has a crush on those handsome guys . ', " I'll surely make introductions for them . "]
['This is the first time for me to have a Chinese guest . I hope you like western cooking . ', ' Yes . I like it very much . ', " Cooking is a hobby with me . I'm always trying to think up new recipes . I hope you like the soup . It's kind of a specialty of mine , so I hope you enjoy it . ", " It's excellent . ", " Thank you for your compliment . Won't you try this fish with white sauce ? I'm rather round of it . ", " It's delicious . ", ' What sort of western food do you like best ? ', ' I like beefsteak very much . Have you tried Chinese dishes ? ', ' I find the Chinese dishes wonderful . ', " Well , it's getting late . I have to get up early tomorrow . So I must say good night . ", " It's still early . "]
['To be a revolutionary needs great courage ! ', ' He must be courageous enough to fly in the face of established authorities . ', ' Galileo is one of them . ', ' So are Copernicus and many others . ']
["I think Andy's party will be fun . ", ' Yeah , I think so . Oh , by the way , I need to ask you something . ', " What's that ? ", ' Could I get back the sweater you borrowed ? ', ' Sure . Oh , that reminds me . Could I borrow your black leather boots ? ', ' My boots ? Er ... Sure , ok . ']
["Hot in here , isn't it ? ", ' Yeah , really . ', ' Is it Ok if I sit here ? ', ' Of course . Suit yourself . ', " Thanks . My name's Bill Peters , by the way . ", " Hi , I'm Susan Jackson . ", ' Nice to meet you . And what do you do , Susan ? ', " I'm a student at UCLA . ", ' Oh , are you ? And what are you studying ? ', ' Medicine . ', ' Really ? ', ' Yes , I want to be a doctor one of these days . What about you ? ', " I'm an engineer , I work for Boeing . Say , would you like a drink ? ", ' Sure . Thanks . ']
['So , Fred , what are your plans for after graduation ? ', " Well , I've already got a job waiting for me back in my hometown . ", " That's cool . Have you already found an apartment to live in ? ", " I ’ m planning on living with my parents . Won't you ? ", " I couldn't even if I wanted to . My parents told me that if I went home , then I'd have to find my own place . ", " You mean they're kicking you out ? ", " Not really , they just don't want me living at home . My older sister did that , and she lived at home for seven years . Once she started living at home , it got harder and harder for her to move out . ", " Well , it's not like my parents want me to live at home the rest of my life . They said that it's ok if I move back home to begin with , but they want me to find a place of my own after a year or so . ", " My parents just didn't handle my older sister very well , and because of that , they want me to be more independent . They think that it's important that I should learn how to live on my own . ", " I know I need to learn that myself , but I just don't have the money for it at the moment . Living at home allows me to save up some money before I started finding a place . "]
["I'd love to continue this conversation , but I really need to go now . I have to get back to the office . ", " Well , let's get together soon . ", ' Okay . Would you like to have lunch some day next week ? ', ' Sure . How about Monday ? ', " Hmm . I'm afraid I can't make it on Monday . I've got to fly to Chicago on business . ", " Well unfortunately , I'm tied up on Tuesday . I'm supposed to have lunch with an important visitor from out of town , and I don't think there's any way I can get out of it.Are you free on Wednesday ? ", " Wednesday ? Let me see . Hmm . Somehow I think I've already got something scheduled for Wednesday . Oh , yes ! I've got an appointment with my dentist to have my teeth cleaned , and it's essential that I keep it . ", " Well , I'm afraid Thursday is out for me . I'm expected to attend a meeting of our personnel committee , and it's very important for me to be there . ", " So that leaves Friday . I don't have any obligations or commitments on Friday.How about you ? ", ' Friday sounds good . Where should we meet ? ', " You know , I really must be going now or I'll be very late . Can you give me a call tomorrow an we'll decide ? "]
['Where are you going ? ', ' It ’ s Tuesday today . I always go to my class on Tuesday night . ', ' I didn ’ t know you were taking any kind of class . Tell me about it . ', ' Well , I ’ m learning how to use math in the business environment . ', ' What for ? ', ' The job market is so competitive nowadays . I want to develop some useful skills . ', ' I really admire you for that . How is it going ? ', ' It ’ s going all right . I ’ m learning some things for the first time , but I ’ m also brushing up on some things that I already know . ']
['May I ask what the name is the girl ? ', ' Which one ? ', ' The tallest one . ', " She is Miao Li . She's come here to see her brother . ", " Oh , it's so . She looks very lovely . Could you give me some else information on her ? ", " OK . She's a costume designer and works in a garment mill . ", ' How do you think about her ? ', ' She looks very beautiful . She is a nice girl . ', " I'm wondering if she has boyfriend . ", " No , she hasn't . ", ' Great ! Thank you very much . ']
['How may I help you ? ', ' I want to get a passport . ', ' You need to apply for a passport . ', ' When can I apply for it ? ', ' You can apply right now . ', ' I ’ d like to do that . ', ' Fill this out , please . ', ' What ’ s next ? ', ' I will need to take your passport picture . ', ' When will my passport be ready ? ', ' It will take about three weeks . ', ' That ’ s great . Thank you . ']
['What are you thinking about ? ', ' About my boyfriend . ', ' Again ! ', ' You are really a wet blanket . ']
['Mr . : For tomorrow , read pages 12 to 20 . Then do exercises one through ten on page 21 . ', ' Do we have to type out our homework ? ', ' Mr . : No . You only do that when you write reports . ', ' Is there anything else ? ', " Mr . : For those of you who don't have a calculator , get one . ", ' We are allowed to use a calculator in class ? ', " Mr . : Yes . By the way , review today's notes this evening . We may have a small quiz tomorrow . "]
['Lucy , come here ! I can see the lake which is in the center of park . ', ' It is beautiful ! Look , there are so many birds around it . ', ' It is a great place for a relaxing vacation . ', " Listen to the sound of nature ! It's like music . ", ' Yeah , I agree . It makes you feel really good . ', ' What are those ? ', ' Do you mean the red things ? They are roses . ', " I'm going to take more pictures today . ", ' Me , too . ']
["So , is L . A . all it's cracked up to be ? ", " Well , the stereotype in the movies is that L . A . is a frivolous town with a lot of flaky people . I guess , in the back of my mind , that's what I expected . ", ' And , is it what you found ? ', " Well , it is and it's not . The city of L . A . is much bigger and more diverse than I had expected . There are people here from all over the country and all over world , like New York . I've heard people say that in L . A . , everyone is from somewhere else . Tha's partly true . So , I've met all kinds of people here . What I'm realizing is that the picture of L . A . that's in movies only represents a small segment of the city . ", " You're right . Life isn't always like the movies . "]
['Good morning , Miss . ', ' Morning . Can I help you ? ', " Yes , I'd like to know how to use the library . You know , I'm a new student here . ", ' All you need is your student identification card to check out books . ', " Yes . Here's my identification . ", " That's all you need . ", ' Thank you very much . By the way , how many books am I allowed to check out ? ', " You can check out two books at a time . But you can't check out newspapers , magazines and periodicals , they have to be read within library . ", ' How long can I keep the books ? ', ' For two weeks . After that you must renew the book if you wish to keep them longer . ', ' I want a book on physics . Could you show me where I can find it ? ', ' Yes , over there to your left . ']
['What a wonderful game ! ', ' Yes , the weather is wonderful , the game is wonderful and the players are wonderful . ', ' I think John is the best player on the field . ', ' He certainly is . He is the Peckham in our collage . ', ' Maybe he shouldn ’ t come to collage , he should become a football star . ']
['Thank you for organizing this great baby shower for me ! I ’ Ve always been to baby showers but never actually had one held for me ! Let ’ s get started ! ', ' Ok , let ’ s start opening some presents ! ', ' Oh look ! What a great little bib for the baby ! This will definitely come in handy ! Oh wow , you also got me a stroller ! That ’ s so great ! Thank you ! ', ' This next one is from Betty . ', ' A highchair and car seat ! Wow Betty , thank you so much ! I really appreciate it ! ', ' One more from Carla . ', ' A playpen and crib ! Thanks Carla ! This is just what I needed ! ', ' OK , that ’ s all of them.No more gifts . Now who wants to guess when the baby is due ? ', ' Umm . I think my water just broke ! Get me to a hospital ! ']
['By the way , how many books am I allowed to check out ? ', ' You can check out two books at a time . ', ' How long can I keep the books ? ', ' For two weeks . After that you must renew the books if you wish to keep them longer . ']
['Susan ? What brings you here today ? ', ' Well , I ’ Ve got some papers due . ', ' Really ? So what ’ s the news ? ', ' Not too good yet . Better than I was though . ']
["I'm going on a guided tour in the mountain . ", " You'll see the world-famous magnificent waterfall . ", ' I like the sight and the sound . It worked on me like a magic when I was a child ', " Your dream will come true . It's really breathtaking "]
['I work so hard that I do not have the energy to exercise . ', ' That is just an excuse.You can always find some time to exercise . ', ' But I work hard all the time for long hours . Often I have no time for lunch . Yet , I am still getting fatter . ', ' Bill , you know that work is not the same as exercise as it is stressful but not relaxing.And skipping meals will not help you lose weight.In fact your body will only store fat if you miss meals . ', " I know you're right , but what can I do ? ", ' How about going for a walk instead of sitting on the sofa reading the newspaper after dinner every night ? ', " But I'll miss the news.It ' s important in my business to keep up with events in China . ", ' I know , I know.Have you got a portable radio ? You can listen to the news and get healthy at the same time . ', " That's a good idea ! "]
['Excuse me , how can I fill in this blank ? What does marital status mean ? ', ' Are you married ? ', " No , I'm still single . ", ' Then , you put S in this blank . ']
['Good morning , you look very tired . ', " Yes , I nearly didn't sleep last night . ", ' Did you hold a party or something else yesterday ? ', " No , I just watched Supergirl , and it began too late in the night . I was too excited to get asleep after one o'clock . ", " I don't like this program , because there are too many constant arguments between the judges . ", ' The contestants are different . These girls perform in free styles . ', ' Do you have much time watching TV ? ', " I think less than 3 hours . This year I didn't watch any entertainment programs . Too many ads between the programs . I prefer listening to the radio . ", " I don't like ads , either . But ads could bring big profits to the TV station . ", ' If they could make beautiful ads , I could bear . ']
['You should draw a picture of a fancy kingdom of animals in forty minutes . ', ' All right . But how ? ', ' Just imagine , if a horse can fly , if a bird can swim ... and things like that . ', ' I see . But could you give me another piece of paper ? ', ' OK . Here you are . Anybody who wants help , please come to me . ', ' Thank you so much , Mr Addison . ']
["Mom , I've got something to tell you . ", ' So , please ! ', ' Aunt Jane buys a new bike for Tom . He is putting on grand airs . ', " I bought you a new one last year . Isn't it handsome ? ", " It is great . But Tom's bike is so much better than mine . ", ' Frankly , he is more well-behaved than you . ', ' Nothing of that sort ! ', " Why hasn't the bus come yet ? Every morning we have to wait for so long . ", " Mom , it's OK . I will buy a big car one day . It is faster than the bus . ", ' Really ? I am looking forward to that . What about the traffic ? ', ' Let me see.Yes . I will buy a plane for you . There is no traffic up there . ']
["Hey Steve . When's the next time you're going to play golf ? ", " I'm going out this Saturday . ", ' Do you already have a foursome ? ', " Unfortunately , we do . Let's plan for something together for Wednesday . We can go right after work . ", ' That sounds good . Where do you want to play ? ', " We won't have much time , so let's play somewhere close to work . ", " How about Bellevue ? It's pretty close . ", ' How much does it cost over there ? ', ' Twilight rates are 21 dollars . ', " That's pretty good . Let's do it . ", " Aright . I'll get a tee time for Wednesday at about 4 ", ' Make it 4 ', " Ok . I'll call you later when I get a tee time . ", " Sounds good . I'll see you on Wednesday then . ", ' Aright . Have fun on Saturday . ', ' Will do . ']
["What's the weather like in your hometown ? ", " Um , very nice . It's warm in spring and cool in autumn . ", ' Is it hot in summer ? ', ' Yes , it is , but not as hot as in Beijing . ']
['He told the police that Ted was the murderer . ', ' He is playing hob with the fact . ', ' Why do you say so ? ', ' Because he stayed with me all the time that night . ']
["Hey , let's arm wrestle ! ", ' Not now . ', " Chicken ! You're afraid I'll beat you . ", ' Are you kidding ? I just feel tired right now . ']
['Oh , God . It ’ s late . I ’ m afraid I have to leave . ', ' But you just got here . Can ’ t you stay a little longer and have some tea ? ', ' That ’ s very kind of you . But if I don ’ t go now I ’ ll miss the last bus . ', ' That ’ s too bad . ', ' Thank you for your hospitality . ', ' Thanks for coming . ', ' How about next time we meet at my place ? And I ’ ll treat you to Chinese food . I know how much you like it . We can order in and watch video too . Anything you like , I promise . ', ' Great idea . I ’ m looking forward to it . See you then . ', ' Well . I really do have to go . ', ' Good night then . ', ' See you tomorrow . ']
["isn't it wonderful walking here ? ", ' what do you mean ? ', ' I mean look at all these magnificent tall buildings around us . ', " yes , look over there . That's the Empire State Building . My book says it's 102 stories tall . ", " it's quite famous but don't you think it looks a bit old-fashioned ? ", " you're right , but when it was built in 1930 it was a marvel of technology and engineering . ", ' what other important buildings are we going to see on Fifth Avenue ? ', " quite a number . Actually every skyscraper has a history . A few blocks ahead we'll see St.Patrick ' s Cathedral and just across the street will be the world-renowed Rockefeller Center . It's a landmark ", " what's there after that ? ", " well then , there's a Central Park . Facing the park on Fifth Avenue is probably some of the most expensive properties in the world . ", ' what are all they for ? ', ' most of them are office buildings , huge department stores , and hotels but some are just private homes . New York is one of the financial centers of the words so there are lots of very expensive places . ']
['Hi , Daisy ! ', ' Hi Simon . Nice to meet you again ', ' I hope you are Settling in at school ! ', " I am ! I've made lots of friends and I really enjoy my courses . ", " Good ! Me too ! By the way . you didn't tell me what you are studying here . ", " Didn't I ? I'm doing business studies . ", " Really ? That's great . You hope to join a company after graduating ? ", " Maybe . My parents moved to Canada the year when I was born . We are living in Toronto . Suppose I might get a job in Toronto when I graduate . It's too soon to say really . ", ' What about your friend Zoe ', " She's from Australia . She lives in Sydney . Her father runs a hotel business there and she is doing a degree in accountancy . ", ' Accountancy ? Really ? She must be very good at figures . ', ' I guess so . What about you , Simon ? ', " I'm studying law . ", " Great ! So I'll know who to call if I ever need a lawyer . ", ' Sure , welcome anytime ']
['Emily , are you getting rushed by a sorority ? ', ' More than one . I think the count is now three , if I remember correctly . ', " Wow . I'm getting rushed too , but just one . Are you thinking of joining any of them ? ", " I don't know . I know there are advantages to joining , but I'm not much into group stuff . ", " The guys I've talked to say that the activities that go on in a frat house can be a little distracting depending on the group . ", " I think I'm going to decline . I just prefer to do my own thing . ", ' Were your parents involved in that kind of thing at all when they went to school ? ', ' My dad was , but not my mom . ']
['Are you studying any languages here ? ', " Yes , I'm studying in the Foreign Languages Department . ", ' What are you majoring in ? ', " I'm majoring in English . ", ' Is it difficult to learn ? ', " Yes . The language is hard to learn , but it's interesting . ", ' Do you know anything about Britain and America ? ', " I'm reading a lot of books about the two countries . I like the culture . ", " Right.It ' s important to learn the culture of a nation if you want to learn the language well . ", " You're right . "]
['How are you ? ', " I'm fine thanks . How about you ? ", " I'm okay . What are you doing these days ? ", " Not a lot , actually . Busy at work of course - we've got a big project coming up in Malaysia . I may have to go to KL in a few weeks . ", " That's great . When are you starting ? ", " Probably in a week or two . I'll let you know . "]
['Mary is such a cautious girl ! ', ' What do you mean by cautious ? ', ' She never puts words into her mouth , she only repeats the opinions of others . ', ' Thats a clever way to escape responsibility . ']
['He has a girlfriend already . ', ' You are kidding ! He just broke up with Ann . ', ' Her new girlfriend is a far cry from Ann . She is like a breath of fresh air . ', ' I hope I will meet her soon . ']
['Let ’ s cross here . ', ' You ’ re kidding . We ’ ll never make it across in one piece ! Let ’ s cross at the light . ', ' Now we have to walk all the way down to the end of the street . ', ' If you want to cross here , be my guest . I don ’ t feel like dodging cars and scooters ! ']
['Jenny , are you having fun here ? ', ' Yes , of course . This is really a nice party with wonderful people and lovely wines . ', ' I ’ m glad you ’ re enjoying it . ', ' Thank you for the invitation . ', ' It ’ s my pleasure . Would you like another glass of champagne ? ', ' Yes , please . Thank you for everything . ']
['Steven , have you ever met Hanson ever since he went back to London ? ', ' No , but we still stay in touch . ', " What's the way you keep in contact ? ", ' We contact through email . ', ' Email is not always the best form . I think QQ is way better . ', ' Your words sound a bit reasonable . But don ’ t forget the time difference . ', " You're right . "]
['Joanna , I will go to the outlet center . You wanna go with me ? ', " It's so faraway . ", ' I saw Emily yesterday evening . She was wearing a CD evening gown . She told me she bought it in the outlet center and she saved $ 120 ! ', ' $ 120 ? ! Then I should go and see what I can get ... ']
['Hello Mike ! Would you like a drink ? ', ' No , thank you . I had too much to drink yesterday evening . I had a bad hangover this morning . My head felt terrible . ', ' Were you celebrating something ? ', ' Yes . It was a friend ’ s birthday party . We drank all kinds of things-beer , wine and spirits . After midnight , we were even drinking cocktails ! ', ' It ’ s a bad idea to drink a combination of alcoholic drinks . You should stick with one for the whole evening . ', ' I know , but it was a celebration , you Kwon ? I don ’ t think I ’ Ve see you drunk . ', ' I usually only drink beer and I rarely drink more than a few pints . ', ' You are a sensible drinker . Anyway , I ’ m not going to drink any alcohol this evening . I don ’ t ’ want another bad hangover . ', ' Let me buy you a soft drink then . How about a coke ? ', ' Yeah . That ’ s a good idea . I heard that coke was first used as a medicine . ', ' Rally ? ... barman ! ... a large coke with ice and lemon , please ... thanks . Here ’ s the money . ', ' Are you going to the wine tasting tomorrow ? ', ' Yes . I thought it might be interesting to learn a little about wine ... ', ' ... and taste a few ! There will be wines from several countries and an expert to give advice on which wines are good and which ones are not . ', ' Yes . I ’ m looking forward to it . ']
['Excuse me , do you know where the visa office is ? ', ' Yes , I do . I ’ ll walk you there . ', ' Thanks ! ', ' Are you applying to study or work abroad ? ', ' I want to study abroad . ', ' What do you want to study ? ', ' I hope to study English literature . ', ' Have you got your visa yet ? ', ' Not yet . I have an interview with the visa official today . ', ' I see . Is it your first interview ? ', " No , I've already been to here for three interviews . ", ' What happened ? ', ' I was denied a visa ? ', ' Why ? ', ' Like most students . I want to work in America after graduation . ', ' I see . Well , good luck ! ']
["He's only interested in harassing you . How can he expect us to have so much time to waste ? ", ' I almost want to send him a virus to shut his stupid computer down . ', ' As obnoxious as Bean is , we should still try to finish this case . ', ' True-well , do you have any forwards for me to send him ? ', ' Yeah ! Remember that one about putting light bulbs in your mouth ? ']
['What does your sister look like , Mike ? ', ' Well , she ’ s tall and pretty . ', ' Is she like you ? ', ' I suppose so . We ’ re both friendly and easy-going . ', ' Is she as clever as you ? ', ' No , she ’ s not as clever as me . ', ' Big head ! ']
['When were you born may I ask ? ', ' On 20th May 1963 . ', ' Do you know what it was according to the lunar calendar ? ', ' 27th day of the fourth month . ', ' By the way , could you tell me when the film will begin ? ', ' It will begin at five thirty . ', " I am frigid I can't be there on time . ", ' You can see it tomorrow . ', " I don't want to miss it today . ", ' See you . ', ' See you . ']
['Honey , do you have a second ? ', ' Sure ! Are you okay ? You seem a bit worried.What ’ s on your mind ? ', ' We need to talk . ', ' Okay ... ', ' I ’ Ve been thinking , and well , I think we need to start seeing other people . ', ' What ? Why ? I mean , we ’ Ve had our ups and downs , and we have the occasional disagreement , but we ’ re happy together , aren ’ t we ? ', ' That ’ s just it , I ’ m not happy anymore , Tim . It ’ s not you , it ’ s me . I know that I can be hard to deal with , and you are a great guy ! You are the type of guythat any woman would kill for ! ', ' So , what are you saying ? You ’ re breaking up with me because I ’ m perfect ? ', ' Tim , you are too good for me . You deserve someone who can make you smile and make you happy the way that you made me happy . Oh , I could say that I ’ ll be all you need , but that would be a lie . I know I ’ d only hurt you , I know I ’ d only make you cry . ', ' Baby , come on . Don ’ t do this to me ! Whatever it is , we can work it out . Just give me another chance ! I know that we can get through this , but we gotta stick together ! Don ’ t leave me . ', ' I can ’ t , Tim . I hope someday you can find some way to understand I ’ m only doing this for you . I don ’ t really wanna go but , deep in my heart I know this is the kindest thing to do . ', ' Laura ... ', ' Here are your keys . I ’ ll send my sister to pick up the rest of my things next week . I ’ m sorry , Tim . I wish you all the best , and I hope that one day we can meet again . I ’ ll always love you . Goodbye . ']
['Did you hear what happened to Mike in Accounts ? ', ' No . What ? ', ' He got arrested on Friday night and spent the night in jail . ', ' No . Really , what happened ? ', " Well , it was all a big mistake , actually . He got home on Friday night really late , and apparently he'd been out drinking with some clients , so he was really drunk . ", ' Was he out with the guys from the bank ? ', ' Yes , I think so . ', ' Oh , yeah , they always get really drunk . ', " Well , anyway , he'd somehow lost his wallet and his house keys , so he couldn't get in . He lives alone , you know . ", ' Oh , really . I thought he lived with his wife . ', ' No , she left him last year . ', ' Oh , really ? Do you know why ? ', ' Hang on , let me finish telling you what happened . Where was I ? ', ' He lost his wallet and keys . ', ' Oh yes , well , he tried to climb in through the bathroom window , but apparently he slipped and broke the glass with his foot . The neighbors heard him and thought a robbery was in progress , so they called the police . ', ' Oh , no . ', " Yes . So when the cops arrived , they didn't believe his story ", ' So then what happened ? ', ' Well , when he sobered up , he called someone from work to come and bail him out . ', " Well , that's a bit of a tricky situation . ", ' Yes , I know . ']
["What's your opinion about childless couples ? Will you choose to have no kids ? ", " To be honest , I wouldn't . ", ' Why ? Do you have to make a choice now ? ', ' Not really . But it has puzzled me for a long time . ', " What's the puzzle ? ", ' My husband and I prefer to have no kids , but my mother-in-law is very traditional and wants grandkids . ', ' Oh , I see . I think the older generation tend to think in a different way . ', ' Yes . It seems she can never accept a childless marriage . We had a fight last night . ', ' Oh , really ? Maybe she is just eager to see her grandchildren . ', " But it's absolutely our own business to have a child or not . ", ' Definitely . ', " You know , I often overhear our neighbor , the young couple , fighting about how to raise their kid and I really don't want kids to spoil our happiness . ", " Don't worry . I think in most cases , children are the glue that keeps a family together . ", " I guess you're right . But I still prefer to have no child . ", ' Sure . You can fully enjoy your time together . ']
["Hi , Jim and Wendy . Where're you going ? ", " We're going to that new restaurant for lunch . Would you like to join us ? "]
['You ’ re a big fan of Andy Lau , aren ’ t you ? ', ' Yes , I ’ Ve been got all his albums and most of his films on DVD . I adore him . He ’ s my idol . ', ' How come you don ’ t have all of his films on DVD ? ', ' Some of his early films are hard to find nowadays , especially the ones where he only played a bit part . ', ' I see . I ’ m sure you ’ ll find them one day . I see you also have several poster of him . ', ' Yes . These posters are new . I bought them last week and put them up on my bedroom walls yesterday . ', ' Are you a member of his fan club ? ', ' I was , but then I discovered you can find out everything for free on the internet , so I ’ m not a member now . ', ' Did you see the interview with Andy Lau in cosmopolitan magazine last month ? ', ' Of course ! I bought two copies . ', ' Two copies ? One to keep and one to cut the pictures out of , right ? ']
['How did you enjoy your family party at “ ginger ’ s ” ? I hear that they have a lovely menu and buffet . ', ' Oh , it was great . We had seafood buffet . They do one every Friday . The waiters and waitresses are very good . They are very attentive , but don ’ t hang around the table . ', ' I like the buffets they have , but if often order a la carte , because I don ’ t feel extremely hungry . I like the wine list there too . ', ' Yes , so do I . they have wines from all over the world . There is a good range of prices to suit every pocket . We ordered some Australian red wine , which tasted delicious and wasn ’ t expensive . ', ' Some restaurants allow you to take your own wine and just charge you corkage , but the don ’ t do that at “ ginger ’ s ” . what was included in the seafood buffet ? ', ' They had almost every kind of seafood . There were oyster , shrimp , prawns , crabs , and fish . I ate a lot of smoked salmon . ', ' Did they have lobster ? ', ' No , they didn ’ t . you could order it from the menu . I think that lobster is too expensive to be included in the buffet . ', ' Yes , it probably is . I don ’ t like ordering oysters in restaurants . You never know whether they are fresh . ', ' I know . I didn ’ t eat any , but a few people in our group did and no one got sick . ', ' When you eat out , do you usually eat from the buffet ? ', ' Not usually . I usually just order a main course and have a dessert if I ’ m still hungry afterwards . ', ' Oh , you don ’ t usually have a starter ? ', ' No , I might have a soup if it ’ s a cold winter day . ']
['Harry , do you like the opera ? ', ' No , not really . ', ' Why is that ? It is called real art . ', " Well , it's very expensive and they're usually singing in another language . That kind of gets on my nerves . ", ' Yeah , that makes sense . ']
['Hello there ! Come on in ! Don ’ t just stand there ! Come and take a seat ! ', ' Um , okay . Well , I just want a trim . Nothing too fancy . ', ' Oh my gosh ! Your hair is amazing ! So silky , so shiny ! I am going to work my magic on your hair ! You hear me ? You are going to look like a million bucks ! ', ' Okay . Um ... can you make sure my sideburns are even and you just take a little off the top . ', ' Don ’ t you worry , I ’ ll take care of everything ! Oh my god ! I just love your curly hair ! It ’ s so fluffy and cute ! You should totally let it grow out . An afro would look great on you ! ', ' Um ... no . ', ' Okay , but you are going to be my masterpiece ! ']
["May doesn't get along very well with her mother-in-law . ", " Yeah . That's just what is troubling John . ", ' Poor John ! He is bothering both sides of this bread . ', " This situation isn't easy to handle . "]
['what do you think about this store ? I heard it ’ s a posh store that ’ s only got branches in big cities . ', ' I love this store . The only problem is that it ’ s extremely expensive . ', ' don ’ t worry . I ’ Ve decided that for your birthday I ’ m going to take you shopping for a new dress . ', ' really ? I thought you hated shopping ? ', ' I do , that ’ s why you should appreciate this gift ! ', ' sure . That ’ s really nice of you . Let ’ s go in and try some things on . ', ' how about this red dress ? I think it would really suit you . ', ' that ’ s gorgeous ! Do they have it in a size 8 ? ', ' here you go.On any other day , it would cost me a fortune , but it ’ s on special offer today . ', ' I think this color isn ’ t quite right for me . Do they have the same dress in white ? ', ' let me look . Let ’ s see ... they ’ Ve got one in blue , green , pink , black ... and white . Here you are . ', ' this is perfect ! What do you think ? ', ' I think you look fantastic . Happy Birthday ! ', ' I ’ m so lucky . You only get a chance like this once in a blue moon ! Thanks honey ! ']
['Judy , what is everybody talking about ? ', ' Haven ’ t you heard ? Richard was fired by our manager . ', ' You ’ re kidding . It can ’ t be true . ', ' Believe it or not . Everybody is talking about it in the company . ', ' Really ? I ’ m surprised . ', ' Me too . ']
['Do you think that climate change is responsible for the recent floods ? ', ' It could be . There are floods in this country almost every year , but in recent years they have been more widespread and more frequent . ', ' It seems that the climate in this country is changing . ', ' The summers are hotter . The last three summers have been the hottest for the past 200 years . There have also been stronger winds . ', ' I think that the changing climate is a sign that we are causing too much damage to the environment . ', ' I think you ’ re right . Climate change naturally over time , but I think that human activities are speeding up the change . I wish that government would join together and try to resolve the problem . ', ' Me too . If we don ’ t do something soon , It might be too late . ']
['I remember you said that you like China because it has cheap beers . ', ' Yes , unbelievably cheap . Carlsborg is less than $ 1 . ', ' Why do you drink ? I mean , where does drinking get you ? ', " It's fashionable . ", " Come on , you don't even know that blinds following is a sign of immaturity . ", " Mary , it's not about the blind following . What matter is I enjoy in drinking . It's like when you get off of work . You're so tired . You need to get relaxed . You can't just turn on the TV and keep watch the programs until you fall asleep . You need to make your after work time more fun . ", ' How ? By drinking ? ', ' Drinking is just part of it . I mean , you have a bunch of friends coming by and having fun . You drink and talk . And the more you drink , the more you talk . It makes me so relaxed . ', ' When did you begin to drink ? ', " It's a long time ago . When I first went to a bar to pick up girls there , I saw the most beautiful girl sitting and sipping a coke . Then I went up to her and said ' can I buy you a drink ? ' ", ' And then ? ', " Then I talked to her and got her number . You know what ? When you don't know what to say ? Just drink . ", ' So you get drunk every day ? ']
['What is your favorite pastime ? ', " Fishing . It's great fun . ", ' Is it ? Mine is climbing mountains on Sunday mornings . ', ' No wonder you always look so active . ']
['hello , Deva , how are you ? ', " can't complain . What about you ? ", ' not bad . Have you heard Wendy divorced her husband ? ', " I've heard . She looks quite depressed . ", ' Yes . They used to be joined at the hip . ', ' I heard they were just married for 5 months . ', " yes , she said they couldn't communicate well with each other and they often argued over trivial things . ", ' yeah . Mixed marriage is tempting but crisis-ridden . ', ' you said it . You know , they fall in love at first sight and quickly jumped into marriage . ', ' maybe they were just attracted to each other but too different to be married . ', ' yeah . We Chinese have quite different lifestyles and values from foreigners . ', " definitely . That's why many cross-cultural marriages end in divorce . ", " we've heard so much about Chinese film stars divorcing foreigners . ", " that's true.Just hope Wendy can recover from the pain of divorce soon . "]
["Here's Copellini's , my cousin's store . ", ' Sounds like an Italian name with an “ i ” at the end . ', ' Admit it . You just think of Mussolini . ', " No , I'm an art lover , so I think more of Bellini and Botticelli ! ", ' Ah , yes . The Italians do love the sensual forms of the human body . ', " Don't we all ... hey ! Your cousin sells gift items ? ", " Yeah-all from Italy . See all the saints ? They're important to Roman Catholics . "]
['Thanks for the pizza . It was delicious . ', " It's okay . ", " Next time , it's on me . ", " Don't be silly . ", " I'm serious . ", ' Alright . Next time , we can try some other flavors . ', ' Certainly . The vegetarian pizza looks pretty good . It must be very delicious . ', ' Definitely . I really like Italian food . ']
['I really admire you , Diana . ', ' Why , Jerry ? Your words just came out of the blue . ', ' You are always happy and able to achieve high scores at school . ', " I work very hard and that's it , you know , practice makes perfect . ", " Isn't there anything else ? ", ' I have no idea . ', ' You must have a high IQ score . ', ' Well , Jerry , let me tell you a secret . ', ' Go ahead . ', ' My IQ score is slightly above average . ', ' Seriously ? But you are such a genius . ', " Maybe I've got a higher EQ . I'm not sure . ", " Well , perhaps you're right . Sometimes EQ matters more than IQ . ", " You can say that again , Jerry . And I'm sure you're high in both of them . With a little more time cracking the books , you can also get high marks . ", " OK , thank you . I'm going to the library , are you coming ? ", " Let's go ! "]
['The academy is an important part of the education system . ', " I couldn't agree with you more . "]
['What does this have to do with me ? ', " You know all about coffee . I need your advice , so I won't look stupid when I order . ", " Order tea . Isn't that what you like to drink ? ", ' Come on , Hugh ! Tea is for wimps ! Please , I need your help . ', ' If you want to be macho , order a double shot of espresso . ', " Now you're talking . That sounds good . What is it ? "]
['Your father looks much younger in the picture . ', ' He was 20 years old then . ', ' How old is he now ? ', " He's over sixty . "]
['Hey , Mike , is Jenny coming with us ? ', ' Yes . Why ? ', " Nothing . I'm just asking . ", " Just asking ? But why is your face burning like mad ? Ah-huh , someone has a crush on Jenny , doesn't he ? ", ' Who has a crush ? ! ', " Come on , Ted , don't be such a chicken . If you like her , you've got to tell her . Maybe she likes you . ", " Well , I don't have the guts to ask her out . ", " What're you so afraid of ? Just tell her what you're feeling about her . ", " I'd totally die if she turned me down . ", " But that's better than keeping everything to yourself . You've got to let her know . Come on ! You've got to take a chance ! Even though you are rejected , it's not the end of the world ! There's nothing to lose , is there ? ", " I don't know ... Well , maybe , you're right , but how am I going to tell her ? "]
["It looks like it's going to be sunny . ", " Yes , it's much better than yesterday . ", " They say we're going to get some rain later . ", " Oh , let's just hope it stays warm . "]
['Does anyone need a drink ? ', " I'll take one . How's the cooler situation ? ", " It's still stocked , and there's plenty of ice . Here you are-cheers ! ", " Cheers . You guys didn't drive , did you ? ", ' No , we walked . Why , do you need us to carry some stuff home later ? ', " No , it's just that it's a holiday . With everyone out partying , there's a lot of drunk driving . "]
['Thanks a million . ', ' My pleasure . ( It was my pleasure . ) ']
['Would you honor us with a visit ? ', " I'd love to . Thanks . ", ' When will you be convenient ? ', ' Any time will suit me . ', ' Are you doing anything tomorrow ? ', " I'm free tomorrow . ", " I'll pick you up at about nine o'clock , will it do ? ", ' All right , see you then . ']
['Would you mind if I use your tape-recorder ? ', " I don't mind . Go ahead . ", " I'll give it back to you in a couple of days . ", ' OK . You can keep it as long as you need . ']
['What are you doing this weekend ? ', ' I am not sure . What are you doing ? ', ' I was thinking of maybe taking a drive to the beach . ', ' That sounds like a great idea ! ', ' Would you be interested in joining me ? ', ' Sure , I would love to go with you . When would you be leaving ? ', ' I thought that we could leave around 8 ', ' That would give us plenty of time to explore . Did you know that there is a music festival on the beach in Santa Barbara ? ', ' That was part of my plan . ', " Well then , I'll see you on Saturday . Thanks for asking me to go with you . "]
['Congratulations on your success in the competition . That is quite something . ', ' Thank you . I was lucky this time . ', ' I think luck played a very small part in your victory . It is solely due to your hard work and efforts . That brings honor to you and joy to us . ', ' I am flattered . ', ' It is real word . ', ' Thank you very much . ']
["Oh ! You're engaged ! What a beautiful engagement ring ! Who to ? ", ' Of course Mike . Who else ? We fell in love at first sight . ', " When's the wedding going to be ? ", " We haven't decided yet . There are a lot of things to sort out , you know . ", ' Are you having a big wedding ? ', " Yes , I've always dream of having a big wedding . ", ' But what do you say about that ? ', " I don't really enjoy big occasions , but I think I ’ ll come round to the idea in the end , It only happens once in a lifetime . ", " Perhaps I'll agree with Mike . I couldn't stand a big wedding with many relatives and friends of my parents or my wife whom I'd never met before . "]
['Who ’ s this ? your girl-friend ? ', ' No , it ’ s my sister . ', ' How old is she ? ', ' She ’ s 18 . ', ' She is tall ? ', ' Yes , she is . ', ' And she is thin , isn ’ t she ? ', ' Well , just a little thin . ']
['How ’ re you today ? ', ' Pretty good , thanks . And you ? ', ' What ’ s the main idea in this essay ? ', ' The United Nations should have more authority . ']
['Hi , Walter ! ', ' Hi , Sterling ! ', ' What do you think of our new teacher ? ', " Professor Wood ? I think he's a brilliant scientist . ", " You're got a point there.But do you think he's a little absent-minded ? ", ' I guess so . ']
["I don't understand why some parents keep beefing and complaining about their daughters not being able to follow suit . ", " Yeah . Li Na's mother has been building a fire under her since her neighbour's daughter got married with a Canadian . She's almost driving Li Na crazy . ", ' If I were Li Na , I would ask her if she had done that . ', " She a as meek as a lamb . She never goes against anyone or anything . She's as good as gold , you know ? "]
['Those are today ’ s top stories . Now let ’ s go to John for the weather . John , what does the forecast look like for our weekend travelers ? ', ' I ’ m afraid we ’ re in for a rough weekend , Mary . There is a storm system moving through the East Coast . It will be drizzling all day today , and there ’ s a 60 percent chance of thunderstorms this eve ', ' That ’ s pretty chilly for the summer ! Will it rain on Saturday ? ', ' Unfortunately , yes . It will be clear early Saturday morning but there is a high chance of showers and thunderstorms later in the day . There is a severe thunderstorm warning for some parts of the Sout ', ' That certainly sounds like a dreary Saturday . ', ' It gets better on Sunday , though . The storm systems move east and the skies will clear up at night . It will still be rather cool , with highs in the low 50s . The West Coast will be experiencing some ']
['May I know how old you are ? ', ' I am 24 . ', ' What is your date of birth ? ', ' I was born on April 15 , 1986 . ']
['What was the last movie you saw ? ', ' A Korean film called Friends , starring Sang Dong-gun . ', " Really ? I've seen that movie , too . ", ' How did you like the movie ? ', ' I thought it was pretty good . ', " Really ? I can't say I agree . ", " You're kidding . The story and acting were outstanding . ", ' I guess I expected too much from the movie , so I was a bit disappointed . ', ' I guess it could happen . ']
['Now the coals are just right . I can start grilling . ', ' Here you go . I made up the burger patties for you . ', ' Thanks . Smell the hickory chips ? They give the meat a nice , smoky flavor . ', " I'll take over for a while to give you a break . ", " Sorry . This is a one-man job . I've got the grill just how I like it , and I've made up my own special sauce . ", " Then I'll tell folks the food's ready . Come and get it ! I've always wanted to say that ! "]
['Jimmy , I ’ d like to wear this robe for tonight cocktail party . What do you think of it ? ', ' Don ’ t dress like that . You ’ ll make fool yourself . You look stupid in that robe . ', ' What ? But it is my favorite piece of clothing . ', ' Maybe it is . But it ’ s out of fashion . ', ' What am I going to do ? ', ' Let ’ s go downtown and pick up some fashionable clothes for you . ']
['Would you mind if I make a suggestion ? ', ' Of course not , go ahead . ', ' Maybe you should try to quit smoking . You know it is very bad for your health . ', ' Well , sure it is . Actually , I have been cutting down the amount since two months ago . I used to smoke a pack of cigarettes for a single day . Now I limit it to 6 cigarettes a day . ', ' You have made a big progress . Quitting smoking is not an easy job . But it will be rewarding in the long run . ', ' Thank you for your suggestion . ', ' You ’ re welcome . ']
["What's your favorite sport ? ", ' Swimming . What about you ? ', ' Indoors activities , such as chess and gymnastics . ']
['The Blacks got divorced . ', ' Really ? Why ? ', ' Mr . Black has been getting a little on the side . ', " Really ? I am surprised . He doesn't look like a guy who'd ever cheat on his wife , does he ? ", " No , he doesn't . Anyway , his wife found out that he has been two-timing for a long time . ", ' Well , I am really surprised . By the way , have you done anything behind my back ? ', " No . The only thing I've ever done behind your back is zipping you up . ", " I like that joke , but I hope it's true . "]
['You are freaking me out . ', ' You don ’ t like the dog ? I promise I will never bring it with me ! ']
['I heard that janet has got a new job . She ’ s working for the united investment group . I hear that they pay very well . ', ' I heard that too . She must be making a pocket . Well , good for her . ', ' now , she ’ ll be able to save up for that holiday in the united states . ', ' yes , she will . At the moment , the exchange rate is very favorable , so she should try to go as soon as possible , while it ’ s cheaper . ', ' you ’ re right . By the way , did you hear that tom inherited some money recently ? ', ' really ? I thought his parents had died several years ago . ', ' they did . He inherited the money form an uncle . I hope he doesn ’ t lose a lot of it in taxed to the government . ', ' dying can be very expensive nowadays ! What ’ s he going to do with it ? ', ' he said that he would probably invest most of it . He ’ s got a well-paid job , so he doesn ’ t need the money to cover day-to day expenses . He just wants some extra money available for when he retires . ', ' I had some good financial news yesterday too . ', ' really ? Have you won a fortune in the lottery ? ', ' no , but I got a pay rise of 5 % and a hours for all the hard work I ’ Ve put in recently . I think it was very nice for my boss to show his appreciation in that way . ', ' It certainly was ! So , what are you going to do with your windfall ? ']
["You haven't spent much time with Sophia lately . Are you speaking to each other at the moment ? ", " No , we're not . We've been drifting apart for a while . ", " But you two used to do everything together . I thought you really enjoyed each other's company . ", ' We did , but since she started her new job , all she does is hang out with her new friends from work . ', " Can't you hang out with them , too ? ", ' I could , but all they ever talk about is work , so I always end up feeling left out . ', " Maybe you should invite her over for dinner , so it's just the two of you . ", " I tried that a few weeks ago and she ended bringing a pal from work with her ! She's so busy these days that it's just impossible to hang out with her . ", " It can't be that bad . She was always a really good friend to you . ", " You're right . She would never talk about me behind my back or hold a grudge . But she just doesn't seem very interested in our friendship anymore . ", " She's probably just excited about her new job . You should give her some time . It would be a shame to lose such a good friend . ", " I've given her enough time . I'm over it now . ", ' I still think you two should try to patch things up . ', " I think I just have to accept the fact that it's time for us to go our separate ways . "]
['Do you love me ? ', ' I ’ m very fond of you . ', ' Yes , but do you love me ? ', ' Why ? You mean a lot to me . ', ' Why didn ’ t you answer my question ? ', ' What question ? ', ' Do you love me ? come on , I ’ m eager to hear . ', ' You know that I care for you . I .. I ’ m proud of you . ', ' Don ’ t cherish your words , dear . ', ' I .. I don ’ t feel like saying it . ']
['Thanks for inviting me . And happy birthday , Julia . ', " Many thanks for your present . I'm so glad you are able to come . "]
['How may I help you today ? ', ' I need to make some copies . ', ' The copier is right over there . ', ' Does it cost to use it ? ', ' We do charge to use the machine . ', ' How much does it cost ? ', ' We charge ten cents a copy . ', ' How many copies am I allowed to make ? ', ' There is no limit to how many copies you can make . ', ' Would you mind showing me how to use it ? ', ' Please read the instructions on the copier . ', ' Oh , okay . Thanks . ']
['Hello , Mary . What ’ s the matter with you ? You look upset . ', ' My friend and I was argued with each other . For this , I ’ m very sad . Because I don ’ t want to lose this friend . ', ' Oh , I ’ m sorry to hear that . I know how you feel . Please don ’ t be sad . ', ' Thank you , but I really want to relax myself . I ’ m very sorry . ', ' OK . Don ’ t let it get to you . Goodbye . ']
["Hi , I haven't seen you in a while . ", ' Yes , it has been a long time ! ', ' How long has it been since we last saw each other ? ', ' I think that we last saw each other two years ago . ', ' What have you been doing for the past two years ? ', ' I have been going to graduate school at USC . ', ' What are you majoring in ? ', ' I am studying international communications . ', ' You should easily be able to find a job with that major . ', ' I am counting on being able to get a good job . ']
["Here you are at last ! You're half an hour late , you know . ", " I'm awfully sorry to have kept you waiting for so long . ", ' What happened ? ', " My watch stopped and I didn't know . I certainly need to buy a better one . "]
["I'm sorry for spilling my drink on your rug . ", " There's no need to apologize . ", ' But I ruined your rug . ', ' Forget it . It was an accident . ']
['Hey ! How was your first day of class ? I ’ m in level two and I ’ m loving my class this semester ! It ’ s great being in a class of international students ! ', ' Mine was ok , except that no one in my class speaks English . I guess it will force me to converse in Chinese more in class so at least I should improve a lot this semester . ', ' That ’ s both fortunate and unfortunate . It ’ s the United Nations in my class ! We have people from all over the world ! There are three Germans , a Pole , a Scottish , two French , an American , a Brazilian , a Chilean , a New Zealander , though he prefers to call himself a Kiwi . Who else do we have ? Oh , we also have a Moroccan , a Togolese , a Pakistani , and two Indonesians ! ', ' That ’ s quite the array of nationalities . Everyone in my class is from Asia , except me . There are a few South Koreans , several Japanese , Malaysian , Thai , Singaporean , Filipino , Kazakhstan , and one Russian . ', ' Well , I think you ’ re pretty lucky actually . You ’ ll have the opportunity to learn so much about Asian culture . ', ' I guess so , but I think it ’ s going to be hard to relate to my classmates , especially with the language barrier . I think I might change classes . ', ' Don ’ t ! Stay the course ! Your spoken Chinese will be eternally grateful . I bet you it will even surpass mine with all that practice . ', ' I highly doubt it . Your girlfriend is Chinese . ', ' Well , there is that , yes . ']
['Currently we are looking for business opportunities in northeast China . ', ' What kind of business do you do ? ', ' We send analysts to companies that run into financial difficulties . ', ' What kind of clients do you prefer ? ', ' Smaller local companies . We specialize in trade & shipping industry . ', ' I used to work for a shipping company for six years , and I am quite familiar with some managers . Would your like to meet them ? ']
['Bob ! ', " Anne ! I haven't seen you for ages . How've you been ? ", ' Fine , just fine . And you ? ', ' Not bad . It really is great to see you again . W here have you been ? ', " Guangzhou . I've got a cousin there . "]
["I didn't like my brother's batting around without doing anything useful . ", ' Maybe he is trying to find a job . When he finds one , everything will be settled . ', ' I hope so . ']
['May I have your attention please ? ', ' Would you please be quiet , Ladies and Gentlemen ? ', " Well , my speech isn't very long . Would you please ... ", ' Quiet everybody ! ']
['Excuse me , are you Miss Green ? ', ' Yes . May I help you ? ', ' May I introduce myself ? ', ' Yes . ', ' I ’ m a new student in the school . My name ’ s John . ', ' Nice to meet you , John . ', ' It ’ s a pleasure to meet you , Miss Green . ']
['So , have you seen all three The Lord of the Rings movies ? ', " Yes , but I didn't really like the third one at all . ", " That's the Return of the King , right ? ", " Yeah . Even though the customs were brilliant , I didn't think it was as good as the first two . What did you think ? ", ' I thought the special effects were amazing , but I got a bit confused . The plot was too complicated for me . ', ' Did you read the books before you watched the movies ? ', ' No . did you ? ', " Yes , I've read them many times . I think it's much easier to follow for people who were already familiar with all the characters . ", ' Yes , trying to keep track of all the characters was quite confusing for me . ', ' I also think that it was much better in the theatre than at home . ', ' Most movies are . Another problem for me was the film was dubbed in German with English subtitles . ', ' That happens a lot in non-English speaking countries . ', ' I heard that The Return of the King was nominated for 11 Oscars . ', ' Actually , they not only had 11 nominations , but they won 11 Oscars , too ! ']
['Jill , how do you like your new job ? ', ' I like it . But how did you know about my new job ? I wanted to surprise you . ', ' I just heard through the grapevine something about you landing a job with some travel agency down town . You can still fill me in on tile details . ', ' Well , two weeks ago I got a tip about a possible job opening at Ace Travel Agency over on Franklin Avenue . ', ' Sure , I think I know the place . ', ' Well , anyway , I made a beeline over to their office , had an interview with the manager , and was told to start work the next day . ', ' That ’ s really great , jill . So , what do you do there exactly ? ', ' Right now I ’ m basically just a secretary , but if I ’ m given the chance , I want to become a travel agent there . ', ' Don ’ t tell me your ’ re already bucking for a promotion . ', ' No , of course not . I ’ Ve got a lot to learn yet . In the meantime , I just want to be a good secretary and not step on anyone ’ s toes . ', ' Well I wish you luck . ']
["Hey , Jack , where's your car ? ", ' I got rid of that clunker . This is my new one . ', ' Is that right ? This sure beats the old one ? ', " Hop in , I'll give you a ride . ", ' Ok . Boy , this looks expensive . ', ' Yeah , it costed a bundle , alright ? ', ' Wow , this thing can haul . ', " Yeah , this sucker is the fastest thing I've ever owned . ", " I believe it . Hoo , this car corners like it's on rails . ", ' We are on the high way . Find the pound shade .. ', ' Wow , this car can really burn rubber . ', " It's a great feeling . ", ' You made a perfect choice , Jack . ', ' Thanks , Daisy . ']
['Woo hoo ! This just might be the start of the rest of my life ! ', ' What happened ? ', ' I ’ m in the market for a job ! I went on a website with hundreds of job listings in the area and browsed through them until I got the names of a few employers I would like to work for . I have the resume I wrote for English class last month and a cover letter will be a piece of cake to write . I ’ Ve even done my research and found the names of the managers so I can address the letters personally . And you know I can be charming in interviews . Goodbye my penniless days ! Hello salary and a career ! ', ' Ben , we ’ re fifteen . What kind of job are you looking for ? ', ' Oh , just for a position as a gas station attendant . You know , starting at a simple lowly job , just like all the greats before they made it big in the world . ', ' Uh-huh . ', ' But I ’ m just in it for the money , right ? How else am I going to be able to afford to keep taking Angela to the movies ? Besides , I love the smell of gasoline , don ’ t you ? ']
['Hello , Ellen . ', ' Hello , Helen , have you heard the news ? There ’ s been a horrible accident . ', ' Oh , no ! What happened ? ', ' Hilda Harris husband , Henry had an accident on his way home from work . ', ' How awful ! Was he hurt ? ', ' Yes . He was taken to the hospital in an ambulance . ', ' How did it happen ? ', ' His car was hit by an express train . It happened at the crossing just behind his house . ', ' How horrible ! ', ' He ’ s having an operation in the hospital now . Poor Hilda ! You can imagine how unhappy she is . ', ' I hope he ’ ll be all right . ', ' I hope so , too . ']
['My son has really taken it out of me . He never keeps out of mischief . ', ' After all , he is a baby . ', ' Yeah . Anyway he is driving me mad . ']
['Alright , we need to have a plan here . First of all , which bed do you want ? ', " Well , everybody wants the bottom bunk . Why don't we flip a coin for it ? ", ' Alright . Do you have a coin ? ', " Yes . Here's a quarter . I flip it , you call it in the air . ", ' Heads . ', " Sorry , it's tails . You lose . ", ' Oh , well . So you get the bottom bunk . What about our stereos ? It looks like we both brought our stereos . Probably we only have room for one . ', ' Your stereo is better than mine . Do you mind if we use yours ? ', " No , I don't mind . I just don't know where we can put the speakers in this tiny room . ", ' Probably we can put one on that counter . And we can put one on the floor by the bed . Over there . ', " Alright . That's a good plan . What about the desks ? We have two desks , one by the window and one by the door ? Which one do you want ? ", " Well , the desk by the window is nicer , of course . Don't you think ? ", ' Yes , I agree . ', " So since I got the bottom bunk , why don't you get the desk by the window ? That would be more fair . ", ' Alright . ', " I mean , we could flip a coin for it , but I would probably win again . I'm incredibly lucky you know . Especially with girls . ", ' Is that right ? ', " Yes , that's right . ", ' Well , I hope you let me hang out with you then . Maybe I can learn from you . ', " Oh , certainly . Certainly . I'm always willing to help beginners.Just call me Big Brother Dave . ", ' Are all lucky people so stuck up ? ', " C'mon , don't take it seriously ! I'm just kidding . ", " Anyway , I get the desk by the window , you get the bottom bunk . That's it . ", " Why don't we start unpacking these boxes ? ", " I will go get something to eat . You unpack first.Then , when I come back , I'll unpack . ", ' Alright . See you later . ']
["let's go swimming . ", ' But , we just finished eating lunch . ', " I know , but I'm really hot . ", " I'd strongly recommend that you wait for a while before going swimming . "]
['Why are you so late ? ', " I've been through a lot today . I forgot to set my alarm clock last night , so I woke up late this morning . And what is worse , I missed the school bus . ", " That's enough . Sit down . "]
['I think we should accept his plan . ', " I'm afraid I can't agree with you . ", ' Why ? ', " Simply because it's not practical at all . "]
["Not a single email until now ? it's already twelve o'clock . I can't believe it ! ", " Can't bear it , right ? I've been there before . I'll feel uncomfortable if no one calls me or sends me text messages , like there is something missing . ", " Yeah , that's right . If no one sends me text messages , I'll go crazy . ", " Actually , this is a kind of addiction called ' infomania ' or ' information overload ' . ", ' Addiction ? checking emails and text messages often can be called an addiction ? no way ! ', ' Yes , it is . Do you consider a frequent check of your in-coming emails to be an integral part of your working day ? ', ' Absolutely . ', ' Do you have your cell phone with you wherever you go and check text messages and phone calls from time to time ? ', " Yeah , it's a must . Otherwise , I may miss important phone calls and text messages . ", " Do you open all your IM tools whenever you're using a computer ? ", " Yes . MSN , QQ , Skype , Google Talk , Ali wangwang , everything , so that I'll be in touch with all friends and relatives . ", " Now I can tell you're definitely addicted to the overflow of information "]
['Do you like chocolates ? ', ' It depends . ', ' Do you like coffee ? ', ' Um . It ’ s delicious . ', ' And do you like English food ? ', ' Not all of it . ']
["It's getting late . ", " Yeah , I'd better head for home . "]
['There must be something weighing on your mind . What is it ? ', " Dad , I lost mum's necklace . I'm afraid she will scold me . ", " Don ’ t worry . I'll buy a new necklace as same as the old one . ", ' It is so kind of you , Dad . ']
['Could you tell me the time ? ', ' Pardon ? ', ' What time is it , please ? ', " It's 9:30 . "]
['Wow , that terrible movie is finally over . Next time I ’ m picking the film , because I don ’ t want to end up seeing a chick flick . ', ' Well you should have picked , in the end you always complain about everything . ', ' Not everything , just this film . Even the title is ridiculous , and it ’ s so long , those are the two and a half most wasted hours of my life , so much so that I ’ m thinking about asking them to give me my money back . ', ' I ’ m thinking of taking you back home . I thought we could have a nice evening , but you ’ re always so negative . ', ' I ’ m only complaining about a movie that I could have rented or bought and then thrown in the garbage . ', ' You see , that ’ s what I ’ m talking about , I can ’ t stand your sarcastic jokes anymore . ', ' Next time , go with your gay friend who is more in touch with his feelings . ', ' Well he ’ s more of a man than you are ; at least he appreciates love stories . ', ' Love stories ? More like one-night-stands . ', ' Don ’ t criticize Mario or else I ’ ll start on those fat , drunk friends of yours , they ’ re no saints . ', ' My friends ? Fat ? What about those whales you call friends ? ', ' You ’ re unbearable , you can walk home , I ’ m leaving . ']
['How about going swimming ? ', ' Ok . Where should we go ? ', ' Why don ’ t we down to the pool ? It ’ s not too far from here . ', ' Fine . I ’ ll be ready in a minute . ']
['I want to go to china for sight-seeing.What do you think of it , Mum ? ', ' Why not ? China is a wonderful country . ', ' Will you go with me , too ? ', " No , I'm afraid not now . I'm too busy . "]
['Mr . : Are you Mary Lin ? ', ' Yes . ', " Mr . : I'm Mr . Rogers , your homeroom teacher . ", ' Where should I sit ? ', " Mr . : Why don't you sit behind Brad ? ", " Who's Brad ? ", " Mr . : He's that guy in the blue shirt . ", ' When does the first period begin , by the way ? ', ' Mr . : As soon as the bell rings after the morning announcement . ']
['Welcome to our university ’ s fifties anniversary , Sir . Please have a seat . ', ' Thank you . Wow , your school has so many honors . Congratulations ! ', ' Thank you . ', ' Excuse me . I wonder see Dean Mr . Lee first . I was wondering if could you tell me where his office is ? ', ' Certainly . Mr . Lee ’ s office building at the south end of the campus , just beside the library . ', ' Excuse me ? ', ' Let me show you the way . Please follow me . ', ' Thank you very much . It ’ s very kind of you . ', ' My pleasure . ', ' This is it ? ', ' It ’ s up on the second floor . You have to use the stairs . The elevator isn ’ t working . ']
["Excuse me , miss . I'm Bob . ", " I'm Amy . How do you do ? ", " I'm very glad to meet you . May I have this dance with you ? ", ' Certainly ! I suppose you dance often . ', " No , I don't often dance . Isn't this a wonderful party ? ", " Yes , I'm glad I have come . ", ' How do you like fox-trot ? ', ' I like it very much . ', ' You dance beautifully . ', " Thank you . It's lucky that I have got a good partner . ", ' Thank you . ']
['I ’ m going to the beauty parlor . Do you want to come too ? ', ' Sure . Let ’ s go . What are you going to have done ? ', ' I want to have a foot massage and haircut . ', ' A foot massage sounds like a great idea . They are very relaxing . I ’ d also like to have a mudpack on my face . It ’ s supposed to help with your complexion . ', ' Good idea . We should also pedicures and manicures . ', ' This could become a very expensive trip to be beauty parlour ! ', ' I think it ’ s a good idea to pamper yourself occasionally . Don ’ t you agree ? ', ' Oh , I agree . We both work hard and a little beauty treatment can relieve stress . ', ' Maybe we should try a thai massage too . ', ' What ’ s special about a thai massage ? ', ' That ’ s when the masseuse walk on your back and massage you with her feet . ', ' Sounds painful ! ']
['I just love your hair that way . ', ' Thanks . ', ' Where did you have it done ? ', ' My sister did it . When did you get yours cut ? ', " Just yesterday . I'm still getting used to it . ", ' Well , it looks very nice . ', ' Thanks . ']
["What's the matter ? ", " I'm feeling a little under the weather . "]
['Is Jack still staying idle everyday ? ', ' No , he has mended his way . After his father died , he set his hand to the job of putting his business affairs in order . ', ' Really ? He is so competent now . ', ' You can ’ t imagine what he is like now . ']
["Sandra is actually a blue chipper . I don't think she could realize that she has married a fool for women . ", " That's fate . ", ' I feel sorry for her . ', " Maybe this is God's will . "]
['Paul , what kind of music do you like to listen to ? ', ' All kinds , but mostly Pop , rock and classical . Why ? ', ' I have tickets to a show . Do you want to go with me ? ', ' What kind of music is it ? ', " Pop . It's Maria Carey . ", ' When is it ? ', ' At 8P M tomorrow night . ', " Yeah , I'd like to go . Do you think we should have dinner first ? ", " Yes , that's a good idea . ", " Let's eat at the restaurant across the street from my apartment . ", ' Oh , I think I know the place you mean . We ate there last month , right ? ', " Yes , that's right . You have a good memory . "]
["Hello , ladies . I'm firing up the grill . We can eat in an hour or so . ", " Chips , finger foods , desserts , baked beans . Where're the pork and beef strips ? ", " Yi-jun , we're in the States . Here it's all burgers , steaks , and dogs . ", " Ah ... hence the buns and condiments we bought . And this is Holly's potato salad . ", ' You can put stuff on the picnic table . Back to work . The grill is calling me ... ', ' Let me know if I can help . ']
['Is Water Shrinking Festival official ? ', ' No , most of the traditional festivals of the minority nationalities are not official . ', " Don't you think these festivals are more interesting ! ", ' What an idea ! ']
['Hey man , what do you have on tap ? ', ' Heineken and Budweiser . We have a two-for-one happy hour special . ', ' Cool , give me a pint of Heineken and half a pint of Bud . ', ' Okay ... A pint of Heineken and and half a pint of bud for table six ! And what about some appetizers ? ', ' Sure ! Let ’ s have some nachos and mozzarella sticks . ', ' Okay . That ’ ll be 80 bucks . ', ' Wait ... What ! ']
['So you are green with envy at your neighbor ? ', ' Well , he ’ s really lucky . It seems that he could win the bet at every turn . ', ' But I don ’ t envy those who are filthy with dough . That ’ s not the whole life . ', ' I know what you mean . I ’ m not only after bucks . There ’ s something more in life . ']
['Now that it ’ s the new year , I ’ Ve decided to turn over a new leaf . ', ' Yeah ? You finally decided to wipe the slate clean ? ', ' You got it ! I have a new job , I ’ m living in a new city , with new friends ! This is my opportunity to make some small changes in the way I live my life . ', ' So what are you going to do ? Take up an art class or something ? ', ' Well , first of all , I ’ Ve decided to stop smoking . It ’ s not that I ’ m pinching pennies or anything , it ’ s just that I ’ Ve been smoking since I was sixteen , and I think it ’ s time to stop . ', ' I ’ m with you on that one . Anything else you ’ re planning on doing ? ', ' One last thing , I ’ Ve decided to come out of the closet . ', ' It ’ s about time ! ']
['Are you doing something on Saturday evening ? If not , welcome to my new apartment . ', ' You moved to a new place ? ', ' Yes , I have been busy emptying the packing boxes and cleaning up the mats . Right now , it looks like a home . I would like to have a small celebration party . Please do come . ', ' Thank you for inviting me . Sounds lovely ! I would like to come . Where is your new apartment ? ', ' It is in the DX community , Room 306 , No . 2 building . It is very easy to find . Just ask the guard at the entrance . ', ' Who else will come ? ', ' I invited all the colleagues in our department and also my former neighbor , Paul . He is a very good person . You should meet him . ', ' Ok , I will be there around 6 . Is that ok for you ? ', ' Yes , great . I am happy you are coming . ']
['Did you remember to bring back that software I lent to you ? ', ' Oh , I ’ m sorry . It completely slipped my mind . ', ' That ’ s ok . If you could just bring it in tomorrow , I would appreciate it . ', ' Definitely , I ’ m really sorry . ']
["I wouldn't dare go bungee jumping . ", ' Chicken ! ']
['Hello , could you arrange a dinner for us ? ', ' Sure , what time ? ', " Eight o'clock tomorrow evening . ", ' For how many people ? ', ' Ten . ', ' Western food or Chinese food ? ', ' Chinese food . ', ' Do you want an expensive meal ? ', ' No , not too lavish . ', ' How much would you like to spend for each person ? ', ' What is the usual thing here ? ', ' Forty to eighty RIB Yuan a plate . ', " Let's say sixty Yuan then . ", " OK . Is there anything special you'd like to have on the menu ? ", " We'd like to have typical Chinese food . ", " Anything you'd rather not have ? ", ' No snakes , please . ', ' How about drinks ? ', ' Mao Tai and Qingdao Beer . ', " Well . Dinner for ten at sixty Yuan a plate , drink's extra , at 8 o'clock tomorrow evening . Is that all right ? ", ' Right , thanks . ', ' My pleasure , see you tomorrow evening . ', ' See you then . ']
["You're going to abandon me , just like that ? ", " I'm sorry , but I've got an important job to do . "]
['Why are you so crazy about bird-watching ? What do you get out of it ? ', " Looking at the beautiful creatures and listening to their songs are such wonderful experiences . I feel as if I'm in direct contact with nature . ", ' Really ? ', ' You bet . You should try it yourself . ']
['How was your vacation in Paris ? ', ' It was exciting ! ']
['When in Rome , do as the Romans do , they say . ', ' What do you mean ? ', ' Roman is living in Rome , of course . And go to work by car , or bus , or on foot . ', ' I think the Romans do what everyone else does . ', ' Certainly . ', ' And Roman really loves life . He knows how to enjoy himself . ', ' Not always . But they like good meal . ', ' Really ? ', ' How can I go there to have a taste ? ', ' By air of course . ']
['Hey , Joshua ! Is Anny coming with us ? ', ' Yes , why ? ', " Nothing . I'm just asking . ", " Just asking ? But why is your face burning like mad ? Aha , someone has a crush on Anny , doesn't he ? ", ' Who has a crush ? ', " Come on , Josh , don't be such a chicken . If you like her , you've got to tell her . Maybe she likes you . ", " I'd totally die if she turned me down . ", " You've got to let her know . Come on ! You've got to take a chance ! "]
["What's that book you have under your arm ? ", " It's the best seller everyone's been talking about for the last six months . ", " How in the world did you get a copy ? I've put a hold on it at the public library for weeks and I'm still waiting my turn . ", ' I checked it out of the rental library . It only costs five cents a day . ', ' Is it really worth paying for ? ', " I can't tell yet . I haven't got beyond the first chapter . ", " If it's any good , I'll buy a copy when it comes out in the pocket edition . "]
['Do you know anyone who ’ s had plastic surgery ? ', " You mean like a breast enlargement ? I don't think that's really necessary . That's not the way a woman should stay attractive . ", " Why not ? Why can't we go back to the way things were ? ", " Because ... I don't know . But , Connie , you wouldn't do that , would you ? ", ' Darned right I would ! ', ' Maybe make-up would be enough ? ', ' Come on , Liz . Be open-minded ! Look at my eyes , they are puffy . And my eye bags , they are dark and loose and full of lines and circles . I really hope surgery can wipe out the tired feelings . ', ' But what would other people think ? ', " I don't care what other people think . I am ready for a lift . "]
["I heard Rose is pregnant . I hope it'll be a boy this time . ", ' I hope so , too.Rose and her husband have been wanting a boy so much . ', ' After three baby girls in a row , Rose is under a lot of pressure from her in-laws.They want a boy in the worst way now . ', ' But baby girls are just as good and just as fun as baby boys . ', ' I agree with you , but you know how old-fashioned the elders are . ']
["I have two finals this week and one oral presentation and I'm not ready for any of them ! ", ' Sounds like you will be doing some serious cramming till Friday ! ', ' I hate this part of school . ', ' Why did you put it off until the last minute ? ', " I didn't mean to . Things just kept taking up all of my time . ", ' Maybe you got your plate too full this semester ? You can change that next semester . ', " I think I'd better . I have twenty four credits this time around . That might be a bit much . ", " I'll say . The regular eighteen is just about all I can handle myself . "]
['I went bungee jumping yesterday . It was so exciting . ', ' Do you really enjoy such dangerous sports ? ', " Yes , They are great fun and very challenging , too . Some day I'll want to try deep-sea diving and rock-climbing , too . ", ' You are a real fan of extreme sports . ', ' Yes . I love facing danger and overcoming it . It has become part of my life . ']
['Honey , would you marry me ? ', ' I want to think about it for some time . ', ' Please , honey , I have made proposals to you fifteen times . ', " I know . But your way doesn't touch my heart . ", ' Oh , god , please tell me how . ', " I can't tell you . ", ' OK , I want you to be happy when we are together , and when you are sad , I would always stay with you . ', ' When I am angry and want to beat someone , you stand there and let me do what I want . Would you ? ', ' Yes , I would . Thanks for being in my life . ', " Don't be so happy , it is just one of my tests ! "]
['My old man always harps on me . ', " So does my father . I'm already used to it . ", " But I can't bear it , John . ", ' How dare you say that ? What they do is just for our good . ', ' Yeah , but he really puts blame on me . ']
['What are you doing tomorrow ? ', ' Nothing really . ', " Let's watch a movie or something . ", " What's on these days ? ", " I think they're playing Lord of the Rings ", " That sounds pretty good . Let's watch that . ", ' Where should we meet ? ', ' How about at the subway entrance . ', " Aright . I'll meet you there at one o'clock . "]
['Jenny , I want to go on a picnic . Could you come too ? ', " I'd be glad to . I love picnicking . ", ' Then , put on your casual clothes and pack some food and beverages . ', ' Can I bring my camera with me ? ', ' Sure . Bring enough films , please . ', ' I sure will . ']
['Ok ... I ’ ll talk to you later . Bye ', ' Carrie , are you ok ? You seem a bit down . ', ' I just got off the phone with my boyfriend . He is always getting upset and losing his temper over nothing . It ’ s so hard to talk to him at times . ', ' Maybe it ’ s just that he is stressed out from work or something . He does have a pretty nerve wracking job you know . ', ' Yeah but , he is always in a really foul mood . I try to find out what ’ s bothering him or get him to talk about his day but , he always shuts down and brushes me off . ', ' Men are like that you know.They can feel nervous , anxious or on edge and the only way they can express it is by trying to hide it through aggressiveness . ', ' I guess you are right . What do you think I should do ? He wasn ’ t always this grouchy you know ... ', ' Talk to him , try to cheer him up when he is down and if that doesn ’ t work , I say get rid of him and get a new one ! ', ' You are something else you know that ? ']
['Is it going to rain today ? ', " It's supposed to rain . ", ' I really hate this weather . ', " Well , it won't last long . "]
['Would you like something to eat ? ', ' Thank you . No . I ’ m late for dinner at my house . I really have to go . ', ' Would you like to call home ? ', ' I ’ d appreciate that . ', ' Please use the phone . ', ' Thanks . ']
["You didn't come to work yesterday.What happened ? ", ' I had to look after my son at home . ', " What's wrong with him ? ", ' He has a fever . ', ' Is he getting better now ? ', ' I think so.Thank you . ']
['How are you doing , Christopher ? ', " To be honest , I'm really fed up with work at the moment . I need a break ! ", ' Are you doing anything this weekend ? ', ' I have to work on Saturday all day ! I really hate my job ! ', ' Are you available on Sunday ? ', " Yes , that's my only day off until Thursday . ", ' Ok , well , my friends and I are planning on going to the beach on Sunday . We tend to leave around noon whenever we go anywhere , so you could still sleep in . Do you want to come with us ? ', " That'd be fantastic ! Which beach are you going to ? ", " It's a quiet beach just about an hour outside of the city . ", ' What should I bring with me ? ', " We've got plenty of inflatables , but if you want to sit on a chair , you'll have to bring your own sunlounger . ", ' I can just use my beach towel . I love lazing around in the sun . ', ' Do you like surfing ? ', " I've actually never tried . Do you have a surfboard ? ", " We've got a few . I can teach you how to surf on Sunday . It'll be fun ! ", " I can't wait ! It sounds like we're going to have a great time . How much money should I bring ? ", " You'll just need roughly $ 10 for food and gas money . My friend is driving , so we usually all chip in a few dollars for gas money . ", ' Ok , where and when should I meet you ? ', " We'll pick you up at your place at noon . Be there or be square ! "]
['Are you sure this is the right restaurant 。 ', ' Positive 。 ', " You don't think you could be wrong ? ", " I'am absolutely sure I'm right . ", " I don't know . It looks a little wrong down . ", ' This is right . There is no doubt in my mind . ', " You're hundred percent sure you want to eat here ? ", ' Check and double check . ']
['Could you help me prepare for my presentation on Friday ? ', ' I would love to help you prepare for your presentation . ', ' I hate to ask you to do something like that . ', ' This will not interfere with my work . I promise you that . ', ' When could we get together ? ', ' I could easily give you some time tomorrow night . ', ' Would you like to meet me at the coffee house next door ? ', ' Yes , and could you write down anything you might be having trouble with ? ', " I'll come prepared . ", " Goodbye until then . I promise you that you'll do well after we meet . "]
['But his wife has wide relations . You may ask her for advice . ', ' Stop talking about her . She gives me goose bumps . I never wish to be in her sight . ', ' She is pretty . Many men praise her highly . ', ' Many people , many tastes . She looks pretty , but the way she speaks gives you goose bumps . I feel sick of it . ']
['I heard you were teaching English over there.Tell me about it . Did you like it ? ', ' Oh , yes , it was very interesting . ', ' What were the schools like ? ', " Oh , I didn't actually teach in the schools . I taught after school . I taught in English institutes . ", ' But you taught children , yes ? ', " Yes . That's right.But children in Taiwan are very different from children in America.At least as far as studying is concerned.Many children in Taiwan go to special institutes after school . ", ' They actually study after school ? ', " That's right.After their school day is over , they go to a special institute to study math or English.They are very serious about learning over there . ", " Hmm . That sounds pretty oppressive for the kids . Don't they ever relax ? ", " Of course they do.You know , Eliza , before I went over there I thought the same thing . I thought that maybe kids in Taiwan study too much.But now that I've worked there , and taught them , I feel it is a good thing.Their parents are very concerned about their education . More than American parents are . And that is good . American kids don't study enough . ", ' Asian cultures value learning very much . I know that . ', " So it was interesting for me to see parents very concerned about education.They would come to me after the class and ask how their son or daughter was doing . I don't think that's a bad thing . I think it's a good thing.In America , too many parents don't pay attention . ", " But aren't the kids tired out ? I mean , they go to school all day , and then they go to school in the evening too . ", ' As an English teacher , I tried to make the lessons as fun as possible . I tried to have a good time with my classes . The students often enjoyed it.And if the students enjoyed it , they learned more . So it was a good experience . ', ' Are the kids in Taiwan very obedient ? ', " That's a stereotype we Americans have.We think that Asian kids are very obedient and quiet.But it's not true . There are plenty of naughty kids too . ", ' Hmm . I know you taught in Costa Rica also.Which did you like better--Costa Rica or Taiwan ? ', " I don't know . In Costa Rica , I taught adults.So it was a very different thing . So I really can't compare . "]
['the dinner was really good . It knocked my socks off . ', " that's very kind of you to say so . Let's try some after-dinner wines . ", ' great . Sweet wines are my favorite . They always make a great finish to a decisions meal . ', ' do you prefer brandy or ports . ', ' port , please . ', ' excellent choice . I love its smooth flavor . ', ' the port is exquisite . It must have spent years aging in barrels . Am I right ? ', ' yes . You always have a good nose for wines . ', ' next time we are about to dinner we should try some Canadian ice wine . ', " oh , what's that ? ", " it's made from naturally frozen grapes . ", ' why not ? It sounds great . ', " oh , here's to your health . ", ' thanks . Cheers . ', ' cheers . ']
['Hey Mike . What are you doing tonight ? ', ' Nothing planned . How about you ? ', " Work is kicking my ass . I'm so stressed . Let's go grab a drink . ", " I'm always up for a drink . To tell you the truth , it's been quite stressful here too . ", " I say we get drunk tonight . I don't want to think about all this stuff . ", ' But we have to work tomorrow . ', " We won't stay out too late . I just need to forget about work . ", " I hear ya . Let's do it . "]
["My wife and I didn't used to spend this much money . ", " What's changed ? ", ' My wife has been pregnant for 7 months . ', ' I see . I guess diapers and baby food are expensive.Bringing up children is not easy . ', ' My wife will be going back to work soon . ', ' You should have more money then . ', ' Yes.We will need milk powder and bassinet . ']
["We came too early . There're still three hours before the performance starts . ", " I know . Sorry , I shouldn't have rushed you , but I just couldn't stay at home and wait . ", ' Never mind . What about taking a look around the theater ? ', " Why not ? I'd love to do that . ", ' Here we go . There is a museum of the Beijing Opera art . ( They come to the museum of the Beijing Opera art . ) ', ' Wow . Look at this . So delicate and beautiful . Did ancient Chinese people really wear them ? ', ' Not really . They are just opera costumes . Do you like the embroidery ? ', ' I surely do . They must have had advanced machines in ancient China to do that . ', ' No , no , no . They are all handmade , girl . You know , the ancient Chinese women were supposed to be good at needlework . ', ' Unbelievable ! I could never do that . ', " Very few can . That's why these clothes only appear in the museum . ", ' Listen ! Some people are singing outside . Is it the opera ? ', ' Oh , yes . I heard there was an opera fans club . They are probably practicing now . Wanna have a look ? ', " Yes , let's do it . ", ' Follow me . Make sure not to interrupt them . ', " Of course not . We don't do that . "]
["I'm worried sick that she might leave me one day . ", " I'll teach you how to keep her . ", ' Tell me , please . ', " After you've solved this problem for me . "]
['Anna , that outfit looks wonderful on you ! The color goes with your trousers perfectly . ', " Thanks , Carla . That's quite a compliment coming from you . You always dress so tastefully . ", ' Well , that dress certainly shows your good taste . It must have cost a lot . ', ' No , not much . I got it on sale at the mall - 60 % off . ', " Really ? You're an amazing bargain hunter ! Next time there's a sale , promise you'll let me tag along with you . ", " It's a promise . "]
['Well , how did you enjoy your seaside trip ? ', ' It was fun , I tell you . ', ' Tell me about it , will you ? ', ' Well , we drove through the valley on our way there in the morning . It was a magnificent sight ! ', ' Did you stop at the Fall for some pictures ? ', " Sure , we wouldn't miss that for anything . After that , we took a short cut to the park . There was very little traffic , so we got there in less than an hour . ", ' You were lucky then . ', ' Yeah , we spent the whole morning under the tall trees . We had our picnic there , too . ', ' What did you do after that ? ', ' We went for a swim in the sea . That was the biggest part of the day . Just look at my nice tan ! ', ' So you must have had a busy and enjoyable day yesterday . ', ' Yes , you are right . And I was so tired out that I fell asleep on the way back . My muscles are still stiff from the swim yesterday . ']
['Where can I buy textbooks ? ', ' First , you need to have the list of books for your class . Do you have that ? ', ' Yes , I have that . ', ' Well , when you have that , you can take it over to the bookstore . Can you find it ? ', " No , I don't know where the bookstore is . ", " Just pass the gym and it's the first door on your left . Were you aware that you can also turn in your old textbooks for money ? ", ' Really ? How can I do that ? ', ' Take your used textbooks with you and give them to the representative near the entrance . He will pay you for them . Are you going today ? ', " No , I can't make it today . ", ' I could help you with buying your books if you meet me there at 1 ', " No , thanks . I'm good . ", " I'll see you later then . Have a great day ! "]
["I don't like the merry-go-round . ", ' But , I want to ride it , Daddy . ', " Ok , I guess it's worthy of two yuan . ", " Great . Let's go . "]
['Hey Lydia , what are you reading ? ', ' I ’ m looking at my horoscope for this month ! My outlook is very positive . It says that I should take a vacation to someplace exotic , and that I will have a passionate summer fling ! ', ' What are you talking about ? Let me see that ... What are horoscopes ? ', ' It ’ s a prediction of your month , based on your zodiac sign . You have a different sign for the month and date you were born in . I was born on April 15th , so I ’ m an Aries . When were you born ? ', ' January 5th . ', ' Let ’ s see . . . you ’ re a Capricorn . It says that you will be feeling stress at work , but you could see new , exciting developments in your love life . Looks like we ’ ll both have interesting summers ! ', ' That ’ s bogus . I don ’ t feel any stress at work , and my love life is practically nonexistent . This zodiac stuff is all a bunch of nonsense . ', ' No , it ’ s not , your astrology sign can tell you a lot about your personality . See ? It says that an Aries is energetic and loves to socialize . ', ' Well , you certainly match those criteria , but they ’ re so broad they could apply to anyone . What does it say about me ? ', ' A Capricorn is serious-minded and practical . She likes to do things in conventional ways . That sounds just like you ! ']
['Oh , my god . How can you stand living in such a messy dorm ? ', ' Our place is spotlessly clean , compared with others . ', ' Have you even tried to clean it once since you moved in at the beginning of the semester ? ', ' In fact , I just swept the floor three days ago . ', ' I think we need to restart the dormitory sanitation inspection system . ', ' I bet nobody will care about it . ']
["Then I'll take them . How much ? ", ' $ 120.The small gift box is complementary . ', ' Here is $ 150.Keep the change . ', ' Thank you ! Have a nice day ! ', ' You too.Bye . ']
["You shouldn't have told her the truth.What can we do now ? ", " I'm sorry , It's all my fault . ", " You are always like this . I've told you many times not to tell her . ", ' Sorry , I had no intention . ', " It's too late to say sorry now.Oh , what am I going to do ? ", ' I know I was an idiot , But if there is anything I can do to make up , Please do tell me . ']
["Are you alright , Ethan ? You don't seem to be as cheerful as you normally are . ", " To be honest , Ava , I've just had a really bad day . ", ' What happened ? ', ' First , I slept through my alarm and ended up two hours late to work . ', ' What did your boss say ? ', " He told me that if I showed up late one more time , he'd fire me . He's so mean ! ", " That's horrible . Was that the first time you'd shown up late to work ? ", ' That was my second time . The first time , I was in a car accident . ', ' Is your boss Chinese ? ', " No , he's from Australia . Before I met him , I thought Australians were supposed to be relaxed and easy-going . I had no idea he'd be so fussy about things . ", ' What are you going to do ? ', " I think I'm going to look for another job . I need to find a boss that is a bit more sensitive and optimistic than my current boss . ", ' That sounds like a sensible plan . Do you want me to help you with your job search ? ', " That's very generous of you . Thanks for the offer . ", " Don't mention it . That's what friends are for ! "]
['Victoria , you are back from vacation ! How was it ? ', ' To tell the truth , I feel tired . ', ' How come ? ', ' I had to visit all my relatives . ']
["Hello , Dora , I haven't seen you for a long time . Where have you been ? ", ' I didn ’ t go anywhere . I stayed at home . ', " What's up ? You look unhappy . ", ' Nothing . I just feel very lonely in this city . I miss my family . ', " Oh , I know . Sometimes I have the same feeling with you . But you'd better not be so emotional . ", ' Can you stay and accompany me for a while ? ', ' Sure , no problem . You can call me any time you are alone from now on . ', ' Thank you so much . You are so sweet . ', ' Not at all . We are friends . ']
['So you said you and Amanda met through a mutual friend . How did it happen ? ', ' Well , my roommate was friends with Amanda , so he introduced us . ', ' Did he tell you what she was like first ? ', ' Yes , he described her to me , and she sounded like my type . ']
['Sorry , sir . I came late because I had to send for the doctor for my grandfather . ', ' I do sympathize with you , I assure you . ', ' Thank you , sir . ', ' I hope your grandfather will recover soon . ']
['I heard many stories about your brother . ', " He's a hero in our town . ", ' What does he look like ? Is he handsome ? ', " Yes , indeed , People say he's the smartest young man . "]
["I've never met anyone like Clyde before . ", " He's such a buppie-a black yuppie . Black people come in all shapes and sizes . Just check out the party . ", ' Wow ! There are so many different people here . I expected mostly athletes and rappers . ', " You'll find some of those here , too . But not if you don't shake it up ! There's an African saying , “ If you can talk , you can sing ! If you can walk , you can dance ! ” ", " Then I'll just shut up and sit down ! "]
['What book is that ? ', ' I just bought a new atlas . I ’ m looking this map of the world . Look at Russia ! That ’ s a vast country . ', ' Canada , china , and the use are huge too . ', ' There are several tiny countries in the world too . Countries like Monaco are smaller than many cities . ', ' Those small countries are microscopic compared to Russia . European countries are relatively small . France looks quite big in Europe , but compared to many countries in other continents , it ’ s not very l ', ' Britain is half the size of france , but great Britain is still one of the largest islands in the world . ', ' The thing with large countries is that often they have vast areas of land that are useless or hardly used . Russia and Canada have enormous areas of ice and forest . ']
['It ’ s going to a volleyball match between the economic department and foreign language department this afternoon . Are any of you keen on volleyball ? ', ' Sorry , I ’ m not a volleyball-fun . I ’ d rather play football . How about you , Mr . Wang . ? Are you interested in volleyball ? ', ' I ’ m afraid not . My favorite is boots-running . I don ’ t care about games . ']
['Tonight is a party night ! What drinks do you think we need ? ', " Well , not everyone wants to drink beer . Make sure there are some soft drinks and juice . Nothing's as refreshing as iced drinks on a hot day . ", " I don't think we need too much in the way of soft drinks , Two super bottles of Cola should cover everyone . What about wine ? ", ' Just buy a cask of wine . Have you bought ice yet ? ', " No , once I fill the tub with beer , I'll get the ice . The beer will be cool if you put the tub under the ice . The cooler , the better . ", " I think a bottle of champagne would be a good idea . It's appetizing and tasty . ", " Well , if you say so . Personally speaking , I'd rather die of thirst than drink champagne . "]
['Hi , John ! I haven ’ t seen you for ages . ', ' Hi ! Yes , it ’ s been a long time . I ’ m really glad to see you . ', ' I ’ m glad to see you , too . How ’ Ve you been ? ', ' Just fine . How is everything with you ? ', ' Not bad . I finally bought a house . It ’ s an old one , but built really solid . It is close to here . Do you want to come over for lunch ? ', ' I ’ d like that , but I ’ m flying home this afternoon , and I told my parents I ’ d meet them at the airport for lunch . ', ' OK , next time you ’ re here . ', ' That ’ s a deal . ', ' I heard that you moved to Florida . ', ' Yes , I ’ m in Titusville . The space shuttle is launched from near there . I ’ Ve seen a lot of space shuttle launches . ', ' Tell me more . ', ' The shuttle launches are beautiful . I saw one that took off at midnight . The whole sky got bright . ', ' Sounds great ! ', ' I ’ m pretty happy living there . ', ' I want to see Disney World , Sea World , Universal Studios , and Weeki-Watchee Springs . ', ' I ’ Ve been to all of them . ', ' I ’ m jealous . I ’ Ve never been to Florida . ', ' The Sunshine State certainly is worth visiting . Come down for a vacation sometime . I ’ ll take you to Disney World . ', ' That sounds great ! I ’ ll take you up on that invitation . ', ' I hope you do . And keep in touch , OK ? ', ' I sure will . ', ' Here ’ s my business card . Send me an email once in a while . ', ' Count on it . And here ’ s my card . Don ’ t hesitate to call me anytime . ', ' Thank you . I ’ d better get going . I don ’ t want to be late for lunch . Mom would worry . ', ' Well , I ’ m really glad we bumped into each other . Have a good trip . ', ' Take good care of yourself , Mary . ', ' I will . Good-bye . ', ' Bye-bye ! ']
["I can't decide what I should do . ", " What's the problem ? ", ' Should I date Tom or should I date Harry ? ', " That's easy . If I were you , I'd date me ! "]
["I'll tell you something that's good about action movies . The special effects are great ! ", " But they are so silly ! They're not art ! ", " That's just your personal prejudice . Do you know who was the director of the movie Titanic ? ", ' James Cameron , of course . ', ' Well , did you know he was also the director of The Terminator ? ', " Well , nobody's perfect ! "]
['Can I help you ? ', ' Yes . I am interested in applying for graduate school in America . ', ' We have some catalogues from U . S . universities . You may check in the reference stacks over there . ', ' Can you recommend some universities with good graduate schools ? ', ' Well , generally in the U . S . each university has its own outstanding fields . But the graduate school accepts no applications after January 29th . ', " Oh , no . It's already February 5th . ", ' So you have to apply to begin the first semester next year . ', ' I will think about it . ']
["Can you be serious for a moment , we've been dating for 6 months now , I really like you . I'd like to take a relationship to the next level . ", ' So what are you trying to say to me ? ', ' It feels like you are not dedicate to our relationship . It seems like you treat it as a just casual dating . ', ' How should I say it ? ', " I don't want to be like this . I think we should get step further . ", " It has only been 6 months , our relationship hasn't had a chance to maturate . We are still have some hurdle we have to jump over . ", ' Like what ? ', ' Last week I saw Brain kissing you on the cheek . ', ' It was only the cheek . ', ' That is ok , then ? Starts on the cheek ? pretty soon you french kiss in the back on his car . ', ' Oh , that is ridiculous . ', ' So is it ok if I kiss other women on the cheek ? ', ' Definitely not . ', ' You see , we still have hurdle . ']
['How did you get around over there ? Did you rent cars ? ', ' No , that would be too expensive . We used the train system.We bought a special pass called a Enrail pass . It lets people use the train wherever they want , as often as they want . ', " I've heard about Enrail passes.So those Europeans really depend on trains a lot . ", ' Yes , they do . I wish we Americans had a better train system . ', ' I know . Our train system is lousy.And besides , Americans love their cars too much . ', ' I agree . And probably the automobile companies are too powerful.They never allowed the government to develop trains . ', " It's too bad for the environment . So much pollution from cars . ", " Americans love cars for different reasons , I think.One reason is that we are very individualistic.And cars are a very individual way of getting around.Americans like the freedom of driving around by themselves.They don't want to ride in a train or bus with a group of people . ", ' Yes , I agree . I think it is a cultural characteristic.It would be very hard to get us Americans to change this.But you know what ? Probably , in the future , Americans will have to change . ', ' Why do you say " have to " ? ', " Because the earth's environment can't tolerate cars forever . I think cars are already causing global warming.When the problem gets more serious , world governments will have to start limiting car use . ", " Maybe you're right . They will have to develop alternative transportation.But it will be hard in America . Too many people are used to cars.Even in our movies cars are very important . ", " Wow ! I didn't notice the time.It ' s almost noon . I have to get home . ", ' Do you want me to give you a ride ? ', ' No , no problem . I have my car in the parking ramp around the corner . ', " Alright.Well , I'll stay here and have another coffee . Nice running into you . ", ' See you around . ']
["It's raining outside , Catherine , it's too bad.What ' s the weather like in your hometown ? ", " It's very hot , the temperature is often over 40C . ", ' Do you like the weather in Seattle ? ', " Not really.But I like it in spring and fall . I don't like it in winter . ", ' Why ? ', " The winter is very rainy , I don't like the rainy day . ", ' What about the weather in Boston ? ', " I lived there for three years . I like summer but I don't like winter . ", ' Is it very cold in winter ? ', " Yes , it is.But it's nice in spring and fall . "]
["I'll help you with your homework . ", ' I appreciate that . ']
["That's a cool jacket . Where did you get it ? ", ' I bought it when I was on vacation in Nepal . ']
['I want to say goodbye to everyone . ', ' You ’ re leaving so soon . When are you off ? ', ' I ’ m catching the nine fifteen train tomorrow morning . ', ' how about I come and see you off ? ', ' You really don ’ t need to . ', ' Ok . I ’ ll miss you . I hope we can see each other again soon . ', ' I hope so , too . Thank you , Lily . Thank you for everything . ', ' You ’ re welcome . ', ' Please say goodbye to the rest of the family for me . ', ' Ok . Take care . I hope you have a good journey . ', ' Thank you . Remember to look me up if you ’ re ever in Washington . ', ' Of course . I will . ', ' Goodbye , then . Thanks again for everything . ']
['Herman , why are you so excited ? ', ' I have met a beautiful girl . ', ' Have you fallen in love ? ', ' Yes . At first sight . ', ' Can you describe the situation at that time ? ', ' At that time her back was ramrod straight as she sailed by , her tone is best , neither over-passionate , nor too cold . ', " What's her outlook ? ", ' She was pretty , her hair was the color of rich dark chocolate , waving gently to her shoulders . Her complexion was clear and golden . ']
['Where is Tom ? ', ' He is in the bedroom and fallen asleep . ', ' What ? It ’ s only 9 p . m . Now . Why today he went to bed so early ? ', ' He ran four miles and came back dead beat . ', ' Oh , I see . ']
['What an attractive blouse , You look so pretty in this blue dress ! ', ' Really ? Thank you . I bought it in Spring Street yesterday . ', " It's very nice.It goes well with your skirt . ", " Thank you.It ' s very nice of you to say so . ", ' Not at all.This dress certainly shows your good taste . ', " That's quite a compliment coming from you . "]
['What college are you attending ? ', ' I am in Nanjing University . I am a junior . ', ' Why did you choose to attend that college ? ', ' Because it enjoys great reputation and it is located in my favorite city Nanjing . ', ' What kind of college is it ? ', ' Ii is distinguished for the strength of law and foreign languages studies .. ']
['How do you like the play ? ', " It is very dull , and the production isn't very satisfactory , either . ", " You're absolutely right . I think the acting could be better . ", ' To be fair , both the costumes and scenery are marvelous . ', " Maybe you're right . But I really don't like it . ", " Well , we'd better go to a musical comedy next time . I think the one we saw last month was very good . ", ' Yes , they had constant changes of scene , and I love variety . ', ' Me , too . I hate to sit there and look at the same stage scenery one scene after another . ']
['Which team has won ? ', ' Neither . The game ended in two all . ', " But I still think AC milan's defence seems better organized . ", ' But the Brazilian is tougher . ']
['I am really tired of Terry . ', ' Oh , but I suppose he has lots of talents . ', ' He is a bootlicker . I suppose that is because he is quick on the uptake . ']
['What are you studying all day long for ? It ’ s summer vacation ! ', ' I know ! I hate it ! But I ’ m taking this crash course in math . ', ' Why ? ', ' I have to take my exams for getting into the university , so I need to prepare . ', ' Do you think it will help ? ', ' It has to ! I ’ Ve been studying every day , eight hours a day ! I don ’ t know , but the school has a great success record . ', ' Hmm ... Maybe I should sign up too . ', ' I ’ ll pick up an application form for you at school tomorrow . ']
['Have you seen the new Hannibal Letter movie ? ', ' Oh , yes . You ? ', ' Yes . What did you think of it ? ', ' I thought it was better than the others-I really liked it.What did you think of it ? ', " I liked it , too . It was scary , but not disgusting . I always enjoy watching Anthony Hopkins . He's brilliant . ", " Mmm . That's what I thought , too . And I always enjoy watching Anthony Hopkins . ", " Oh , yes , he is brilliant . What's the name of the young actor ? ", ' Hum , Edward Norton , or something like that . ', ' Yes . He was excellent . They worked well together . ']
['Mary seems depressed . What ’ s the matter ? ', ' She didn ’ t expect to get a kick in the teeth after a day ’ s hard work . ', ' Poor girl ! ']
['Hi charles , I want you know that i finally found an apartment in haitian . ', ' You did ? that is great ! ', ' Yeah , I am having a party this saturday night , a sort of house warming , and i want to invite you . are you busy ? ', ' No i am free , i will be there , what time the thing starting ? ', ' Around seven . ', ' Ok , great , should i bring anything ? ', " No , but thanks for offering , actually could you bring some fold-up chairs for people if you have any ? I am afraid not everyone's going to have a seat , do you have any ? ", ' sure , I will be happy to bring a few , what is the address ? ', " Don't worry , I will come to pick you up at about six thirty . ", ' Got it . ']
['Did you watch the Oscars on Sunday night ? ', " No , but I heard about that Angelina Jolie and Brad Pitt didn't attend . ", ' Yes , that was surprising . I heard that they got into a fight and then decided not to go . ', ' They must be the most famous celebrity couple in Hollywood . ', " They're also one of the richest couples . They have so much money and they can buy almost anything they want . ", ' I also heard that Tom Cruise and Katie Holmes made an appearance at the Oscars . ', ' Did either one of them win an Oscar this year ? ', " I think Tom might have been nominated for one of his films , but I don't think he won anything . ", " Tom Cruise may be handsome , but I think he's a bit crazy , don't you ? ", ' Yes , his marriage to Katie is actually quite scandalous . ', ' I still think that they only got married to get more publicity for their movies and themselves . ', " People in show biz can have such an easy life ; I don't know why they have to make it so complicated . ", ' I would never want to be a celebrity because the paparazzi would also be after you . ', " That's true . I guess it would be difficult to have people taking pictures of you everywhere you go . ", " Thank goodness we're not rich and famous ! ", " Being famous , I can do without , but I wouldn't mind being rich . "]
["Oh , my God ! I've been cheated ! ", ' What ? What did you buy ? ', " It's a brick ! I can't believe how stupid I was . Damn it ! ", ' What is it ? Why did you buy a brick ? ', ' There was a guy on the sidewalk.He had three new boxes , Panasonic video camera boxes.He said he had to get rid of them quick . ', ' And ? ', " So he said he'd sell me one for twenty dollars . A four-hundred-dollar camera for twenty bucks . ", " And it's a brick ? ", ' Yes . ', " I can't believe how stupid you are . Why didn't you open the box ? ", " I wanted to . But he said , no , the box is still in its plastic wrap from the store.If it's opened , other people won't believe it's new . ", ' So he had the boxes wrapped in plastic . ', ' Yes , it was the kind of perfect plastic wrap that comes with new products.Look , it even had a bar-code price sticker on it ! It looked brand new . ', ' But why would a guy be selling new video cameras for twenty dollars ? ', ' He said he had to get rid of them . They were stolen . ', ' Aha ! Now I understand.You were trying to buy stolen goods on the sidewalk.So , what I think is , you deserve to get cheated ! ', " C'mon , don't blame me ! I thought it was a new camera . We could use it.We were even thinking about buying a camera . I don't understand how he could have such a perfect-looking box . ", " That's no problem.He just has a friend who works in a shop that can do plastic wrap . That's easy.And probably it's the same shop he got the boxes from.Maybe his friend works in an electronics store . They sell video cameras there . Probably they had a couple video camera boxes lying around.So they get the idea of wrapping bricks to sell to fools like you.Twenty dollars a brick . That's a good profit if they can sell enough bricks . ", " You're right , Sarah . I was a fool . I can't believe it . How could I fall for such a trick ? "]
['What do you like to do in your spare time ? ', ' I am a girl of many interests . I like dance , chess , collecting stamps , travelling and taking photos . ', ' What kind of dance do you like ? ', ' I like rumba and tango . ', ' Great . I am not interested in Chinese chess . It is too difficult for me . ', ' You can learn Chinese checkers or military chess . Both of them are much easier . ', " OK , I will try . As for stamp , don't you think it is an expensive hobby ? ", ' Yes , it is . But it is full of fun and knowledge . What about you , what do you like to do as hobby ? ', ' I like gardening . I take care of them everyday . I like those flowers and the swing in my garden . If the weather is nice , I would like to lie on the lawn . ', ' Sounds pleasant . ']
["I've heard of ground-level ozone but can you explain what it is exactly ? ", " Yes , it's one of the main air pollutants . Factories don't emit it directly into the air . It's actually formed when nitrogen oxides and VOC emissions come into contact with heat and sunlight . ", ' Sorry ? What does VOC stand for ? ', " Oh , Vous are ' volatile organic compounds ' . That's a technical term for solvents or other chemicals found in things like paint . ", ' So , what damage does ozone do to the environment ? ', " Well , it can cause smog , which can affect people's health - especially people with breathing difficulties . "]
['I heard Tom was caught stealing something again in the supermarket . ', ' Really ? He deserves it ! They should teach him a good lesson . ', ' But the word is his brother would go bail for him . Last time it ’ s his father who went bail for him . ', ' Then he is really lucky . ']
["Do you have the day off today ? How come you're not at work now ? ", " I don't have the day off . Our labor union is staging a nationwide strike today , all of the workers in our department are supporting the labor union by participating and not going in to work this week . ", " Are you serious ? Why would they have to go to such extreme measures like a strike ? Doesn't your company have a pretty good corporate image ? I'll bet the folks at headquarters are going nuts over something as serious as a strike ... ", " It happens quite often , actually.Whenever there arises a dispute between the union and the executive group , the first thing they do is to call a strike . Usually it only lasts a day or two before both sides can come to an agreement and we start work again . Anyhow , it's a nice , unanticipated holiday ... "]
['Are you going to take the job ? ', " I'll have to sleep on it . "]
['We ’ re going to the movies . Will you join us ? ', ' I ’ m very sorry I can ’ t . ', ' Why not ? ', ' I ’ m afraid I have some business to attend to . ', ' Then would you like to have lunch with us ? ', ' I ’ d love to but I have to help John with his math problems right now . ', ' Would you like me to give you a lift ? ', ' No , thanks . His home is not far and I can walk there . ', ' Come on . It ’ s no trouble at all . ', ' Ok , thank you . ']
['What sports do you think women excel at most ? ', ' I think women excel in every sport except the ones that are taboo for us to join in , like football . ', ' I mean which ones are they better at than men ? ', " Why do you care ? Women and men are different all around . I don't think they can be compared . ", " That's a good point . Let me change my question . What sports do women like best ? ", ' Well , I know some women who love golf and I know others who love contact sports . ', " Are you saying that women can't be generally categorized ? ", ' Are you suggesting that anyone can be ? ']
['I am going on my first date tonight . Can you give me some suggestions about what to wear ? ', ' Well , I think you look very pretty in your polka dot purple dress with your hair piled at the rear . That makes you very graceful and mysterious . ', " Yeah , that's a good idea . Let me try it . ", ' Remember to match it with your glittering star-shaped necklace . Very attractive on formal occasions . ', ' Do I look more mature in the highheel shoes ? ', ' Sure , more elegant and taller . ', ' I shall wear light make-up instead of heavy . The face powder will lighten my skin color . ', ' If I were your date , I would be so charmed by you . ', ' Thank you . ']
["How's your new car ? ", " Perfect ! Couldn't be better . ", ' You made a good choice , then ? ', " It's just what I want . ", ' No regrets . ', ' I am really pleased with it . ', ' I am glad you are happy . ', " It's super . "]
["Hey , let's eat out tonight . ", " What's the occasion ? You won the lottery ? ", " No . Just want to relax a little bit . You don't have to win the lottery to relax , do you ? ", ' Well , I am kind of broke . ', " Come on . It's on me . ", " Really ? It's very nice of you . ", " Don't be silly . I'll take you anywhere you wanna go . ", ' Wonderful ! You know what ? I wish you wanted to relax everyday . ', ' Dream on ! ']
['Do you mind retiring earlier ? ', " No , I don't mind in the least . I want to do something of my own . What about you ? ", " I do . I don't know what to do after I retire . I'd like to work till I drop . "]
['who is your favorite NBA star ? ', ' Kobe Bryant , of course . ', ' Kobe ? I know him , the key guy of the Lakers , a heck of a NBA player . He is on fire when he breaks through enemy defense . ', ' He is competent both in driving the lane and shooting jumpers , but what really makes him formidable is his ability to switch up and dribble with his left hand . ', ' Maybe he is not good ay rebounding ? ', ' indeed , no man can be perfect . He is just so-so in crashing the boards . Usually he plays shooting guard . Rebounding might not be his strong suit . ', " Kobe came to Beijing during this summer's Olympics . Did you go to the match between China and USA ? ", " who wouldn't ! My friend Lee went so far as to get an autograph from him . ", ' well then , what are your spoils ? ', ' well , nothing more than a jumble of photographs . ']
['Can I help you ? ', ' Have you got the latest ONXIU magazine ? ', " Yes , but it's checked out . ", ' What a pity ! I missed it again . ', " It's popular you know . You want to reserve it ? ", ' Yes , please . ', ' Fill out this form and we will send you a note when we get the book . ', ' Thank you . What shall I do when I check out these books ? ', ' Take the card , and fill in your name and library card number . ', ' Thank you so much . ']
['What do you like to do with your free time ? ', ' Study English . ', ' You mean you like to study English ? Why ? ', ' It gives me great satisfaction . ', " Studying English wouldn't give me any satisfaction.It ' s hard work . ", " I don't mind the work . I think it's worthwhile . "]
['Good news ! ', ' What is it ? ', ' The state of economy is starting to go up in our country . ', ' That ’ s just the short in the arm we need . ']
['Mary ? Are you still there ? ', ' Yes . What do you want ? ', ' Did your bid win ? ', ' What do you care , dork ? ', " Hey ! I'm trying to be nice , and you still want to fight ! Did you get the statue or not ? ", ' You mean fat boy ? ', ' Sorry . I take that back . I mean the copper Buddha you wanted . ']
['Do you mind if I sit here ? ', ' Of course not , help yourself . ', ' What are you studying ? ', ' I have a test tomorrow . ']
['The final examination will be held at the end of this month . Have you made good preparation ? ', " Sure . I've reviewed all the lessons I have learned this academic year . ", ' Are you sure you can do well this year ? ', ' I am 100 % certain . ', ' According to what you did last time , I have my doubts . ', ' I am sure I can get a 95 this time . ']
['He always likes to say something as if all his geese are swans . ', ' I know this characteristic of him . So I never think seriously of his words . ', ' Yeah . This is a clever way to be in contact with such a person . ', " It seems that you don't like him . ", ' You like to communicate with him ? ']
['Can we have two tickets for seven thirty ? ', ' Yes , and would you like to have seats in the front or at the back ? ', ' In the front , please . ', " That's 35 yuan each . ", " Thank you . And what's on tomorrow ? ", ' Tarzan . ', ' Can we get tickets now ? ', ' I am afraid not . Tomorrow is premiere . ']
["That radio's pretty loud . Could you turn it down , please ? ", ' Sorry . Was I disturbing you ? ', " Yes . And something else , please don't borrow my clothes without asking . ", " Sorry . I guess I wasn't thinking . I won't do it again . "]
['Does bullfight interest you much ? ', ' Absolutely ! Everything that ’ s thrilling turns me on . ', ' So I ’ Ve got two tickets to the latest show but I need a little favor from you . ', ' What is it ? ']
["I'm afraid I spilled coffee on the tablecloth . ", ' Oh , never mind . I am just going to do the laundry today . ', ' I want to apologize . Is there anything can do for you ? ', " It really doesn't matter at all . I never did like it anyway . "]
['I ’ m glad to have had the opportunity to meet you here . ', ' I trust you ’ re keeping well ? ', ' I ’ m doing great , thank you . ', ' So we can get down to business . ']
['Whoa , look at all those ice cream choices ! ', ' Yes , that is a lot of choices . What is your favorite ? ', ' I love anything with chocolate the best . ', ' I like chocolate myself . ', " Is there any kind of ice cream you don't like ? ", " I really don't like any ice cream with nuts in it . ", " I haven't ever cared for that myself . ", ' Have you ever had garlic ice cream ? ', ' That sounds absolutely disgusting ! ', " It was . Let's stick with the regular choices today , though . "]
['Hi Colin . How are you feeling today ? ', ' Oh , I feel ok but I ’ m still very tired . ', " It's probably jet lag . ", ' I think so . One minute I feel quite awake , and the next I feel very tired . ', ' Do you want to visit any tourist spots in the city ? ', " Oh yes , I'm very interested in Chinese history so I ’ d like to visit the Summer Palace . ", ' Good idea . I ’ d be very happy to go there . ']
['Stephanie ! Did you just get to school ? But you were up and about when I left the dorm this morning ! That was about an hour and a half ago . This happens all the time ! Why do you always take so long ', ' It ’ s a skill . What can I say ? I don ’ t know why , I just have a long routine . ', ' Please explain because it makes no sense to me . How can a girl ’ s routine be so complicated ? You get up , you shower , you get dressed , you brush your teeth , you ’ re out the door . Half an hour , tops . ', ' Jacob , you have the luxury of having a haircut that rarely needs styling . I don ’ t . I have to set aside about an hour and a half to get ready in the mornings . Every day , I wake up and head straight for the shower . Every second day , I wash my hair . If it ’ s a hair-washing day , I frequently need to wash my hair twice because it gets really oily . Then I usually put in a conditioner and have to rinse that out too . Because my hair is so long , I seldom manage to take a shower in under twenty minutes . Afterwards , I often put on a pot of coffee and get dressed while I wait for it to brew . I take a long time to get dressed in the morning . Every now and then I remember to choose my outfit the night before , but usually I do it in the morning . In all , getting dressed takes about half an hour , at which time my hair is now semi-dry so then I have to style my hair . From time to time I ’ ll put my hair up , butoften times I bloody it straight . And then , because of the texture of my hair , I regularly have to flat-iron it to keep it from frizzing . That ’ s another twenty minutes or so . After that , I have my daily makeup routine . ', ' True , I hardly ever see you without your hair done and your makeup on , even when you show up to class in sweatpants . Tell me , how long does it take you to choose that outfit in the morning ? ', ' Not funny . ']
['Did it take you a long time to quit smoking ? ', ' No . I just went cold turkey , and I never smoked again . ']
['How do you do . I ’ m Mark Rancor . ', ' Nice to meet you . ', ' May I know your name , please ? ', ' I ’ m Rose Teller . I think I ’ Ve seen you somewhere before ? ', ' Ah , yes . I remember now.Were you Mr . John ’ s dinner partner last month ? ', ' Yes , I was.You work for 3M , right ? ', ' I did but now I ’ m for Microsoft.How are things with you ? ', ' Good . ', ' May I know what you do ? ', ' I ’ m a fashion designer.Next month , I have a fashion show . I ’ d love it if come . I can get you a couple of tickets.So you can bring a friend if you like . ', ' Sure.That would be great.Good luck . ', ' Thank you . ']
['You like Titanic ? That movie is so cheesy . ', " It's not cheesy ! It's romantic . When it first came out , I saw it in the theaters five times in one week . ", ' Really ? Well the special effects might have been good in 1997 , but when you watch it today they make the film seem really cheesy . ', " Alright , maybe it's a little bit cheesy . But come on , isn't it fun to go to a cheap flick once in a while ? ", ' Actually , I have to admit that you\'re right . I like some pretty cheesy movies too . I love Arnold Schwarzenegger action flicks , especially " Terminator . " ', " Haha , that's definitely a cheesy movie too . Did you watch it over and over again ? ", ' Well ... I saw it only once , but for the next two months when I talked to people , I pretended I was the Terminator . ']
['I see that there are Olympic mascots in your car . ', " Yes . I am very interested in the Olympic Games , and I'm especially excited about 2008 Beijing Olympics . ", ' Me , too . I want to be a volunteer for 2008 Beijing Olympics . ', " That's cool . Care for a little quiz on that ? ", " No problem . I'm an ' Olympic expert ' . ", " Wow , you've talked the talk . Now it's time to walk the walk . Here we go . First , can you tell me something about the ancient Olympics ? ", ' The ancient Olympics originated in ancient Greece . ', ' Good . Why do people name it Olympics ? ', ' They name it after the place where it was first held . ', ' Who started the modern Olympics ? ', ' This question is a piece of cake . A Frenchman named Baron de Coubertin . ', ' What did people call him ? ', " Of course he was called ' the father of the Olympics ' . ", ' What did he do for restoring the Olympics ? ', " He once made a speech on the ‘ Renaissance of the Olympics ' . ", " Well , that's for all . Excellent ! ", " I've told you I'm an expert . "]
['Can we go to the beach on foot ? ', " Oh , it's too far to walk there.We can take a bus . ", ' Is the bus station close by ? ', " Yeah , it's a block away down the street . "]
['I really should be on my way . ', ' Oh , don ’ t go yet . Let ’ s at least have one more . ', ' No , thank you . I can ’ t . ', ' It ’ s too bad that you have to leave so early . ', ' Thank you very much . I had a really good time . ', ' Thanks for coming ! We should meet again sometime soon . ', ' That would be great ! Actually , can I get your phone number , Ella ? That ’ s assuming you don ’ t mind if I call you sometime . ', ' Anytime . You can reach me 5558929 . ', ' ok , got it . I ’ ll call you sometime next week . ', ' Fine . ', ' It ’ s time to go and I hope we can get together again soon . ', ' I hope so , too . Bye ! Ben . ']
['May , could you bring this note to Professor Li for me today ? ', ' Sure , no problem . Asking for leave again ? You have been absent from class five times this semester . ', " I know . But attending Miss Li's class is just waste of time . No more than one third of her students will go to her class . ", " I agree that Miss Li doesn't teach so well . Most students either sleep or do other things in her class . ", ' Yeah , my boyfriend plays the video game every time in class with me . Or I chat with my friends through text messages . ', ' Fortunately her class is just an elective course , not as important as compulsory courses . ', ' Right , so we must spare some time to attend selective courses . ', " But isn't it too impolite to be absent ? ", " What can I do ? I have things to do in Students ' Government . ", ' Oh , I thought you just gave an excuse on this note . ', ' Sometimes I will try various excuses . But this is my last time asking for leave . Or I will have a bad record . ', ' Yeah , besides , your credit will be deducted . That is kind of serious . ', " I have been absented from many classes this semester just because of my work in the Students ' Government . ", " You can't write with one hand and draw with the other . ", " I am thinking about quitting my job in the student government . But before that , I must do my job . Bye . Don't forget about that note . ", ' You can count on me . ']
['Do you know that working overtime in some companies is a regular thing ? ', ' How regular ? ', ' An average ten hours or more a day according to a survey , the worst thing is that the employees get no pay for that . ', ' You are kidding me ? It is against the labor law . They should be aware of their rights . ', ' But these people say nothing about that . They are worried about losing their job because there is surplus in labor force these days . ', ' That ’ s not right , somebody should do something . ']
["Can we have two tickets for the 7:30 showing of ' Beautiful Mind ' . ", ' Sorry , we have sold out the tickets . ', " What's on tomorrow at that time ? ", " ' Beautiful Mind ' will be playing again . And there's also ' Titanic ' . ", " Terrific , that's a wonderful movie , I like it very much . Can I get tickets now for tomorrow ? ", ' Yes , 20 yuan for each . ', ' Two tickets , please . ', ' OK . Here you are . ']
['What would you like to be in the future ? ', ' A teacher . ', " But if I were you , I would be a singer . You've got such a beautiful voice . ", " I wouldn't like to be a singer , but I'd like to become a music teacher to teach children to sing , That dream developed in my mind when I was a child . ", ' Are you sure about that ? ', " I'm quite sure . I've always loved working with children . "]
["Didn't Joe feel it a shame to live on his parents since he has graduated from college ? ", ' He has no sense . ', " If I were him , I wouldn't brazen it out by asking my parents for money . ", " But Joe won't you . "]
['My goodness ! She is thirty seconds faster than the world record in 5000 metres race . ', ' Excuse me , what did you say ? ', ' A Chinese girl has broken the world record in the Olympic Games . ', " That's incredible . I can't believe it . ", ' You have to . It is sure . ', ' How amazing ! ']
['I like small towns . ', ' But many roads are very narrow . ', " Not always , and there're also few cars ! ", ' Yes , because of fewer people . ']
['Veronica ! Veronica ! Veronica ! Are you OK ? ', ' Steven ! What ’ s going on ! Who were those guys ? I didn ’ t know you have a gun ! What ’ s going on ! ', ' I will come clean as soon as we get to safety , OK ? For now , you have to trust me , please ! I would never do anything to hurt you . ', ' Steven , I ... ', ' I haven ’ t been completely honest with you Veronica , I ’ m sorry . I ’ m not a fireman . I ’ m not even from the United States . I ’ m a spy for the Indian government . ', ' What ? Why didn ’ t you tell me before ? What are you doing here ? ', ' When I was a young boy , I used to play cricket my father back in my hometown of Hyderabad . It was a peaceful town , and my father was a renowned chemist . One day , he was approached by members of the CIA , claiming that my father had made the discovery of the millennium in his small lab back at the university where he taught bio-chemistry . I never saw him again . I vowed to discover the whereabouts of my father and consequently joined the Indian Intelligence Bureau . ', ' What does that have to do with those men shooting at us ? Most importantly , why did you lie to me ! ', ' I ’ m sorry , I wasn ’ t supposed to meet you . I wasn ’ t supposed to fall in love with you , but you have to believe me when I tell you that what I feel for you is real . ', ' I can ’ t believe this ! Why are all these things happening to me ! I can ’ t take it anymore ! Let me out of the car ! ', ' Veronica , wait ! ']
['Hey , May . How about getting together for a movie tonight ? ', " Sure . What's playing ? ", ' Well , Let me check the newspaper . What about The Terminal ? ', ' Wow , it stars Catherine Zeta-Jones , my favorite actress . ', ' Well , birds of a feather flock together . I like her too . She was in a lot of dramas . ', ' She is so beautiful and elegant . And she is famous for her fine acting . ', " What's more , she doesn't have scandals . And she likes to take part in the charitable activities . ", ' Who is the director ? ', ' Steven Spielberg . Another superstar . ', " Yes , a legend , also . I still remember , his movies , Jurassic Park and Schindler's List got him nine Oscar awards in 1994 . ", ' Can you introduce the story of The Terminal briefly ? ', ' It tells a romantic and humorous love story . ', ' This is really exciting movie . Lets go to this one . ']
["He's too young for the job . ", ' Give him a chance . ']
['Happy New Year ! ', ' Thank you ! The same to you . ', ' Have you got any plans ? ', " I've been invited over to a friend's . And you ? ", " My roommate's having a party . "]
['What musical instrument do you play ? ', ' I can play the piano a bit . ', ' Then we can have one more program at our party ? ', " No , no . My playing isn't good enough for me to perform in public . "]
['Just make yourself at home . ', ' Thank you . You are cooking up a storm . ', " Wouldn't you like some more chicken ? ", " No , thank you . I'm afraid I can't take in anymore . "]
['Oh you look awful ! What ’ s the matter ? ', ' Oh ! I feel really under the weather . I ’ Ve got a sore throat and a bad cough . ', ' Oh dear . Maybe you ’ Ve caught a cold . ', ' Yes , I ’ Ve had lots of overtime to do recently and I haven ’ t slept much at all . ', ' Well then , you should get some rest this weekend and don ’ t go out drinking . ', ' Yes , I think you ’ re right ! ']
['Hi , Fanny . ', ' Hi , Andy . ', ' Are you feeling OK ? You sound a little tired this morning . ', ' I did not sleep much last night . I really feel bad . It was a crazy night . ', ' What happened ? ', ' I had a bad dream . I was walking alone in the graveyard , and suddenly all the ghosts jumped out of their graves . They began to chase me through the graveyard and shouted that they wanted my blood . ', ' Oh , what a nightmare ! Then what happened ? ', ' My mother woke me up . She had heard me crying out for help . ', ' You have got a great mother . ', ' I felt embarrased . After all , I am 18 years old . Mom gave me some chocolate cookies and a glass of milk . ', ' That sounds good ! ', ' Yeah , but i was afraid to fall back asleep . I am worrying about getting into the University of Michigan . ', ' Me too . But I tell myself that if they don ’ t accept me , another school will . ']
["Hey ! That food was terrific . I can't eat another bite . Are you sure you don't want another dish ? ", " No , I'm full . My stomach isn't growling at me any more . ", " I know what you mean . I'm so full that I can burst . Shall we go then ? ", " I'm all set . Thank you for the dinner , Jack . ", ' You are welcome . ']
['Hey , Maris , are you a part-timer ? ', ' Part-timer ? Is that a new buzzword ? ', ' Oh , it ’ s pretty popular among my classmates these days . So are you ? ', ' Sure , I have a part-time job as a bartender . ', ' Cool ! It must be amazing to work at a bar ! ', ' Yeah , but I ’ m not there for fun . I have to remain professional and if I get distracted , the manager would be pretty upset . ', ' That ’ s true . I ’ m wondering did you learn anything from the job ? ', ' Of course . There ’ s always much to learn . I got to know more about the real world . ', ' You mean you got working experience , right ? ', ' Not just working experience . I would say the biggest lesson I learned is how to deal with people from all walks of life . ', ' It must be very demanding . ', ' Sometimes it is . But after working for a few weeks , it ’ s easy to figure out . ', ' Really ? It sounds interesting . ', ' Maybe you can come to the bar one day and I ’ ll show you around . ', ' Great . I ’ m looking forward to it . ']
['Did you set your clock forward for daylight savings time ? ', ' What ? Why do we have to do that ? ', ' Well , at the start of the spring we usually have more daylight in the mornings and less in the afternoon . This is basically due to our position on the planet and the rotation of the earth . In any case , to take better advantage of the daylight available , we compensate by moving our clocks forward one hour . ', ' I see . That ’ s convenient ! I never understood things like this , such as GMT . I never know what time zone we are in or when to change my clock ! ', ' That just stands for Greenwich Mean Time . Here in California , we are in Pacific Standard Time , that is eight time zones west of Greenwich . Remember when we were in Beijing ? Well , then we were in China Standard Time , and that ’ s eight time zones east of Greenwich ! ', ' That ’ s why it was so weird traveling from Beijing to LA ! Because of the huge time difference , even though we left Beijing at noon and flew for more than eight hours , we still arrived in LA the same day at noon ! It ’ s like we went back in time ! ']
["You wouldn't believe what happened to me today . ", ' What ? ', " The teacher asked me to make a speech in English class and I wasn't prepared . He punished me by making me stand in front of the whole class . It was so embarrassing . "]
['Does your girl friend like swimming ? ', ' Yes , she does . She is good at backstroke and free style . ', ' Then you can help her with the breaststroke and sidestroke . ', ' But she wants to learn the butterfly stroke ', ' Really ? Then just ask her to follow me . ', " I heard you are now practicing underwater swimming , aren't you ? ", ' Yes . But I still have some difficulties it breathing . ', " Say , kid , keep on practicing , you're sure to be a first-class swimmer . ", ' To tell you the truth , I have never thought of being a swimmer . I swim just for fun . ', " That's good . "]
['He was once a poor man but now he is a man of means . ', ' How did he make a fortune ? ', " He didn't make any effort . His aunt died and left him a fortune . "]
['what do you think of studying abroad ? ', " I think it's a great idea . Studying abroad will offer you plenty of new opportunities . Are you planning on going abroad ? ", ' yes , I hope so . I am studying for my BELTS right now . ', ' which country do you want to go to ? ', " I'd like to study in the UK , but it's really expensive . ", ' have you applied to any schools there ? ', ' yes , I received a conditional offer from Oxford University a few days ago . ', " congratulations ! That's excellent news ? What do you have to do to get an unconditional offer ? ", ' I have to get an BELTS score of 7.5 overall . Do you think I can do that ? ', " if you study hard , I don't see why you wouldn't . Have you received any other offers ? ", ' I was also accepted into Yale University , and Sydney University . ', " if you're worried about money , the cost of living is lowest in America . However , if you go to Oxford University , you'll probably be able to get any job you want in the future . ", " I just can't decide where to go . It's not an easy decision to make . ", " if I were you , I'd apply for some scholarships and grants before you decide . Whatever you do , I know you'll succeed . "]
['You have drank dozens of cups . You are bound to get a bay window . ', ' Thank you , but I am in a terrible mood indeed . ']
['Mr . Lin , what are you interested in ? ', ' I enjoy camping . ', " Really ? I'm not much of an outdoor person . What do you like about it ? ", ' I love the fresh air , the scenery the exercise , and the time to think . ', ' Do you hike or fish on your trips ? ', ' Yes , both . Last trip I fished a little and hiked five miles . ', ' Did you catch anything ? ', ' Yes , but I threw them back . ', ' How about Joining our summer camp next week ? ', " Great ! I can't wait . "]
['Hey , Jim . I didn ’ t know you biked to work . ', ' Yeah , it helps keep me fit and helps the environment , too . ', ' One less car on the road means less pollution . ', ' Right . Since my work is near a park , it ’ s a really nice ride , too . ', ' How far is it ? ', ' Oh , about 10 miles . It takes me about an hour . ', ' That doesn ’ t sound too bad . I wish I could do it , but I work in the city . So I take the train . ', ' You ’ re doing your part for the environment by using public transportation , too . ', ' True . Well , see you tomorrow . ', ' See you . ']
['Did you hear about Neil ? ', ' No , what ? ', " I hear that he's quitting . ", " You're kidding ! ", " I'm afraid not ! Now this is just between you and me . "]
['I wonder if I could possibly borrow two bikes from the shop tomorrow ? I ’ ll take actual care of them . I promise you . ', ' Well . All right , Mark . Just this once . But you have to pick them up yourself . I ’ m a very busy man . ', ' Oh , that ’ s all right . It ’ s very kind of you . Can I come around now ? ', ' I ’ d rather you didn ’ t come immediately as I said I ’ m very busy at the moment . Come after lunch , Mark . ']
["Yeah . You don't need to rub it in . ", ' And then she made the deal with MicroPower . Vince wanted to sell for fifteen million ... ', ' Fifteen ? And Zina pushed them up to seventy-five ? ', " That's right . Vince still stops by her office every day to thank her . ", " Anyway , I'm still happy I left . I'm working as a freelancer now . ", ' You really should have stayed with us , Dave . ']
['I feel I work harder when I am under pressure . ', ' Me too . I get much more done when I am under the gun . ']
['You spoken English is pretty good . Please tell me your experience in learning English . ', " Uh , I don't know what to say . What do you want to know ? ", " What's your method of learning ? ", ' Let me think a minute . I think I always try to take every chance to practice . ', " What if there is no chance ? I mean what if you don't have a partner , what will you do ? ", ' Well , I talk to myself . That is , I play one role first , then the other . ', " That's a good idea . You are really creative . "]
['I am not convinced by your explanation . Could you explain it ? ', " Sorry , I really can't do that . There's little time left for us . ", " I can't accept your excuse . It's five o'clock . ", ' Yeah . But I have an appointment with Ann . ', " Ok , sounds good . But I think it's your trick . "]
['Hello , Tom ! ', ' Hello , Steven ! ', ' How are you doing ? ', ' Not bad . What about you ? ', " I'm just a little tired . ", ' Why ? ', ' I have a lot of work to do in the company recently . ', ' How is your family ? ', ' Pretty fine , thanks . ', ' Where are you going now ? ', ' I am going to buy a new air conditioner for my parents . Oh , it ’ s two o ’ clock . I must go now . ', ' OK , see you next time . ', ' See you . ']
['Hi , John . What brings you to town ? ', ' Hi , Mary . Lily wanted me to buy her some things for the party . ', ' What do you think of the traffic today ? ', ' It ’ s pretty bad . ', ' Yeah . You can say that again . It ’ s noisy too . ', ' I am glad I did not drive a car . ']
['Which season do you like best ? ', ' I like spring . ', ' Why ? ', ' Oh , everything comes back to life in spring and the weather gets warmer . ', ' I like spring , too.We can go for a walk and enjoy the fresh air . ']
['Bill , how can you hear so happy today ? ', " Aha . I've read of my roommate . I made a move today . ", ' Really ? What was the matter ? ', ' You knew Brain Locker ? ', " Brain Locker ? No , I don't think so . What does he look like ? ", " Well , he's thin and tall . He has brown hair , a holt nose , green eyes and wearing glasses . ", " Mm . I've seen him a couple of times , I think . "]
['How are you doing today ? ', ' Good . Thanks for asking . ', ' What may I do for you ? ', ' I need help with something . ', ' What do you need help with ? ', ' I am looking for a newspaper article . ', ' Have you looked in the periodicals ? ', ' I didn ’ t even think about that . ', ' I can show you where they are . ', ' That would be a lot of help . ', ' Follow me , please . ', ' Thank you so much . ']
['What do you usually do in your work time ? ', ' Some routine job . Files , documents , faxes and so on . ', ' Are you usually busy ? ', ' It depends . Sometimes I am very busy . ', ' What depends ? ', " Oh , that means I can't make sure for my own . ", ' Oh , I see . ']
['Thanks for inviting me to your friend ’ s wedding . I was surprised to hear the bride and groom talking to each other that way during the marriage ceremony . Is that common ? ', ' Well , some people use a standard set of words , but many couples today write their own wedding vows . ', " Your tradition of throwing rice as they got into their car was interesting , but it didn't look like real rice to me . ", " It wasn't . It was birdseed . We don't throw rice anymore because someone discovered that birds come along and eat the rice and have trouble digesting it . ", " Oh , I didn't think of that . Well , this reception reminds me of weddingparties back in China . Plenty of food and drink , music and dancing , and interesting traditions . ", " Wait until you see what happens next ! The bride is getting ready to throw her bouquet . Let's go over and watch . ", ' She ’ s got quite a crowd around her . Oh , look ! That little girl caught it ! ', ' She ’ s my friend ’ s ten-year-old niece . I guess there won ’ t be another wedding in this family for a long time . ']
['You look run down , Brian . ', " I've been feeling under the weather recently . I caught a bad cold last week , and I still haven't got over it . ", ' Well , you wanna take a sick leave ? All you need now is a good , long rest . ', " I guess so . Even though I seem to be over the worst of it . I don't want to give the bug to anyone in the office . ", ' Good idea . ']
["You seem to be in the seventh heaven . What's put you on ? ", ' Sarah and I could see eye to eye with each other . ', ' Did she give up her decision to marry Dick ? ', " No , I encourage her to go her own way , but she's now having a change of heart . "]
['Excuse me . Can you tell me how to find some books on social science ? ', ' Sure . You see all these little drawers here and all the way around the walls ? ', ' Yes . ', ' These drawers contain cards describing every book in our library . Together they constitute the library\'s " card catalog " . You can see that each drawer runs from one part of the alphabet to another . Fox example , this drawer goes from SCA to SCM . ', " So if I'm looking for a look called A History of Western Society , I'd just look under ' A ' . ", " No . You'd look under ' W ' . The articles ' a ' and ' the ' don't count in our alphabetization , and cards are generally omitted for extremely common words and phrases such as ' history of ' , ' introduction to ' , ' story of ' and so forth . ", " What if I don't know the title of the book ? ", " Well , you can look under the author's name . ", ' Could you give me an example ? ', " Suppose you want to find a book by your professor , William Smith . You'd look under SMITH and then WILLIAM . Since that's very common name , you may have to go through several ' William Smith ' until you come to the one who wrote book on the subject you are interested in . "]
['Julia , are you free tonight ? ', " What's up ? ", ' I want to invite you to go to the movies . ', ' Are you asking me for a date ? ', ' Yes . ', " I don ’ t like to go to the movies on a date . It's noisy there . ", ' Where do you want to meet ? ', " Let's go to the coffee shop then . It's quiet there . ", ' What time should we meet ? ', ' How about seven ? ', ' All right . ']
['Hello , Catherine . Would you like to go out tomorrow ? ', ' Tomorrow ? ', ' Yeah , I was thinking we could get a bite to eat and catch a movie . ', ' That sounds great . ', ' Yes . We can do something else if you like . ', ' OK . Dinner and a movie will be perfect . ', ' Well . What time would you like me to pick you up ? ', " How about 7 o'clock ? ", ' Good . I will see you then . ', ' OK . Bye . ', ' Bye . ']
['Hey , there ’ s Leo . I wonder why he ’ s walking arm in arm with that young woman . ', ' It ’ s as plain as the nose on your face . They ’ re dating each other . ', ' You ’ re pulling my leg ! She must be thirty years younger than Leo . Talk about robbing the cradle ! ', ' Well , you can bet this relationship ’ s going to be a flash in the pan . ', ' It must have been love at first sight because I know he didn ’ t have a girlfriend last week . ', ' I think you are absolutely right . Actually , my father proposed to my mother after knowing her only two weeks . They got married a month later . ']
['Do you think maybe it would be better to just talk to Vince ? Explain the situation ? ', " No way . I want the satisfaction of squishing this bug myself . Plus , what if it's Vince ? ", " I don't think so . Your admirer seems kind of sweet . Aren't you even a little curious about him ? ", " He's just a distraction , like a mosquito buzzing in my ear . I want no distractions . ", ' A little distraction might do you some good , Zina . ']
["You didn't ring me last night . You said you would . ", " I'm sorry to have made you disappointed . ", " That's all right . But why were you so rude to me at lunch . ", " Was I ? Sorry , I didn't mean to be . I do apologize . ", ' And why are you yarning now ? Are you bored ? ', " Forgive me darling . I'm very tired . "]
['Hi , how is it going ? ', ' Pretty good , Sam . Only the awful weather , you know . ', ' That ’ s right . I ’ Ve never really liked it since I got here . ', ' Me either , but I ’ m dealing with it anyway . ']
['Would you like to go skiing with me ? I heard the new ski area is great . They have safe tracks , especially for the beginners and provide free training . I think it suits you best . ', ' Sounds not bad ! You know , the only thing I worried about is the safety . I ’ m not an active exerciser and my muscle may be not strong enough for such an intense sport . ', ' Then you can go to the three-day-long training camp first . There ’ re some professional teachers and they can guide you to do certain necessary exercise . ', ' I will think about it . ', ' Come on ! It is really a fun game . ']
["What's that ? ", " It's my new pendant . Do you like it ? ", ' Is that Hello Kitty ? ', " Yes , in a monkey suit . It's adorable ! ", ' Is it real gold ? ', ' Yeah . Two-toned , white and yellow . ']
['what date is it today ? ', ' why ? ', " look at the girls in the street . They all have bunch of flowers.Is it Valentine's Day ? ", ' Oh , yes ! I completely forgot about it . ', ' did you have a fight with Jack ? ', " no , but now he'll be in trouble . What's a boyfriend for ? To forget about Valentine's Day ? ", ' come on , dear ! You forgot it , too . ', ' you know , it\'s OK for a girl to forget these " big days " , but for a guy , to do that is unforgivable . ', ' is that your phone ? ', " oh , it's Jack . Excuse me . ", ' wow ! good timing . ', ' he asked me out to a dinner tonight . How about joining us ? ', " come on ! three's a crowd ! ", ' so what ? ', " just go ! it's Valentine's Day ! "]
['We ’ re going to the Dragon Boat Festival tomorrow . Feel like coming along ? ', ' Sure . I ’ Ve never seen a dragon boat race . ', ' Really ? I think you ’ ll love it . ', ' As long as I don ’ t have to row . ']
["I must admit I'm not at all interested in math . ", " I'm sure you'll soon begin to like it.It ' s such an interesting subject . ", " But I don't think I'll ever show my liking to math . "]
['Hi , Ellen ! How is it going ? ', ' Can ’ t be better ! Bob , aren ’ t you glad the semester is over ? ', ' Yep ! Are you going to the rock concert Friday night ? ', ' I didn ’ t think much of it . Are you ? ', ' Sure . Would you like go with me ? ', ' Sounds like fun . ', ' You ’ ll have to buy your own ticket though . ', ' Are you broke again ? Let me treat you . ', ' Wow ! When did you come into so much cash ? ', ' You know , I am a waitress at the student center . Anyway now those final exams are almost over . I ’ d love a night out . ']
["not a single email until now ? it's already twelve o'clock . I can't believe it ! ", " can't bear it , right ? I've been there before . I'll feel comfortable if no one calls me or sends me text messages , like there is something missing . ", " yeah , that's right . If no one sends me test messages , I'll go crazy . ", ' actually , this is a kind of addiction called " infomania " or " information overload " . ', ' addiction ? checking emails and text messages often can be called an addiction ? no way ! ', ' yes , it is . Do you consider a frequent check of your income emails to be an integral part of your working day ? ', ' absolutely . ', ' do you have your cell phone with you wherever you go and check text messages and phone calls from time to time ? ', " yeah , it's a must . Otherwise , I may miss important phone calls and text messages . ", " do you open all your IM tools whenever you're using a computer ? ", " yes . MSN , QQ , Skype , Google Talk , Ali wangwang , everything , so that I'll be in touch with all friends and relatives . ", " now I can tell you're definitely addicted to the overflow of information . "]
['Mark . Where have you been ? I ’ Ve been calling you all morning . ', ' I ’ Ve been playing computer games . ', ' What ? So you blew me off yesterday and today over a stupid video game ? What game is so important that you have no time for me anymore ? What are you playing ? ', ' It ’ s called Counter Strike.It ’ s a first person shooter game.It ’ s awesome.It ’ s a multi player game where you can go online and compete against players from all over the world . ', ' You ’ Ve been wasting your time on this ? I can ’ t believe it ! It doesn ’ t even look fun or challenging ! ', ' My laptop is on my bed . If you think it ’ s so easy then get on line and try to beat me . ', ' Fine ! ', ' Damp it ! How are you killing me with a single shot ? It ’ s not fair ! I don ’ t want to play anymore ! Let ’ s go get something to eat . ', ' Can you bring me something ? I am totally hooked on this game ! ']
['Why did Tom quit his job ? ', ' He said his present job seemed to be a blind alley . ', " If he doesn't change his attitude toward work , I don't think a new job can make any difference . "]
['What did he say ? ', ' He said he would tell us the secret of becoming a successful man . ', ' It ’ s too good to be true ! If I were there , I would ask him if he himself was a successful man . ', ' Nobody would drive him up a wall by asking him such a question , you know . ']
['Nice dress . How do I look ? Be honest . ', ' Hmm ... you look too dressed up . How about this purple top and these jeans ? ', ' Well , that top is a little too tight , and those jeans aren ’ t dressy enough . And I don ’ t feel comfortable with that . What do you think , Vicky ? You ’ Ve been very quiet up to now . ', ' Be confident . Wear styles you ’ re going to be comfortable in . ']
['You had better get a grab instead of getting upset about little things . ', ' I know . But my life seems super stressful . I really don ’ t know how to get a better grab on things . ', ' I think as long as you try your best and don ’ t think of anything too much , everything will be all right . ']
['Here ’ s a letter for you . ', ' Let me see it . ', ' Who ’ s the letter from ? ', ' It ’ s a letter from UCLA about my acceptance . ', ' Read it ! ', ' UCLA accepted me ! ', ' Really ? ', ' I ’ m not joking . I got accepted ! ', ' I ’ m so happy for you ! ', ' UCLA was my second choice , but I ’ m happy knowing I ’ Ve been accepted . ', ' I am really proud of you . ', ' You have no idea how proud I am of myself . ']
['Do you think the weather will be good this weekend ? ', ' I heard it might rain . ', ' Oh . That ’ s a pity . I thought that we might go hiking in the hills . ', ' Mmm ... Well we could go to that new art gallery instead . ', ' Yes that might be a better idea . ', ' Maybe we ’ ll meet some of the artists too . ', ' Ok - let ’ s do that then ! ']
['On balance , dress designing appeals to me most . ', " Yes , it's to my liking , too . ", ' Say , how would you like to be a dress designer ? ', " It's my dream . "]
['How often do you use the internet ? ', ' I use it almost every day , but I usually only use it to check my email . I don ’ t often surf the net . You use the internet a lot , don ’ t you ? ', ' Yes . I use it to find products and components at the lowest price for my company . It can be frustrating when the connection is poor . ', ' So , you ’ re online eight hours a day . ', ' Yes , I like the job though . Sometimes , I help other people in the office if they ’ re having trouble online . ', ' How useful do you think the internet is as a source of information ? ', ' I think it ’ s fairly useful , but there are two big problems . First , a lot of the information you find online is false . Second , when you buy something online , you don ’ t see it until you actually get it . ', ' How do you solve the website problems when you ’ re buying something online ? ', ' What I do is find the website of shops . Then someone from our company visits the shop and buys when they ’ re seen that the products are genuine and suitable . ']
['Today more and more families have personal computers . People have wider range of choice to communicate with the outside world . ', ' Right . With the establishment of Internet and a lot of web companies , people are getting more and more dependent on the web . ', ' One of the common uses of PC is that people can buy goods through it without going out to the physical stores . ', ' Can you tell me how it is done ? ', ' If a customer is interested in some certain goods , he can ask the web company to have the specimen of the goods shown on the color screen , and then the customer can place an order online to the sales company . And then the goods you want will be delivered to your home . The service is perfect and the delivery is free of charge . ', ' I see . So great . ']
['Hi , Bob ! How are you doing ? ', ' Fine ! How are you ? ', " I'm fine too , thank you . ", " I've come to tell you I'm going to the concert this evening.Will you come with me ? I've two complimentary tickets . ", ' With the greatest pleasure.Where is the concert this evening ? ', ' It will be held at the Music Hall . ', " What's on the program ? ", " It's a piano recital . I'm fond of piano , you know . "]
['What a good day ! ', " Yes . It's really wonderful here The grass is greener and the air is fresher than those in the city . ", " Right . Let's go out and enjoy the beautiful natural scenery . ", " Great , let's go . ", ' Wow , what a beautiful lake ! The green hills and clear water really provide magnificent scenery . ', " En , it's so beautiful that I don't want to move my eyes from it . ", " I feel as if I'm living in a different world , honey . ", ' The same to me . All the things here make me happy , the mountain , the water , the grass , the birds , the sunshine ... ', ' I think we should go out more frequently . The natural scenery can do us good . ', " That's the point . We should walk into the nature and enjoy its beauty whenever we have time . ", ' Right . The city life has made us tired and out of energy , while the natural world can bring us quite new feelings . ']
['My mother and my wife are always holding different ideas . ', ' If you are really in love with your wife , you should be in support of her . You can ’ t have it both ways , of course . ', ' You mean I should please her by following her suggestion . ', ' Yeah . Love me , and love my dog . ']
['Get changed ! ', ' What for ? ']
['what a nice uniform ! ', ' thanks ; do you like it ? ', ' not really . I was being sarcastic . Does it come with the job ? ', " yes , everyone on the sales floor has to wear one . They're supposed to make us look more professional . ", " they're not actually that bad . They could be worse . What do you think about it ? ", " I don't mind it , actually . I don't have to worry about what I'm going to wear every day . ", ' so are you enjoying your new job ? ', " it's much better than my old one . My new boss is great . ", ' how do you like working in sales ? ', ' I like the fact that I get to work with people . It makes the day go by much faster . ', " that's good . Have you met Jane yet ? She's the intern in the international travel department . ", " yeah , I've met her . She's a genius saleswoman ! ", ' I know ! She could sell fridges to Eskimos ! ', ' how do you know her ? ', " she's my cousin . ", " why didn't you tell me about that before ? ", " I don't know . I didn't think it was that interesting . ", ' well , now that I know that , maybe we should all go out for dinner sometime . ', " that's a good idea . Let's discuss after work . "]
['Isn ’ t this great ? I always wanted to own a farm , live out in the country , grow my own food ! ', ' This is very beautiful . Though I have to confess , I don ’ t know the first thing about farming ! ', ' That ’ s fine ! Don ’ t worry about it ! ', ' What was that ? ', ' Relax , it was just a goat ! ', ' And that ? ', ' It ’ s just the cows that are grazing over there . We can milk them later . ', ' What was that ? ', ' Honey , seriously , It ’ s just a sheep . Relax ! ', ' Relax , that was just the horses and donkeys that are in the stable . ', ' You know what ? I don ’ t think I can hack it here out in the countryside . I ’ m going back to the city ! ']
['What do you base our grades on ? ', ' All of your coursework is important , including everything from attendance and homework to all of your test results for the semester . ', ' Does the final count the most ? ', ' All of it is important ; please just do your best at all times . ', ' How do you total our scores ? ', ' The final and mid-term are twenty percent each ; homework , attendance , and quizzes are the rest . ', ' What if we are out sick ? ', ' Make sure you contact me as I only allow one unexcused absence . ', ' How can we know if we are doing OK during the year ? ', ' Your grade will not be a surprise ; you will know what you need to work on . ']
['I watched a very interesting documentary about plants yesterday evening . It was called unusual plants and looked at several species of plants from around the world which have unusual features . ', ' Really ? Tell me about some of the plants they showed . ', ' Well . There was one type of plant that catches insects and eats them . ', ' Is that type of plant found in this country ? ', ' No , it isn ’ t . it ’ s a pity , because I ’ d like to see it in action . ', ' So would i . what other unusual plants did they show ? ', ' They showed flowers that only provide their nectar to one type of butterfly or bee . The insect has to be the exact size to get the nectar . Other insects cannot get it . Of course , when the insect molle ', ' That ’ s very specialized . So , the insects and the flowers rely on each other . If one became extinct , the other would too . ', ' That ’ s right . That ’ s one reason why it ’ s so important to protect every species . ', ' I see . The plants that fascinate me most are cacti . I find it amazing that they can survive in such dry desert conditions . ', ' According to the documentary , they have an incredible ability to find water supplies , however small , and then store them without losing much through evaporation . ', ' That ’ s why they often have long roots to find water spines instead of leaves , to reduce water loss . ']
['I got the job you recommended me for last week . ', " That's great ! Congratulations . ", " I really don't know how I can thank you enough . ", " Oh , it's my pleasure . After all , you are very qualified for the position . ", ' Thank you very much indeed.You helped me rebuild my self-confidence . ', " Don't mention it.You ' re always been good.What do you say we go out to celebrate ? ", ' That would be great . ']
['The Great Wall is a great attraction for visitors . ', " It's a man-made wonder . I've seen it many times in textbooks and it's part of my dream to visit it . ", ' Someone claimed it was one of the two man-made wonders that could be seen on the moon . ', " That's true . "]
['I can ’ t believe it ! ', ' What ’ s wrong ? That was a great goal . ', ' Yes , but I bet $ 200 dollars on the Cougars ! ', ' Looks like you ’ re going to lose out on this game then . ', ' I can ’ t believe it ! I thought the Cougars were going to win for sure . ', ' What were the odds ? ', ' 20 to 1 , in favour of the Cougars ! ', ' Too bad . ']
["Hey , let's go out and grab a couple of beers tonight ! ", " Sorry , I can't . I have to work late at the laboratory . ", " Nigel , you sure lead a dog's life , what's up with that ? ", ' My boss wants me to finish this project tonight . ']
['What do you think of your teacher ? ', " He's very strict with us . ", ' And I hear he gives very good lectures . ', " Indeed.He ' s strict with himself too . "]
["Ernie , I'm really excited about starting this band together . We're going to be the two coolest students on campus . ", " I know ! It's gonna be great . But what kind of music do you think we should play ? ", " That's a good question . You know I love hip hop , so maybe we can play some Vanilla Ice songs . ", ' Hmm ... Vanilla Ice ? I know his most famous song , " Ice Ice Baby , " but I don\'t know his other songs . ', " That's OK . You can buy his songs on iTunes and listen to them . "]
["What's taking you so long ? ", " Don't worry . I'm almost finished . ", ' I need you to hurry up . ', " All right . I'm finished . ", " I think there's more you need to do . ", ' What do you mean by that ? ', ' My hair looks awful . ', " What don't you like about it ? ", " I just don't like my hair . ", " I'm sorry that you don't like it . ", " I won't be paying you for this . ", " I'm sure we can work something out . "]
['Honey , why are you so angry ? Can you tell me ? ', ' You don ’ t love me , Roy . ', ' Why do you say such words ? I love you very much . ', ' No , you used to be . But not now . You are in love with someone else . You are in love with my friend , Janet . You appreciate her very much . You think she is beautiful and fun to be with and you think I ’ m dumb and uninteresting . ', ' Susan , just one last week I went out to have a lunch with her . There is nothing for you to be jealous about . I like your company much better than Janet ’ s . ', ' I envy her and also I hate her at the same time . ', ' Honey , you should know that I love you so deeply . ', ' Oh , shut up , Roy . ', ' But honey , I think you ’ re terrific . There is nothing ... ', ' Oh , SHUT UP ! ']
['what kinds of tv programmes do you enjoy watching ? ', ' I like current affairs programmes and documentaries , especially wildlife ones . How about you ? ', ' I like those kinds of programmes too . They ’ re very informative . I think that many people underrate the education value of tv . ', ' I agree . People often criticize tv for showing too much sex and violence . ', ' yeah . And that ’ s so funny because most people prefer watching sex and violence to watching something more educational ! ', ' right . You can ’ t blame the tv stations for showing popular kinds of programmes . They need to make money from advertisements shown during and between programmes . ', ' in my country , there ’ s a time limit on the advertisements that can be shown . I think it ’ s about six minutes per hour . ', ' that ’ s great idea . But don ’ t the tv station lose a lot of money because of that ? ', ' no . they don ’ t . they simply charge higher prices at peak times . Is there no limit on the amount of advertisements that can be shown on tv in your country ? ', ' not as far as I know . We have so many advertisements . the interruptions are unbearable sometimes ! That ’ s one reason that many people prefer satellite or cable tv , where you pay a fixed amount each mo ', ' some people have satellite and cable tv in my country , but people don ’ t seem to keen to pay for their tv programmes . Besides , the terrestrial channels offer a good range of programmes . ', ' well , there ’ s a wildlife documentary on tv in a few minutes . Shall we ? ']
['Bon voyage ! ', ' Goodbye . ']
['Can you believe me ? ', ' Sure . ', ' Please count on my love . ', ' I will . ', " I'll be yours through endless time . ", " I see . And I'll always be devoted to you . ", " Thank you . I know I've nothing to offer you , but I'll never give you reason to cry . ", " I'll never hurt you ; I'll never lie . ", ' My love will grow , like a river to flow . ', " It can't be dry , and can't die . ", " I don't know whether we are in a dream . ", ' Aha , Aha ... ']
['Hi , Sara , what are you reading ? ', ' Hi , John , I am trying to find a carpenter . ', ' Why ? ', ' Well , I want to build a deck in my back yard . ', ' What for ? ', ' So I can have a special place to hang out with friends , and also do some barbecuing on weekends . ', ' That sounds cool . Do you mind if I recommend myself for the job ? ', " You ? Do you have a carpenter's license ? ", ' Yes , of course . But I only freelance on weekends with my uncle . ', " Wow ! That's cool . So , let me give you some details about the deck I want . ", ' Please go ahead , I am listening . ', " I'd like my deck to be at the same level as the back door . ", ' Is your back door higher than the ground level ? ', ' Yes , the back door is about four or five steps higher than the ground . ', ' Okay , then you need a deck with a guardrail . ', " I don't like things to be fancy . ", " Don't worry . I will build your deck with a simple but classic look . ", " Hmm , that's good . Can you use cedar or redwood to build it ? ", ' Cedar is a good choice . ', " Well , let's take the measurements right now . "]
['Are you tired ? ', ' Not really . ']
["It's late.It ' s high time I left.Thank you for a most wonderful evening . ", " Don't mention it . ", ' Good night then ! ', ' Good night ! ']
["I'm going to try sky diving this weekend . ", " I wouldn't do it if I were you . ", " It's sounds like fun . ", " It's very dangerous , you know . ", ' I want to try something exciting . ', " It's an easy way to get hurt , let me tell you . ", " I'll tell you all about it next Monday . ", " Well , take care of yourself , and don't say I didn't warn you . "]
['Joan is a thorough drag ! ', ' What is it ? ', " She keeps talking when I'm reading . ", ' There must be something wrong with her . ']
["The results of the poll show Bill Clinton's approval rating has gone up in his second term . Do you find that interesting ? ", ' Well , I think Clinton deserves high marks for doing his job generally , but he may get low marks for his honesty and personal image . ', ' That is exactly what the poll shows . Although the stating of Clinton as a person has gone down in the last two years of his term , his approval rating is as high as 66 percent . ', " I don't find this surprising . The poll data sound quite right . He is a good president . ", ' But the poll says only 15 percent say he will be remembered as an outstanding president . ']
['What courses are you taking ? ', ' Chinese , maths , English , chemistry , physics , biology and so on . ', ' What do you think about the teachers ? ', ' To be honest , I like most of them , except for my Chinese teacher . She is quite young , but her class is too boring ! ', " That's too bad . Do you have any foreign teachers ? ", ' Yes , my oral English teacher is an American . He is from a small town in California . ', ' What is he like ? ', ' He is great . He always tells us not to study for exams , and to pay more attention to communication rather than just memorizing . ', ' Are you able to follow him ? ', ' Not everything , but nearly . He speaks very clearly . ', " Oh , that's good ! He sounds like a good teacher . ", ' Absolutely ! If you come to our class , I am sure you will like him . ']
['How do I apply to an American university ? ', ' You should go to the library to find some information about American universities , and write to the Admission Office . Then the Admission Office will send you application forms and other related materials . From experience , many applicants write to several universities instead of just one . ', ' I was told that it took a lot of time and effort to apply . ', ' That is true . I ’ ll list for you the requirements of almost all the universities . First of all , you need official transcripts of your undergraduate work , three letters of recommendation from your professors who know your competence , and the official TOEFL ( Test of English as a Foreign Language ) score ( It ’ s usually 550 ) . Then you need a financial guarantee , and an application fee of 25 dollars . ', " What's to come next ? ", ' If they agree to enroll you , they will send you a TAP - 66 Form . With TAP - 66 , you can apply for a passport from our government , and then apply for a visa from the US . Embassy in Beijing . ', ' How long will it take to go over all the procedures ? ', ' From 3 to 6 months if everything goes well . ', ' Thank you . I appreciate your help . ', ' You are welcome . Please feel free to ask if you have any more questions . ']
['Good morning . I ’ m from the new york book review . Could I ask you some question about your latest book ? ', ' Sure . Take a seat ... what would you like to know ? ', ' First , I ’ Ve heard that your latest book is based on a true story . ', ' That ’ s correct . It ’ s a murder mystery based on actual murders that book place in florida several years ago . The main character-the police invesigator-is based on the man who investigated the case . ', ' How do you research your books ? ', ' I always visit the places that I use as setting for stories . Readers like things to be as factually correct as possible-even in fiction ! I usually base my characters on people I have met . Most charact ', ' I really like your books . I ’ Ve just finished this one . I read it from cover to cover in a single day . Congratulation on making the bestseller list yet again ! ', ' Thank you . Let met sign it for you ... there you go . ', ' Oh ! Thank you very much . I heard that you are currently writing a collection of short stories . What are the stories about ? ', ' There ’ s a real mix of stories in the book . I haven ’ t finished all of them yet , though . Many of them are short detective stories , but there are also horror stories and sci-fi ones . If you give me your ', ' Thanks very much . I ’ m sure it will sell well . I can ’ t wait to read it . Here ’ s my card . Thank you for you time . ']
['This is my friend Jenny . ', " What's her last name ? ", " It's Snow . ", ' What color are her eyes ? ', " They're blue . ", ' What color is her hair ? ', " It's brown . ", ' How old is she ? ', " She's 42 . "]
["I like watching comedies , like ' Boat ' . Do you like watching comedies too ? ", " Not really , I like watching horror movies , like ' The Unborn . ' ", " You like horror movies ? I don't like them because they're too scary ! I like comedies because I love to laugh . ", ' I like horror movies because I like to be scared . ']
['Good morning . Is this where I can get a library card issued to me ? ', ' No problem , we have a short form right here ; just hand it to me when you are done . ', " I'm done . ", " That looks great , but I will also need your driver's license or other form of I . D . ", ' Sure , here it is . ', ' Well , this looks nice . Do you know how to use it ? ', ' I am pretty sure how to use it , but can you remind me ? ', ' Of course , just remember that all of the needed information is on the card . ', ' I see . ', ' Well , I hope you have a wonderful time on your library visits ! ']
['When did you and Amanda meet each other ? ', ' I met her about one year ago . ', ' So you met her right after you got to school ? ', " That's right . We've been dating since last September . "]
['Do you like snakes ? ', " Of course not . I'm afraid of them . ", ' I mean , do you like snake meat ? ', " I'm afraid I'll feel sick at the sight of it . "]
['What do you do in your spare time ? ', ' During the weekend I often take the family out on short trips . ', ' That sounds interesting . ', ' Yes , it helps me to relax . ', ' Do you have any hobbies ? ', ' I like to paint . \x7f ', ' What kind of things do you paint ? ', ' Mainly seascapes . ', ' What kinds of sports do you like ? ', ' I like almost all sports , and I enjoy both playing and watching . I especially like tennis and mountain climbing . I was in the climbing club all through school . ']
['Hi , Mary , it ’ s been a long time . ', ' Hello , my old friend . Long time no see . How are you doing ? ', ' Well , I ’ m doing okay . And how about yourself ? ', ' Not so well . To be honest with you , I broke up with Tom . ', ' Oh . I ’ m sorry to hear that . What happened ? ']
['What can I help you with today ? ', ' I need to check out this book . ', ' Do you have your library card ? ', ' I don ’ t have one . ', ' Would you like to apply for one right now ? ', ' That ’ s fine . ', ' I ’ m going to need you to fill out the application . ', ' All right . All done . ', ' All right , now please sign the back of the card . ', ' Okay . I ’ Ve signed it . ', ' That ’ s all there is to it . ', ' Great . Now can I check out this book ? ']
["How's your time spent in the United States ? ", ' Well , pretty good . ', " I'm glad to hear that . What impressed you most ? ", ' Well , the cultural differences impressed me most . ', ' You mean we Chinese think differently from the Americans ? ', " That's right , quite different . One day one of my American friend looked pale , so I asked him whether he was sick or not . But he was reluctant to answer my question . ", " That's weird . ", " And what's more , when he told me he had caught a cold for several days , I suggested him to go to the hospital as soon as possible . ", ' You really cared about your friend . ', " Sure I am . But he responded by saying'what do you mean ? ' . ", " I'm confused . Why did he say that ? ", " I felt the same at first . Later he told me that I'd better not give him any suggestions when he was sick . Offering unsolicited help or advice is like showing sympathy to the weak or the poor . But back in China , helping others is always regarded being kind . ", ' Absolutely . Now I understand why he responded that way . ']
['He has so many friends supporting him . ', ' And he himself is very diligent . Considering all these , I think he has the ball at his feet . ', ' But he has to stick to it and to it long enough . ']
["It's time to leave the office for the night . Firstly I log off my computer , then I set the electronic security system . ", " That's pretty advanced . ", " Now I'll quickly send a short message to my wife and take the elevator down to the basement . ", ' Is that where you park ? ', ' Yes , the car park is under constant video surveillance , so my car is quite safe . Please get in . ', ' Thank you . Where is your key ? ', " There's no need , I have keyless entry , and the steering wheel recognizes my finger prints before starting the car . Now , we can look at the navigation system to find the best route home . ", " That's amazing , it even shows all the roads that are congested at the moment . ", ' Using GPS I can rely on this to direct me home . Now I just need to find my E-Card to automatically open the gate and we can drive out . ', ' Pretty soon cars will be driving themselves . ', ' Maybe , but in the meantime why not help me find the remote control for my garage door ? ', ' Here it is , and here we are . ', ' When I turn off my home alarm , the house will automatically tum on the lights and set the climate to a comfortable level . ', " I have to get home , but I don't need all of this fancy technology , I think I'll just walk . "]
['Have any plans for the weekend , Tom ? ', ' Yeah , I ’ m going for a hike in the southern Rocky Mountains . ', ' Oh , do you go hiking often ? ', ' I go as much as I can . I love hiking because you can really get in touch with nature . ', ' It would be nice to get out of the city . Do you want some company ? ', ' Sure . But , it will be a long hike , 30 miles in three days . Have you been hiking before ? ', ' Yeah , I go a lot too . I saw a bear and a mountain lion on my last hike . ', ' Wow ! You must have been pretty far away from the city . ', ' Yeah , my friend and I hiked in a very wild part of the national forest . ', ' Well , bring him along too . We ’ ll have a great time this weekend . ', ' Thanks , I ’ ll ask him . ']
['Miss Wang , would you mind my asking you a personal question ? ', ' No , not at all . Go ahead . ', ' Are you married ? ', ' Yes . Is that so important ? ', ' Frankly yes . We like to employ married people . By the way , do you have any children ? ', ' Yes , I have a three-year-old son . ']
['Hello . ', ' Mark , this is Lucy . ', " What's up ? ", ' I have a friend . He is my best friend and he wants to learn English . He would pay about 100 yuan per hour . Are you interested ? ', " I don't know . ", ' So I take it you are not interested . ', " No , Lucy . Don't get me wrong . I mean school will be open on Sept . 2nd , and I will have a very tight schedule by then . ", " Don't worry . My friend says he can always arrange his schedule around your schedule . ", ' That will be fine . When can I see him ? ', " Let's do it this way . I'll take him to your place this Saturday . Then you two can make a schedule . ", ' Make sure you come here before noon . I will be picking up my friend at the airport in the afternoon . ', ' How are you going to get there ? ', ' By bus , of course . ', ' I am sure my friend can give you a ride . ', ' Great . By the way , what does your friend do ? ', ' He is a lawyer . ', ' Ok , see you then . ', ' See you . ']
['He ’ s got laid off again . I do feel sorry for him . ', ' Do you really ? ', ' What do you mean ? ', ' Well , I just think he deserves it . ']
['Could you tell me something about the Mid-Autumn Festival ? I find it also very interesting . ', " OK . It falls on the 15th day of the eighth lunar month . It is said that there is a beautiful goddess Chang'E on the moon who had eaten some sort of elixir and had to depart her husband . She is always expecting to see her husband again . So , later we have the traditional idea that when there is the full moon , it is time for the family members to come together . ", ' So , I understand why people eat moon cakes on that day . ', " You are right . In China , ' round ' is an auspicious word . The moon cakes are in round shape . ", ' Is it official ? ', ' It was not in the past . But from 2008 , we can enjoy a three-day holiday for this festival . ']
['Good morning , Miss . ', ' Morning . Can I help you ? ', " Yes , I'd like to know how to use the library . You know , I'm a new student here . ", ' All you need is your student identification card to check out books . ', " Yes.Here ' s my identification . ", " That's all you need . ", ' Thank you very much . By the way , how many books am I allowed to check out ? ', " You can check out two books at a time . But you can't check out newspapers , magazines and periodicals ; they have to be read within library . ", ' How long can I keep the books ? ', ' For two weeks . After that you must renew the books if you wish to keep them longer . ', ' I want a book on physics . Could you show me where I can find it ? ', ' Yes , over there to your left . ']
['I think this one will do . ', " I'm sorry . I don't think so . ", " Why ? What's wrong with it ? ", " It's much too hard for his age . "]
['Have you heard that we will have reorganization ? ', ' No , really ? ', ' Yes , flexible , aggressive and creative people are urgently needed in the marketing department . ', ' Who will be there ? ', ' James is going to be packed off there . ', ' That is good . He can leave you alone this time . ']
['Mrs . Smith , you are always worried about your children . ', ' They are my own flesh and blood . It ’ s hard for me to see them suffering . ', ' That ’ s human nature . ']
["Happy birthday , Lillian . Here's a little present I bought for you . ", ' Thank you , Paul . ']
['Hi Isabel ! You wanted to see me ? ', ' Yes Anthony , come on in . Have a seat . ', ' Is everything okay ? You seem a bit preoccupied . ', ' Well , Anthony , this is not going to be an easy conversation.The company has made some decisions which will have a direct impact on your employment . ', ' Okay ... ', ' I don ’ t want to beat around the bush so I ’ m just gonna come out with it . We are going to have to let you go . ', ' What ? Why ? I mean ... just like that ? I ’ m fired ? ', ' I ’ m sorry but , to be honest , you are a terrible employee ! ', ' What ! I resent that ! ', ' Anthony , you were caught making international calls from the office phone , you called in sick in eight times this month and you smell like alcohol ! ']
['Have you heard about Anlesen David ? ', ' No , have they have another fight ? ', ' No , they got engaged . ', ' You must be joking . Those two ? ', " Well , my dear . I didn't believe either . But got it straight form the horse's mouth . David called me this morning . ", ' So when did all this happen ? ', ' Last weekend , while they were on the Sik trip . ', ' Well , I believe it now , and when are they are getting married ? ', ' Next June . ', ' I can hardly believe it . ']
['How about going to dance this evening , Jane ? You will find that the night life of this city is very interesting ! ', " Good idea . There is a good nightclub nearby , isn't it ? ", ' Yes , the dance hall is nice with various styles of music . ', ' ( In the club ) Look at those people in the dance floor , they are so crazy . ', " That's rock and roll with fast tempo . ", ' I like the slow dance . I am good at rumba and waltz . ', ' Take it easy . The time for slow dance is the middle part of the party . ', " Let's find a quiet seat and sit down for beverage . ", ' OK , follow me . ', ' Listen , it is waltz . I like the elegant step of the old styles . ', ' May I ? ', ' Sure . ', ' ( When they are dancing ) You dance gracefully ! ']
["Tom , you promised to cut the lung . You won't forget , will you ? ", ' No , I assure you . ', " And you'll repair the television , won't you ? ", ' Ok . ', ' Do you promise ? ', ' Of course . ', " And Tom , you will help Johnny with his homework , won't you ? ", " I'll see . I will if I can but I won't promise . ", " But you'll promise not to be late for dinner tonight , won't you ? ", ' Yes . But only if you ask me nicely . ', " Tom , darling . You'll try not to be late for dinner tonight , won't you ? Please ! ", " Ok . I'll keep my promise . "]
['How did Jim get the money ? ', ' He borrowed it from Nick . ', ' He must be mad ! Nick is a loan shark . ', ' He was too desperate to find some other way . ']
["Too much , Harry . Don't blame her anymore . ", ' But it was her that makes us so embarrassed . ', " I know . But there's no point in making her feel worse , isn't there ? ", " I don't care . "]
['My goodness ! You ’ re kidding ! ', ' No . I ’ m serious . I ’ m going to quit my job . ', ' That ’ s amazing ! You got a good pay here , didn ’ t you ? ', ' It ’ s true . But I can ’ t show my abilities . ', ' Come on ! Don ’ t be silly ! ', ' Your present job is something better . Why do you change ? ', ' Well . How do you know ? ']
['But Sue is indeed beaut . Men can hardly resist such a knock-out . ', ' Birds of feather flock together . You must be one of these men . ', ' I know little of her . I only think she ’ s pretty and intelligent . Of course , she ’ s diligent , too . ', ' That ’ s enough for you to worship the ground she treats on . ']
['I wish I knew who had moved our flower pots . ', ' It was me . I am so sorry . ', ' What did you think you were doing ? ', ' I had to move it , so that I can get my bike through . ', " How dare you be so inconsiderate ? That's wrong . ", " I am awfully sorry . I didn't think you would mind so much . ", ' Never do that again . ', ' I promise . ']
["She is so beautiful , isn't she ? ", ' Who ? ', ' Julia Roberts . ', ' Yeah , she is so charming . I like her , too . ', " It's said that her new movie is going to come out . ", " What's the movie about ? ", " I'm not sure . ", " Isn't it silly to see a movie that you know nothing about ? ", ' I already told you , because Julia Roberts is in it . I like her because she is not only a great actor but also is very generous to give a lot to many kinds of charities . ', ' Yeah , she is great . I also admire her for her concern about society . ']
['I hope the teacher decides to curve our test grades . ', " I wouldn't count on it . ", ' She did last time . ', " Yes , but I'll bet she won't again . "]
['Could you tell me how to use the library ? ', ' Sure . All you need is your student ID card or admission card to check out books and read journals or magazines in the library . ', ' How many books am I allowed to check out at a time ? ', ' Two books at a time . Except magazines or journals , they have to be read within library . ', ' How long can I keep the books ? ', " For one month . If you can ’ t return the books in time , you'll be fined . But if you renew them , you can keep them longer . ", ' I see . Now I want to check out two books on spoken English . Can you show me where I can find them ? ', ' Yes , just over there to your right . ', ' Thank you very much . ', ' You ’ re welcome . ']
['How did you do that ? ', ' It was a piece of cake . ']
["That new Sony camcorder you've got is just beautiful . ", ' Yeah.It is the very latest in digital video cameras . ', ' I can see digital video products are quickly going mainstream with their plunging price . ', ' Getting cheaper is not the only reason for their popularity.They come with a lot of inviting functions . ', ' Such as ? ', ' They offer clearer and sharper images . Many of them also have up to 20x optical zoom lenses , a photo mode and fast-action mode . ', ' They are very compact and are designed to be used with one hand . ', ' Right ! Anyway , the basic difference between a digital camcorder and its traditional counterpart is that it speaks digital . ', ' What does this mean ? ', ' This means digital camcorders can be connected with the digital equipments you have at home , like your digital TV or your computer . ', ' I can transfer my home video clips from my camcorder to my computer for editing . ', ' Sure ! And without any conversion process or loss of quality ! You quickly find , cut , and record video segments and create slide shows . Some camcorders even offer editing software for adding titles and special effects . ', ' What special effects ? ', ' Like creating a sepia tone look and some special effects such as fades and dissolves . ', " That's great ! ", ' With the development of the broad band Internet , you can easily upload your video files to websites or e-mail them to relatives or business partners . ', " So everybody's getting video mail . "]
['Hi , David ! What are you doing ? ', " Oh , just looking at these club notices . I'm thinking of joining one . Hey-why don't we join a club together ? How about the Tennis Club ? ", " Actually , I'm not good at tennis at all ... ", " Neither am I . It's just that the best-looking girls are in that club . ", " Oh , come on . That's no reason to do something you're not interested in . ", ' Well ... What are you interested in ? ', ' How about the Classical Music Club ? ', ' Joanna , give me a break . ', ' Hey-how about the Cinema Club ? ', " Sounds OK to me . I like movies . Hey , Joanna , look - there are a lot of decent-looking guys here . And the club jackets - they're really hot ! I think we made the right choice ! "]
["Either we'll be millionaires , or we won't ... won't have a dime . ", " And it's all coming down to the next three weeks . ", ' The only person who seems confident the software will be done on time is Zina . ', " Yeah , she is some kind of Superwoman , isn't she ? ", " Failure just isn't an option for her . I'm glad she's on our team . "]
['So , Monica , what do you feel like doing this afternoon ? ', ' Actually , I had a perfect plan for this afternoon , but it is totally ruined by the sand storm . I woke up this morning and found it was sunny . So I called Lucy and asked her to go shopping with me . We were going to look for a new purse . Now it turned out to be like this . Neither of us wants to go to outside anymore . ', ' That ’ s too bad . I hate sand storms too . It can be worse than any kind of bad weather . ', ' What ’ s wrong with climate ? Anyway , I think the sand storm happens more frequently these days than the years before . Can ’ t people do something to stop it ? ', ' It is not an easy job . The government is working on it . Lots of trees have been planted in the north of the capital . Also , methods of generating rain are being used by the government to fight against the drought . But of course , it will not work overnight . So , have you come out with a new plan for today ? ', ' My new plan is to wait for the end of the sand storm and clean my apartment . ']
['May I help you ? ', ' I would like to return this book . ', ' May I do anything else for you ? ', ' I would also like to check out this magazine . ', ' I can ’ t let you do that . ', ' Why is that ? ', ' Our policy doesn ’ t allow anyone to check out the magazines . ', ' What things am I allowed to check out ? ', ' You are only allowed to check out books or videos . ', ' I really need to check out this magazine . ', ' I ’ m sorry , but that ’ s our policy . ', ' That ’ s stupid . ']
["I've heard that Tom is going to move . ", ' What ? Are you sure about that ? ', ' Yeah , he is going to move next month . ', ' Where is he going ? ', ' He is going to Canada and to live with his son . ', ' What a pity ! ', " Why did you say that ? It's a good thing for him to live with his son . ", " I know that . But it's pity for us to lose such a good neighbour . You know I always appreciate Tom's company . ", ' Me too . But anyway we hope he lives happily in the future . ']
['Have a nice Thanksgiving ! ', ' The same to you ! ', ' Are you going anywhere ? ', " I thought about going to my sister's . How about you ? ", " Oh , I'll probably just stay at home . "]
['Have you noticed the Mexican restaurant on the other side of this street ? ', ' You mean the one with the yellow bricks ? But last time I saw it , it wasn ’ t really in business yet . I saw some people inside furnishing the rooms . Is it open now ? ', ' Yes , someone give me a pamphlet introducing the restaurant and its business hours when I passed by this morning . So , let ’ s have a try . My treat . ', ' Great , I like the idea of trying some new food . ', ' Good for you . Today we have more chances to try some new food because there are now many new form restaurants in our city coming from places all over the world . ', ' Also some traditional Chinese food , like noodles and dumpling are marketed in modern ways with improved food quality . I heard this year , the government has imposed very stringent inspection on the hi-gene conditions restaurants and suppliers of food are also under tighter control . For sure all the customers will benefit from this . ']
['Steve . Is that you ? ', " Yeah . What's going on ? ", ' Not much . What a surprise to see you here . ', " Yeah . It's been a couple of months since I saw you . ", ' What have you been up to ? ', ' I just started working out . ', ' Really ? Where do you work out at ? ', ' I joined the Samsung Health Club last month . ', ' What do you mostly do during your workout ? ', ' I concentrate mostly on my legs , chest , arms and stomach . ', ' I should start exercising more . ', " It's hard work while exercising , but it is a great feeling when I get done . ", ' I have a running machine at home . I used to use it , but I already got sick of it . ', ' Exercising at home is hard . The environment is not suited for exercising . ', ' If I want to exercise , I will need to join a gym . ', ' I have a couple of guest passes . You want to check out my health club ? ', " That's a good idea . Let's go over the weekend . ", " Great . I'll call you Saturday morning . ", " Aright . I'll talk to you later . ", ' Ok . Bye . ']
['Anything interesting in this city ? ', ' We have a beautiful natural park . ', " It's worth the time . ", " Come on.Let ' s walk there . "]
['Is there anything wrong ? ', ' I ’ m worried about my daughter . She can ’ t decide about college . ', ' Don ’ t worry . That ’ s just a part of being a teenager . ', ' I don ’ t mind that . But she disagrees with me about everything . ', ' You should encourage her to make up her mind by herself . You shouldn ’ t affect her decision . ', ' But I just want to give her some tips . ', ' Oh , she can make her own decisions . ']
['Merry Christmas , Lily . ', ' The same to you , Joey . ', ' This is your first Christmas in the US . Here is the gift for you . ', " It's very thoughtful of you . Wow , it is so beautiful . Could you tell me how American people celebrate Christmas ? ", ' Ok . People decorate their houses , place a Christmas tree in the room and maybe sing a Christmas carol together . ']
['The teacher should give us more time to complete this assignment . ', " You're right . Let's ask her to give us one more week . "]
["Good evening . I've come to see Miss Morrison ", " Oh ! Good evening . I'm sorry , but she is not in . She's gone out to the theatre ", " Oh ! I've just come back from Canada and I've brought a parcel from her parents ", ' Please come in ', " But you're busy , aren't you ? ", " I was preparing my supper but I've finished now . ", " I can leave the parcel with you , can't I ? ", ' Oh ! yes ']
['Brad , wait ! ', ' What ? ', " How come you have a locker but I don't ? ", ' Mr . Rogers probably forgot to assign a locker to you . ', ' I had to carry my backpack with me all day . ', ' Remind him to give you a locker tomorrow . ', ' Does it have a lock ? ', " No . You have to buy your own . You'll have to go to a hardware store to pick one up . "]
["You didn't tell me she was married ! ", ' I tried . You were preoccupied . ', ' I got carried away . I made such a fool of myself . They were both laughing at me ! ', ' You got drunk , and you were hilarious . Lighten up . ', ' That guy was definitely a Don . ', ' So now you can say you had a mafia experience . Ha-ha . ', ' Yeah . If I leave Little Italy alive ... ', " Are you kidding ? Don had fun scaring you . He'd probably buy you dinner if we go back . "]
['Who is this on the water buffalo ? ', " That's my grand-father . He was a farmer . When he was young , he had to take the water buffalo to graze in the field . ", " Oh yes , that was the best job in most farm families . That's where many of them learned to play the flute . ", ' My grandfather did that too . He used the time to study instead . ', " That's interesting . Go on ! ", " My grand grandfather was a merchant who ran a small business . He couldn't afford to send my grand father to school . ", ' So he became a self-taught man ? ', ' Right . Later he was a soldier and a fireman in the village . When he was middle aged , he became a great man , quite famous . ', ' In what field ? ', ' As a leader of police officers in charge of the whole country . ', ' Is he still in that that type of work . ', ' No . He retired from that . He is a senator now . ', ' Would you want to be a senator ? ', " Well , maybe when I get old . But first I'll be a lawyer . "]
['I am not certain , but I think I might ask to be considered for the new job . ', ' Why are you considering trying for it ? ', ' I think that I might like it , but I am still thinking about it . ', ' What is it about this job that appeals to you ? ', " I think that I would enjoy the position but there isn't a lot of creativity involved . ", ' Yes , you could be right . There is a lot to consider . ', ' I am also wondering about the pay . ', ' Would a slight decrease in pay be worth it for a new opportunity for growth ? ', ' I am thinking that might be the case . ', ' I think you should give it a shot . What do you have to lose ? You can always change your mind . ']
['I was just thinking to call you , then the phone rang and it was you calling me . ', ' Great minds think alike . ']
['Hello , Kevin . I hate to do this , but I have to cancel our appointment . ', ' Oh , no ! Why ? I was looking forward to seeing you at my new place . ', " Yeah , I really wanted to come , too . But something unexpected in shanghai have come up . I have to fly out for a few days , but I'll be back soon . ", ' No problem.Call me when you get back . ', ' I should have some free time next week . Say , next Wednesday evening ? ', " That's good for me , but do you think you'll be back by then ? I'd really like to see you . ", " Yeah , I'm expecting to come back on Tuesday . ", " Great ! That's settled then . ", ' OK . ']
['Look at this , A Brief Introduction of Hollywood . ', ' Hackneyed theme ! ', ' What ? How much do you know Hollywood ? ', ' Nearly everything . ', ' You are full of boasts . I can examine you by question and answer . What is Hollywood ? Where is it ? What is the function of it ? ', ' Too easy questions . Listen carefully . Hollywood is the movie capital of the world.It is located in southern California . Many films have been made there , and the kinds have changed often . ', " Not bad . What kind of film did it produce from the ready to mid 1930 ' s ", ' Gangster movies . Movie-goers at that time could get a look at the people involved in crime and their violent activities by watching it . ', ' Mm . What came after that ? ', " After all that violence , people needed to laugh , so from the mid-to-late l940 ' s , many detective movies about policemen who solved crimes were made . Then came musicals . ", ' Pretty good . Please continue . ', " Right . By the mid - 50 ' s , this light-hearted genre was competing with films about more serious subjects . There was one kind that could be found throughout all of these years , and that was the , mm , the . . . ", " The western films about America's cowboys , Indians and early settlers . ", ' Come on . ', " Since the early 1960 ' s , there are horror movies about people who encounter frightening , unnatural situations , and serious films such as documentarist about events that actually happened , and science fiction movies about possible friture and future worlds . Some people have also enjoyed watching psycho-dramas about the everyday problems that people have . ", ' Any more ? ', ' Of course , no list of film would be complete without animated movies . These are especially popular among children . ']
['Hi , Bob . Can I have the book back I lent to you last month ? ', " Oh ! I forgot all about it . Of course you can have it back , John . I'm sorry about the delay . ", " Well , it doesn't matter . I almost forgot it too if it is not for Peter who asked me about it this coming . "]
['Excuse me . May I use the phone first ? ', ' Are you in a hurry ? ', ' You bet . I was supposed to call my mother an hour ago . ', ' In that case , here , you go first . ']
["Oh , it's getting late . I've got to run.It was nice talking to you , karren . ", ' Thanks , Tim.Nice meeting you , too . ', " I guess we'll see just around . ", ' Ye , I hope so.well.Take it easy . ', ' You too . ']
['How good are you at sports , Bill ? ', ' Are you kidding ? I ’ m terrible ! But I love to watch sports . I go to football or baseball games a lot . And I read sports magazines every week . ', ' Wow ! ', ' Do you like sports , Janice ? ', ' Oh , yes . I like to exercise . But I don ’ t watch sports or buy sports magazines . I don ’ t have much time to do those things . ', ' Oh , I see . You know , we spend time doing different sports . How much time do you spend exercising ? ', ' Well , I guess I exercise about two hours a day . I do aerobics three times a week , and the other days I play badminton 1 with my husband . I always feel good afterward . ', ' That ’ s great ! I ’ Ve heard people say that before . ', ' Well , why don ’ t you try to get some exercise ? It ’ s difficult , but very rewarding . ', ' Oh , I ’ m too lazy to play sports , and I ’ m not good at anything either . It hardly excites me . ']
['Alice , your father is amazing . He ’ s 90 years old and he lives alone in that big house . ', ' I know . He doesn ’ t like to ask anyone for help . My dad insists on paying his own bills and taking care of himself ! ', ' That sounds like my Grandmother . She was always stubbornly independent . ', ' It seems that folks like my father and your grandmother are determined to be on their own . ', ' They see their independence as a kind of character strength . ', ' Sometimes they are too independent . ']
['This little wooden stick is called a tee . ', ' What do you do with it ? ', ' For the first drive , put the golf ball on the tee , and push the tee into the ground . ', ' Okay . ', ' Pick up a wood and hold it like this , interlocking your fingers . ', ' OK . ', ' Position yourself , swinging the club , watch the ball and hit it as hard as you can . ', ' Hey ! ', ' Not too bad . The goal is to get the ball into the hole with as few hits as possible . ', ' Got it . ']
['Excuse me . Is anyone sitting here ? ', ' No , nobody . ', ' You don ’ t mind if I smoke , do you ? ', ' Well , to be frank , yes , I do . ', ' Oh , I ’ m sorry . But this isn ’ t a no-smoker , is it ? I mean would you mind if I smoke here ? ', ' Actually it is . Perhaps you haven ’ t noticed the sign . ', ' Sign ? What ’ s sign ? ', ' There , on the window . ', ' Oh , sorry . I didn ’ t notice it . Sorry . ', ' That ’ s all right . ']
['Are the ceremony and reception held in the same place ? ', ' No , not usually . Most people are married in a church , and then the wedding party and guests go to another place for the reception . Sometimes , however , they hold the reception in a big room in the church . ', ' Where do they go ? ', ' Either they go to a public place such as a hotel , a restaurant , or a club , or to the home of the brid ', ' They go to the home of the bride ? ', ' Why do you ask ? ', " The Chinese custom is to go to the groom's home-just the opposite . ", " Oh ! In our country the bride's family is responsible for the entire wedding-arrangement , costs , etc . So the reception is held at her home . ", " That's very expensive for the family of the bride . ", ' Many American furthers joke that they would rather hold the ladder for their daughter to climb down and elope than pay for a wedding . ', " Tell me something about the bridal bouquet . Isn't it the custom to throw it ? ", ' Yes . When the bride and groom are ready to leave on their honeymoon all the single girls gather in one place . The bride stands with her back to them and throws her bouquet over her shoulder and they each try to catch it . The one who does will be the next one married . ', " Maybe I'll be the one . "]
['Guess what I just heard ? ', ' What ? ', ' The boss is planning to sell the company . ', ' You must be joking ! ']
['And the cover is great ! The colors are brilliant ! ', " Give me a break . You don't care about the colors . You just like the hot babe on the cover . ", ' OK , you got me . So , do you have a subscription ? ', " Of course . I'm currently the subscriber of 10 different fashion magazines . ", ' So what do you do with all the out-dated issues ? ', " I guess I'm lending them to you ... "]
["I've moved . ", ' Where to ? ']
["We're going out to dinner and then to the movies . ", " Hold on ! I can't afford to pay for both . ", " Don't worry . I've got money . It's my treat . ", " Gee , that's really nice of you . "]
['Hi , Kenji . ', " Hi , Debbie . Have a seat . How's it going ? ", " I'm OK . How are you doing ? ", ' Pretty good . Listen ... have you heard about the new Thai restaurant over on University Avenue ? ', ' Do you mean The Bangkok ? ', " That's the one . A bunch of us are going there for dinner tomorrow night.How about coming with us ? ", " Sure , I'd love to . ", " Great . I'll call and make reservations . ", " Any time after 6 o'clock is good for me.Oh ! I'm late ! I have a class . ", " All right . I'll call you tonight and tell you the time . ", ' Great . Talk to you then . ']
['Mr . Lee , I was wondering if you and your wife had plans for next Friday night ? ', ' Yes , I think we might be free . What did you have in mind ? ', " I've mailed a formal written invitation to your home inviting you to a dinner party at my home . ", ' That sounds great . Is it casual ? ', ' Actually , we thought it would be fun to have a formal sit-down dinner for the holidays . ', ' That sounds good . It will give my wife a chance to dress up . ', " Yes , we've invited four other couples , so it should be a good mix of people . ", ' That sounds wonderful . Will there be anyone there that I know ? ', ' Oh yes , everyone we are inviting is from our company . ', " Great ! I'll look forward to it . We'll make sure and check the mail for our invitation . "]
['Do you know who that tall man is ? ', ' I don ’ t know . But he must be a big shot . ', ' Why ? ', ' Because everyone is trying to butter him up . ']
["You are blue in the face , arn't you ? ", " The cat has eaten my fish , I'll kill it . ", ' But supposing your son killed like the fish , what do you think then ? ', " I'll beat him . ", " So beat the cat , but don't kill it . "]
['Did you go to see Michael last night ? ', ' Yes , He had just bought a new motorcycle . ', ' Did he let you ride it ? ', ' Yes , I tried it and I quite liked it . ', ' Weren ’ t you frightened ? ', ' Sure . But I still liked it . ', ' Would you like to buy a motorcycle yourself ? ', ' No . Although motorcycle is nice , I ’ d like to buy a bicycle . ', ' But why ? Since you like it so much . ', ' Because bicycles are safer . ']
['I passed history test . ', ' Really ? That ’ s marvelous ! ', ' And then you ’ re old man won ’ t be beaten this time . ', ' I ’ Ve made up my mind not to be beaten again . ']
['Mr.Ben , What do you think of the book ? ', " It's an excellent one . I like it very much . ", ' Why ? ', ' It includes a lot of useful words and phrases . ', ' I agree with you . ']
['How do I buy my textbooks ? ', ' Do you have your book list for your class ? ', ' Yes , I have my list . ', ' Fine . Once you have it , you can go to the bookstore . Do you know where that is ? ', ' Yes , I know where the bookstore is . ', " OK , so once you pass the gym , it's the first door on your left . Do you know you can also sell your used textbooks there ? ", " No , I didn't know I could do that . ", ' You just take them with you and trade them with the used textbook man just outside the door . Do you think you will be going there today ? ', ' Yes , I am going today . ', ' Well , if you decide to go , I could meet you over there at 1 ', ' Yes , thank you . That would be great . ', " Well , then , I'll talk to you later . Have a good day ! "]
['Is there anything wrong with your food this evening , Miss ? ', " Sorry to trouble you . But I don't think this fish is fresh . It actually tastes a bit off . ", " Sorry , Miss . I'll place it immediately , can I get you another drink , or you wait ? ", " No , please don't do that . I'd just like to return it . ", " I'm sorry , Miss , but I'm afraid we can't do that . You'll order something else instead . I'd love to suggest the steak , it's the special today , and quite tasty . ", ' Ok , then please bring me the steak mediun-rare , thank you . ', ' Ok , Miss . I hope you enjoy the rest of your dinner . ']
['Bill . Bill ! You gotta help me ! ', ' What ’ s wrong ? Slow down or you are gonna give yourself a heart attack . ', ' Tomorrow is Christmas and I haven ’ t bought my mom anything ! I ’ m such a bad son ! ', ' Take it easy ! Let ’ s go to the mall , window shop a little and see if there is anything she might like . ', ' That ’ s just it ! I don ’ t know what to get her ! Last year I got her a ring that was two sizes too big and a pair of shoes five sizes too small ! I suck at getting presents for people . ', ' That ’ s where you ’ re making a big mistake ! You can ’ t just guess peoples ’ likes or sizes ! Especially with clothes or jewelry . On top of that , I think that you should get your mom something that shows how much you love her . At the same time you should show her that you took the time and effort to look for something that she would really like ! ', ' Yeah , you ’ re right . When it comes down to it , I can be pretty tacky . ', ' Yeah , tell me about it . I know ! Your mom is trying to learn Spanish , right ? Why don ’ t you get her a gift certificate for this great website I saw called SpanishPod . ', ' Now that ’ s a great idea ! ']
['Do you do morning exercises ? ', ' Yes . I do one set of shadow-boxing every morning after I get up . ', ' Shadow-boxing ? How interesting ! Do you think it really helpful for your health ? ', ' Definitely . It not only keeps me fit but also helps me concentrate on my soul . ']
['He loves that blonde girl . ', ' Yes , he once gave her seven roses . ', ' Did she accept it ? ', ' No way to know . ']
['Would you recommend some places for sightseeing ? ', ' How about Great Canyon ? ', ' Is it worth seeing ? ', " Of course ! It's the most wonderful natural works . "]
['I just got a telegram from Margaret and Greg . ', ' Are they coming to Chicago again ? ', ' Yes . They ’ re coming the beginning of August . ', ' Oh , good ! We can all get together again . ', ' I ’ m glad they ’ re coming in August . Maybe Greg and I can play some golf or get tickets to a baseball game . ', ' And Margaret and I can take the dog and go jogging in the park . ', ' Remember the garden party they gave when we were in England ? ', ' Oh , yes . We all sat on the grass , and Margaret played the guitar and sang Greek songs . ', ' I had a great time . It ’ ll be good to see them again . ']
['Did you punch in ? ', ' Yes . By the way , you are having a great make-up today . I like the color of your lipstick . So adorable ! ', ' Really ? It took me really a while to find the color . I am happy you like it . ', ' Well , girls like us are happy to spend our time on those kinds of things . Actually , do we still have a meeting this afternoon ? ', ' Sure , when those never ending meetings . ']
["I like the kid . He's so lovely . ", ' How old is he ? ', " Twelve . He's very sensible for his age . "]
['John seems to be in high cotton . He may well become a big shot . ', " I bet my button dollar that he won't . He is no more than a nine day's wonder . ", ' What is your idea ? ', ' Many people like him get a flying start but soon disappear . ']
['Hey . Owen ! Have you gone on your family vacation yet ? ', ' Oh , yes . I got so tired . My son began to cry the moment we got on the train . It was very embarrassing because we took the over-night train and the noise made it difficult for other people in the cabin to sleep . ', " Didn't you bring his favorite toy ? ", ' Yes , we did . Fortunately we put his Teddy Bear in the bag , and finally he fell asleep at mid-night with it in his arms . ', " Where did you go ? You've got a beautiful tan . ", " My wife didn't like to go to amusement parks , so we compromised and finally went to the seaside . I think vacation in summer is not good . ", ' You must have had a great time . Most children love to play in the sand on the beach and go swimming . ', ' Yes , he was every excited to see the blue sea and picked up many seashells to give as gift for his classmates in kindergarten . ', ' His friends will be very happy to get the little souvenir . ', " And I taught him how to swim in the sea . It was fun and made him braver than before . After we returned home , he wasn't afraid to sleep alone in his bedroom . "]
["This is going to surprise you , but I'm happy . I think you're making the right move . ", ' You do ? ', " Look , maybe I shouldn't tell you this , but I'v going over to WebTracker , too . ", " No way ! That's great ! Then we'll still be together ! ", " Actually , I'm already working for WebTracker . Vince never wanted to give me what I was worth , so I figured , what the heck . ", " No kidding ! I can't believe this . You devil ! ", " It's kind of cool , isn't it ? I'm sort of like a secret agent . "]
["Life's so boring . ", ' Well , most of the time it is , I guess . ', ' What do you think will make you happy ? ', ' I think money will make me happy . ', " You heard people say that money doesn't guarantee happiness . ", ' It will for me . Then I can do all the things I want to do . ', " You'll get bored eventually . ", " Then I can find something new to do . If I don't have to worry about money , then I don't have to work . ", " That's true , I guess . If I didn't have to work , I think I would be happy . ", " You see ... money doesn't equal happiness , but it takes away a lot of responsibilities . "]
['Have you signed up to join the company ’ s Christmas party ? ', ' Sure , I have . Will you join ? ', ' I will . You know , as a newcomer , I think it might be a good opportunity to get to know people from the other departments of our company in a more relaxed atmosphere . ', ' You are right . Our company ’ s Christmas party has always been an amazing occasion for everybody to relax and get to know each other better . It is also a time to make new friends and do some networking . ', ' I hope that it is not a formal one when the boss is there . ', ' No , it will not be formal at all . It is a fun time . You will love the game show . Please dress casually . Usually there is an over abandon of drinks , so be careful with that . ', ' Don ’ t worry , I can handle that . And I know if the boss is there , even it is an informal evening , it does not make a good impression to get totally drunk in front of him . ']
['My father ’ s angry face always makes my blood run cold . ', ' You mean that he is bad-tempered and often gets angry with you . ', ' Not often . Just when I make mistakes . ']
['I have never you mention this friend . Are you on very good terms with him or her ? ', ' We have been on good terms . She is a very nice girl . But she got in Dutch with her boss . I don ’ t have the heart to see her pounding the pavements . ', ' You must be stuck on her , or you would not use your elbow grease . ', ' Well , we hit it off with each other . Nothing more , nothing much . ']
['Crossed cousin marriage is not allowed in China . ', ' It it true of many countries . ', ' You know why ? ', ' Sure . If people are near in blood , they might pass on some genetic disease to the next generation . ']
['Hello , Susan , it ’ s me , An . ', ' Hi , An . How are you ? ', ' I am fine . I am going swimming this afternoon . Are you coming with me ? ', ' I am afraid I can ’ t this afternoon . I take my daughter to her tennis class at the club on Wednesday afternoons . ', ' Maybe I can meet you at the club and we can play tennis together . ', " Ok , I'll meet you at the club at two thirty . "]
['Do you have girlfriend ? ', ' Yes , why ? ', ' Well , I came to know a girl three weeks ago . We have so much in common . ', ' So ? ', ' So I think I may fall in love with her . ', " That sounds great . But how do you know that's a crush or a real love ? ", " Then what's the difference between having a crush and falling in real love ? ", " That's a big question . Well , if you're in love , maybe you will take every opportunity to talk to her or telephone her for no reason at all . ", " That's what I do . ", ' And you think about her all the time ? ', ' Yes . ', ' And maybe you suddenly have new interests . I mean you suddenly begin to do things you used to avoid . For instance , you used to sleep in every morning , but because she jogs every morning then you begin to like jogging . ', " That's it . She likes dogs so much now , and I begin to love dogs . ", " Oh , congratulations . Sounds like you've found your soul mate . ", ' Thanks , but I know falling in love is one thing while staying in love is another . ', " Yes , that's right . If you find this person becomes more and more important to you and you can totally trust her , then you can stay in love . ", ' Yeah , falling in love is so good . ']
['What book is that ? ', ' I just bought a new atlas . I ’ m looking this map of the world . Look at Russia ! That ’ s a vast country . ', ' Canada , China , and the USA are huge too . ', ' There are several tiny countries in the world too . Countries like Monaco are smaller than many cities . ', ' Those small countries are microscopic compared to Russia . European countries are relatively small . France looks quite big in Europe , but compared to many countries in other continents , it ’ s not very large at all . ', ' Britain is half the size of france , but great Britain is still one of the largest islands in the world . ', ' The thing with large countries is that often they have vast areas of land that are useless or hardly used . Russia and Canada have enormous areas of ice and forest . ']
['So Peter , do you have a favorite comedy ? ', " Well , that's hard to say because there are so many good ones . I don't think I could pick a favorite . ", ' You know what comedy I really like ? " Ace Ventura , Pet Detective . " I think Jim Carry is really funny . ', " Oh yeah , that's one of my favorite flicks . I think Jim Carry is one of the funniest comedians ever . ", ' I agree . But even though I like comedies , I usually prefer more serious films . My favorite movie is " Titanic . " ']
['How about a movie tonight ? ', ' It doesn ’ t matter to me . ', " Does 7 o'clock suit you ? ", ' Either way . I don ’ t care . ', ' How about a snack after work ? ', ' I couldn ’ t careless . ', ' Would you rather stay home ? ', ' Whatever you say . ', ' Are you really interested in doing something ? ', ' I don ’ t mind if you want to . ']
["I'm going shopping . ", ' Do you have enough money to buy that dress ? ', ' No . I need to borrow $ 50 . ', ' Sure , here you go . ']
['Do you have any siblings ? ', ' Yes , I do . I am the oldest child . I have a sister and a brother . My sister is in college and my brother in high school . ', ' How do you get along with them ? ', ' We get alone very well . ']
['What do you think of the test ? ', ' Rather difficult . How about you ? ', " It wasn't too bad . Were you nervous ? ", " Rather . I'm afraid I didn't do very well . ", " Oh , I wouldn't worry about it . ", " That's because you did well . ", " No , I wouldn't worry about you . ", ' Why ? ', ' It seems to me that you always do better than you say . ']
['I think that the company retreat should be in the mountains this year . ', ' What a great idea ! ', ' January would be a good month for a mountain retreat . ', ' I like the mountain idea , but I am not so sure about the month of January . ', ' You know , now that I think about it , you might be right . ', ' April might be nice . It is far enough away to make the necessary arrangements . ', ' That is a good suggestion . ', ' We could ask everyone what would be the best time for them . ', ' Yeah , that would let us know what would work best . ', " I'll put the survey online this afternoon . "]
["I think he won't remember White Day . ", ' Silly , you should make sure he does . ', ' Uh-huh . How about you ? ', ' He ’ s buying me a handbag , and then dinner at a gorgeous restaurant . ', ' You got a big return for a small gift . ']
['You ’ ll never guess what ! My friends Julie and Alex are getting married ! ', ' Wow that ’ s great news ! They ’ re a great couple ! ', ' I know ! Anyways I just talked to Alex ’ s best man and he is organizing the bachelor party It ’ s gonna be so much fun ! All the groomsmen are thinking up all the wacky and crazy things we are going to do that night . ', ' You aren ’ t going to a strip club , are you ? I don ’ t want you getting a lap dance from some stripper with the excuse that it ’ s your friends party . ', ' Aw come on ! It ’ s just some innocent fun ! You know how these things are ! We are gonna play drinking games , get him some gag gifts and just have a good time . Nothing too over the top . ', ' Well , I don ’ t know . ', ' Come on ! If one of your friends was getting married I wouldn ’ t mind you going to her bachelorette party ! ', ' Good , because my friend Wendy is getting married and I ’ m organizing her party ! ', ' What ! ']
['Hi , what ’ re you reading ? ', ' Oh , it ’ s Death on the Nile . Have you read it ? ', ' No , not that one . But I saw the movie . Could I borrow it when you finished ? ', ' Sure . I didn ’ t know you like mysteries . ', ' Oh , I ’ m crazy about them . ']
['Our son is gone and my heart is gone too . I don ’ t know how to spend the rest of my years . ', ' Oh , darling , we must stand shoulder to shoulder and face the music . I know you can pull yourself together . ', ' I feel life is meaningless without him . ', ' Cheer up . You have got me at least . ']
['Hey , guys ! Did you see that sign ? ', ' No . What did it say ? ', " There's a garage sale around the corner . ", " A garage sale ... that's where people check out cars , right ? ", ' What ? Cars ? Are you serious ? ', " I'm pulling your leg , Paul . I'm a shopping queen , remember ? So of course I know what a garage sale is all about ! "]
["It's amazing to me how international business has become . Take my store for example . On any given day , you will find imported items from more than 20 different countries on our shelves . ", ' How many different varieties of products do you import from China ? ', ' China provides the bulk of our product inventory , for sure . We import more than 40 different items from China . Most of the imports that come out of China are low-grade plastics or toys . Japan produces many electronic exports , Germany produces excellent mechanical exports . ', ' Do you import any food items ? ', ' Generally speaking , food items are difficult to import . Food with the short shelf life is liable to spoil in the time it takes to ship from one place to another . The only food items we import are specialty canned or preserved foods . The shelf life is longer for these products . ']
['We still have one more day to go before we return home . What will we see tomorrow ? ', " No idea . We've enjoyed both the natural scenery and the city sights . What else is there to see ? ", ' What about a factory tour ? ', ' You mean visit a factory ? ', " Yes . I heard there's a lager motor company nearby which is open to the public every weekend . We can go to see how a car is manufactured and learn more about the automobile industry . ", " Good idea ! I've always been interested in that . How much is the entrance fee ? ", " I'm not sure , but as far as I know , most factory tours are free . They are sponsored by the company providing the tour . ", ' Really ? What do the companies do that for ? ', ' I believe most of them think it as good public relations . They can promote their product and make their company better-known . ', ' Oh , ISEE . So factory tours are good for companies as well as visitors . ', ' Exactly . ', ' Do we need an appointment beforehand ? ', " I'll call the tourist information centre to check . "]
['Here , Let me get the door for you . ', ' Thanks . ', ' Do you need a hand with that ? ', ' Actually , i could you some help.Thank you so much . ', " Don't worry about it . "]
['Are you still on your summer vacation ? ', ' Yes . ', ' When will school start ? ', " It'll start on lst September . "]
['I just had a terrible week . ', ' what a shame ! ', ' I fell down and hurt my arm . ', " That's too bad . ", ' Then my son drove into a tree . ', ' I am sorry to hear that . ', ' The dog bit the delivery boy . ', ' What a pity ! ', ' And a storm blew our roof away . ', ' Ho , no ! ']
['Good evening , Mr . Wu . ', ' Good evening , Mr . Smith . ', ' Have you met my wife , Mary ? ', ' No . I haven ’ t had the pleasure . ', ' Mary , this is Mr . Wu , my new Chinese friend . ', ' How do you do , Mr . Wu ? Welcome . ', ' How do you do ? ', ' Have a glass of wine , Mr . Wu ? And let me introduce you to some of my guests . ']
['This is my house.Let me show you around it . ', ' How beautiful the detached house is ! ', ' Follow me to the back-yard . ', " It's marvelous ! The lawn looks like a green carpet , and the garden with so many lovely flowers . ", ' We had the grass cut and the flowers trimmed this morning . ', ' No wonder it smells fragrant . ', ' Here is the swimming pool and we can swim later . ', " It's fantastic ! "]
['You mean it shuts off to save energy ? ', ' Yep . And it breathes , see ! ', " It's not breathing ! ", ' Yes , it is . Look at the little light ! It blinks off and on . ', " Jen , it's not alive ... but it does look user-friendly . ", ' I would look so cool carrying this around ! ', " And you'd look so cool ! "]
['Are you studying here ? ', ' Yes , I am studying in Eastern Asian language department . ', ' What are you majoring in ? ', ' I major in Japanese . ', ' What do you think of the literature course ? ', " It's very helpful . The course has let me into a new world of literature . I read so many great literatures . "]
['Some people are easily flimflammed . ', ' Maybe they are still wet behind ears . ', ' They are blind with bucks . Blind people are more easily conned , fo course . ', ' Sure . Many people , including men and women , and be easily ripped off . ']
["Okay , let's begin . Hello , everyone . My name's Karl Roberts , and I'll be your teacher for this class , Intercultural Communication . ", " ( quietly ) I don't understand what the teacher is saying . ", ' Uh , to begin with , please take a look at the syllabus in front of you . As you all should know by now , this class meets on Tuesdays and Thursdays from 3:15 to 4:50 . ', " That's terrible . He speaks too fast . How can I catch his meaning ? ", ' Again , as you see on your course outline , grading is determined by your performance on a midterm and a final test , periodic quizzes , and classroom participation . ', " I'm not sure whether I can pass the course or not . "]
['I heard that Janet has got a new job . She ’ s working for the united investment group . I heard that they pay very well . ', ' I heard that too . She must be making a pocket . Well , good for her . ', ' Now , she ’ ll be able to save up for that holiday in the united states . ', ' Yes , she will . At the moment , the exchange rate is very favorable , so she should try to go as soon as possible , while it ’ s cheaper . ', ' You ’ re right . By the way , did you hear that Tom inherited some money recently ? ', ' Really ? I thought his parents had died several years ago . ', ' They did . He inherited the money from an uncle . I hope he doesn ’ t lose a lot of it in taxed to the government . ', ' Dying can be very expensive nowadays ! What ’ s he going to do with it ? ', ' He said that he would probably invest most of it . He ’ s got a well-paid job , so he doesn ’ t need the money to cover day-to day expenses . He just wants some extra money available for when he retires . ', ' I had some good financial news yesterday too . ', ' Really ? Have you won a fortune in the lottery ? ', ' No , but I got a pay rise of 5 % and a bonus for all the hard work I ’ Ve put in recently . I think it was very nice for my boss to show his appreciation in that way . ', ' It certainly was ! So , what are you going to do with your windfall ? ']
['Julia , I saw two men fighting beside our door this morning . ', ' I know them . They are the two brothers living next door . ', ' Brothers ? Do you know why they quarreled ? ', " It's said that the father's will caused the dissension among the two brothers . ", ' Is there anybody acting as mediator in the dispute ? ', " No , everyone keeps in mind that ' Don't intrude in a family dispute ' . "]
["I think I'm going to go home . ", ' Why ? We just got here . ', " I know , but it's 12 ", ' 12 ', " Three or four o'clock ? ", ' Yes . ', " I never stay out that late . That's too late . ", " But why is it too late ? It's Saturday night.You have nothing to do tomorrow . Why not stay out and drink with us ? ", ' Were you so wild when you were still in Taipei , Sharon ? ', ' Yes , I was . And I like living here.People know how to party here . In Taipei , some people know how to party.But here , everyone does . ', " What is that they're doing on the couch ? ", " They're smoking pot . Don't worry about it . ", " Pot ? Isn't that marijuana ? ", ' Yes , it is . ', " But , Sharon , that's illegal ! The police could come , and we could go to jail . ", " Don't worry about it . It is true that pot is illegal in America.But the laws aren't as strict as in Taiwan.If people are arrested , and they have a little pot in their possession , they don't go to jail . They just have to pay a fine . ", ' Really ? ', ' Yes . ', " I didn't know you had such wild friends . Do you smoke marijuana too ? ", " I tried it a couple times . But I don't like it . I like alcohol better.Don ' t worry about them , though . If you don't want to smoke pot , you don't have to . ", " I don't want to . ", " That's alright . But you really should have another drink.People will probably start dancing soon . ", " I don't know if I can drink more . I already had two drinks . ", " You had two drinks at nine o'clock . C'mon , Ann , you are in an American university now ! You have to learn how to drink . ", ' I thought a university was for studying . ', " It is . We study hard all week.And then , on the weekend , we party hard . That's the best way to live . ", " Alright . I'll have another drink . "]
["Hi , Michael , how's it going ? ", ' Well , things are all right . ', " I heard you got a new roommate . What's he like ? ", ' Yeah , Bob moved in last week . He is a nice guy and so far everything is cool except this girlfriend . ', " Oh ? What's wrong with his girlfriend ? ", ' She came over last weekend . She is a nice girl but there\'s something about her voice that really creeps me out . I tried to smile and be polite , but the whole time all I could think was " what\'s wrong with your voice ? " ', ' Well , I guess it might take some time to get used to . ', ' I doubt it . Last time was an oral train wreck . Listening to her talk is like chewing tin foil . ', " Oh come on , it's not that bad . ", " No , it's so much worse . And tonight they invited me out to dinner . I really have no idea how I'm going to pull it off . ", ' Rough . Maybe you can do the most of the talking . ', " That's the plan . ", ' Good luck . ']
['Hey . Why did you take that money ? You are such a cheater ! I should send you to jail ! ', ' I am not cheating . When you pass go , you collect $ 200 , Everyone knows that ! ', ' Well you can ’ t just take the money . You have to ask the bank for money . And I ’ m the banker . ', ' Banker ? ', ' Yes ... ', ' Can I have my $ 200 please ? ', ' Sure . Here you are , $ 200 , Thank you , please come again ! Now it ’ s my turn to roll the dice . ']
['Hello , is that Cathy speaking ? ', ' Yes , is that you , Allen ? ', ' Yes , how are you doing ? ', ' Not bad . ', " Say I've got two tickets for the concert this evening.Would you like to come with me ? ", ' Sure.Thank you very much . ', " Then I ' ll pick you up at six thirty.OK ? ", ' Ok , see you . ', ' See you . ']
['David , do you think which team will get the champion tonight ? ', ' It is hard to guess now . Both of the teams chose the excellent players this time . I guess the game will end in a tie . They are equally matched . ', ' I am so nervous now . What a terrific game ! ', ' Which side are you on ? ', " It's hard to say , because each team has my idols . ", ' Wow ! AC wins . It is a close shave , you know . ', ' I will never forget this match . The angle is so terrible and so correct . ', ' What a good goal ! ']
['There are lots of new teachers in our class this semester . ', ' Yeah , so what do you think about the teachers ? ', " To be honest , I like all of them , except for the math teacher . Though he must be quite young , he seems like an old person . He's so boring . ", " I think so too . I don't like him either . Well , who do you like best ? ", ' It might be the English teacher . What about you ? ', " Me , too . She speaks very clearly and doesn't use very complicated words so that it is easy for us to understand her . ", ' She is a pretty good teacher ! With her help I think I can make great progress in English . ', ' Yeah , I like her way of teaching . She told us not to cram for exams , and to pay more attention to communicating than memorizing . ', " I think it's a good way to develop our language ability . ", " Actually , our new math teacher is a good person . He just can't find an appropriate way to teach us . "]
["Don't cover up your sadness . Let it go . ", " I'm sorry . ", " It isn't your fault . No one will blame you . ", ' You are so thoughtful . ']
['Can you recommend a resort to me ? ', ' What about the Yellowstone National Park ? ', ' Have you ever been there ? ', ' Yes . The scenery is so breathtaking . ', ' What is especially impressive ? ', ' There are thousands of hot springs and fountains . The park is known for them . ', ' Is there a waterfall ? ', ' Yes . The well-known Yellowstone Waterfall is formed when the Yellowstone Lake falls down into the Yellowstone Canyon . ', ' What an attractive place ! How can I get there ? ', ' You can take No . 2 bus . ']
['Bobby ! Come here , look what I got you ! ', ' What is that ? ', ' A chess board ! Daddy is going to teach you how to play ! ', ' Cool ! ', ' Ok , each player gets 16 pieces . You can be the white ones and I ’ ll play with the black pieces . Now in the front , you set up the pawns . Those are the least valuable pieces and can only move one space forward . When you are about to capture another piece , it can move one space diagonally . ', ' What about all these other pieces ? ', ' See this one that looks like a tower ? It ’ s called the rook . The one with the tall hat is called the bishop . See this little horsey ? This is called the knight , it ’ s a very important piece so it ’ s best to not let your opponent capture it . ', ' And these two ? They are husband and wife ? ', ' That ’ s right ! That ’ s the queen and that ’ s the king . If the other player captures your king , he will say Check Mate and the game is over ! Doesn ’ t this sound fun ? ', ' Nah ! This is boring ! I ’ m gonna go play Killer Zombies on my PlayStation ! ']
['Hello , Elitherbeth How are you ? ', ' Fine , thanks . ', ' Are you sure you ’ re alright . You look a bit worry today ? Is anything wrong ? ', ' Well , Yes . There are something wrong actually . Perhaps you can give me some advice . ', ' of course if I can . ', ' Well , Last night when I returned from thetheatre I found I lost my wallet . ', ' Oh dear . That ’ s terrible . What was in your wallet ? ', ' Well , some money of course , a vise , all my identity cards and some photos . ', ' Well , If I were you , I would go to the police station straight away and calling . ', ' Yes , I have already done that and they already look for it . I ’ ll leaving soon and I need my vise and identity cards badly . ', ' Oh dear . What a pity . Are you sure you lost your wallet in theatre ? ', ' Yes , quite sure . ', ' I think you should put an advertisement in china daily . Things where you lasted . ', ' But that takes too long . ', ' Wait a minute , My uncle lives in Beijing and he lives very close to theatre . I ’ Ve telephone here and ask him to go to theatre to require it . We ’ d better have breakfast now . and meet him later . ']
["Well , it's too bad that we like different kinds of movies . Maybe we're just different kinds of people . ", " Yeah it's too bad ... but actually I think I know what to do . ", " What's that ? ", " We can go to a horror movie , and I'll hold your hand so you don't get scared . ", ' You mean ... like on a second date ? ', ' Of course ! Or are you still too scared ! ', ' No way ! That sounds great ! ']
["Oh , it's getting late . I've got to run . It was nice talking to you , karren . ", ' Thanks , Tim . Nice meeting you , too . ', " I guess we'll see each other around . ", ' Yeah , I hope so . Well , take it easy . ', ' You too . ']
['Jared , I just heard about your father . How is he doing ? ', " He's in the hospital resting . The doctor's didn't give a clear answer yet . ", " I'm so sorry to hear that . But this is a good hospital . I'm sure they will do whatever they can . ", ' I hope so . ', ' You must feel really worried right now . But you know your dad is a fighter . ', " Yeah . I think my mom is the most worried . I'm basically worried about how she is doing . ", ' Where is she right now ? ', " She's in the hospital with my dad . I have to go back tonight . ", " Hey , I'll go with you . ", " You don't have to . ", " It's really no problem . ", " Ok . Let's go right after dinner . "]
['All right . But these are black and I don ’ t like black shoes . They ’ re dull . ', ' Well , black is a better color than pink . Pink ’ s for girls . ', ' Then why are you wearing black shoes ? ', ' Because ... oh , all right . You win . Let ’ s pay for them and go . ', ' Hey , thanks , mum . ']
["I'm really sorry , Bob . I accidentally damaged your bike . ", " Uh-oh . It'll probably cost a lot to fix it . ", " I'll make it up to you . Let me know how much it costs and I'll give you the money . "]
['Tell me about your brother and sister , Sue . ', ' Well , my sister is a lawyer . ', ' Really ? Does she live here in Seattle ? ', " Yes , she does . But she's working in Washington , D . C . , right now . Her job is top secret . ", ' Wow ! ! And what does your brother do ? ', " He's a painter . He's working in Argentina this month . He has an exhibition there . ", ' What an interesting family ! ']
['What do you do now ? ', " I'm out of work at the moment . ", ' Why ? ', ' I was fired last week . ', " I'm sorry to hear that . ", " It doesn't matter . ", " What's your plan now ? ", " After the tour I'll have a rest . And then go to find a new job . ", ' Best wishes for you . ', ' Thank you . ']
['Your face is so red , you must running a temperature . ', ' I have a severe headache now . ', ' Please go to see a doctor . ', ' Would you like to go with me ? I ’ m afraid of the hospital . ']
['He got the scholarship to Harvard . ', " You're kidding ! ", " It's true . He is a hard worker . ", ' I know he really deserves this . ']
['What happened to you yesterday ? ', ' Oh I fell over on the way to work . ', ' Oh I see . So that ’ s why you didn ’ t come in ? ', ' Yes and I broke my phone too so I couldn ’ t call you . ', ' Oh dear , that sounds terrible . ', ' It was ! But the worst thing was I tore my best shirt . ', ' Oh dear . Well , get well soon and try to be more careful in future . ']
['Hey , David . Would you like some drinks ? ', ' OK . Shall we go to a bar ? ', ' Good idea . I like hanging out in bars at night . ', ' Why ? ', ' For killing time and making new friends . ', " Don't you think it ’ s too noisy here ? The rock music ! I can hardly bear it . ", " Calm down ! My little guy ! You'll get used to that after you come here several times . ", " Well , I'll try . Then what would you like to drink ? It's on me . ", " I'd like a gin and tonic . "]
['What ? ', ' What happened with that guy at the cafe ? ', ' nothing . ', ' But you ’ re crazy about him . ', ' Yes , I am . ', ' Why don ’ t you run off with him ? What are you waiting for ? ', ' I don ’ t actually know him . ', ' Really ? ', ' I only know him through the ... you are not gonna believe this . ', ' Oh , let me guess . Through the internet ? ', ' Yes . ', " Hmm . ' You ’ Ve got mail . ' "]
['Happy Birthday ! This is for you , Kate ! ', ' Thanks.Miss Zhang . ', " You know in China we usually don't open presents until the guests leave . ", " Really ? I've already opened this one.Say , this is sweet , and it's just what I need to go with my new suit.Thank you ever so much . "]
['This place is so quiet and peaceful . It ’ s really different from my pad at city . ', ' Sure , do you think you could live out here ? You know , back to nature at all ? ', ' I don ’ t know . I don ’ t mind coming out here for a while , but that will get old pretty soon . ', ' That ’ s what I was thinking . I mean can you imagine Friday night instead of going out with your friends you ’ d have to stay in your tree house and talk to birds and squirrels . ', ' I think I ’ d go lonely if I do like that . ', ' And where would you get a cup of cappuccino ? ', ' Now that would be hard to live without . We city folks are pretty spoiled . ', ' Maybe . But I ‘ d rather be spoiled than turn into a crazy guy with a long period to talk to the birds . ']
["I don't stand a chance of passing the exam . ", ' Come on , Brenda ! Never say die . ']
['Have you ever been to Britain ? ', ' Oh yes , I ’ Ve been to Britain many times . I go there on business . ', ' Really ? How often do you go there ? ', ' Usually , I go to London twice a year but sometimes I go three or four times a year . ', ' Do you always go on business or do you sometimes go for a holiday ? ', ' I ’ m afraid I never go for a holiday . It ’ s always business . ']
['I plan to emigrate to Canada . ', ' Have you found a suitable job ? ', ' No . But it is said the welfare in Canada is very good . ', ' But as to me finding a good job is the most important thing . ', ' Maybe you are right , so I will try my best to find a suitable job . ']
['Mary , would you like to get something to eat with me ? ', ' OK . When ? ', " At 10 o'clock . ", ' 10 in the morning ? ', ' No , at night . ', " Sorry , that's too late . I usually go to bed around 10:00 PM . ", ' OK , how about 1:30 PM ? ', " No , that's too early . I'll still be at work then . ", ' How about 5:00 PM ? ', " That's fine . ", ' OK , see you then . ', ' Alright . Bye . ']
['Have you been to Shanghai before ? ', ' Yes I have . I ’ Ve been there three times in the past year . ', ' That sounds great . Have you been to the top of the Pearl Tower ? ', ' No I haven ’ t . I haven ’ t visited the Bund either . I ’ Ve always had too much work to do . ', ' So you haven ’ t done much then , in Shanghai ? ', ' Actually , I ’ Ve eaten soup dumplings in a lovely restaurant on Nanjing Lu . They were delicious ! ']
['Are you enjoying your trip to New Orleans ? ', ' Oh , yes . I really like it here . ', ' Would you like to do something tonight ? ', " Sure . I'd love to . ", " Let's see . Have you been to a jazz club yet ? ", " Yes . I've already been to several clubs here . ", ' OK . What about an evening riverboat tour ? ', " Uh , actually , I've gone twice this week . ", ' So , what do you want to do ? ', " Well , I haven't been to the theater in a long time . ", " Oh , OK . I hear there's a terrific show at the Sanger Theater . ", " Great ! Let's make a reservation . "]
['what sort of music do you like ? ', ' I love just about anything by Prince . ', " so , you're into 80s music then ? ", ' well , I like all kinds of music , but he is one of my favorites . How about you ? ', ' I like alternative music . ', ' do you have a favorite band ? ', " to be honest , no . I'm always in search of new music to listen to . ", ' do you often go to concerts ? ', ' I usually go to see a live band about twice a month . What about you ? ', " I love going to live gigs . Are there any good local bands playing around here that you'd recommend ? ", " there's an open mic night at the pub down the road every Thursday night where my favorite local band usually plays . You should come along next week with me . ", " I'd love to , but I have a night class on Thursdays . ", " that's too bad . Maybe another time . ", ' let me know if you hear about any good bands playing on the weekends . I have more free time then . ', " I'll let you know . Did you want to watch some TV ? ", " sure , what's on ? ", " there's a reality TV show about a group of people who are trying to lose weight . ", ' that sounds dreadful ! ']
['I want to try something different today . ', ' What do you mean ? ', ' I want a different hair style . ', ' What style do you want ? ', ' Can you make my hair short ? ', ' Exactly how short do you want it ? ', ' Make it a few inches long . ', ' Are you sure you want me to cut it that short ? ', " I've been thinking about this for a while now . ", " Okay . I'll do it if you're positive that this is what you want . ", ' I honestly want my hair that short . ', " All right , then let's begin . "]
['Would you please tell me something about the agriculture and industry of New Zealand ? ', ' The agriculture in New Zealand is highly mechanized . The industry mainly focuses on the manufacture of agriculture and stockbreeding products . ', ' I see . ', " If you need any further information , please don't hesitate to ask me . ", ' OK , I will . ']
['How are you , Sue ? ', ' Pretty good . I ’ Ve just had my new poems published . ', ' Congratulations on your success . ', ' Thank you . ', ' And how ’ s your brother ? ', ' He is fine . ', ' He ’ s going to be sent to Britain to study , really ? ', ' Yes . He ’ s already got the passport and visa . ', ' Fantastic ! Please send him my congratulations . ', ' Thank you . He ’ s very lucky indeed . ']
['How long have you been in Taiwan ? ', ' About 3 years , so I came here 2000 . ', ' So , where did you grow up ? ', ' Providence , Rhode Island . do you know it ? ', ' I am not sure , where exactly is it ? ', ' Well , not so far from New York . So what about you ? Did you grow up here ? ', ' No , I was born in Gaoxiong , I only moved to Taipei after I graduated . ']
['What are you doing ? ', ' Look at me . I look so old ! I look as if I were thirty . ', ' Come on ! Stop being so vain . You look great ! You are beautiful ! ', ' Yes , I am , but I think it ’ s time for some plastic surgery I ’ m tired of these wrinkles and sagging skin . See ? ', ' I don ’ t see any wrinkles or sagging skin ! You are stop beings ridiculous . Besides , I think that people who get Boto , have facelifts , or tummy tucks look weird.It doesn ’ t look natural . ', ' Whatever , I think I ’ m gonna get liposuction and a nose job and some breast implants as well . ', ' I think you need to get brain surgery . I honestly don ’ t think you need cosmetic surgery.You look amazing . ', ' I thought you were my friend and would support me on this ! I just want to feel better about myself and feel more attractive . ', ' You don ’ t need plastic surgery to do that . You are fine the way you are and you have guys drooling all over you ! Plus , plastic surgery hurts ! ', ' Really ? ', ' Yeah ! When I got my nose job I was black and blue for a week ! ']
['What time is it by your watch ? ', " I'm sorry , my watch has stopped . ", " It's 2:42 by my watch . But it moves a bit fast . ", " Let's ask someone else . "]
['So how much should I gamble ? ', ' Why not fifty or one-hundred dollars ? ', ' Okay . One-hundred then . Do you think I will lose it ? ', " I don't know . You have to be smart , but you have to be lucky too.Some games are all luck . With some , you need to be smart . ", ' I want games that are all luck . ', ' I knew you would say that ! Then you should play the slot machines . ', " Slot machines ? No , I don't want that ! That's too boring . I want a game with cards or dice . ", ' So what do you want to play then ? ', ' Blackjack.We can play blackjack . And I will gamble one-hundred , or maybe two-hundred dollars . ', " Huh ? You are breaking our rule already ! And we didn't even start to play yet ! ", " Oh , don't be so strict ! We are in Las Vegas . ", ' Yes , and if I stay with you , we will have to walk back home to New York.Because we will lose all our money and our plane tickets too ! ']
['I just won the lottery . ', " You're kidding ! "]
["I didn't expect to see you at this hour . You must have goofed off again . ", " Goofed off ? Maybe , but I'm not a clock-watcher . I finished doing what I should do and then knock off an hour earlier . ", " You'll be sorry if you the boss finds it out . He may probably give you the bag . ", " I'm sure of what I'm doing . "]
["Professor , I've handed in my paper . Did you read it ? ", " Yes . You've done a good job . But there's one thing . You should narrow down your topic . ", ' What about water pollution instead of pollution ? ', ' Well done ! ']
["Look , it's all water over the dam now . Let's leave it behind us . ", " Yeah , I know , but it's too hard to do . ", ' Our eyes should look into the future . We could not live in the past . ', ' Only sometimes when I think about it , I feel very sad . ', " It's normal . Time will change everything . "]
["Many people say it's a good story.But I think it's boring ! ", " I don't think I share your view there.The writer is writing about history , society , human nature and so on.It ' s too hard to understand . "]
['How good are you at sports , Bill ? ', ' Are you kidding ? I ’ m terrible ! But I love to watch sports . I go to football or baseball games a lot . And I read sports magazines every week . ', ' Wow ! ', ' Do you like sports , Janice ? ', ' Oh , yes . I like to exercise . But I don ’ t watch sports or buy sports magazines . I don ’ t have much time to do those things . ', ' Oh , I see . You know , we spend time doing different sports . How much time do you spend exercising ? ', ' Well , I guess I exercise about two hours a day . I do aerobics three times a week , and the other days I play badminton with my husband . I always feel good afterward . ', ' That ’ s great ! I ’ Ve heard people say that before . ', ' Well , why don ’ t you try to get some exercise ? It ’ s difficult , but very rewarding . ', ' Oh , I ’ m too lazy to play sports , and I ’ m not good at anything either . It hardly excites me . ']
['I had broken up with him , how painful I feel . I ’ m going to drown my sorrows . ', ' I see . But Jane . He ’ s not worth your sorrow and you should restart your new life . ']
['My brother started investing money when he was 16 years old . ', ' The early bird catches the worm . ']
['What can I do for you ? ', ' I would like to use the copy machine . ', ' The machine is over there . ', ' Do I have to pay to use the machine ? ', ' Yes , you will have to pay to use it . ', ' How much ? ', ' It costs ten cents a copy . ', ' Am I limited to a certain number of copies ? ', ' You can copy as much as you ’ d like . ', ' Could you show me how to use the copier ? ', ' The instructions for the copier are posted on it . ', ' That ’ s fabulous . Thank you . ']
["Mom , happy Mother's Day ! A necklace for you . ", " What a surprise ! This is the best present I've ever received . ", ' Thank you for your love and care over the years . I love you so much . ', ' I love you , too . ', ' How about a dinner tonight ? My treat . ', " Actually , I prefer to eat at home , and then we'll have more time to have a chat . ", ' All right . Let me prepare the supper . ']
['What do you know about Julia Roberts ? ', ' Her acting is OK . ', ' I mean her personality . ', " I'm afraid I know less than you do.Tell me more about her , will you ? "]
["How's the weather today ? ", " It's hot . ", " I really don't think this weather will last . ", " Let's just hope it doesn't get hotter . "]
["Nice day today , isn't it ? ", " Yes , it's beautiful weather we're having . ", " We can't complain about the weather recently . ", " Yes , the sun shines day after day . It's neither too hot nor too cold . ", ' I wonder how long this weather can last . ', " I hope it will stay fine tomorrow . I'm going to have a picnic with my family . "]
['Excuse me . Do you study Chinese at the university here ? ', ' Yes , I do . But my characters are very bad . ', ' It takes a long time to learn Chinese writing . ', ' Are you Chinese ? ', ' Yes , I am . I am from Taiwan . I came here to study political science . ', ' How do you like it ? ', ' I like it so far . But my English still needs work . ', ' I want to study Mandarin and international relations . ', ' Does the Chinese department here teach regular characters or simplified characters ? ', ' They teach regular characters . ', " I see . I'm from Taiwan , so I know regular characters better than simplified . ", ' You just said your English needs work , yes ? ', " Yes , that's true . Especially my writing . I think my papers aren't good enough . I make too many grammatical mistakes . ", ' Well , I am very serious about learning Chinese.But for me the hard part now is pronunciation.You have the four tones in Chinese . It is very hard . Maybe , if you have time , maybe we could do a language exchange . ', ' You mean you and I ? ', ' Yes , why not ? I mean , if you come to this cafe often , maybe we could meet here and practice Chinese and English . ', ' That sounds like a good idea . How often would you like to do it ? ', " Let's see ... My schedule right now is quite busy.But I think I could spend 90 minutes a week in language exchange . ", ' How would we manage it though ? How would we spend the 90 minutes ? ', ' First , we could spend 45 minutes working on your English writing.If you want , I could help you edit your papers.Or we could do English conversation . Whatever you want.And then the next 45 minutes you would help me with my Chinese . ', ' Would I help you with writing ? ', ' No . For me right now , the important thing is spoken Chinese . I need practice . So you could tutor me in speaking.We could use my textbook , and you could ask me questions.Then you could correct my mistakes . ', ' I think it sounds like a good system . But when is it convenient to meet ? ', ' Well , today is Monday.Actually , for me Monday at this time would be the best . I am free from now until 11 ', " Me too . In fact , I'm free until 1 ", ' So if you want to meet at 10 ', " It sounds good . I will bring the papers I'm working on . ", ' And I will bring my textbook and a tape recorder . I would like to record some things so I can practice on my own . ', ' Let me give you my phone number . ', " Sure . I'll give you mine too . Then we can call if we have to cancel for some reason . "]
['could we possibly discuss my salary some time ? ', ' sure . ', " first of all , I want you to know that I really like working for this company . Do you think I'm doing a good job here ? ", ' well , you are a very hard-worker . ', " I try very hard . The problem is , my salary just isn't enough to live on . Now that I have a wife and a child to support , we hardly have enough money for food and rent . ", ' there are trying times for everyone . What do you propose ? ', ' I could really use a 5 % rise . ', " that's quite a bit . If I give you a raise , I'm going to have to give everyone a raise . ", " listen , if you give me a raise , I'll take on extra responsibilities . ", " that sounds reasonable . How about this , from now on , you can be responsible for scheduling . That means that if you can't find someone to cover a shift , then you'll have to do it . ", " that's fine . Do I get over-time for any extra hours that I work ? ", " of course . It's be against the law if we didn't . ", ' that sounds good to me . I really appreciate it . ', " you are welcome . Come in early tomorrow and I'll show you how to do the scheduling . "]
['Your knowledge of English is really surprising . ', " Oh , it's nothing to speak of . ", " No , seriously . I'm impressed . ", ' Thank you . I appreciate the compliment . ']
['Are you watching the soccer match tonight ? It must be the most exciting one in this season . ', ' Well , of course I can ’ t miss it . Which team are you for ? ', ' Manchester United . What about you ? ', ' Me too . Do you think they are going to get the championship this time ? ', ' I have confidence in them . ']
['Where are you going to spend your holidays this year , Tom ? ', " We may go abroad , my wife wants to go to Egypt , and I'd like to go there too . We haven't made up our mind yet . ", ' Will you travel by sea or by air ? ', " We may travel by sea . It's cheaper . ", " I'm sure you'll enjoy yourselves . "]
['David , I ’ m going to China . ', ' Really ? How do you get the chance ? ', ' You know . I took part in the Chinese contest . I was the best and they gave me this reward . I don ’ t have to pay for my trip . ', ' Congratulations . How lucky you are ! ', ' Thank you . I ’ m leaving tomorrow morning . ', ' I ’ m sure you ’ ll enjoy the trip . China is such a beautiful country . ', ' I ’ m sure I will . ', ' Have a nice journey , Lily . ', ' Thank you , David . ']
['Your search on this project has been excellent . ', ' Thank you . I couldn ’ t have done it without the help of a strong team . ', ' The final report is exceptionally thorough and well done . I think that you have been come up with some interesting recommendations for the client . ', ' Well , I hope the client feels the same way ! ', ' I am sure they will be pleased . ']
["I'm exhausted . My new exercise is so hard . ", ' I think it is easy . I could work in your class with no problem . ', ' You thing so ? ', ' Oh , without doubt.When is the next class ? ', ' Tomorrow morning.Try it . ', ' No problem . ', ' Are you going to this class this morning ? ', ' Of course , easy.No sweat . ', " You're no able to move after this class . ", " Are you kidding me ? It's going to be up a piece of cake . ", ' You want to bet ? ', " Yeah , what't the bet ? ", ' I bet I can go one hour in your class this morning and not feel a thing . ']
['Happy Birthday , Mary ! ', ' Thank you . ', ' Here is a gift for you . I hope you like it . ', ' What a lovely dog ! How did you know I love things like this ? ', " I had my own ways of finding out.It ' s a secret . You look so beautiful today . Your new shirt goes well with your skirt . ", " Maybe you won't believe this , but it was made by my grandmother . ", ' Really ? It looks so nice . ', ' Thank you , Please have a cup of tea . ', ' All right . ', ' How about some fish ? ', " No , thanks . I've had enough.Now , Mary , before you blow out the birthday candles , you have to make a wish.After that , you may cut the cake . ", ' OK.Let me make a wish ... Do you want a big piece of cake ? ', ' No , just a small one.Next Let\'s sing " Happy Birthday " to Mary . ', " It is so very kind of you . I'm so moved by you . "]
["Does anyone mind me turning on the air conditioning ? It's hot in here . ", " Actually , I prefer if you didn't . Air conditioning makes me sneeze . ", " All right . I'm opening the window , though , is that OK ? ", " Oh , sure . It's very stuffy in here . "]
['More and more women don ’ t want to stay at home and keep house now . ', ' This is the result of women ’ s liberation . ', ' Now , many people think that women ’ s liberation is a kind of civilization , but children are getting less love from their mother because of that . What is your opinion ? ', ' I have no idea . ']
['Thank you so much for coming tonight . Everybody really enjoyed your performance . ', " I'm glad I could help . ", " Here's the check . I included a little extra for you . ", " You didn't have to do that ! ", ' I know , but you deserve it . ']
['Graham , why are you always on the phone with Jane ? ', ' Because we are partners in our science lab . Why are you so jealous ? ', ' The other night when you came home there was lipstick on your right cheek . How do you explain that ? ', ' My aunt Mary just flew in from Cleveland and she laid one right on my right cheek . ', ' Are you sure ? ', ' Of course I am . I only love you , Amy . ', " Okay , I'm sorry . I believe you . ", ' Why do you always accuse me like that ? ', " Because you are the most handsome boy at the university and I love you so much ! I guess I just go crazy sometimes . That's all . ", ' Oh , Amy . I am the luckiest guy in the world . ', ' Why ? ', ' Because I am loved by the most beautiful girl in the world ! ', ' Oh . Graham . I love you so much and I really believe in our love . ']
['What are you doing this weekend ? ', ' Nothing much . I ’ m going to the cinema on Friday night but that ’ s all I have planned . ', ' So you ’ re free on Saturday night ? ', ' That ’ s right . ', ' Would you like to have dinner with me ? ', ' Oh , that would be lovely . Shall we say seven o ’ clock ? ', ' Perfect . I ’ ll pick you up then . ']
['And so , that concludes my outline for our marketing strategy next year . Thank you very much for your time . ', " Hey , that was quite the presentation ! Honestly , I was completely blown away by your strategy outline . I've gotta say , Alex , you really wowed me today . ", " Aw , come on , it was nothing . I'm just doing my job . ", ' No , I think you deserve some recognition here ; I mean , if I look back on your previous presentations , this is a huge improvement . ', " Well , Kristin did give me a hand with the slides.She ' s a real wiz on PowerPoint . ", ' And I saw that you took on board my feedback about pricing strategies . I really appreciate you taking the time to think though my suggestions . ', ' Yeah , well , that was some good advice . You made some really good points . ', ' Well , I just wanted to say well done . Really you did a great job . ']
['What are you listening now , Fred ? ', ' What ? ', ' Hey ! Man , put your earphone out . I said which song you are listening to . ', " Jay Chou's title song in his new album . ", " What's your comment on his new album ? ", ' Gorgeous ! There is another song combining Chinese and western music styles . I am crazy for it , so I hear it over and again . And I plan to make it as the ringbone of my mobile . ', ' Let me enjoy it . ', ' I suppose this song can be the No . 1 on the top chart . ', " I cann't wait for buying his CD now . "]
['Are you sure that this is the place to wait for our school bus ? ', ' Yeah . Look , other kids are coming this way . ', " But it doesn't look like a real bus stop . ", " That's because regular buses don't stop here . ", ' How much is it going to cost ? ', " Nothing . It's free . ", ' Is that yellow bus it ? ', " Let's go sit in the back . All the cool kids do . "]
['How is Jim recently ? ', ' He has lost his job , and his wife died from cancer not long before . ', ' Poor guy ! It will take him a long time to get back on his feet . ']
['She lives a happy life after marriage . ', ' We all know that . Her husband always make a fuss of her . ', ' Lucky her . ']
['Excuse me , are you American ? ', ' No . ', ' Do you speak English ? ', ' A little , but not very well . ', ' How long have you been here ? ', ' 2 months . ', ' What do you do for work ? ', " I'm a student . How about you ? ", " I'm a student too . "]
['Excuse me , I bought this sweater yesterday . But when I got home and tried it on , I found it ’ s too small . ', ' Do you have the receipt with you ? ', ' Yes , here you are . ', ' Thank you . Do you want your money back ? ', ' No , can I exchange it for a bigger one ? ', ' I am afraid this is the biggest size we have . ', " Oh , that's too bad . ", " Maybe you would like to try this one with the willow pattern . The price is the same and it's bigger . "]
['Did you enjoy that new movie ? ', " That movie's just a lot of noise , same as Simon . ", ' Oh , what happened , Carole ? ', " I had to go by myself , he couldn't make it . ", " What ? I met him just before I took off from Kitty's , he said he was coming . ", " Kitty's ? He sure gets around , doesn't he ? ", ' Looks like it . So how did he handle it to ? ', ' His excuse was familiar . He said his car died again . ', " I think that's a bunch of nonsense . It seemed ok to me . ", ' I know . Last week he gave me a lie about being too busy . ', " Doesn't sound promising . ", " Well , I think it's the time to pull the plug . ", " If you want I'll let him know if I run into him . ", " Thanks anyway , but I'll do it , Rebecca . Let's get the class . "]
['Hi , it is a pleasant surprise ! ', ' Yeah , it ’ s been ages ! So how have you been ? ', ' Couldn ’ t be better . And you ? ', ' Just as usual , you know . ']
['How do you celebrate Thanksgiving in the US ? ', ' Well , Thanksgiving is family event.So on Thanksgiving , family members will get together and enjoy a big Thanksgiving dinner . Kids will have lot of fun . ', ' Do you say prayers before dinner ? ', ' Yes , we do . It is an exciting moment . ', ' What is the biggest fun for you on Thanksgiving ? ', ' For me ? The football games of course , I love football games . ']
["You seem really ticked off . What's up ? ", ' Just get out of my face , would you ? ', " Chill out ! What's eating you , anyway ? ", " Sorry . I'm just that I think I blew the final and now my parents are going to get all bent out of shape . I like totally drew a blank on everything ! ", " Well , now you're really going to freak out when I tell you who aced it ... what's-her-face ... the one who always kisses up to the teacher . ", " Jennifer Davies ? Give me a break ! I can't stand her . She's such a dweeb ! How could she possibly ace it when she keeps cutting class all the time ? ", " She's the teacher's pet , that's why . Besides , he's so laid back he lets her get away with it . She just really rubs me the wrong way . And you know what ? I think she's got the hots for him , too . ", ' Get out of here ! ', " I'm dead serious . Yesterday , before class starts , she walks up to Mr - Edward's desk and goes , ‘ Good morning , Jim . ’ ", " Oh , gag me ! She's totally gross ! "]
['Is the Chinese team taking the lead ? ', " No , it's the Japanese team . ", ' Japanese teams always play a dark horse . ', ' Well , their team work is well worth learning . ']
['You are quite busy every day . ', ' Yes . Work starts at eight and I arrive home after six . ', ' So you have to work all day . ', ' I can take a break at lunch time , but it is only 30 minutes . ', ' I see you sometimes work on weekends , too . ', " Yes , I really don't like it . "]
["Hi Mary , how's it going ? ", ' well , last night I had a big argument with Ann . ', ' terrible . It must be something serious . You two are such close friends . ', " now that I look back at it , it wawsn't that big a deal . I shouldn't have lost my temper . ", ' really ? What happened ? ', " it's just we've been planning to go the beach for a while , and we decided we could both make it this weekend . Then out of nowhere she called me up , said her boyfriend had made plans and that she nee ", " that's pretty harsh . ", ' I know , but I was so upset . I mean , come on ! Does she have to do everything her boyfriend says ? ', ' you know she probably feels just as bad . ', " well , I think I was being a little selfish myself . I know they don't get to see each other very often . ", " well , in that case I guess maybe you can be more understanding . You shouldn't let a trivial thing like this stand in the way of your friendship . After all you can go to the beach anytime you want . ", " yeah , I'll call her later to patch things up . "]
['Henry , I want to ask you something . ', ' Say what you want to say . ', ' You see . The wage is not paid yet , I am wondering if you could possibly lend me some money . ', ' I am sorry . But I do not have any money to lend to you . ']
["OK , Devon , I've been putting on a few pounds and you're quite a lean fit guy . ", ' Well , thank you . ', ' What do you recommend ? What can I do to lose weight ? ', ' Well , I exercise a lot . I go running at least three times a week . But more than that I enjoy playing sports and so different sports use different muscles and all of it helps to lose that weight that you might have gained . ', ' Yeah , well , actually , one of the problems is that I actually exercise a lot . ', ' Do ya ? ', " Yeah , so maybe it's my diet . ", ' It could be and so in that case you might want to eat something perhaps more nutritious or maybe even less of what you do eat . Maybe , I eat three meals a day and I try not to snack in between . No potato chips . No popcorn . No candy bars . ', " That's pretty tough ! "]
["I don't think the manager will get mad at you for being late . ", " I don't know about that . "]
['I hear you are moving to Dalian . ', ' Yes . I found a very good job down here . ', " Well , we'll certainly miss you here . ", ' I am going to miss you , too . ', " Let's keep in touch . ", ' OK . I will write to you as soon as I get there . ']
['Nice weather , honey ! ', ' The days are getting longer ! ', ' May and Daniel often like this kind of weather . ', ' Yeah , they can enjoy themselves in the day time and it is not so hot . ', ' Honey , how about taking them to the beach this weekend ? ', " That's great ! ", " Since last time we've climbed the mountain , we haven't gone out for a long time . ", ' And this kind of weather is rare for the season either . ', ' Yes , I remember last year this time , the weather is so hot . ', ' So we must seize this chance to go the beach . ', ' Daniel loves the beach very much ! ', ' He will enjoy himself this weekend . ']
['Have you met John recently ? ', ' I saw him last week . It seems he was a bit queer in the head . ', ' Yes , he has been like that since his accident . ', ' What a pity ! ']
['What are you doing tonight ? ', ' I have to run to the grocery store . ', " Don't you hate fighting the crowds on the weekends ? ", ' Yes , but I am out of food and milk . ', ' What store do you shop at ? ', ' The small one , just down the street . I like their generic brand . ', ' I have been using the store across town for years . ', ' I hear they have very nice stuff . ', " They do , but they're a little expensive on certain items . ", ' Well , you should try my store . The prices are good . ', ' I will sometime . Thanks for the advice . ']
["I'm happy to see you again . ", ' Me too . ', ' We should do this more often . ', " Okay , I'll give you a ring next week . "]
['What will happen to the children if you break up ? ', " That's a relief for me and a misery for the children . ", " Why don't you make up with John . ", " It's too late . "]
['What upsets you ? ', ' My parents called . As usual , they reminded me again that I should have a plan to marry by my late 20s.Easier set than done . Who should I marry ? I have no time to go on a date . ', ' It is not your mother finding one for you ? ', ' I will find one myself , of course . I ’ m a modern girl . ', ' Perhaps you can try the three minutes date , the latest type . ', ' You mean dozens of the opposite sex meet each other for three minutes in a dimly bar serving alcohol , I hate that idea . ', ' No , there is an updated version , three minutes video date . I know an online dating website providing such service with a microphone and webcam , you can sigh for it . You can be face-to-face with a guy talking for maximum three minutes . ', ' I don ’ t think it makes sense . Three minutes is such a short time . ', ' I think you can find out if there is a possibility of romance within the first second of meeting someone , so-called love at first sight . ', ' Anyway , I don ’ t want to post my face up for sale on the internet like that . ', ' Don ’ t worry . There are many other options using the internet as dating methods . Some sites operate at international standard even have got certifications . ', ' Of course , for these sites , you have to pay a membership fee . But all in all , it is more serious and professional . The chance of meeting a good and serious person who does not play games is higher . ', ' I don ’ t want to post my personal information on the internet . I ’ m not knowing who is reading it . ']
["Hi , dear , I've got your voice at last . ", ' Hi , darling , I am thinking it is the time of your calling . ', ' Are you OK today ? ', ' Quite good except thinking of you so much . ', ' So do I . You are a beautiful flower in my mind . ', " It's called love is blind , I think . "]
['Did you watch the movie program on Channel 6 last night ? ', ' Yes , I did . It is a horrible movie . ', ' I wonder why TV programs often show much violence . ', ' Actually , more and more people have realized that violence on TV may lead to the increase of crime rates among teenagers . ', ' They are especially harmful to teenagers . ', ' But anyhow there are many worthwhile programs . ']
['I hate to see the abuse of animals . ', ' It makes me sick . ']
['Hi ! Bob , are you having problems with that ? ', ' Yes , how should I set up my new computer ? ', " It's easy , let me help you . ", ' Great , thanks a lot . ']
['Good morning , Mr.Jones ! ', ' Good morning , Miss Bell ! ', ' Nice to see you again . ', " Nice to see you too.It ' s been a long time . ", ' How is everything ? ', ' Just fine , and you ? ', ' Quite well , thank you . ', ' Did you drive yourself to the airport ? ', ' No , I was driven by my husband . ', ' Did someone meet you at the airport here ? ', ' Yes , thanks . ', " Is this where we'll be holding the meeting ? ", ' No , the meeting will be held on the fourth floor . ']
['What should we do this Saturday ? ', ' Rocky six is suppose to come out this Friday . ', " Yeah , but I don't know if it is going to be any good . ", ' The only reason I want to see it is because I have seen the previous five . ', " True . Ok . Let's see it this Saturday . ", ' How about we hook up for lunch at 12:00 , and then go see the movie afterwards . ', " Sounds like a plan . Let's meet in front of Tower Records at 12:00 . "]
["It's almost Christmas . What are you doing this weekend ? ", ' Nothing special , just working . Why do you ask ? ', " Well , I still haven't finished my Christmas shopping . Do you want to go shopping with me this weekend ? ", " I'd like to , but I'm not sure if I can . Work has been really busy lately . Why don't we go on Friday instead ? ", " Friday's not good . I think the stores will be very crowded and I have to work . ", " OK , then let's try to go this weekend . I should know if I can go by Friday . Is it OK if I call you then ? ", " Yeah , that's fine . ", " What's your number ? ", " 233-331-8828 . Let me give you my email address too . It's Tom861@gmail.com ", " OK , I'll talk to you soon . ", ' OK . ']
['Can I borrow these magazines ? ', ' Fill in the slip , then take it to the circulation desk . They will get you what you want . ', ' Are we allowed to go into the stacks to look for books ? ', ' Sorry , the stacks are closed to undergraduate students . ']
["I never watch foreign films . They're too boring . ", ' Jason , you have no taste . You think First Blood is a good movie . ', ' Hey , it is ! A lot of people like that movie ! ', " I'm sorry , but it's a bad movie . The plot is stupid , and the script is poorly written . ", " Face it , you don't like action movies because you're a snob . ", " No , I don't like action movies because I'm cultured ! "]
['This is tough to say , John , but I think we should break up . ', ' Are you serious ? ', ' Yes , I mean it . ', ' But why ? Did I do anything wrong ? ', " No , we are just too different . This relationship isn't going anywhere . ", " Hey , come on . It's too early to say that . We can fix things . ", " I have thought about it for a long time . I think it's time to move on for both of us . ", ' But I still love you . ', " I'm sorry . ", ' I knew this would happen some day ... ', " Then why didn't you talk to me ? ", " Well . It's not all my fault , Anna ... ", " I don't want to argue with you anymore . This is going to be tough , but let's try to forget that and be friends . ", ' Have you made the decision yet ? ', " I think we'll be better off if we are apart . ", ' Then shall we keep pure friendship ? ', " Sure , let's just be friends . "]
['Hi , charlie , are you busy this evening ? ', " Sorry , I'm afraid that I've got plans tonight . ", ' What are you doing ? ', " I'm going to my parents ' house for my father's birthday . ", ' How old is he today ? ', " It's his 50th birthday . ", ' Well , wish him a happy birthday for me . ', ' Sure thing . What are your plans for the evening ? ', ' I was just thinking of going to a movie tonight . ', " Well , if you can wait until tomorrow night , I'll go with you then . ", " Sorry , I've got people coming over tomorrow night . ", " Sounds like this weekend just isn't going to work out for us . ", ' Sounds that way . Maybe some other time then ? ', " Sure.Hey , I'm sorry , but I've got to get going . ", " Yeah , me , too . It's about time I made a move . ", ' Say hello to your friends for me . ', ' Likewise . See you later . ', ' Bye ! ']
['I was wondering if you could help me to get a library card . ', ' Of course , just fill out this form and let me know when you are finished . ', " I'm finished . ", " I will also need your driver's license ; hand me the filled-out form , please . ", ' OK , the form is all filled out . ', ' Perfect ! Do you know the hours and rules for the library ? ', ' No , I have no idea what they are . ', ' Everything you need to know is printed on the card and handout . ', ' Yes , right . ', ' Great ! You are all set to enjoy the library . ']
['What did the boss say to you ? ', ' He asked me to beef up in the work . ', ' Yeah . You look so unhappy recently . What ’ s the matter . ', ' Nothing , thanks . I am just not in the mood these days . ']
['Hey Joanne . What are you up to ? ', " I'm just watching some television . ", " I'm so bored . I don't know what I'm going to do today and it is only ten in the morning . ", ' Me too . Do you think we are boring people ? ', " I don't think we are boring . It's just that we don't have any hobbies . ", " That's right . What do you think we should do as a hobby ? ", " That all depends on what you like to do . For example , I like to doodle on the notepad , so I'm thinking about doing some real drawings . ", ' I like to play the piano for fun . ', ' Yeah . That can be a good hobby . ', " Hobbies are great . I'm going to make a list of all the things I like to do . ", " That's a great idea . I'm going to do the same . "]
["Jack , what's wrong ? ", ' You ! ', ' What are you talking about ? What did I do ? ', ' You told Martha that I was on a date ? What was that all about ? ', " No ... that's not what I meant . I didn't mean that . She asked me where you were and I jokingly said that you were on a date with Sara . I thought Martha knew that you and Sara were just friends . ", ' She started feeling suspicious after you said that . ', " I'm sorry man . I didn't know . I didn't mean to screw anything up . ", " Martha gets jealous easily and it took a while to convince her that Sara was just a friend . Now , I have to explain to Sara that I can't hang around her because of you . ", " Look . I really didn't mean to , and next time I see Martha , I'll really tell her that you and Sara are really just friends . ", " Don't bother . "]
['Shall we for go out for a meal this evening ? ', ' I don ’ t really mind . ', ' We can go to that new Chinese restaurant . ', ' I suppose I could . ', ' Come on , let ’ s try it . ', ' All right . If you really want to . ']
["Mr.Martin , we're on arrival . ", " It's nice of you to see my off at the airport . Thank you very much . ", " We'll miss you . I hope we'll keep in touch . ", " Sure . You've given a great help to me in the past days . ", " It's my pleasure . We hope you'll visit Beijing again . ", " Certainly . I'll be glad to . ", " It's almost time to get aboard . ", ' Yes , we should go . Thank you very much . Goodbye ! ', ' Bye bye ! Have a pleasant journey ! ']
["People say that you never have a real winter in the South China , but I don't think so . ", ' Why ? ', ' I did experience a winter with snow in Kunming , the Spring City . ', " With snow in Kunming ? That's crazy ! "]
['Can you tell me where I can park ? ', ' Are you driving a motorcycle or an automobile ? ', ' I drive an automobile . ', ' Fine . You can either park in the student lot or on the street . Do you know what a handicapped space is ? ', ' Yes , I have seen those spots . ', ' Well , when you see the blue spots with the handicapped logo , do not park there unless you have a special permit . Are you going to be parking in the daytime or the evening ? ', ' I park in the evenings . ', ' Then you also need to be aware of the time limits on the street signs . Have you seen those signs ? ', ' Yes , I have seen those signs . ', ' The signs always tell you how long you can park there and on what days . Do you know how to read the curb colors ? ', ' Yes , I know what the curb colors mean . ', ' Well , just as long as you realize that red means no parking and white means loading and unloading , I think you know what you need to know . ']
['How long have you been in America ? ', ' For more than five years . ', " Do you think it's easy for a Chinese to get accustomed to the western culture ? ", " It's no picnic . "]
['There are things that are actually even smaller than atoms . ', ' What are those ? ', ' They are the things that make up the atom , such as electrons and protons . ', ' Is there anything that is smaller than electrons and protons ? ', ' Of course there is . Things can be divided and broken down into indefinitely small parts if we can . ', " I really don't want to know about this . Physics gives me a headache . "]
["Guess what I've brought for you . ", " Oh , a bouquet of flowers . It's very kind of you . ", ' I hope you like it . ', ' I love flowers , you know . Thank you very much . ', " That's all right . "]
['Who is it ? ', ' Supervisor . Open the door . ', ' Wait a sec . ', ' What are you doing here ? ', " We're watching a football match . What's the matter ? ", " Your neighbors complained that you were so noisy that they can't sleep . ", " I'm sorry about this . ", " Please turn down the TV . And not another shout or I'll have to report you to the school administration . ", " You can rest assured that we won't disturb others anymore . "]
['So Kevin , what is your type ? ', " I like girls who like to have fun , and aren't too serious . ", ' I agree . I like guys that can make me laugh . ', " That's true . Having a very serious boyfriend or girlfriend can be boring . "]
['Are you free tonight ? ', ' I think so . ']
['I can ’ t decide what to do today . ', ' Well . Let ’ s go swimming . ', ' Don ’ t you think it ’ s a bit cold for that ? ', ' Then why don ’ t we go for a walk in the hills . It ’ d be very good for us you know . ']
['Car trouble center . How may I help you ? ', ' My car won ’ t start ! Stupid old car ! ', ' Hold on , before you kick your car let ’ s go through some possible problems . ', ' Fine . ', ' OK , first of all , can you turn the key in the ignition ? ', ' Yeah ! I am here with my friend and he thinks it may be the spark plug or the starter motor . ', ' Those are possible problems , but tell me , when you turn the key , do you hear the starter motor crank ? ', ' Yeah , it sounds like it usually does when I start the car , but nothing else happens . The engine won ’ t start . Should I maybe press the accelerator ? ', ' No . If you step on the accelerator pedal you can flood the carburetor and your car will never start . ', ' So what do you think it is ? ', ' I know this may seem like a silly question , but does your car have gasoline ? ', ' Umm . yeah ! Right ! I got the car started ! Thanks for your help ! I told you to fill the tank ! ']
['I quit my job . ', " You can't be serious . "]
['Do you have a copy of today ’ s newspaper ? I want to check the results from the world athletics championship . ', ' Yes , I ‘ m just reading them myself . It ’ s been a great competition . We got gold medals in three events . ', ' Yes , we won the men ’ s 110 metres hurdles . I watched that on TV . What other events did we win ? ', ' We won the men ’ s high jump and the women ’ s 1500 meters . ', ' That ’ s great . Those athletes must train for years to get into peak physical condition . They must be terribly disappointed if they don ’ t win . ', ' The woman who won the 1500 meters also broke the world record by 2 seconds . ', ' That ’ s amazing ! Were any other records broken ? ', ' A Russian man broke the discus record by a centimeters . Out best athlete broke his personal best in the long jump , but it only got him third place . ', ' Did you see the final of the men ’ s 100 metres ? It was very exciting . One competitor made two false starts . ', ' Was he disqualified ? ', ' Yes , he was . I imagine he must be very angry with himself for that . ']
['Hi , Ellen . That outfit looks terrific ! ', ' Thanks , Jim . I didn ’ t think guys paid attention to stuff like that . ', ' No , we just don ’ t usually admit it ! ', ' Well , thanks for the compliment anyway ! ']
['Hey , Mike . Can I ask you something ? ', " Sure , what's up ? ", " I'm going to gamble on the world cup tonight . Who do you think will win ? ", ' Good question . I have to think about it . ', ' My husband is betting on France . ', ' France ? Is he crazy ? ', ' What do you mean ? ', ' Well , how can I put this ? France is a terrible team . ']
['Is there something wrong ? You look so sad . ', ' My house was robbed last night and the thieves stole all my furniture . ', ' No wonder you look so upset . Have you called the police ? ', ' Yes , I have . But I have to wait . ']
['How are you feeling , John ? ', " Oh , not too bad , but I've got to stay in bed . ", ' Do more exercises after you are healthy . ', ' Ok , I will . You have said that many times . ', ' Are you hungry ? Do you want me to buy something for you to eat ? ', ' No , there ’ s no need . Thank you all the same . ']
['did you go to university ? ', ' yes , I graduated with a BA in English from Qingdao University . ', ' when did you graduate ? ', ' just a few years ago . What about you ? ', ' I just graduated from high school . ', ' are you planning on going to university ? ', " I'd like to get a BA , but I don't know where I should go . ", ' have you applied anywhere yet ? ', " yes , I've applied to four universities and have been accepted into all of them . ", ' congratulations ! Which one is the cheapest ? ', ' the tuition is the same for all of them . ', ' which one has the most interesting course ? ', ' I think the course at Leeds University is interesting , but I think the one at Manchester University would be more practical . ', ' where would you like to be located ? ', " I'd really like to be in London , but it's the most expensive city in England to live in , so I don't know if I can afford to live there . ", ' have you applied for grants or financial aid of some sort ? ', ' not yet . ', ' I think you should do that soon . It will help you make a decision about the school you go to . ', " that's a good idea . ", ' good luck ! ']
['Excuse me , could you spare me a few minutes ? ', ' Yes , certainly.How can I help you ? ', ' Do you know if train 10 is on time to be here ? ', ' Sorry , I don ’ t know . I ’ m a passengers ’ m waiting for my train .. ', ' Do you mind if I read your newspaper for a while ? ', ' Certainly not.Here it is . ', ' Thanks a lot ']
['Would you like a cup of coffee ? ', ' Yes.That would be good . ', ' Oh , no . ', " What's the matter ? ", ' This machine is out of order . ', " You shouldn't have used the machine.Did you lose your money ? ", ' I sure did . ', ' You ought to complain.These machine are always out of order . ']
["You seem to like her very much , don't you ? ", " I can't deny that . She is so beautiful that I fell in love with her at the first sight . I wish I knew more about her . ", ' But I heard that she had a three-year-old girl . ', ' I cannot belive that . It must be cooked up by someone . ']
['There are so many environment problems in the world today . Do you think we can really solve them all or will destroy the world ? ', ' I hope that world leaders can get together and agree on a plan of action , but I doubt it ’ ll happen before it ’ s too late . ', ' We need to solve the problem of air pollution before we destroy the atmosphere . There ’ s lots of clean , modern technology , but companies in developed countries say it ’ s expensive . Developing countries ', ' Everyone is looking at the issue in the short term , rather than the long term . It ’ s the same with the destruction of the rainforests . Countries and companies just want the wood . They ’ re not thinking a ', ' In other parts of the world , especially in Africa , there is a problem with desertification . Climate change and over-farming are causing farmland to turn into desert . In means that people cannot grow e ', ' It also means that people sometimes fight over the farmland that remains . Damaging the environment actually leads to conflict between people . ', ' Have you ever thought about joining an organization committed to protecting the environment ? You could get involved with projects to improve the environment . ', ' I think I ’ d like to do that . I could take the things I learn here back to my country when I have finished my studies . ']
['Going to the cafeteria ? ', ' No , I am not eating there anymore . I have ordered my favorite food in the restaurant around the corner . The food served in the cafeteria is not my type . I am a total meat lover . But the cafeteria is doing its best to force me to be a vegetarian . They have been serving the Chinese cabbage and white gorse for three days . Haven ’ t you noticed that ? ', ' That ’ s fine with me . I don ’ t hate vegetables and I don ’ t eat much during lunch . ', ' Well , then the cafeteria suits you best . But anyway , if you like to have a lunch outside the company , feel free to join me anytime . ']
['How old are you ? ', " That's a secret . "]
["I've brought a little dog for Alice , girls usually like looking after pets . ", " Thank you , but Alice is only a visitor here . I don't know if she'll keep it . ", " To tell you the truth , the dog isn't my real reason for coming . I want to ask Alice if she'd like to be my girlfriend . ", ' Really ? ']
["hi , I'm Lucas , I just moved in next door . ", " oh , hi Lucas , come on in . I'm Barbara . Nice to meet you . ", ' nice to meet you too . ', " would you like something to drink ? I've got tea and some grape juice . ", ' thanks . Some tea would be nice . Chinese tea is great . I really like your tea set . Where did you get it ? ', ' oh , there is a supermarket not far from here . But there is also a tea house around the corner , where you can get tea and a tea set as well . ', " oh yeah , I saw the tea house the other day . I think I might go and have a look sometime . It's a nice neighborhood here . ", " you are right about that . It's quiet and very convenient . You can get to the bus and the subway stations within ten minutes'walk . There's a grocery store , a book store , a gym , and many restaurants ", " there's a gym nearby ? That's exciting ! I really want to start to go to gym as soon as possible . I've been lazy this summer holiday and have put on some weight . ", ' well , if you want we can go together sometime . Actually I was thinking of going this afternoon , if you like , you can join me and I can show you the neighborhood along the way . ', ' that would be wonderful . Thanks ! ']
['I am totally fed up with my boss . He has crossed the line one too many times with his sexist comments . This time I am really going to report him for sexual harassment . ', ' What happened ? Did your boss say something to offend you at work ? ', ' He constantly lets inappropriate things slip out , referring to the women employees as girls or calling us sweetheart or darling . I doubt any of my male colleagues would stand for such treatment . ', ' Don ’ t you think you are overreacting a little ? Calling you by nicknames shouldn ’ t be so bad ... ', ' You ’ re missing the point . It ’ s about respect . He treats us with such a patronizing attitude , as if we are not equal or not as serious as our male co-workers . It ’ s his attitude that needs to be changed , not just his words . ', ' That ’ s what you get for working in a male-dominated field . I think you ’ ll find that most male bosses in your industry are already conditioned to treat females in this way . You probably won ’ t be able to change him . ']
["Is your lady beautiful ? Since I came here from the country , I've not seen her close . Tell me , is she beautiful ? ", ' Thomas , if I could write with the beauty in her eyes , I was born to look in them and know myself . ', ' And , her lips ? ', ' Her lips ? The early morning rose would wither on the branch if it could feel envy . ', " And her voice like a lark's song ? ", ' Deeper , softer , none of your twittering larks . I would banish nightingales from her garden before they interrupted her song . ', ' Oh , she sings too ? ', ' Constantly . Without doubt , and plays the lute . She has a natural ear . ']
['Would you like to have dinner with me tonight ? ', ' Sorry , I have to work overtime . ', ' You are really career minded . ', ' My boss promised to pay me double time . ']
["It's going to strike 12 o'clock . Let's get the firecrackers ready , Rose . ", " Aren't firecrackers forbidden in the city ? ", " Well yes , but they are not allowed only in downtown areas . It's OK here . It would be difficult to ban customs that have thousands of years of tradition . The habit does bring kids joy and excitement so long as precautions are taken . Let's go out and set off firecrackers out there . ", ' Fantastic ! The whole city is echoing with crackling sounds ! ', ' What other activities will you have tomorrow ? ', " Quite a lot . The celebration of the New Year has just started . The first day we southerners have sweet rice cakes for breakfast , and people in the North have Jiaozi . Afterward , we will make New Year calls on family relatives , husband's side on the first day and wife's side on the second . ", ' Do you bring some gifts along ? ', " That's for sure . Fruit , cream cakes , medical tonics are often for parents and aged relatives , and cash enclosed in a red envelope for the kids . All this , of course , should be well prepared beforehand . ", ' Is it the same practice for all families ? ', ' Not all the same nowadays I must say . Many families , especially those of newly married couples , choose to make an overseas trip to escape the routines . Rose and I had a tour to Singapore , Malaysia , Thailand and Hong Kong last year . We stayed there for two weeks until the last day of the holiday . ', " I really appreciate the way you Chinese people exchange feelings . The holiday's long enough for you to relax . ", ' Well , for city dwellers , the Spring Festival is a holiday of seven days . While in the country where traditions are still heavily emphasized , the festival lasts ten days . ']
['You seem to be very hesitant about doing things . ', " I don't know why I cannot take a step forward . ", ' You are meeting trouble halfway , I guess . ', " Many things are troubling me . I don't know whether I should come and go . ", " That's where the shoe pinches . "]
["How's your new apartment ? ", " I thought it was in a quiet neighborhood , but it isn't . ", " What's wrong ? ", ' One of my neighbors has a dog . ', ' Does it make a lot of noise ? ', ' It barks all night long . ']
['Dad , I ’ d like to borrow some money . ', ' Sure , Johnny , how much do you need ? five bucks ? ', ' Come on , Dad , I need thirty thousand . I wanna get into the market . You know , I ’ m tired of hearing all this news about the economic downturn , the inevitable recession , people stuffing their money in their mattresses . I look at this as an opportunity . This is a chance for me to get a jump start on building my nest egg . ', ' I don ’ t know about that ; with all the uncertainty in the markets right now , it would be a very unwise decision to invest . I don ’ t know if you ’ re aware son , but there has been a lot of turmoil in the markets recently . There have already been half a million layoffs in the last few months , and we have no idea how the proposed stimulus package will impact the economy . There ’ s just too much instability . I wouldn ’ t feel comfortable investing in this climate . ', ' But look at it this way , every challenge is an opportunity . And anyway , I ’ m not talking about investing in the domestic market . There are emerging markets that promise great returns . Look at China , for example , they have 1.4 billion people , half a billion of whom have recently entered the middle class . Here alone the aggregate demand for consumer goods represents an amazing wealth generating opportunity . ', ' Come on , son , you ’ re looking at this too naively , the Chinese market has exhibited a great deal of instability , and their currency has been devalued by almost a whole percentage point . ', ' Fine , then ! If that ’ s the way you feel , so be it . But you ’ re losing out on a great opportunity here . I ’ m going to go hit up Mum for the cash . ']
['What do you think of smoking ? ', ' It ’ s harmful not only for yourself but for others . ', ' What in your opinion can be done to stop smoking ? ', ' Stop producing cigarettes . ', ' But that ’ ll affect the national economy . ', ' That ’ s right . But I don ’ t think there are better ways . ', ' How about printing a warning on each cigarette packet ? ', ' Maybe it can take effect . ']
['do you like playing games ? ', " I like playing computer games , but I'm not really into board games . ", " how about individual games like the Rubik's cube or solitaire ? ", " the Rubik's cube is so difficult to solve that I think it should be banned ! ", " if I taught you how to do it , I'm sure you could solve it . ", " how did you figure out how to slove the Rubik's cube ? ", " I didn't really have to figure it out . I just followed the instructions ! ", ' I had no idea there were a set of instructions . I thought everyone who could solve it were all geniuses ! ', " hints are really important when you're solving puzzles . If you give me some hints about playing that PS2 game , I ’ ll show you how to solve the Rubik's cube . ", " it's a deal . ", " do you remember , years ago , when everybody at the New Year's party had yo-yos ? ", ' yeah . That was a strange party . Can you still do any of those yo-yo tricks ? ', " I don't know . I haven't tried yo-yo since that party ! ", ' I could never figure out how to use my yo-yo . ', " if you don't start when you're young , it's hard to get the hang of it . ", " let's get started with this game then . ", ' ok . ']
['A beautiful center ! ', ' And good shot ! ', ' A goal ! ']
["Mary , there's one more thing that you must do for me before you leave . ", ' What is it ? ', ' You have to take the math and English evaluation tests . ', ' Why ? ', " Because you're from a foreign country . The school needs to find out how good you are at both basic skills . ", " It's so that I can be put into the right math and English classes , right ? ", ' You are a smart girl ! ', ' This is going to take more time than I thought . ']
['I have a bone to pick with you . ', ' Okay . Let ’ s clear the air . What are you getting at ? ', ' You always have a chip on your shoulder . ', ' I ’ m sorry . But I don ’ t meant to get your goat . ']
["OK , Nick . Here's the question , What movie and its sequel both won an Oscar for Best Picture ? ", ' The Godfather and The Godfather II , of course . They were both directed by Francis Ford Coppola . ', " Whew ! I'm impressed ! You really know your stuff ! ", ' Only about old movies , really ... ']
['It is obvious that their government is nursing the hope of having all other countries over a barrel and bring them completely under their control . ', ' It ’ s a typical of them to do so . ', ' What can we do ? ', ' We must keep developing our economy and unite with other developing countries to fight against it . ']
['This is today ’ s schedule . At eight thirty , conference with the department managers . At 9 o ’ clock , live for the workshop where you ’ ll award prizes to the stafffor preventatives . ', ' That ’ s great . What are the prizes ? ', ' 3000 RIB as bonus for each person . ', ' To encourage the staff increases . ', ' Ok . Next thing is laying the corner-stone for the new plant at 10 AM . At 12 AM , back here for lunch . ', ' What about the afternoon ? ', ' At 2 PM , give a presentation here with the press . At four o ’ clock sharp , have dinner with Mr . Smith , manager of NCC . ']
['How do you get along with your co-workers ? ', " I get along pretty well with most of them.It seems there are always a few rotten apples in the bunch , though , Like Margaret . I don't know why management hasn't fired her yet.She ' s a terrible gossip . ", ' Do you think management should fire someone just because they gossip ? ', " It's not only that she gossips , but she also tries to start problems among other employees by spreading rumors and telling lies about her co-workers.She ' s not trustworthy , and in my opinion , I think she's nuts . ", ' So how do you develop good relationships in the office ? ', " I think one of the important things is just to be considerate of your co-workers'feelings and needs.If you are aware of other people and do your part to make a good working environment , you should be able to get along with most of the people you work with . ", " I think you're right , but it does seem that there are always a few co — workers that are harder to work with than others . "]
['Thanks a lot for having us . We had a good time . ', " I'm glad you came . You're welcome anytime . ", ' Thanks . By the way , tell your wife she throws a great party . ', ' I will . See you later . ']
['So how did you meet Bill ? ', ' I met him through a computer bulletin board . ', ' Oh , really ? Which bulletin board ? ', " It was one I used down at the local coffee house called the San Francisco Net . It's been around since around 1991 . ", " I've heard about that , but I've never tried it . ", ' You ought to . One dollar buys you 15 minutes of computer time . A Chat session links you with cappuccino sippers in other cafes and also to home computers on the network . ', ' I have no desire to talk on a network with a bunch of strangers . ', " That's the whole point . All your inhibitions disappear because you can ’ t see the other person . This network allows you to talk to people whom you normally wouldn ’ t talk to . ", ' I just want a private conversation with one other person . ', ' You can do that . A private session lets two people talk alone . This techno-chat program lets you talk about anything with everybody , without prejudice because you can ’ t see them . ', " Well , maybe I'll tag along and watch how you talk . ", " That's fine with me , but we'll have to get there early . Because after 8 pm , there is always a long line . ", ' It ’ s that popular ? ', ' It sure is . ']
['Have you seen that house ? ', ' Yes , it looks interesting . ', " You're right . I love it very much . ", ' It must be old . ', ' At least more than 100 years old . ', " Let's enter it ! ", " I can't open the door . ", ' It must be locked . ', ' Let me ask the old woman in that reception office . ', " She can't answer you . ", ' She must be deaf . ', ' It must be a haunted house . Are you frightened ? ', ' Frightened ? You must be joking . ']
['Have a nice weekend ! ', ' Thanks.You too ! ', ' Do you have any plans ? ', " Well , my family's away and I can't afford to do much.What about you ? ", " Oh , I haven't decided what I'm going to do yet . "]
['What did you major in ? ', ' I major in Chemistry . ', ' What is your specialty ? ', ' Organic Chemistry is my specialty . ']
['The National Day is coming . What are you going to do during the holiday ? ', ' I have no idea . ', " Why don't you go sightseeing ? ", " It isn't a good time because there must be many tourists in the scenic spots . What about your plans ? ", ' I intend to stay at home for the whole seven days and have a good rest . ']
['Good morning , John . Have you finished reading the novel by Dickens borrowed from the library ? ', ' No . I caught a cold two days ago . I only finish reading half of it . ', " I'm sorry to hear that . How are you feeling now ? ", " I'm feeling better today . ", ' How many days do you plan to finish reading it ? ', ' About more three days , I think . ', ' OK . After three days , I will come to you for it . ', ' No problem . ']
['Ouch ! ', ' Are you all right ? ', ' Yeah , I just bumped into the table . ']
['Hi , Lilly , it ’ s so nice to see you again . ', ' Hum , me too . This winter holiday was especially long . What have you done ? ', ' Nothing special . I had a get-together with some schoolmates at the high school , visited the Internet and read a couple of books which I had been longing for . How about yours ? ', ' You know , I like traveling . I made good use of this long vacation and enjoyed myself . ']
['You know , I really don ’ t think Americans are very romantic . ', ' Where did you get that idea ? ', ' That ’ s the impression I get from the movies , and from looking around . Men and women seem very business-like in their relations with each other . ', ' Well , I ’ m still not sure what you ’ re asking me . ', ' Is it true or isn ’ t it ? ', ' Do you want to know something about the American character ? ', ' I just think you ’ re trying to change the subject . But go ahead . ', ' No , this will help answer your question . In American society boys and girls are raised together . They ’ re not segregated in their activities ! Boys and girls go out together from an early age . ', ' OK , go on . ', ' After being raised together , men and women can be business-like in each other ’ s company . It really doesn ’ t have anything to do with the way a man and woman behave toward each other when they are in love . Does that answer your question ? ', ' Not exactly , but I see your point . ', ' I think Americans are pretty romantic when they are in a relationship and a lot of flirting goes on in every office . After you ’ Ve been in America for a while , you will probably see what I mean . ']
["It's a lovely day , isn't it ? ", ' Yes , the weather sure is nice today . ', " I love it when the weather is like this.Why don't we sit down outside and have our lunch ? ", " That sounds like a good idea.The sky is clear , the sun is shining and there's a nice cool breeze , so it is not too hot . ", ' I really miss the change of seasons like we have in Colorado.but I must admit , this sure is a nice spring day . ', ' Hey , this spot in the shade looks really comfortable . ', ' Okay.Hey , is that a dark cloud over there ? Do you think it will rain after all ? ', " I don't think so . I say the weather report last night , and it said the weather should be fine all day . ", " If the weather stays nice perhaps we can go to the beach this weekend.It ' s been a while since I've not really gotten some sun . "]
['Are you going to the cafeteria downstairs ? ', ' Yes . ', ' Could you please get me a takeaway ? I have some urgent work to finish . So I don ’ t have enough time to go out for lunch . ', ' No problem . What should I bring ? ', ' I am not picky on food . Just bring me the day menu . ']
["What's your weight ? ", ' 150 pounds . ', " Do put yourself on a diet , otherwise you'll be too fat . ", " I can't bear eating less . "]
['Did you ever take History 231 ? ', ' Yeah . Last semester . ', ' Who was the professor ? ', ' It was Professor Johnson . ', ' I have him this semester . What do you think about him ? ', " He's a terrible instructor and demands a lot , but fortunately , he's an easy grader . ", ' What did you end up getting ? ', " I got an A - . Sounds good , but none of my test scores were that high , so I don't know how I got a decent grade . ", " That's probably because he grades on a curve . ", ' Are you enjoying the class so far ? ', ' I hate it and I was about to withdrawal . But after hearing your experience , I think I will tough it out . ', ' Yes . Definitely stay in the class . You will get a better grade than your test scores . He does that deliberately to make all the students study a lot . ', ' Thanks for letting me know . I feel relieved now . ']
['So how long have you known Mary ? ', ' Only four days . ', " Only four days ! That's so short , and you seem so crazy about her . ", " I know . I can't help thinking about her . She's always on my mind . "]
['Hi , happy new year ! ', ' Hey , the same to you ! ', ' Time flies ! One year has already been a history ! ', " Definitely , it's time to say bye-bye to the last year and to say hello to the new year ! ", ' Yeah . Have you made any good resolutions for this new year ? ', " Some resolutions ? That's a wonderful idea , but I have no idea yet . How about you ? ", ' I want to be healthier this year , so I think I should take more exercise . ', ' That will be a good one ! Anything else ? ', ' Maybe I should make a plan about learning my biochemistry , which is a mess ! ', ' Sounds great ! ']
["It's weekend again , I'm glad I can arrange for my personal matters . ", ' What do you mean by that ? ', ' Oh , that means I can do whatever I like without few interruptions . ', " You've been always active and versatile . It seems that you are interested in everything . ", ' Oh , really ? I just have lots of hobbies in my spare time ; such as going to the concert , painting , handwriting , reading novels and reading fashion magazines . What about yours ? ', " I have fewer hobbies than yours . That's why I find campus life a bit dull and uninteresting . ", " Oh , you can't think like that . We young people should try our best to learn new things and accept new ideas . You like taking photos and going to photography shows , why not practise the technique and catch something unforgeable ? ", " That's a good suggestion . It's fine today . Maybe I can take photos on the scenery of the lake at sunset . It must be fantastic . ", ' I quite agree with you . With our hobbies , our life can be more colorful and exciting . ', ' And I can concentrate on my study after the relaxation over the weekend . ', " Yes , it's a good habit to have a life-long hobby . Those who practise calligraphy and Qigong always live longer . "]
["Hey , Jane ... are you familiar with our company's insurance policies ? ", " Umm ... I think so . What's up ? ", " I've never really paid attention to the fine print of our insurance policies ... but it looks like I'm going to need to make a claim . ", ' Really ? Are you OK ? ', ' I have a slipped disc in my lower back and the doctor says surgery is probably the best option . Does our worker insurance cover this kind of thing ? ', " If the injury is workplace related I'm sure it's completely covered . ", " Hummum ... I think I'll have to talk to the doctor again about that.Anyway ... now that I'm going to have to make some claims , I think I'd better try and understand how the system works . Would you mind breaking it down for me ? ", " Sure . Basically we have two insurance policies for employees ... workman's compensation and medical insurance . The company pays the premiums for workman's compensation , and for a significant part of the medical coverage , but you pay part of that premium , too . ", " That's the charge for insurance I see on my pay slip each month , right ? ", ' Yep . Every country in the world has a different system , but here we buy insurance from a private provider . ', " So workman's compensation is if I slip and break my arm while working in the office or on the job , right ? ", " That's right . The company pays for all your medical bills and there is also some financial compensation if you have to take days off to see doctors or spend time recuperating . "]
['I decided to go for this kind of life . ', " Try to keep cool . It's not an easy take . ", ' I know . I always hope for the best and prepare for the worst . ', ' Then you will be in line for a doom . ']
['How are you ? ', ' I ’ m great . Thanks . ', ' Did you need something ? ', ' I need your help . ', ' How may I help you ? ', ' I need to find this newspaper article . ', ' Have you checked the periodicals section yet ? ', ' I forgot about that section . ', ' If you ’ d like , I can show you were to find it . ', ' Could you do that ? ', ' Follow me . ', ' Thank you for all your help . ']
['Wow , American football is more exciting than I thought . ', ' You ’ re in America now , my British friend . We just call it football . ', ' Oh , right . So , I can ’ t quite follow what ’ s going on ... who ’ s winning ? ', ' The Giants are up by three points because of the field goal they kicked , but the Redskins have the ball and there pretty close to the end zone . ', ' Wow ! What a hit ! ', ' Yeah , he tackled him so hard his helmet came off . ', ' Is he ok ? ', ' It looks like it , he ’ s getting up . ', ' I guess he hit him too hard ; the referee just called a penalty on the home team . ', ' The Giants ? ', ' Yeah . ', ' Well , here we go again . ', ' What happened ? Why did everyone get so quiet ? ', ' The Redskin ’ s quarterback just threw a touchdown pass for seven points . We ’ re losing again . ']
['Jack ! Do you want to see a picture of my new puppy ? ', ' Sure . I thought people only showed off pictures of their new babies , not new pets ! ', ' Well , this is my new baby . He ’ s just as much trouble . That ’ s for sure ! But , he ’ s a lot of fun ! ', ' I see what you mean . He ’ s really cute . How old is he ? ']
["I'm going to Ireland this summer . ", ' Are you going to take your children along ? ', " No , I'd like to go alone . ", ' Have a nice holiday ! ']
['A new film is on . Have you ever seen it ? ', ' What kind of movie is it ? ', " It's a feature film . ", " Oh , I've no interest in such films . "]
['How old are you , Su ? ', ' I am seven . ', ' I see , you have seven candles on the cake . ', ' Yes , I am seven . I am a big girl now . ', ' We will have a party here , right ? ', ' Yes , come on , and we will have fun . ']
["I've had enough of that ! ", ' Why , this is the most interesting film ! ', " I hate the hero.He ' s too cruel . ", " But it's only a film . "]
["Honey , I've got good news for you . ", ' What is it ? ', ' You are going to be a father . ', ' What ? Do you mean that you are pregnant ? Is it true ? ', " Yes . We'll have our baby soon . ", " Oh , dear , I'm so happy . ", ' Me , too . ']
['Hi . You enjoying the party ? ', " Yes , actually . I don't really know anyone , but it's a nice place . Are you having a good time ? ", " Yes . The drinks are very good ! I'm Paul , by the way . ", " Hello Paul . I'm Jane . So what do you do ? ", " I'm in finance . You ? ", " Really ? Me , too . I work for an accountancy company , T & D . Maybe you've heard of them . ", ' T & D ? Oh , yes , sure . How long have you worked there ? ', ' About two years . And you ? Are you based here ? ', " No . Actually , I'm based in Shanghai . I'm just here for the conference . So , T & D eh ... "]
['Are you still working day and night ? ', ' Not anymore . Now I work nine hours a day , and I get a good sleep almost every night . No more burning the candle at both ends . ']
["The stepmother was very wicked . She couldn't stand a happy smile on the boy's face . ", ' And ? ', ' And she did her best to pull out the thorn in her flesh and the boy lost whatever made him happy . ', ' Poor child ! ']
['Excuse me , are you Sara Wilson ? ', ' Yes , I am . You must be Tom . Nice to meet you . ', ' Nice to meet you too . Let me help you with your bags . ', ' Be careful , Tom . Those are pretty heavy . ', " Wow , you're not kidding . Hold on a second . Hello , could you give us a hand , please ? "]
['Would you mind taking your feet off the table , Mike ? ', " Not at all . But I've found satisfaction in it ! ", ' Do you put your feet on your own table ? ', ' No , I never do that . ', ' Why not ? ', " I don't want to mark my table , of course . ", ' Well , will you please put them down ? ', " I'm sorry . I thought you wouldn't come back so early . ", ' I forgot something on the table . ', " Oh , you've got a good memory . "]
['May I help you ? ', ' Could I check out this book ? ', ' Let me see your library card . ', ' I need to get one . ', ' You can apply for one right now , if you ’ d like . ', ' Okay . Let me do that right now . ', ' Could you fill out this application ? ', ' I ’ m finished . Here you go . ', ' Could you please sign the back of the card ? ', ' All right . ', ' That ’ s it . ', ' Now may I check this book out ? ']
["But the auction is a blast ! And I haven't even told you the best part yet ! ", " I don't care what the best part is . Whatever you say won't change my mind . I'm not buying anything ! ", " That stamp you've been looking for is for sale . ", ' The 1879 Large Dragon ? Are you serious ? How much ? ', " Hey ! I thought you weren't interested ! Sorry , I've gotta go ! I'm going to switch over to eBay and see if my bid is still the highest . "]
["I'm so excited ! We have two weeks off ! What are you going to do ? ", " I'm not sure . I guess I'll just stay at home . Maybe I'll catch up on my reading . What about you ? Any plans ? ", " Well , my parents have rented a condominium in Florida . I'm going to take long walks along the beach every day and do lots of swimming . ", ' Sounds great ! ', " Say , why don't you come with us ? We have plenty of room . ", " Do you mean it ? I'd love to ! "]
["I can't stand the stupid guy any longer.It ' s unbelievable ! ", ' Oh , my dear lady.Take it easy.You should forgive a green hand like him . ', ' He does everything so mindlessly that he is going to drive me crazy . ', ' I suggest you talk with him and teach him how to deal with the problems . ', " I have told him how to do it several times , but he's never listened to me . ", ' Maybe you should communicate with him like a friend and not a boss . ', ' Oh , I always have difficulty in getting along with the staff . ', " Just take them for your good friends and have a talk with them as we do , make sure you don't lose your temper . ", " I think that's a bad idea . I'd hate anyone here to think of me as a friend.How would they ever respect me as they can do whatever they want ? ", ' I disagree . All you have to do is respect the staff and their opinions . ']
['Did you sign up for the picnic party ? ', ' Yes , of course . I love the picnic party . It ’ s really family fun time . ', ' This time you can bring your daughter with you . ', ' Right , she is so excited and simply can ’ t wait . ', ' There are times of games planned , should have a grand time . ']
['Frank , I want your advice on something . Some scientists I met at the conference 6 this afternoon have invited me to a party . Actually , they called it an informal get-together . ', ' And what ’ s the problem ? ', ' When I asked how people were going to dress , Dr . Lite said it was casual . ', ' And you want to know what to wear ? ', ' Well , last night I went out with some journalists for a casual party , but I was overdressed . I wore what I consider casual - - an outfit of skirt , blouse , scarf , and medium heels ... you know . ', ' That sounds just right to me . What was wrong with it ? ', ' Everyone else there was wearing blue jeans . Several of the women had on running shoes . I felt out of place . So I have no idea what to wear tonight . ', ' My guess is you can safely wear last night ’ s outfit to tonight ’ s party . ']
["T he nineteenth of June is my birthday . I'm planning to have a small party . Could you come ? ", " Happy birthday to you ! I'd really love to come , but I'm not sure right now . I'll try to make it.Thank you for your invitation . "]
['Who got ripped off ? ', " Big time ! A hacker broke into the company's files and got all her personal information . You really think it's completely safe ? ", ' Well , maybe not 100 percent . I did hear about some tricks people use . ', " Now we're getting to the truth . ", ' There are shills . A shill is someone who bids up the price of their own sale . ', " See ? And I bet that's easy to do online . Everybody's anonymous . "]
['How many courses do you have for this semester ? ', ' Eight altogether . ', ' How are they proportioned ? ', ' Six are compulsory , two optional . ']
['I ’ Ve always wondered , what ’ s the difference between English for Chinese students and English for native students ? ', ' I don ’ t know . What do you think ? ', ' I think a Chinese student concentrates on written English , and uses it as a basis for communicating . From start to finish he ’ s learning vocabulary and fundamentals of grammar . This is a very difficult way to learn . ', ' What do natives get ? ', ' They get higher level English , which is more formal than everyday spoken English . They also deal with matters of style and creativity . ', ' Do you mean that a native doesn ’ t make any mistakes in grammar ? ', ' Absolutely not ! Native speakers make a lot of grammar mistakes , especially if they come from a home where nonstandard English is spoken . ', ' I suppose that only a small percentage of college students don ’ t know standard English in American universities . ', ' Actually there are more non-native speakers than you think . That ’ s why it ’ s so important to quit worrying about making mistakes . Just talk to everyone every chance you get . ']
['Do I need a visa ? ', ' No , I shouldn ’ t think so . But you must take your passport of course . ', ' Yes , I know . I must get my traveler ’ s check and some foreign currency . ', ' Yes , you need the traveler ’ s check but you needn ’ t get any foreign currency . You can have my US Dollars , I don ’ t need them . ', ' Really ? That ’ s very good of you , Helen . But I must get a new suitcase , my old one needs repairing . ', ' You needn ’ t buy one . You can have mine . ', ' That ’ s very kind of you , Helen . I hope you don ’ t mind my leaving you like this . I need a holiday . It won ’ t be long . ', ' Don ’ t be silly , John . I ’ m going with you . It ’ s necessary for me to have a holiday too . ']
['Is that your phone ? ', " yes , it's my new business phone . Do you like it ? ", " it's very impressive . Can you use the Internet on your phone ? ", " yes , it's got wireless Internet access . ", " that's really convenient . Does it have the Bluetooth ? ", " yes , but I don't really use it that often . Have you ever used it ? ", " no , but I think it'd be really great for people like you who are always on the go . ", ' yes , I guess I should try to use it . ', ' does it have a camera ? ', " of course it does . Doesn't every new phone include a camera these days ? ", " I guess so . Would you mind if I checked my email quickly ? I'm supposed to be getting an important email this evening from a client . ", ' sure . Here you go . ', ' have you checked your voicemail recently ? ', ' no , why ? ', ' I think this icon means that you have a voicemail message . ', " oh , yeah . Probably . I don't really know how to use this phone yet . ", ' do you want to listen to your messages first ? ', " no , it's ok . Check your email first ; I'll check my unbox later . ", " I'm surprised you don't use more of the features on your phone . ", " I'm surprised you know so much about it . Where's your phone ? ", " it quit working last week and I haven't had a chance to buy a new one yet . ", " how have you been living without a cell phone for a week ? hasn't it been driving you carry being without a phone ? ", " it's not that bad . It kind of feels like I'm on vacation , not having to answer my phone all the time ! ", " let's go shopping . You can't depend on public phones in this day and age ! "]
['Are you feeling better today , Bill ? ', ' Well , it ’ s hard to say . I coughed a lot in the evening . ', ' You ’ d better give up smoking . It ’ s bad for your health . ', ' You ’ re right . But you know it ’ s so hard to give up the old habit like smoking . ', ' But you should make up your mind first . ', ' You know I often have to work far into the night . I need smoking to keep me awake . ', ' Why don ’ t you go to bed early and get up early ? You ’ ll have the same time for work . ', ' Thank you for your advice . I ’ ll try it . ']
['What are your weekend arrangements ? ', " There're many things I can do on weekends . ", ' What sort of things are you interested in ? ', " I'm keen on talking short trips to nearby scenic spots . More often than not , I go with some of my friends . By the way , what are your favorites ? ", ' I love swimming and cycling . On Sunday morning I have swimming practice for an hour . In the afternoon , I just ride my bike around the city or along the country roads for almost two hours . ', " That's great ! I think they do you a lot of good . Where do you swim ? ", " Mostly in the city's swimming pool . But on occasion , I go to the beach with friends . Well , what do you do at leisure ? ", " I'm fond of dancing . ", ' Good.You really know how to enjoy yourself . ']
['Why did the boss come down on Joe like a ton of bricks . ', ' He spoke evil behind his back . ', ' How did he know that he had bad mouthed him ? ', ' Someone told Joe off . ', ' He is then in a very difficult situation . ', ' Sure . He ’ ll get the bag , I think . ']
["I'm sorry for spilling my drink on your rug . ", " There's no need to apologize . ", ' But I ruined your rug . ', ' Forget it . It was an accident . ']
['Why are you cut up recently , Nancy ? ', ' I ’ Ve just parted with my boyfriend . ', ' Oh , cheer up . A boyfriend is not everything . ', ' But I cannot forget him . ']
["We'd like a half-day package . ", ' We offer many different sea water treatments . ', ' How many can we choose ? ', ' The aquamedic pool is included . You can choose three . ', " We'll do the seaweed wrap , the jet bath , and the foot massage . ", ' OK . Here are your robes . You can go shower first . ']
['Are you going to Helen ’ s birthday party on Friday evening ? ', ' I wouldn ’ t miss it for the world ! It ’ s sure to be fun . She ’ s invited a lot of people . Do you think everyone will be able to get into her house ? ', ' If everyone turned up , it would be a squeeze , but a few people said that they couldn ’ t go , so I think it should be ok ? ', ' Are you taking anything ? ', ' I ’ Ve got her a birthday present and I ’ ll take a bottle fo wine too . ', ' That ’ s a good idea . She told me that she had bought plenty of food and snacks . I think it ’ s going to be a noisy party . I hope her neighbours don ’ t mind too much . ', ' Helen gets on very well with her neighbours . I wouldn ’ t be surprised if they went to the party too . ', ' I ’ m ready looking forward to it . This party is going to be a blast ! ', ' Well , don ’ t be late . I ’ ll see you on Friday at Helen ’ s . ']
['I hated the hand-me-downs to wear when I was a kid . ', ' That ’ s understandable . Every kid likes new clothes . ', ' It was not just that . I didn ’ t like them because they never fitted me . ']
['Shall we have two tickets for for seven thirty ? ', ' Yes , Would you like to have the seats in the front or at the back ? ', ' In the front , please . ']
['What did you do last vacation ? ', ' I learned to drive and I got a driving license . ', ' What will you do this vacation ? ', ' Travel . ']
['Do you like Barry ? ', ' No , not very much . He ’ s too ambitious and dishonest . ', ' I agree . I like his brother , Paul . They are not alike . ', ' Yes . They are completely different . Paul is very sociable and much more honest than his brother . ', ' What kind of person do you consider yourself to be ? ', ' I think I ’ m polite , careful , relaxed and shy . ', ' Oh , I don ’ t think you ’ re shy ! You are always chatting with new people when we go to a party . ', ' Well , yes , but those people always start talking to me . I never talk to them first . Perhaps I ’ m not as shy as I think . Anyway , you ’ re certainly not shy ! ', ' You ’ re right . I love going out and making new friends . ', ' So , you ’ ll be at my birthday party on Friday ? ', ' Of course ! ']
['Hello 。 this is Susan . ', ' Hello , I ’ m Mark . I ’ m just wondering if you are free this weekend . ', ' Yes , I think So . ', ' Good . I was thinking that I ’ d like to invite you to watch a movie . I can meet you at the cinema gate . ', ' What ’ s the time ? ', ' Six thirty , tonight . ', ' Oh , I ’ m sorry I can ’ t.because I have to do some housework.You can ask Jenny to go with you . ', ' All right.Maybe next time I can go with you.Bye ! ', ' Good bye ! ']
['Congratulations ! Is it a boy or a girl ? ', " It's a boy . "]
['What do you think are the most important things to do when running a business ? ', ' Well , there are several things . Of course , you must do everything you can to keep costs down and revenues high . ', ' So , do you think workers should be paid as little as possible ? ', ' No . if you do that , the workers won ’ t like their jobs . They will be less efficient and you will get a high staff turnover . Those things will increase you costs . ', ' How can a business maximise revenues ? ', ' You need to invest in some good advertising . You have to know where your potential customers are and target them . It ’ s no good trying to sell computer games to older people . The market is too small . ', ' What else do you suggest ? ', ' Find out what other companies charge for the same products or services . Price yourself near the low end . Don ’ t be much cheaper than everyone else , because many customers distrust very cheap things . They think that is must be poor quality if it ’ s that cheap . ']
['This paper absorbs water so quickly ! ', " Yes , it's great for cleaning up spills . "]
['John has some trouble in his life . ', ' I hear that his father died . ', ' Yeah . He ’ s been having an easy time since he was a boy , and now he doesn ’ t know how to face the music . ', ' He is out of luck . ']
['Welcome back , soccer fans . My name is Rick Fields and , as always , I am joined by my commentating wingman , Bob Copeland . ', ' And we ’ re on the brink of soccer history today , as Ecuador and Brazil are tied one-one as we begin the second half of the 2022 World Cup ! ', ' The ref calls the players for the kick off , and here we go ! Ecuador quickly passes the ball to the midfield , but , oath , it ’ s out of bounds . ', ' That will be a throw in for Brazil . Adriano has the ball and makes a long pass to Robin , and the ref has called him offside . ', ' No question about it . He was offside by a mile ! We have a goal kick for Ecuador . Edison Mendez heads it to Valencia , he shoots ! Deflected by the defender and we have a corner kick . ', ' Delgado takes the corner . We have a foul ! Oh no , Did , the goalkeeper , has fouled the Ecuadorian player ! He gets a yellow card and that will be a penalty kick ! ', ' This is the perfect opportunity for Ecuador to get ahead in this match and become World Champions ! He gets ready for the kick . He shoots ! and he ... ']
["Hi , I'm Jake . I'm new to the choir . What's your name ? ", ' Hello , there , my name is Tonia . ', ' Do you sing alto ? ', ' Actually , I can do both soprano and alto but the director asked me to sing alto for the next perforate . What about you . ', " Looks like we both float back and forth . I'm baritone . ", " Our bass section is really good . You're going to love singing with them . ", " I heard them warming up earlier . You're right . ", " It's good to have you in the group . We can always use a good baritone ! "]
['How happy you are ! Next Monday is your wedding day . Congratulations ! ', ' Thank you ! ', ' Fred is really a good guy . And he loves you so much . ', " Yeah . I'm lucky to be his wife . ", " He's after your own heart , it is important . ", ' So he will make a perfect husband . Make sure you will be here next Monday . ', ' I promise ! ']
['Hey , buddy . Are the fish biting today ? ', ' They sure are . They are practically jumping in the boat . ', ' Is that so ? Well , what kind of bait are you using ? ', " We're catching most of our fish with lures . ", " Lures ? We're using live bait over here . ", ' What kind of live bait are you using ? Worms or minnows ? ', " We're using worms . ", ' Are you having any luck with the worms ? ', " No , we haven't even gotten a nibble today . ", " That's too bad . Why don't you try using lures instead ? ", " I would , but I don't have any in my tackle box . ", " That's too bad . Well , where are you fishing ? ", " I'm just fishing from the shore . How about you ? ", ' We went out in our boat . I have a favorite fishing hole out there . ', ' Sweet.Can you tell me where it is ? ', " Oh no , I can't tell you . It's a secret . Say , why don't you go over by the lily pads and try fishing there ? ", " Do you think that's a good spot ? ", ' Sure , I used to catch my legal limit of bass there all the time . ', " Thanks . I think I'll go check that out now . ", ' Good luck . I hope you each some fish . ']
['So John , have you ever been to China before ? ', ' No , I haven ’ t . This is the first time I have been to China . ', ' Have you travelled to many other countries ? ', ' To be honest , I have never been to an Asian country before but I have visited many countries in Europe . ', ' What about America ? Have you ever been to the United States ? ', ' Actually , I haven ’ t been to the states but I have been to Canada . ']
['What kind of movies do you like , Sue ? ', ' I like all kinds of stuff . I admit I love romance . ', ' Just like my wife . So , what ’ s your favorite movie ? ', ' You mean my favorite movie of all time ? I guess I ’ d have to say “ pretty woman ” . ', ' Yeah , my wife likes that one , too . Personally , I prefer action movies . ']
['By the way , could you tell me what day it is today ? ', " Well , it's Thursday today . ", ' And the date , please . ', ' The 5th . ']
['What will you do now ? Propose to her . ', " Of course I won't chill out . Opportunity knocks only once . ", ' You should strike while the iron is hot . ', " You're right . I will have a talk to her about that . "]
['Would you allow me to drive your car ? ', " No problem , but you've got to be careful . ", ' Surely I will . ', " Here's the key then . "]
['I could get along fine without all the office politics . ', " What's going on ? ", " There is a position I've had my eye on for several months now and I had good reason to believe that it was mine for the asking . ", ' So what happened ? ', ' We were awarded government funding last year and in order to keep it we have to hire so Ay new employees . ', ' So what does that have to do with this position ? ', ' Someone in the main office has a nephew who he thinks can slide right into the Management position I wanted . ', ' All under the precept of keeping the funding ? That stinks . ']
["Hello , Hanson . Today I come to say goodbye to you , for I'm going back to London tomorrow . ", ' No , not so soon . Couldn ’ t I persuade you to stay a couple of days more ? ', " Much as I wish to but I really can ’ t . I've already booked the flight . ", ' I hope this won ’ t be our last meeting . ', ' Of course not . You can come to London to visit me in future . And I also will come here if I have a chance . ', ' I will miss you . ', " I will miss you , too . You're really a good friend . ", " It's a pity that I'm too busy to see you off tomorrow . ", " It doesn't matter . ", ' Take care of yourself and remember to keep in touch . ', ' I will . ', ' Goodbye and have a good flight . ', ' Thankyou . Goodbye ! ']
['What are you reading ? ', ' It ’ s an article about language . It talks about the idea of having a single global language . ', ' It seems that English already is the main global language . Does the article suggest that there should be an artificial language like Esperanto as the world language . ', ' Actually , it suggest English . The main argument is that English is already being studied as a second language in most countries-china , India , mexico , Nigeria , Pakistan , and japan – so beginning again ', ' Does the article say anything about other language ? How will they survive in an English-speaking world ? ', ' The article points out that many languages have been lost and will be lost , but others will continue to be used for generation , even if English continues to be the dominant language . ']
['Hello ? ', ' Hi , Shelley . Have you had lunch ? ', ' Not yet . ', ' So shall we have lunch together ? I ’ d like to take you this time . ', ' I ’ d like to , but I can ’ t . ', ' How come ? ', ' I ’ Ve a lot of paper work to do right now . I ’ m behind schedule . ', ' All right . Can we make it another time ? ', ' Sure , thanks . ', ' I ’ ll call you later . Bye . ', ' Bye . ']
['Our neighbour ’ s tape recorder is so loud that it annoys us to death . I ’ Ve made up my mind to cut the electricity off . ', ' What ? That would be to cut off your nose to spite your face . ', ' Then what shall we do ? ', ' Call the police . ']
['Welcome to our school . If you need any help , please come to me . ', ' You are so kind . Thank you very much . ']
['What do you think about violence in movies ? ', " Personally , I'm not for it . I feel it's bad for kids to watch . ", " But kids like watching things like that . It's just for fun , would't you say ? ", " If you ask me , I have to disagree . Something shouldn't be watched for fun . "]
['I know you are a good dancer . What dances do you like ? ', " I like the old styles of dance . Such as fox-trot , waltz , rumba , tango and so on . They're all graceful . ", ' Why do you like old styles of dance ? ', ' Why not ? Do you think I should like modern dance ? ', ' I think so , because most young people like modern dances , such as rock and roll . ', " Oh , sorry . I don't like them . Why not ask Lily . She likes modern dance . ", ' OK , I will.Thank you . ']
['Can you help me do an internet search ? ', ' Sure . What do you want to find ? ', ' I want to find information on World War Two . ', ' Well , can you be more specific ? There are a lot of websites about that . ', ' Yes , I want to know about the Normandy Landing . ', ' Ok . Well , go to www.google.com , and type in Normandy Landing . ', ' Oh , wow ! There are lot of sites . ', " Here , try this one . It's a good site about Normandy Landing . ", ' Thanks . ', ' For detailed information , however , you should read a history book . ', " Thanks . If I am interested , I'll go to the library . "]
["I want to redo this poster , but John and Mary think it's good enough as it is . ", " I'm on your side . It needs to be done over . "]
["We're lucky today . ", " Yes , there aren't any clouds in the sky and we've got such a beautiful view here . Look ! This is St James Park . And there's Buckingham Palace ", " Where's Hyde Park ? ", " It's on the other side of the Palace . ", " That's the place where people make speeches on Sundays , isn't it ? ", " Yes , you're right . Politicians of all kinds , religious people , and one or two madmen . ", ' Well , are we going there today ? I want to take shots there . ', " Sure . I can see you're enjoying your trip today . ", " Of course . Everything's so striking and fascinating . "]
['Hi , John , how was your vacation ? ', ' Awesome , we went to Australia and New Zealand . ', ' That must have been wonderful . Do anything interesting ? ', ' Well , we went bungee jumping when we were in Australia . ', ' Wow ! Isn ’ t that dangerous ? ', ' A little , but the rush was worth it . ', ' Tell me about it . ', ' We jumped off a bridge and fell 500 feet before the bungee cord caught us . ', ' 500 feet ! I would never be able to do that . ', ' Yeah , it was scary , but exhilarating . ']
['How ’ s the food ? ', ' It ’ s pretty good . ', ' Well I don ’ t think so . I don ’ t like it at all ! ', ' I ’ m afraid you ’ re being too particular about your food . ', ' I eat dog food when my parents are out . ', ' We ’ re in the same boat ! I ’ Ve eaten fast food the whole week . I hate it now . ', ' Poor us ! All this junk food lacks nutrition ! ', ' Let ’ s dine out tonight for a change ! ', ' Good idea ! ']
["I'm afraid we can't increase salary this year , money is just too title . ", " I'm not sure I can't agree , dan . ", ' Why not ? ', ' Surely , there are other ways to save money . ', ' What are you talking about , we tried everything ! ']
['I ’ m sure you never dare to go against your wife . ', ' Why should I go against her ? She always seems to have better ideas . ', ' Have you ever got the goods on her for wrong doings ? ', ' Get the goods on her ? She never allows me to go to her office . And she is a good woman . She has been faithful all these years . ', ' Well , it ’ s nice to have a husband like you . ']
["I'm calling to say good-bye . ", ' When do you leave ? ', " I'm catching the eleven o'clock train . ", " Take care of yourself and don't forget to keep in touch . ", ' Goodbye . Thanks again for everything . ']
["Can we have two tickets for this evening's film ? ", ' Sure.Which one ? ', ' Titanic . ', ' Where do you want to sit ? ', ' Front , please . ', " Are these seats all right ? They're in the second rows . ", ' Do you have seats in the fourth or fifth rows ? ', " Sorry.We ' Ve nothing further back . ", " All right.We ' ll take the second row.By the way , how much is it ? ", ' Thirty yuan . ', ' Fairly expensive . ']
['Hi , come on in . Can I take your coat ? ', ' Sure , thanks . I brought you a bottle of wine as well . ', " You're the first guest to arrive . I'll just put your coat away and then I'll get you something to drink . ", ' Should I take my shoes off ? ', ' Whatever you prefer . ', ' This is a very nice place . How long have you been living here now ? ', ' Just over three weeks . Would you like a drink ? ', ' Sure , what do you have ? ', " I've got white wine , red wine , gin and tonics , ginger ale , lemonade , orange juice , and sprite . ", " I'll have a glass of red wine please . ", ' One glass of red wine coming up ! ', ' So how many people are coming for the dinner tonight ? ', " There's just going to be 6 of us tonight . ", " Oh , I thought there were going to be eight . who isn't coming ? ", " Marcia and Paul called to cancel at the last moment . Paul was running late and Marcia wasn't feeling well . ", " That's too bad.They ' re such good company . ", " I think there's someone at the door . Excuse me while I go and get that . "]
['The weather is really miserable . It has been raining hard all day long . ', " Yes , it's so cold . ", ' Do you think the rain is going to let up soon ? ', ' Yes , I think so . The rainy season will be over soon . ', ' How long does the rainy season last ? ', ' About two months . ', " I can hardly stand these wet and cold days . It seems that it doesn't bother you very much . ", " I'm used to this kind of days . ", ' But I prefer warm weather . ', ' Spring will come soon . And we will have some pleasant weather then . ', ' I hope so . ']
['Would you like to go skating with me this afternoon ? ', " Oh , I'd love to . But we're going to clean our dormitory . I can't be absent . ", " Maybe another time . People say that boys ' dormitories are in a mess , is it true ? ", ' In fact , our dormitory is much worse than they can be described . ', " It's hard for me to imagine . How can you stand that ? ", " You'll get used to it gradually . ", " Oh my God , don't you know that such living environment is not healthy ? ", " Yes , we do . That's why we have a cleaning every three months . ", ' Three months ? Incredible ! ']
['How long can I keep these books ? ', " A month . Don't forget to return them by the due date . ", " What if I can't finish them by then ? ", ' Bring them back to the circulation desk and renew them . ', ' Any terrible fines ? ', ' Sure . ']
['Are you excited about your trip next month ? ', " Yes and no . I can ' t wait to go to Europe , but at the same time I am terrified . ", ' Why ? ', ' Well , I have acrophobia . I have a chronic fear of flying . ', " Oh really ? I have an uncle who is also terrified of flying . It ' s not that bad though , I mean , it is pretty scary to be in this big machine flying through the air at seven hundred miles per hour . I actually have arachnophobia . ", " You ' re scared of spiders ? I actually have two more phobias . Acrophobia and glossophobia . ", ' I guess that explains why you are afraid of flying , but public speaking is not that bad . ', ' Are you kidding ? When I get on stage , my palms start to sweat , I get really nervous and I can hardly speak . ', ' Well , I must confess I am a bit claustrophobic . I hate being in an elevator for more than 5 seconds . ', ' We are such weirdos right ? ']
["Hello , Rachel . It's glad to see you here . ", ' Hi , Ross . Glad to see you , too . ', " I'm going to throw a party tomorrow night . Would you like to come ? ", " A party ? Yes . I'd love to . Thank you for inviting me . Will Monica come ? ", ' Of course . ', " That's great ! What time will it start at ? ", " At 6 o'clock . ", " OK . I'll come . See you then . ", ' See you . ']
['How could you have done that without asking me first ? ', " I didn't realize you felt so strongly about it . ", ' Well , you should have thought . ', " I'm sorry . I'll ask next time . "]
['Would you like to have dinner with me tonight ? ', ' Oh , that sounds great ! ', ' I ’ ll pick you up at ... say , 7,30 ? ', ' Yes , that would be perfect . ', ' See you tonight then . ', ' Yes . Thank you for inviting me . ']
['How are you getting along with your paper ? ', " I haven't finished it . It is very difficult . ", ' You should hand it in before next Sunday . ', ' Oh , I know . I will try my best . ', ' I believe you can do a good job . ']
['Would you like to come to our party ? ', " I'd like to . But I'm not myself today . ", ' what happened ? You look so pale . ', " It's the end of the world for me . ", ' What makes you say that ? ', " Today , I'm told I failed three courses . ", " Oh , that's too bad . Work harder next term . ", " I'm such a fool that duplication of effort is only a waste of time to me . ", " Don't loose heart . Everything will be fine . ", ' I hope so . ']
['I had a terrible journey back from Bangkok last week . ', ' Really ? Why ? What happened ? ', " Well , first of all , the taxi that was taking me from the client's office to the airport broke down on the freeway . ", ' Oh , no . ', " Yes , and the driver didn't speak any English or Chinese and he didn't have a phone on him-can you believe it ? - and his radio didn't work . So there was no way he could get in touch with the office to get them to send another taxi . ", ' So what did you do ? ', ' Well , I actually thumbed a lift . ', ' You what ? ', ' Yes , I stood on the side of the freeway and stuck my thumb out , and a passing truck stopped and took me to the airport . ', ' Wow , good for you . ', ' Yes , except he drove really slowly , and I missed my flight . ', ' Oh , no ! ', " Yes , so I had to wait three hours for the next one . I didn't get home till four in the morning , and when I got home I realized I'd left my house keys in my hotel in Bangkok . ", " You really have bad luck , don't you ? ", ' Seems like it . ']
['Do you have change for a hundred ? ', ' Sure . ']
['Have you read the new rules about using cell phone at work ? ', ' Yes , not bad . Like turn your cell phone ringer off and find a private place to make calls which it ’ s showing your respect to your co-workers . ', ' Well , but for this one , don ’ t bring your cell phone to meetings , I think it is not reasonable . What if there are some important calls ? ', ' Well , this one is not compulsory . It is just suggestion . ', ' I didn ’ t pay attention to that . ']
["Do you know about All Fools ' Day ? ", ' On that day , people play all kinds of tricks on others , and the one easily taken in is called April fool . ', ' April fool ! ', ' April the first is coming.Be careful ! ']
["Daniel , I can't catch up with the English teacher very well . ", " What's the problem ? ", ' You are quite good at English , can you help me with it . ', " That's OK . But you'd better take an additional course in some English schools . ", ' English school ? What is that ? ', ' This kind of school is good at helping people to improve their English . ', " Is that different from our school's English course ? ", ' Yes , before you start your training , they will test you on your English first . ']
['Have you ever seen coco ? ', " I've seen her on TV but not in the flesh . ", " I'm so familiar with her songs , but I don't know what kind of person she is in real life . "]
['Joseph , who is that woman ? ', " That's Susan . ", ' What does she do for work ? ', " She's a lawyer . ", ' Is she American ? ', ' No , but she speaks English fluently . ', " She's really tall . Do you know her ? ", " Yes , I know her . We're friends . ", " Who's that man standing next to her ? ", ' Which man ? ', " That short guy on her right . What's his name ? ", " Oh , that's Matt . ", " He's really good looking . ", ' Yeah . ', ' Do you know him ? ', " I don't know him , but I think my sister does . ", ' Is he married ? ', " Yes , he's married . ", ' I remember now . I met him before . ']
['I ’ Ve gotta hand it to you , you really did a good job ! ', ' So glad that you think so ! ', ' I think you deserve a promotion . ', ' Oh , really ? Thanks a lot ... well , I still have a lot to learn , I guess . ']
['Are you going abroad to study ? ', " I'll have to think about it . "]
['Billy , you are late again . ', " I'm sorry I'm late . I overslept . Is the manager here today ? ", " Yes he ' s in his office . ", " Oh , I hope he didn't notice me . ", " Don't take any chances . It'd be best if you told him and promised not to be late again . He's already mad at you for last 2 times . Any more and he might fire you . ", " You said it . It won't happen again . Do you really think he'd fire me ? ", " I think he might . You'd better go to his office . ", " You are probably right . I'll go right now and apologize . I try hard not to be late but it is difficult with Beijing traffic . ", ' Good luck ! ']
['Sam , what shall I do with my stocks ? Will I lose money ? ', ' There ’ s a possibility . ', ' What do you mean by that ? ', ' I mean if you don ’ t sell your shares now , it ’ s quite likely that you ’ ll end up losing your shirt . ', ' Is that so ? ', ' Absolutely . Take my word for it . ']
['Ann invited us to dinner this saturday afternoon . ', ' What should we take ? ', ' How about a china vase ? ', ' Good idea ! ']
["Which of the two do you think is better ? I mean , what's the difference between them ? ", " Well ... this one costs more , but it has a much better sound.This part of it is made of wood , not plastic . And there's a tone control , too . ", ' I only want it for the kitchen . I like to listen to the news at breakfast time . ', " Hmm ... well , the other one is good for the money . It's much cheaper . We sell clot of them and all our customers are satisfied with them . ", " Hmm ... I'd like the cheaper one , please . Can I pay hy cheque ? ", ' Certainly . ']
['Did you have a good weekend ? ', ' Yes , thanks . Did you ? ', ' Not bad . What did you do ? ', ' I went to Tamshui . You ? ', " I wasn't feeling too well , so I stayed at home . "]
['What do you do for a living ? ', ' I ’ m a doctor . ', ' Really ? Do you like it ? ', ' Yes , I do . It ’ s very interesting . What ’ s your job ? ', ' I ’ m a bus driver . ', ' Oh , do you enjoy it ? ', ' No , I don ’ t really like it . It ’ s boring . ']
["I'm sorry , Sam . I don't want to go to the folk concert . ", ' How about going to the theatre ? ', " I don't like going to the theatre . ", ' Well , what do you like doing ? ', ' Travelling , swimming , going to the cinema . And you ? ', ' I like painting , sailing , watching football and talking to you . ', ' I like talking to you , too . ', ' Do you want to go to an exhibition ? There is one at the Xinghai Exhibition Hall tomorrow . ', " That's a good idea . "]
['You want to go to the movies tonight ? ', " Sure ! What ' s playing ? ", ' The new Twilight movie ! ', " Twilight ? As in the vampire movies ? No way , I am watching that , but I don ' t understand why everyone is so excited about these films about vampires . It doesn ' t make sense . ", " Of course it does . It ' s like a modern tale of Romeo and Juliet . You can see a couple who are in love but can ' t be together because they are so different . And in the fact that immortality and super human strengthen this really sexy and there you have it ! Plus the cast is hip , young people that make the movie even more enticing . ", " I don ' t buy into that . I think it ' s just a fad . Pretty soon this will pass and everyone will be into wear-wolves or zombies ! "]
['What kind of person do you consider yourself to be ? ', " I think I'm polite , careful , relaxed and shy . ", " Oh , I don't think you're shy ! You are always chatting with new people when we go to a party . ", " Well . Yes , but those people always start talking to me . I never talk to them first . Perhaps I'm not as shy as I think . Anyway , you're certainly not shy ! ", " You're right . I love going out and making new friends . ", " So , you'll be at my birthday party on Friday ? ", ' Of course ! ']
["Let's invite Bobbie and John to our party , OK ? ", ' You can never do that . ', ' Why ? ', " There's been bad blood between them since Bobbie took away John's girlfriend . "]
['You look really wiped out ? ', ' I had meetings back to back all morning . And phone rang off the hook from the minute I walked into the office . ', ' Not a good day . I hate to tell you that Mr . Thomas wants to see the profit ’ s statement for new project tomorrow morning . ', ' I can ’ t believe it . I guess I ’ ll be here until 10 again tonight . ']
['Is this a photo of your family ? ', ' Yes , it is.It was taken just before I was leaving for college . ', ' You look so lovely . ', " How time flies ! I'll not see twenty again . "]
['Can you speak Japanese ? ', ' Yes , I can , but not very well . ', ' Where did you learn it ? ', " At school . And I'm still learning it now . ", ' How long have you been learning it ? ', ' About three years . ', ' Can you speak any other languages ? ', " I'm afraid not . "]
['Mary , do you remember when we met ? ', " I won't ever forget it ! I was sitting in the cafeteria all by myself ... ", ' And I came up and asked to sit by you ... ', ' Oh , it seems like it was just yesterday . ']
["May , we are fools to hang out at noon . It's dying hot today . My skin is too weak to be exposed under the summer sun . ", ' Do you have any sunscreen lotion ? ', ' You know , honey , I used it all on the way over . ', " I think I'm getting a heart stroke . ", ' The heat is driving crazy and I hate my new hat . ', " Why ? It's brand new , and it's perfect on you . ", ' But I bought it to get rid of the heat . Now it does nothing but burning my head . ', ' Beauty costs , honey . ', ' Laugh all you want , whatever . We need to get out of the heat . ', ' Walking under the sun is certainly not the way . ', " Give me a break . It's not funny . ", " Right . Sorry . Anyway , the radio said that it'll rain later today . ", ' Hope so ! Good thing is that autumn is just around the corner . ']
['Do you know much about computers ? ', ' Not a great deal . ', " I've just been reading an article about them . They'll be used for all sorts of things now . ", ' For accounting system and things like that , you mean ? ', ' Yes , but they are used for other things , too . Do you remember when we went to buy a ticket for the flight to Paris . ', ' Yes ? ', ' The man asked where we want to go , then he type out the information on the form and waited for a reply . A few moment later , he gave us two tickets . ', ' Of course , his machine must have been connected to a computer . ', " That's right . "]
['It ’ s time for me to go now . ', ' Would you like me to go with you ? ', ' I ’ d rather you stayed in the office and did these things . ', ' Do you want to type that letter ? ', ' I ’ d rather you typed it . ', ' Do you want to tell her ? ', ' I ’ d rather you told her . ']
['Which season do you like best ? ', ' I like spring . ', ' Why ? ', ' Oh , everything comes back to life in spring and the weather gets warmer . ', ' I like spring , too.We can go for a walk and enjoy the fresh air . ']
["John , my father isn't there at all . Are you kidding ? ", " Poor fellow ! What's the date today , buddy ? ", " It's ... OH , it's the first of April , April Fools ' Day . ", " You forgot all about it , didn't you ? "]
["I've booked an air ticket to Venice . ", ' How long will you be there ? ', " I'd like to stay there for a week . ", " So you'll have a tour of the famous city . ", ' Certainly . ']
['Oh , the ink is spilled on the desk . ', ' Did it spill on your clothes ? ', ' No , but the table cloth was dirty . ', " That's OK . ", " I'm afraid it's too hard to wash off the stain . ", " It's no big deal . ", ' I really feel great shame . Let me buy a new one for you . ', " Don't be silly , forget about it . "]
['Are you a happy married man ? ', ' Yes , I am . My wife and I understand each other . ', ' You are a lucky man . How about Mr . Smith . ', " I don't know . But they say that Mrs . Smith wears the pants in the house . ", ' You mean she bosses her husband around ? ', " That's right . She is pretty , but she wants to control everything in his life . "]
['The country is strong only in appearance . Don ’ t you think so ? ', ' Yes . In fact there are quite a large number of people who have no food to eat and no place to live in . ', ' You can say that again . The government must open it ’ s eyes to the fact . ']
['Elaine ’ s back from school . I think it might be a nice gesture if you asked her out . I suppose she ’ s not good enough for you , is that it ? ', ' Look , Elaine Robinson and I do not get along . ', ' How do you know ? You haven ’ t seen her since high school . I guess your evenings , whatever you do with them , are just too valuable . ', ' That has nothing to do with it ... ', ' I guess I ’ ll just have to tell Mr . Robinson that you ’ re too busy every evening – doing God knows what ... God don ’ t go on like this . If you absolutely refuse to take her out ... ', ' I do . ', ' Then I will simply have to invite all the Robinson ’ s over for dinner on Thursday . ']
['It smells like an ashtray in here ! ', ' Hi honey ! What ’ s wrong ? Why do you have that look on your face ? ', ' What ’ s wrong ? I thought we agreed that you were gonna quit smoking . ', ' No ! I said I was going to cut down which is very different . You can ’ t just expect me to go cold turkey overnight ! ', ' Look , there are other ways to quit . You can try the nicotine patch , or nicotine chewing gum . We spend a fortune on cigarettes every month and now laws are cracking down and not allowing smoking in any public place . It ’ s not like you can just light up like before . ', ' I know , I know . I am really trying , but I don ’ t have the willpower to just quit . I can ’ t fight with the urge to reach for my pack of smokes in the morning with coffee or after lunch ! Please understand ? ', ' Fine ! I want a divorce ! ']
['Jack , could you check your calendar ? ', " Sure , what's going on ? ", " We're planning a weekend camping trip , and we want to know which weekend is best for everyone . ", " Let me see ... The weekend after next looks pretty good.Otherwise , I'm all booked up . "]
['It is reported that the temperature is going to drop dramatically tonight . ', ' Really ? ', " Yes . So you'd better dress warmly before you go out . ", ' I will . Thanks for telling me . ']
["What's wrong , Dave ? You look down today . ", " I didn't pass the English exam . How to learn English well ? Can you give me some suggestions ? ", ' Well , English is a " paper tiger " . Its natural enemy is adequate practice . ', ' I have done a lot of reading comprehension exercises , and I also spend much time in memorizing English words . ', ' I suggest you read English texts aloud every day , and try to speak more . That will be beneficial to cultivate your sense of the language . ', " Really ? I'll have a try . Maybe I will get high marks next time . "]
['The answer for number 6 is C , 7 is B , 8 is A ... ', " Ms . Lee , could you tell me what number 7 is again ? I didn't catch you . ", ' Sure . 7 is B . Any others ? ', ' No , thank you . ']
['Look ! That man who is baking bread is so handsome . ', ' Watch his bread , it seems to be delicious . He had a lot on the ball . ', ' Oh , my god ! He ’ s so perfect . ']
["I don't know what I'm going to do . I need to find a job . If I don't , I won't be able to stay here next semester . ", ' Have you tried university part-time jobs ? ', ' What do you mean ? ', ' I mean in the library , or in some information center.Often the university hires foreign students for part-time positions . ', " Yes , I know . I tried that.They don't have anything now . So what can I do ? ", " Well , since you're a foreign student , it's hard.That ' s because it's actually illegal for you to work in America . ", " I know that . You don't have to tell me that . That's my problem . I know I have the right to work for the university . That's legal.But they don't have a job for me . And it's illegal for me to get a job elsewhere . ", ' Anyway , there must be some solution.You know there are many people working illegally in New York . ', ' But I need a pretty decent job . I need to make enough to pay my rent at least . ', ' I have an idea . ', ' What ? ', " Since you're Chinese , maybe you can find part-time work in Chinatown . ", ' I already had that idea . ', " Well , why don't you go and look down there ? ", " But I don't know what I would do . ", ' It may be part-time work as a waitress or something.It would be illegal , but sometimes waitresses make a good salary . ', " Maybe . I don't know . ", " I will ask my friends for you.Maybe someone knows a company that needs part-time people.That ' s another thing you should do . Ask all your friends to ask around for you.You might find something . ", " I have to find something.Otherwise I have to go back to Taiwan . I'll be broke in two months . "]
['I have some photos here taken by myself . Would you like to see them ? ', " Sure . Speaking of photos , what type of film will be the best ? You know , I'm planning a tour to Jiuzhaigou Valley . ", ' I would get Fuji 200 film for taking photos of natural beauty . ', " Thank you so much . You're an expert . "]
['Excuse me , Professor , is there a time when I could meet with you ? ', ' I could meet with you tomorrow anywhere from two until four ; what time works out best ? ', " I would like to come in at three o'clock . ", ' I am glad that that works out ; can you find my office ? ', ' Yes , I can . ', ' Just follow the walkway to the outside and climb the stairs to the third floor . ', ' I got it . ', ' If you do get lost , just ask someone in the building to point the way . ', " Thank you , I'll be there . ", ' If you need to cancel your appointment , please give me a call ! ']
['At what age do children start school in your country ? ', ' At five . ', ' Do boys and girls go to school together ? ', ' Yes , they do . ', ' Do you think this is a good idea ? ', ' Yes , I do . ', ' Do some children go on to university ? ', ' Yes , they do . ', ' What examinations do they take first ? ', ' O levels and A levels . ', ' How long do you usually stay at university ? ', ' Three or four years . ']
['Are you okay , man ? You don ’ t look very well . ', ' Ugh , I feel terrible . I went out last night with Trevor , and things got a little out of hand . ', ' Nice ! So , where did you guys go ? ', ' We hit a couple of local bars , and met up with some friends . Everything was cool until Mike came along , and it turned out that it was his birthday yesterday ! ', ' Oh no ! Mike ’ s birthday is a drinkfest for sure ! ', ' Tell me about it ! We drank everything in the bar ! ', ' Is that why you missed work today ? ', ' Yeah . I woke up this morning feeling really nauseous . I threw up like five times . ', ' Www ! ', ' I was so dehydrated that I drank like a gallon of water , and my head has been pounding all day . I swear , I ’ m never gonna drink again ! ', ' Too bad man , tonight is Tracy ’ s going away party and she asked if you were gonna go . ', ' Oh , yeah . I ’ m there ! ']
["Hey Claire , you've been really quiet these last few days . Is something wrong ? ", " I've been really stressed . It's the end of the year and I've got so much stuff to do ! I feel like I'm drowning in work . ", " Well , stress is a real thing . It's not an imaginary condition . ", " It's seriously affecting my life ! I can't sleep , I don't have much of an appetite and my husband says I've been kind of short tempered . Other people seem to handle stress okay ... why am I so weak ? ", " You're not weak ... you're stressed out ! Stress has been a part of the human condition for millions of years . Back when we still lived in the trees we had to watch out for predators ... and as you might imagine , that was pretty stressful . ", " Yeah , but I don't see any tigers or leopards roaming around our office . My stress is just about silly paperwork ! ", " But you're actually having the same reaction as our tree-dwelling ancestors ! It's called the flight or fight response . Each time you feel like something's threatening you , your body decides whether to run away or fight ... it causes all sorts of chemical reactions in the body . ", ' So a deadline will cause that same reaction ? ', ' It could . Modern humans actually have more flight or fight responses than our ancestors did . They just had a couple of close calls every day , but today , we have dozens or even hundreds ! ', ' So the life of a cave woman was less stressful than my life ? ']
["Hey , Mary , what's up ? ", ' Not much . Last night I met this great guy at the bar and we had such a wonderful time that we decided to meet again tonight . ', " Oh , that's exciting . What's this guy like ? Is he hot ? ", " Well , I ddin't think so at first . But as we started talking , I found him extremely funny and witty . I couldn't stop laughing at his jokes ! We have so much in common . We like the same teams , music , and most amazingly , we both love Chinese food ! I have the feeling that we are going to be great friends . ", ' It seems you two are a good match . What qualities do you look for in a friend ? ', " There's nothing definite I think . I don't have a list or anything , but when I first meet somebody , I can usually tell whether or not that person is going to be a good friend . It seems I have a radar helping me spot new friends . ", " Well , that's something I've never heard of . But if you ask me what I value most in a friend , I would have to say honesty . ", " I agree . You can't expect a close relationship with a dishonest person . Those are the people that will turn their back on you when you are in need . ", " Yeah , I know . A friend in need is a friend indeed . I don't need fair-weather friends either . "]
['I must be going now . ', " Really ? Can't you stay a little longer ? ", ' No , I really must go now.My family are expecting me home soon . ', ' Be seeing you then ! ', ' See you ! ']
['When you are in a restaurant you want the waiter to bring the bill , what do you do to attract his attention ? ', ' I just make eye contact with him and nod my head . Then I tell him when he comes over to the table . Why do you ask ? ', ' I went out with my girlfriend to a nice restaurant last night and I noticed that many people shouted for the bill . ', ' That seems a little impolite in such a restaurant . ', ' That ’ s what I thought . I just thought I ’ d ask you and see what you thought of it . Anyway , what did you do yesterday evening ? ', ' Well , it was a warm evening , so I stretched my legs . I walked along the canal for a couple of miles . Actually , several other people had the same idea . I saw Bill . ', ' Did you ? How is he these days ? ', ' He seemed ok . We didn ’ t stop and chat because we were on opposite banks of the canal . We just waved at each other . ', ' I need to move some furniture . Could you help me to lift it ? ', ' Of course . What do you want to move first ? ', ' Let ’ s move the sofa . Can you get a grip on the bottom at that end ? I ’ ll lift this end . I want to move it sideways in that direction . ']
['Guess what ? ', ' What ? ']
["I don't like this movie . It's a bomb . ", " Look , I've already paid for the tickets , so whether you like it or not we're going to finish watching it . ", " Well , give me the Walkman . I'll listen to the music then . ", ' Come on . Give it a chance . The movie just started . ']
['Excuse me , Miss . ', ' Yes . May I help you ? ', " I'm a graduate student here in mathematics . I've just come from China and I've never used a western library before . I'll be here for five years , so I'd like to learn to use the library as efficiently as possible . I wonder if someone might have time to show me around . ", " I'd be very glad to show you around , but I'm very busy right now . Could you come back about 3 thirty ? ", ' Sure . 3 thirty this afternoon . ', ' Good . See you later . ', ' Thank you . Good-bye . ']
["Don't open any of my forwards ! I got a virus ! ", " Don't tell me you got the dreaded Bush virus . I've heard that that bug is threatening to infect the world . ", " Yes , that's exactly the bug I got . Though , I do kind of like the pictures . ", ' Those clothes do suit him better . ', ' Wait a second-are these pictures copyrighted ? ', " Probably not . It's off the Internet . What difference does it make ? "]
['Say , do you go to see your grandparents often ? ', ' Of course , my grandpa is generous and kind.My grandma cooks the most delicious Chinese dishes in the world . ', ' You are very lucky . ']
['I need some flowers for my girlfriend . ', ' No problem . Would you like some artificial carnations ? ', ' Oh , no . Carnations are not very elegant.Artificial flowers have no passion . ', ' How much did you want to spend ? ', ' Money is no object . ', ' Our most elegant flower is Golden Lily . ', ' I will take ten . ', ' Do you want to add some baby ’ s breath for that ? They are equally popular now . ', " Of course . Can I have it delivered to my girlfriend's house this afternoon ? ", ' Yes , but there is a five dollars delivery charge . ', " That's ok . Here is the address . "]
["Julie , what's on the tube ? ", ' nothing but bench of commercials . These days the amount of commercials is amazing . ', " yeah . Maybe we can change to another channel . what about the sports channel ? Let's see if there's a game on . ", " okay . Nope , it's a replay of yesterday's soccer match between Brazil and Spain . ", ' it was a good game , but not good enough to watch again . Keep surfing . ', " alright . Hmm , this movie is a rerun ... I don't know how many times I've seen this show ... Commercial again ... and a replay of the talk show ... oh no , this show is terrible , you don't wanna watch it . ", ' oh , what is it ? ', " it's a total rip-off of an American reality show , but the imitation is unbearably clumsy . ", " oh , I know this kind of shows . Sometimes they really piss me off . If I wanted reality , I'd go outside . ", " yeah ... it seems what we have on TV now are either repeats , or commercials , or low-quality shows . There's really nothing to watch . ", " I don't get it . We have more than 100 channels and there's still nothing good on ! Maybe we should just turn off the TV , get outside , and do something real . ", ' cool . ']
['That woman is a thorough drag ! ', ' What is it ? ', ' She keeps spitting on the ground . ', " Maybe there's something wrong with her . "]
['To be a revolutionary needs great courage ! ', ' He must be courageous enough to fly in the face of established authorities . ', ' Galileo is one of them . ', ' So are Copernicus and many others . ']
['Did you go to the bank to withdraw money ? ', ' Today is so hot , besides I had so much housework to do . My friend came for a visit and stayed for two hours . I didn ’ t forget , but I had no time at all . ', ' So you didn ’ t . Is that right ? ', ' Yes . I ’ m sorry . ', ' Why didn ’ t you just answer my question directly ? Why would Chinese answer questions this way ? I simply asked if you did it or not . It ’ s a very simple question . And Chinese often give the reason before they would give a direct answer . ', ' Yes , I ’ m sorry . I know it bothers you very much . But I don ’ t know why Chinese sometimes would do this . ', ' You know , today I asked a student if he brought his dictionary with him . It ’ s a rule I made for the class that everyone brings a bilingual dictionary with them because sometimes they don ’ t understand me . The funniest thing is that this student gave me a lot of reasons and no direct answer . ', ' But you know if he brought it or not , right ? ', ' Yeah , after all the explanations like , it ’ s too heavy , I was in a hurry ... whatever . ']
['Uncle , have a heart , please lend your new car to me . Only once . ', ' Where are you going ? ', ' I have a big date tonight . ', ' You have got a car , haven ’ t you ? ', ' Oh , please . Only once lend your new car to me . ']
['Betty and I will throw a dinner party this weekend , we ’ d like you to come . ', ' That would be very nice . Only that I ’ ll be a little late . Is that OK ? ', ' Sure . We ’ ll be looking forward to that day . ', ' So will I . Thank you . ']
["I think it's going to be a nice day . ", " It's certainly a big improvement over yesterday . ", " But it'supposed to get cloudy and windy again this afternoon . ", ' Well , the worst of the winter should be over . ']
['David , I heard you lost your job . ', ' Yeah , you remember that assignment I wanted ? When I heard the manager had given it to someone else , I blew my top . So the manager fired me . ', " Well , that'll teach you to control your temper . "]
['You look very professional in the suit . ', ' The company regulates that men should wear a suit and tie in business meeting . Company policy is not negotiable . ', ' I appreciate it . It is related to company image . ']
['Do you know Mark ? ', ' Yeah ! He is a nice guy . He is very helpful and always bends over backward to help those who are in need of help . ', ' Can you introduce him to me ? ', ' Sure . ']
['Did you tip the bellboy ? ', ' Yes , but I don ’ t think it was enough . He looked disappointed . I gave him three dollars . ', ' That sounds about right to me , fifty cents a bag . If they think you don ’ t know better , they ’ ll try to get more . ', ' It ’ s the same in Balloon . But I definitely think we over-tipped the cab driver . The fare was twenty dollars , and you gave him a five-dollar tip . That ’ s twenty-five percent of the total ! Too much ! ', ' I disagree . He was polite and informative , and he drove smoothly . One should reward good service . ', ' I ’ ll sign for dinner and charge it to our room.Let ’ s see.The bill is one hundred dollars . That seems reasonable . How much tip should I leave ? ', ' Remember last month when we were in Europe ? Maybe Californians use that same system they add the waiter or waitress into the bill , so you don ’ t have to leave anything extra . ']
["Thomas , would you be so kind as to lay the table for me ? I'm busy in the kitchen . ", ' Of course ! Where are the things ? ', " They're all here . ", " Right ! I'll do it straight away . ", " Thanks a lot . I'm most grateful . "]
['William told you that his grandmother is sick , huh ? What exactly did he say ? ', " He said his grandmother got cancer and has only a few weeks to live . It's really so sad ! But when I talked to him on the phone , it sounded like he was holding up really well . ", " It didn't sound like he was too upset , huh ? What did you tell him ? ", ' I asked if there was anything I could do to help his family , and I told him that I could be a shoulder for him to cry on . ', " Well I hate to tell you this Jen , but both of William's grandmothers passed away more than five years ago . "]
["The boss announces the pay raise today , right ? How much do you think we'll get ? ", ' No idea . Your guess is as good as mine . ', ' It better be more than last year . ', ' Well , anything is better than nothing . Wait and see . ']
['Do you like to dance ? ', " Sometimes , if there's music playing . ", ' What kind of dancing do you like ? ', " It all depends . If it's rock music I'll do disco , and if it's romantic music I'll do ballet . "]
['Mom , what are you doing ? ', " I'm clipping coupons . ", ' Still clipping coupons ? ', " It's a good way to save money . ", ' Saving money ? How much money can you save by those 1 or 2 dollar discount coupons ? ', ' How much ? Last week I save $ 10 on food . ']
['Sorry ! Excuse me ! I got your message . ', ' Taylor ? Taylor ! Is this a joke ? Is it really you ? But ... but ... everyone said you were dead ! ', " That's OK . Just let it out . I'm OK ! I was out of town with ... Femi . ", " Oh , Taylor ! I'm so ... so happy . But then ... who's that ? ", " Taylor Smith . But not me . The pallbearers are carrying out the casket . It would be rude to just leave . Let's follow . "]
['Okay , next question . If Eric asked you out on a date , what would you say ? ', ' Duh ! I would say yes ! Eric is the most popular kid in school ! Okay , my turn . What would you do if you won the lottery ? ', ' Let ’ s see ... If I won the lottery , I would buy two tickets for a trip around the world . ', ' If you buy me a ticket I will go with you for sure ! ', ' My dad will freak out if I even mention a trip like that ! ', ' Alright this is a good one . What would your mom say if you told her you are going to get married ? ', ' If I told her that , she would faint and have me committed ! ']
['Wow , there are so many lanterns to appreciate . ', " Now . you can see why it's called the Lantern Festival . ", ' Yes , it deserves its name . ', ' Did you notice the characters on the lanterns ? ', " Sure . But you know that I can't read any Chinese characters . What do they say ? ", " They are puzzles . It's a tradition to solve the puzzles on the lanterns during the Lantern Festival . ", " It's interesting and I want to buy one home . "]
['Do you have s second ? ', ' Sure . What do you want ? ', " I want to tell you I've put in my notice . ", ' Really ? Why ? ', " I've been thinking about this for several months , well before the Spring Festival holidays . ", ' And the holidays provided you a chance to think over all this and make a decision ? ', " Yeah , after receiving my yearly bouns , I want to search out better opportunities in the spring job market . I've been working in the company for nearly a year and a half and I still haven't received a pay rise . It's unfair . ", " Absolutely . With your expertise and experience , you're clearly working below your pay grade . ", " That's exactly why I decided to quit the job and find a new one . "]
['Hi Joe . You met my new assistant , right ? ', " Emm ... yes . But I wasn't too impressed . I found her a little stuck up . ", " You are kidding , but she's so helpful . ", " Tom ... you are her boss , you down . Of course , she's helpful to you . ", " Come on . She's like that with everyone . ", ' I don\'t think so actually . She never even says " hello " to me . ']
['What a boring film ! ', ' The acting of the heroine is too artificial . ', ' And the plot is so simple . ']
['So , John , what do you do for a living ? ', ' I ’ m a sales manager in a publishing company . ', ' Oh , really ? That sounds interesting , what kinds of book do you publish ? ', ' Oh , mostly fiction , lots of romance , science fiction , biography , stuff like that . ', ' Oh , What a cool job ! How long have you worked there ? ', ' About two years now . ']
['Are you planning on studying abroad ? ', " I'd like to , but I'm not sure if I'll have enough money . "]
['I feel pity for the old man . ', ' I feel the same way . ', ' It must be dreadful to grow old . ', ' It sure is.He has no one to turn to , very miserable indeed . ']
['Dad , you keep talking about family in New Zealand . Who are they ? ', " Well , that's your uncle Bill , his wife and two of their daughters . ", ' Is uncle Bill your brother ? ', " No , your uncle Jack is my brother , Bill is my brother-in-law , your mom's brother . ", ' So his two daughters are my cousins ? ', " That's right , Sarah and Jane are both your cousins although they are step-sisters . ", ' What are step-sisters ? ', " Sarah is your uncle Bill's older daughter . When she was young , Bill's first wife , Sarah's mom died . Three years later Bill married again . ", " So uncle Bill's wife is Jane's mother but not Sarah's mother . Right ? ", " Yes . She is Sarah's step-mother . ", ' And when are they coming to visit us ? ', ' They want to travel to Europe next year , and will visit us at the same Ae . ']
["I'm worried sick that she will leave me tomorrow . ", " It's no use arguing the toss . ", " Maybe I'll have to face the music . "]
['I like pop music very much . ', ' What ? ', " I said I like pop music very much.It ' s so lovely . ", ' Is it ? ']
["I'll help you , Lucy . Look at what I've got here . In this small bottle , there's a magic love potion . ", ' A magic love potion ? ', " Yes . If you put a few drops on someone's eyelids while he's asleep , he'll fall in love with the first person he sees when he wakes up . ", " It can't be true . ", ' Take my word for it . ', ' So what am I going to do ? ', " Just come to our house and stay over . You'll sit by his bed and greet him like a beautiful red rose , ' Good morning ! ' ", ' That sounds like a blue rose ! My sitting by his bed ? ', " Don't be so shy , Lucy . "]
["All right , let's see who's ruining my TV time . ", ' What are you going to do ? Call my boss and chew him out ? ', ' Is your boss named Vic ? Your pager says , This is Vic . Here I come ! ', " Impossible . My pager is really old . It doesn't display messages . ", " Here , see for yourself . That's really strange ! It's almost the same as when I ... ", " Gosh , you're right ! It's from some guy named Vic . I wonder who he is ... "]
["I'd like to say good-bye to everyone . ", ' What time are you going ? ', ' My plane leaves at seven twenty-five . ', ' Well , good-bye and have a good trip ! ', " Good-bye . Remember to look me up if you're ever in Washington . "]
['Well , what brings you here ? ', ' I came to see my aunt . ', ' Does she live nearby ? ', ' Yes . She lives on the next block . ']
["Don't talk too much , Tom . We are on duty today , we should hurry up . ", ' OK . ', ' Tom , your task is to clean the blackboard . ', ' How about yourself ? ', " I'm going to sweep the floor first . ", ' Daniel , I am not tall enough to reach the of the blackboard . ', ' Stand on the chair , Pig Tom . Use your brain . ', " OK , I've finished cleaning the blackboard . ", ' How about the podium ? ', " Oh , I forgot about it . I'll get it . ", ' Be quick , please . Our teacher and classmates will come soon . ', ' I will be done before they come . ']
['I think he deserved his gold . ', ' Did you see his last dive . ', " Yes , it's perfect ! ", " He's diving for the gold . "]
['Jim , I heard you took a trip to San Diego . Is that right ? ', ' Yeah , I just got back this morning . ', ' That sounds really nice . What did you do there ? ', " Well , we were only there for three days , so we didn't do too much . We went shopping and went out to dinner a few times . And at night we walked around the city with some friends . ", ' Did you take any pictures ? ', ' Yes , I have them with me . Do you want to look at them ? ', ' Sure , I love looking at photos . ', ' This one is of my wife and me on the beach , and this one is our daughter Emily standing next to my wife . ', ' Your daughter looks like her mother . ', ' I know , they look very similar . ', ' Where was this picture taken ? ', ' That was taken at the train station before we left . ', ' Did you have time to go to the zoo ? ', ' No , not this time . We went there last time . ', ' It looks like you all had a nice time . ', ' Yeah , it was a lot of fun . ']
['Are you interested in history ? ', ' Yes , I am . I enjoyed studying it at school , though I had trouble remembering all the dates , so my teacher never gave me good marks . ', ' I love history , but I ’ Ve always thought that learning the reasons behind events is more important than remembering exactly when they happened . ', ' I wish you had been my history teacher ! I might have got better marks ! ', ' Some people say that history repeats itself . ', ' What does that mean ? The same events never happen twice , do they ? ', ' The idea is that the people and dates change , but the reason why things happen stay the same . ', ' I see . I think I ’ d agree with that statement . People often seem to make the same mistakes over and over again . ']
["Nice day today , isn't it ? ", " Yes , beautiful weather we're having . ", " We can't complain about the weather recently . ", " Yes , the sun shines day after day . It's neither too hot nor too cold . ", ' I wonder how long this weather can last . ', " I hope it will last fine Sorrow . I'm going to have a picnic with my family . "]
['Excuse me , Sir , May I have the time , please ? ', ' Beg your pardon ? ', " Er ... I'd like to know what time it is now . ", " Oh , Let me see ... It's three forty-five . Er ... wait , My watch is five minutes fast . So it should be three forty ", ' Thank you . By the way , what day is today ? ', ' Today is Friday . Are you new in Beijing ? ', " Yes , I've just come from the States , yesterday in fact . I'm still a bit confused about the time . ", " Welcome to Beijing . This is my business card . I'm an engineer . If you need any help in Beijing , just give me a call . ", " Oh , that's very nice of you . I don't want to sound pushy , but I still l have one more question . ", ' Go ahead . ', " What's the date today ? ", " It's October the 1st , our National Day . I'd like to talk some more , but I've got to get going now . It was nice talking to you , though . ", ' Yeah , it was nice to meet you . Hope I run into you again sometime . ']
['I really enjoyed that film ! What about you ? ', ' So did I . At first , I thought it was going to be boring , but then it turned to be good . ', ' What part of the film do you like best ? ', " Well , the scene of the hero's struggle with enemies impressed me the most . ", ' I loved it , too . To tell you the truth , I even dropped tears . ', ' Actually , tears also came to my eyes . ', " It has got this year's Oscar Award . ", ' It deserves it . The film gave us a lot of inspiration . ']
['I just got a letter from an old high school buddy . ', " Really ? That's nice . ", ' He usually keeps me posted . ', " I've been completely out of touch with my old friends . ", " It's hard to keep up contact when people move around so much . ", ' Yes , people just seem to drift apart . ']
['What did you think of the film ? ', ' I liked it . I thought it was great . ', ' Yes , I liked it , too . Did you like the acting ? ', " Yes . I thought it was excellent . Didn't you ? ", ' Not really . I thought it was disappointing . ', " It's a nice cinema , isn't it ? ", " Do you think so ? I don't like it very much . I found it rather uncomfortable . "]
["John's very late.Do you think he's coming ? ", " Well , it doesn't seem like it.He must have forgotten . ", " I suppose you're right.He can't have remembered . "]
['I don ’ t know why bucks have such a great charm that a great many people are after nothing else . ', ' They want to be filthy with dough and think it the only source of their happiness . ', ' But many rich guys don ’ t think they are truly happy . There is always some empty feeling deep inside them . ']
['What are you using for bait today ? ', ' We are fishing with worms . The fish seem to like them . ', " Is that so ? We're using lures , and the fish are biting those too . ", ' Looks like a lucky day for everyone . ']
['How is your ankle ? ', ' My what ? Oh , that , right as a trivet . ', ' Please be careful next time . ', ' I will , thank you . ']
['Do you know something about Mount Tai ? ', ' Yes . But not too much . It is considered as the head of five sacred mountains in China . ', ' Five sacred mountains ? Why people call them so ? ', ' Because in history , the Chinese emperors used to climb onto these mountains and pay tribute to their ancestors and pray for good harvest and prosperity for the whole nation . ', ' Got it . Can we see any things left by them ? ', ' Definitely . There are many wall paintings and inscriptions on the huge rocks on the mountain . ', ' I want to see them . How can I go there ? ', " That is easy . You can go directly to Tai'an city and buy a ticket to Mount Tai . "]
["Mary , this is your homeroom . It's 213 . Remember that . ", " What's a homeroom ? ", ' You sit in there , listen to the morning announcement with other kids , and then you go to your classes . ', " Cindy , I'm scared . ", ' But I have to go to my homeroom . ', ' Do we have the same classes today ? ', ' No . ', ' Do you think the school can put us in the same homeroom ? ', " Stop worrying , Mary . You'll do just fine . "]
['Helen , you must be excited at going to America to study . ', " Yeah , I've been looking forward to it for ages . ", ' What do your classmates think of it ? ', ' They give me a lot of congratulations . ', ' How long will you study there . ', ' Oh , maybe three years . I will study and get the master degree first . Then I will decide whether I will stay there or come back . ', ' Which university will you go to ? ', ' Chicago University . My major is Economics . ', ' Good luck ! ', ' Thank you ! ']
['Look ! Someone is celebrating his birthday . ', ' This must be his 21st birthday . No doubt about it . ', ' Why ? Do you know that guy ? ', " No . Well , in America , 21 is the age when you're allowed to drink . So , many guys celebrate it in bars . ", " That's interesting . But it would be really expensive , I suppose . Just think about all the drinks . ", " No . If it's your birthday , then you don't need to pay a cent . Just blow out the candles and open the gifts . That makes the birthday a special day . Your friends will take care of everything . ", " Wow . That's wonderful . ", " What about in China ? What'd you do to celebrate your birthday ? ", " Nowadays , it's no difference from America . But in old times , we have traditional ways to celebrate it . "]
['have you adapted to the lifestyle in China ? ', ' yeah , almost . But there is one thing . ', ' what ? ', " I still wonder what privacy meant for Chinese people . I don't mean to say that there's no privacy in China , but ... ", ' what is it ? ', ' some of my Chinese colleagues just share their personal stories in front of others . ', ' that makes you feel uncomfortable ? ', ' yeah . we never do that in a public office . ', " perhaps that's because we hold different ideas about privacy . ", ' i have felt that . One day when i was in a queue , reading a newspaper story , the man behind me peered through my shoulder and stared at the newspaper I was holding . ', " well , that's not rare . I've seen people reading at others ' newspaper while taking a metro or a bus . ", ' just stare at the newspaper holding in the hands of the one next to him ? ', ' yeah . ', " Oh , I'm shocked . "]
['Excuse me , Miss . ', ' Yes . May I help you ? ', " I'm a graduate student here in mathematics . I've just come from China and I've never used a western library before . I'll be here for five years , so I'd like to learn to use the library as efficiently as possible . I wonder if someone might have time to show me around . ", " I'd be very glad to show you around , but I'm very busy right now.Could you come back about 3,30 ? ", ' Sure . 3:30 this afternoon . ', ' Good . See you later . ', ' Thank you . Good-bye . ']
["what's your apartment like ? ", " it's furnished two bedroom flat in a three-story building on campus . ", ' what is it like living in on-campus housing ? ', " it's not as bad as I thought it would be . The freshmen that live nearby are really loud , especially on the weekends . But , the rent is much cheaper than private housing , so it's worth it . ", ' did you have to pay a deposit ? ', " no , but we do have to pay 9 months rent in 6 months , so for the first months we pay 1/2 month's rent each month . ", ' do you have to pay utilities on top of your monthly rent ? ', " no , it's all included . Besides , students don't have to pay council tax , so we're saving quite bit of money by living here . ", ' how long is your contract for ? ', " that's the bad thing---the contract ends in June , so we'll have to find a new apartment soon . ", ' have you started looking again yet ? ', " not yet . I'm hoping we'll be able to find something cheap once all the students leave the city for the summer . ", ' Good luck ! ']
['Have you seen the news that there is a serious flood in the South ? ', " Yes . I've got to cancel my traveling plan . ", " What a pity ! I know you've been longing for it these months . ", ' The only thing I can do now is waiting for another chance . ']
['You should have seen the T . V . show that was on last night , the topic it covered was really interesting , animal rights . ', ' Do you really believe in that ? If they are going to focus on something , they should do it on civil rights . ', ' Yes , but we can ’ t deny that animals are vulnerable , defenseless , and are completely at the mercy of human beings . ', ' I understand your point , but we continue to have transgressions against human rights . If so much attention weren ’ t devoted to the topic of animals , we would then concentrate more on saving a human being instead of protecting a koala . ', ' You can ’ t compare apples and oranges . I believe that both topics are important and that we can ’ t ignore them , the mistreatment of animals can cause a great environmental imbalance . I believe that governments should prohibit activities like poaching . ', ' Well , you are right on that point . This is the reason that I don ’ t buy leather and I try to buy synthetic products . ', ' As long as you don ’ t treat it better than your wife , it ’ s fine . ']
['Excuse me . May I take a picture of you and your little boy ? ', ' What ’ s it for ? ', ' It ’ s for a book . ', ' Oh , that ’ s a nice idea . Well , it ’ s fine if you take our picture . ', ' Thank you . I appreciate your help . ']
['Just dab it all over your face and then take a look at the symbols that appear . ', ' Yeah ... hearts , stars and some weird looking things . ', ' Those are money bags , and they represent your financial situation . ', ' So decode this for me , Madame Psycho . ', " That's Madame Psychic to you . ", " I'm waiting ... ", ' Well , you have three hearts — lucky in love tonight . Dress up and go on a date ! ']
['Mary , how was your date with john ? ', " it's ok . It seems we have a lot in common . ", ' oh , really . That is great news . What does he look like ? ', ' he is tall and slim , fair-haired . ', ' sounds like he is pretty cute . What do you think of him ? ', ' he is a nice guy and very considerate . I was impressed with how smart he was and he has a great sense of humor . ']
['Did you go to the concert last weekend ? ', " No , I didn't . And you ? Was it good ? ", ' Yes , I did . I enjoyed it a lot.There was a folk singer , a violinist and a pianist . ', ' How much was the ticket ? ', ' I only paid two dollars for mine . ']
['Hi , nice to hear from you , when does your plane leave ? ', ' It leaves in 20 minutes . ', ' Good . ', ' Can you pick me up from the airport ? ']
['Will you help me take these things to the car ? ', ' OK , which car do you want me to put them in ? ', " Bring them to my wife's car . ", ' Which one is hers ? ', ' The blue SUV in front of the Honda . ', ' What should I take first ? ', ' That chair over there , but please be careful with it . It was a gift from my mother-in-law . ', " Don't worry , I won't drop it . Wow , it's really heavy . I don't think I can move it by myself . ", " Let me help you with that . I don't want you to hurt your back . ", ' Where are you taking all this stuff ? ', " Didn't I tell you ? We're moving to Florida ? ", " You're moving now ? I knew you were moving , but I thought you said you were moving next month . ", " Yes , that's true , but my wife found a new apartment on the Internet the other day and she wants to move right away . "]
['Have you received your TOWEL test results yet ? ', ' Yes , I did . I passed ! ', ' Congratulations ! I knew you could do it . ', " Well , I certainly couldn't have done it without your help . You are the best tutor I've ever had . ", ' Thank you , but it was your hard work that did it . ', " You deserve credit , too . I've learned so much from You . "]
["You didn't come to work yesterday.What happened ? ", ' I had to look after my son at home . ', " What's wrong with him ? ", ' He has a fever . ', ' Is he getting better now ? ', ' I think so.Thank you . ']
['It sure is hot today . ', " That's for sure . I feel like I'm melting . "]
["how's it going ? ", " I'm in a good mood today , actually . How about you ? ", " to be honest , I'm a bit fed up . ", " what's wrong ? ", " there's a girl in my company that I really like but I always get shy when she is around . ", ' I see ! Do you want to ask her out ? ', ' sure , but how ? ', ' you can ask her out for drink after work . ', " but for what reasons ? She doesn't even know who I am . ", " then you've got a lot of homework to do . You need to get her notice first . ", ' easier said than done . ', ' you can start by meeting her at the bus stop and saying hello to her . ', ' but I always get tongue-tied when I see her . ', " that's something you need to overcome . Men should make the first move as most of girls prefer being chased . ", " I see . I'll try . ", ' good luck ! ']
["It's getting late . I'm afraid I have to leave.Thank you for a most wonderful evening . ", " Don't mention it.Don ' t forget to take your daughter along next time . ", ' OK . ']
['Lisa , would you like to go to the library with me ? ', ' OK . Do you think we can go buy a newspaper first ? ', " Sure . First we'll go buy a newspaper and then we'll go to the library . ", ' Are we going to walk or drive ? ', " The weather is really nice today . Let's walk . ", " The weather is good now , but I think it's suppose to rain this afternoon . ", " Alright , then let's take an umbrella . Is your brother coming with us ? ", " No , he's still sleeping . ", " Wow , it's already 10:00 AM . He must have been up late last night . ", " Yeah , he didn't come home until 12:00 AM . ", ' I hope he can come later . ', " I hope so too . I'll give him a call when we get there . ", ' How do we get to the library from here ? ', " It's straight down this road on the left , next to the museum . It takes about 10 minutes . "]
['Hi , Lucy , you are very popular with people around you , what are your tricks ? ', ' Thank you for saying so . I don ’ t know , probably because I like sharing my experience and knowledge with them . I think this kind of communication helps to improve our work efficiency and also helps to get along with colleagues . ', ' Sharing knowledge can be very settled and some second stances . People may think you are telling them how to do their work . If they take it personally , they feel angry at you and even become reluctant to support you at work . ', ' That is true . Some people will misunderstand your intention and lets you do it in the long threatening way . For example , it is not sensible at all to arguing with the others or correcting someone in front of other people . To show your friendliness and willingness to share is much more important than to show off . ', ' You are quite right . Thank you for sharing your experience with me . I learned a lot . ', ' You ’ re welcome . ']
['how was your education going on in Australia ? ', " I'm going to graduate this summer . ", ' where are you going to work then , in Australia or back in China ? ', " I'm planning to return to China after graduation . ", ' why are you choosing to leave a foreign country ? Many people are reluctant to leave the superior living environment abroad . ', ' well , I think personal development is much more important than simply having a superior living environment . ', " yeah , China's developing so fast and development opportunities can be found almost in every corner of the country . ", ' absolutely , many Chinese enterprises are going global , and they are in great need of excellent returnees to help them with their overseas business . ', ' the rapidly expanding economy has encouraged many students to pack their bags AMD head for home . ', " that's right . Most of the Chinese students pursuing higher education in Australia intend to return to China . "]
['How do you like this dress ? ', " It's nice . But what kind of dress are you looking for ? ", " Something attractive and dressy . Maybe a little sexy too . New Year's Eve is a special occasion and it only happens once a year , right ? ", " Of course . It's common too that we wear something special for our Chinese New Year . ", " People here always wear the best clothes they have . Many people go out and buy clothes especially for New Year's Eve . ", ' Any other common customs of your New Year ? ', " Before the New Year , we always send greeting cards to our relatives and friends to wish them a happy year . On the street and in stores people usually greet others with a ' Happy New Year ' . It's also common for people to make a New Year's resolution . ", " What's that ? ", " It's when people quit a bad habit or do something they find hard to do . Many people resolve to quit smoking , lose weight , or stop nagging their wife , etc . However , it usually lasts only for a few days ! ", " By the way , where are you going on New Year's Eve ? ", " We're going to a night club for dinner and dancing , then we'll go down to the city square for the big celebration . There's always a fireworks display put on by the local government . We all want you to come too . ", ' Thanks a lot . ']
["My name's McDonald . ", ' Is that spelt M , A , C or M , C ? ', " It's M , C , capital D . "]
['Hey , you wanna see a movie tomorrow ? ', ' Sounds like a good plan . What do you want to see ? ', ' How about Legally Blonde . ', " Ah , my girlfriend wanted to see that movie . I have to take her later so I don't want to watch it ahead of time . How about The Cube ? ", " Isn't that a scary movie ? ", " How scary can it be ? Come on , it'll be fun . ", " Ok . I'll give it a try . ", " That's the spirit . I'll see you tomorrow after class . ", ' Ok . See you tomorrow . ']
['Could you help me to register for a class ? ', ' Do you know what class you want to take ? ', ' Are there any Psychology classes available ? ', ' I believe there are still two Psychology classes open . ', ' On what days are the classes ? ', ' There is one class on Tuesday and Thursday from 2 to 4 . ', ' Can you tell me about the other class ? ', " It's from 10-12 on Monday and Wednesday . ", " You're positive that these are the only classes left ? ", ' These two are the only ones . ', ' The class on Monday and Wednesday will be fine . ', ' Very good . ']
['Which season do you like best ? ', ' Autumn . Autumn is the best season in Beijing . ', " I like autumn , too . Where I'm from , Autumn is the best time of year . "]
['How would you like your hair cut ? ', ' I want it short . ', " Then , I'll just trim it . ", ' It will do . ']
['Lucy , you ’ re back . How was your first day of school ? ', ' It was great . I had a really good time . ', ' What classes did you have ? ', " Well , I had English from 9 o'clock to 11 o'clock , art from 12 o'clock to 2 o'clock , and math from 2 o'clock to 4 o'clock . ", ' What do you think about the teachers ? ', ' To be honest , I liked all of them , except for the math teacher . Though he must be quite young , he seem like an old person . He ’ s so boring ! ', ' That ’ s too bad . How was your English teacher ? ', ' She was great . In today ’ s class , she gave us a lecture on how to be a good student . She told us not to arm for exams , and to pay more attention on communicating than memorizing . ', ' Where is she from ? ', ' She said that she ’ s from a small town in the middle of America . ', ' Were you able to understand everything that she said ? ', ' Not everything , but nearly . She speaks very clearly and doesn ’ t use very complex words so that it is easy for us to understand her . ', ' She sounds like a good teacher . Do you think you ’ ll pass her class ? ', ' Yes ... with flying colors ! ', ' What does that mean ? ', ' It ’ s a new phrase that she taught us today . It means that I will not only pass the class , but I will do extremely well ! ', ' If you like the class this much already , I ’ m sure you will . ', ' I hope so . ', ' did she give you any homework ? ', ' not today . She said she wanted us to relax tonight instead of doing homework , ', ' no wonder you like the class so much . ']
["I know you're sleepy and I hate to bother you , but I think you're late for work . ", ' Oh , no . I forgot to turn the alarm clock on ! ', " Don't worry . I can give you a lift . ", ' Thank you . You save me . ']
['Annie , what is troubling you ? You look unhappy . ', ' A man is pursuing me . He was my schoolmate in college , and he has been carrying a torch for me for three years . ', ' Do you like him ? ', ' Yes , I do like him . ', ' Then why are you hesitating ? ', ' You know that I have had a series of miserable relationships . Last summer , I fell in love with John . But the romance blossomed for six or seven weeks , and then wilted . ', " One love drives out another . You shouldn't be afraid to start a new relationship . ", ' Maybe you are right . ']
["How's work ? ", ' The same as usual . ']
['The police need our help finding a robber . ', ' How do you know ? ', ' The TV news is reporting a bank robbery . ', ' Do they know what the robber looks like ? ', " Yes , he's 6 feet tall , 200 pounds , black hair , and about 30 years old . ", ' What race is he ? ', " They didn't say . ", " The TV news doesn't tell us the race anymore . ", ' Of course not . That would be racist . ', " But how can we identify someone if we don't know their race ? ", " Don't ask me . ", " Then they also shouldn't tell us if the robber is male or female , because that is sexist . "]
['What are the pop groups that you like ? ', ' Oh , there are so many good ones ! I loved the Spice Girls . They were so cool ! ', ' I agree ! I cried for a week when they broke up . ', ' I was really sad too , but at least I can still listen to their Cds . ']
['David , imagine meeting you here ! ', " Janice , I found you stole my vegetables at four o'clock this morning . Is that true ? ", ' All right ! I stayed up yesterday and waited for your vegetables . I stole your peaches and flowers . ', ' It is so hard to prevent them from being stolen . I also got something this morning . ', ' How many vegetables do you steal today ? ', " I stole many from Fred's farm , and from yours . I planned to have a dog on farm . ", ' So funny . By stealing , I forgot all my sorrows and pressure from work . ', ' I could not agree with you more . For us , there are so many unhappy things and I am so bored ; however , I got lots of fun from stealing . ', ' I really want to be far away from the reality now . ', " But we still need to go back to it . Don't overdo it . "]
['Mom ? ', ' Mm ? ', ' Can my friend , Tom Mitchum , come home with me for lunch tomorrow ? ', ' Of course , Jim . Have I met Tom before ? ', ' Mm — hmm . You met him last summer . He is small and very smart . ', ' Oh , yes . I remember Tom . His family comes from Maine , right ? ', ' Yes . ']
['Do you know who ’ s just got married ? Old Mc Donald . ', ' Never ! He ’ s over 80 , isn ’ t he ? ', ' He ’ s nearly 90 . ', ' Good gracious ! Are you sure ? ', ' I am . Whatsmore , his wife is 84 . ', ' Is she really ? ', ' Yes , she is . And guess what , he is her sixth husband . ', ' Really ? Quite a woman , isn ’ t she ? ']
['I wanna register for this mathematics course . ', ' I ’ m sorry registration has closed . ', ' Closed ? The clerk told me I could come back and register any time during the first week of classes . ', ' Well , that ’ s not possible . The computer ’ s official student account has already been sent to the state . And that ’ s what our budget is based on . Who told you that anyway ? ', ' Some woman in here when I tried to register three weeks ago . She said I just had to pay a late fee . ', ' She must have been a part-time worker . They didn ’ t have much training . Why didn ’ t you register then ? ', ' She said I couldn ’ t until I had my birth certificate . Here it is . ', ' Huh , that is no reason to demand a birth certificate . We only need to establish residency , you know , a phone bill with your name and address on it would have been fine . ', ' Serious ? Only the proof of my address . ', ' Yes , I am afraid she gave you the wrong information . ', ' But it ’ s unfair . ', ' Well , I sympathize with your problem , but , to be honest , I don ’ t think there is any thing anyone can do for you . You were trapped in the system.If you want , you can talk to the director . She will help you if she can . ', ' Great . ', ' Don ’ t get your hopes up . ']
["Why didn't you tell me you had a girlfriend ? ", ' Sorry , I thought you knew . ', ' But you should have told me you were in love with her . ', " Didn't I ? ", " You know you didn't . ", " Well , I'm telling you now . ", ' Yes , but you might have told me before . ', " I didn't think you'd be interested . ", " You can't be serious . How dare you not tell me you were going to marry her ? ", " Sorry , I didn't think it mattered . ", " Oh , you men ! You're all the same . "]
['Will you give your friends a buzz and put out a feeler to see if they like to offer me a loan ? ', ' Give them a buzz ? What can I say to them ? Say that you want a loan ? ', ' I just want to make sure that there is possibility of giving us a loan . ', ' And they , too , want to make sure their loan is worthwhile . ']
['Hello , Jim . Where are you going ? ', ' To the cinema . What about coming with me ? ', " No , thanks . I'm going home . My wife's expecting me . ", " What a pity . I believe it's a very good film . ", ' Do you go to the cinema a lot ? ', ' Once a week . Most nights I sit at home and watch telly ', " Do you know what's on tonight by any chance ? ", " No , I'm sorry I don't . I never read the papers till I get home . ", ' Oh , I see . By the way , where are you going for your holidays this year ? ', " I don't know yet . My wife's going to her mother's for a couple of weeks . She Livesay the sea , you know . ", " Oh , does she ? That's convenient . ", ' Yes , but I want to go to the country . ', " Don't you like the sea ? ", " Yes , very much . But I need peace and quiet when I'm on holiday . What are coughing to do ? ", " I'm going to stay at home . ", " Aren't you going to have a holiday abroad this year ? ", " No , I want to buy a car , and that's going to take every penny I've got . "]
['Hi charles , I want you know that I finally found an apartment in Haitian . ', ' You did ? that is great ! ', ' Yeah , I am having a party this saturday night , a sort of house warming , and i want to invite you . are you busy ? ', ' No I am free , I will be there , what time the thing starting ? ', ' Around seven . ', ' Ok , great , should I bring anything ? ', " No , but thanks for offering , actually could you bring some fold-up chairs for people if you have any ? I am afraid not everyone's going to have a seat , do you have any ? ", ' sure , I will be happy to bring a few , what is the address ? ', " Don't worry , I will come to pick you up at about 6 thirty . ", ' Got it . ']
['Hey , Dora ! What kind of books do you like to read ? ', ' I read everything I can get my hands on but I like love stories best . What do you think about the love stories ? ', ' I hate to tell you this , but they are nothing but sob stories . ', " I don't think so . I like them . Then what's your favorite book ? ", " I'm fond of history books . ", ' Oh , the history books are dull to me . ']
["What ? I don't get it ... ", ' Many of the slower dances are danced to the lyrics of tragedies . He meant that you turned it into a comedy . ', " Well , I'm glad I made everyone happy . ", ' He meant it in a good way . You added a little spice to the performance . ', " I'm glad you guys all have such a good sense of humor . Ha-ha ... ", " Of course ! That's why I always say , Eat , drink and be Greek ! "]
['Is anybody in ? ', ' How can I help you ? ', ' I have a headache . ', ' Let me take your temperature with a thermometer . ', ' OK . ', ' I think you have a small fever . ', ' I thought so . I felt dizzy this morning . ', " You should've called in sick ! Next time , have either of your parents call the school office . "]
['Can you tell me a little about Paris ? ', ' Sure . What do you expect to know ? ', ' I want to see some of the famous places like Eiffel Tower , the Seine River ... ', " And you shouldn't miss the Louvre Museum . You can stay there for at least a whole day . ", " That's a good idea . I almost forget it.What else ? ", " The night life there . It's so romantic ! ", ' Oh , wonderful ! How is the weather ? ', ' I went there in August , and it was hot . But I was told autumn is the best season . ', " Sounds exciting . I can't wait . "]
['This shirt you gave me is not my favorite brand . ', " Don't look a gift horse in the mouth ! That was the best they had . "]
['Which film shall we see ? ', " There is nothing good at the moment.Let ' s do something different.Would you like to go to a concert ? ", " Yes , I'd love to.Here is a good one , Mozart and Beethoven.It ' s on the Festival Hall.Shall we go there ? ", ' Fine ! Do you want anything to eat now ? ', " No , I'm not hungry . ", " Well , let's go and have something to drink instead . I know a good place . It's a little expensive , but it's fun . "]
['Did you take my money from the table ? ', " Absolutely not ! I'm not a thief . "]
['Both our countries are quite small . How would you describe the landscape in your country ? ', ' My country is well know for being very flat . There are some hills in the southeast of the country . ', ' Is it really completely flat ? ', ' Pretty much . The land rises and falls only a few meters . The southeast , the hills rise to a height of a few hundred meters . There are mountains over 1000 meters high in your country . ', ' Yes , there are . They are not very big compared with the mountains in other countries . ', ' The coast of your country is very varied . The coast of my country is just made up of sandy beaches . ', ' That doesn ’ t sound too bad . Great for sunbathing ! The coast of my country changes even within a few kilometers . There are cliffs , then sandy beaches . Then rocks . There are lots of caves in the cliffs . ', ' There are many lakes and rivers in your country too . We also have many rivers , but only a few lakes . ', ' We also have waterfalls in the mountains . They make the landscapes look very scenic . The landscape has been shapes by millions of years of erosion , especially by water . ']
['Any idea about James ? He ’ s a pain in the neck . ', ' Guess what ? He has just got the sack . ', ' Oh , is that so ? ', ' Exactly . ']
['Is this your new teacher ? ', ' Yes , it is . ', ' Is she short ? ', ' No , she ’ s average . ', ' What color are her eyes ? ', ' They ’ re dark gray . ', ' What color is her hair ? ', ' It ’ s blond . ', ' And how old is she ? ', ' I don ’ t know . ']
['Do you know that Mary ’ s marriage is on the rocks ? ', ' Really ? I ’ Ve never heard of it ! ', ' I saw her husband have it out with her yesterday . ', ' I think Mary must be sad , because she loves her husband very much . ']
['I don ’ t understand why you always look so happy , so energetic . It seems like you ’ Ve got good news everyday . ', ' Really ? Do I look happy all the time ? ', ' All I know is you look quite differently from other teachers . ', ' Oh , do you know why ? Actually , it ’ s easy . Because I always exercise . My exercise , I think , is very hard . I often feel very good after conquering these difficulties . I feel alive ! ', ' Oh , I know . I saw you doing pull-ups one time on the campus and some students trying to imitate you . ', ' Yeah , they are doing it for fun . Seldom would people like my exercise . It ’ s difficult and boring . ', ' It ’ s true . Many students do the exercise when they have to . We have P . E . once a week . ', ' But I think Chinese students need to exercise more . Besides exercise will help them learn new things better . Don ’ t students want to have a good memory ? ', ' Of course . I didn ’ t know that . I only know exercise makes bodies stronger . I should take some exercise then . Do you have any suggestions ? ', ' Well , do what you like to do . It can be anything . Jogging , doing aerobics , going bicycling , and playing ping-pong . Absolutely anything . Doing three or more workouts a week is good for you . But remember to do some stretches first . ', ' Oh , I know . Thank you . ']
['The woman was beaten again . Why didn ’ t she call the police . ', ' Because it was her husband who beat her . ', ' It is incredible . ', ' She said that she didn ’ t want to foul her own nest . ']
["Now let's begin the class . Who is on duty today ? ", ' I am , sir . ', ' Please come to the front to have five minutes ’ free talk in English . Very well ! Whose turn is it to have a free talk ? ', " It's me , sir . But I am sorry I have forgotten to prepare for it . ", " Well . Don't forget to perform your duty next time , ok ? Now , let's start our lesson . "]
['How was your job at the state-owned enterprise ? ', " Oh , I no longer work there . I'm working with a multi-national corporation . ", ' You changed jobs again ? Why do you move so frequently ? ', ' I want to try different things before I find the one I really like . ', " Why don't you stick with one job for a bit longer ? ", ' I could handle everything pretty well in the old position , so I decided to move around and learn something new . ', " How's your current job going ? ", " I'm pretty satisfied with it . I can broaden my experience , learn lots of new things , and have more development opportunities . "]
['Do you have a boyfriend ? ', ' Yes . Why ? ', ' Well , I came to know a girl 3 weeks ago and we have so much in common . ', ' So ? ', ' So I think I may fall in love with her . ', " You are attracted to her . That sounds great , but how do you know that it is a crush or it's real love ? ", " Then what's the difference between having a crush and falling in love ? ", " That's a big question . Well , if you are in love , maybe you ’ ll take every opportunity to talk to her or telephone her for no reason at all . ", " That's what I did . ", ' And you think about her all the time ? ', ' Yes . ', ' And maybe you suddenly have new interests . I mean you suddenly begin to do things you used to avoid , ie.You used to sleep in every morning , but because she jogs every morning , then you begin to like jogging . ', " That's it . She likes dogs so much now , and I begin to love dogs . ", ' Oh , congratulations ! Sounds like you ’ Ve found your soul mate . ', ' Thanks . But I know falling in love is one thing , while staying in love is another . ', " Yeah , that's right . If you find this person is more and more important to you and you can totally trust her , then you can stay in love . ", ' Yeah . Falling in love is so good ! ', ' While staying in love is even better . ']
["If you wanna keep healthy , you must give up smoking . It's extremely bad for your health , you know . ", " I know it's not good for me , but the problem is I just can't help it . ", " Well , I've got an idea , put the label cancer sticks on each pack of cigarettes , and read it before you smoke . It may give you a feeling to reduce it . ", " I'll try . "]
['What happened ? ', " I don't know . ", " Let's stop and have a look . ", " Don't waste time . ", " I'm curious about that . ", " But it's none of our business . "]
['It ’ s very kind of you to invite me to dinner . ', ' Please sit down and make yourself at home . Please don ’ t stand on ceremony . ', ' This dish is really delicious . ', ' I ’ m glad that you like it . This is only the first time that I made it . ', ' You ’ re great . Could you say it in Chinese ? ', ' Sure , we call it doubt . ']
['Wake up , Erik , time to rise and shine . ', ' Huh , oh , hi , Jane . I must have fallen asleep while I was reading . ', ' You and everyone else . It looks more like a camp-ground than a library . ', ' Well , the dorm ’ s too noisy to study in , and I guess this place is too quiet . ', ' Have you had any luck finding a topic for your paper ? ', ' No . Prof . Grant told us to write about anything in cultural anthropology . For once I wish she hadn ’ t given us so much of a choice . ', ' Well , why not write about the ancient civilizations of Mexico . You seem to be interested in that part of the world . ', ' I am , but there is too much material to cover . I ’ ll be writing forever , and Grant only wants five to seven pages . ', ' So they limit it to one region of Mexico . Say the Yucatan . You ’ Ve been there and you said it ’ s got lots of interesting relics . ', ' That ’ s not a bad idea . I brought many plenty of books and things back with me last summer . That would be great resource material . Now if I can only remember where I put them . ']
['I really like my debate class . ', " Do you think you'll be interested in studying law later ? ", " I've entertained the idea . But I'm I leaning more toward politics . ", ' You want to be a politician ? Yuck . ', " That's not like you to generalize . ", " Sorry , you're right . I think you'll be a good politician . ", ' I think I can do a lot of good for our country . ', " You're right . We need more people like you in politics . "]
['I dare you to talk to that girl . ', ' Okay , I will . ']
["Hey , what's the matter ? ", " It doesn't matter . I just feel a little dizzy . ", ' Are you sure that this has nothing to do with sleep ? ', " I don't know . "]
["Excuse me . My name is David Walker . Haven't we met before ? ", ' Well , let me see ... Do you work at IBM Corporation ? ', ' Yes , I do . ', ' Now I remember . We met at a conference in Tokyo last year . ']
['The last thing I want to see is to lose face before my friends . ', ' That ’ s really unbearable . ', ' But you know , things cannot always go as you expect . ', ' So get prepared for everything . ']
['Have you ever thought about having children , Kaitlyn ? ', ' My husband and I have thought about it , but we ’ Ve decided not to have any . They are just too expensive . Besides , with all the news about global warming on the news lately , who knows what kind of world we ’ ll have in the future . What about you ? ', ' Well , I ’ Ve always wanted to have lots of children . Growing up with only one brother , I always felt a bit lonely . What do you think about families with only one child ? ', ' For me , growing up in a big family always made me yearn for attention . I always wanted to be an only child so that I could always do what I wanted and so that I wouldn ’ t ever have to share . ', ' Don ’ t you think you would miss having other people around ? ', ' No way ! I spent 20 years of my life with relatives around me 24-7 . you know , I don ’ t think I ’ Ve ever actually spent any time by myself in my parents ’ home . What do you think of the one-child policy in China ? ', ' If China didn ’ t have such a policy , can you imagine how many people there would be in China now ? ', ' That ’ s true . But as a woman , I ’ m glad that even though I don ’ t want any children , I at least have a choice in how many children I have . On the other hand , I can ’ t imagine what China would be like if there weren ’ t a one-child policy ! ', ' Do you think most families with many children envy or feel sorry for other families with only one child ? ', ' I don ’ t know what other people think , but I , for one , envy only children ! ']
["I'm sorry I'm late . ", " Oh , that's all right . I just wondered what was keeping you . ", ' The bus I took . ', ' What do you mean ? ', ' I took the wrong bus . ', " Oh , did you ? That's very easy to do . "]
['Hi , Anna . I haven ’ t seen you for ages . Where have you been ? ', ' I ’ Ve been away on holidays for sometime . ', ' No wonder I haven ’ t seen you recently . Where did you spend your holidays ? ', ' I went with my husband . Our first stop was Bangkok . We stayed there for 5 days . Then we flew to Hong Kong , stopover for 3 days . Our last stop was China . We visited the Great Wall . ', ' You must have a wonderful time . ', ' Yes . We enjoyed ourselves very much . Have you traveled much , Luke ? ', ' No , my wife doesn ’ t like traveling . We haven ’ t been traveling for more than ten years . The first time we traveled together was in 1978 when we just got married . We spent our honeymoon in the Alps . ']
['I think I need a new notebook ... ', ' Why ? Is there some new , cool computer out on the market ? ', ' You bet there is . Feast your eyes on this puppy ! ', " That's a notebook ? ", ' Believe it ! ', ' It looks more like a toy , or a cool briefcase ! ']
['Is there a lot of crime in your city ? ', ' There ’ s some , but I don ’ t think it ’ s a big problem . A lot of it is petty crime , burglary and car theft . There ’ s very little major crime . ', ' It ’ s the same in my city . We also have a lot of drug addicts . A lot of the crime is committed by drug addicts who need money for drugs . ', ' That happens in many places . In my city , there is a very good drug rehabilitation programme . The police and courts are also tough on people who commit crimes , but I don ’ t know if that ’ s the reason for ', ' Some people believe that a tough approach is better . Other prefer a more lenient approach . ', ' I think that the best way to reduce crime is to spread wealth more evenly . If most people have similar amounts of money , they will not think of stealing from others . ', ' That ’ s possible , but I ’ m not sure it would really happen like that . ']
['Why do you like this computer ? ', " It's user friendly . "]
['What can I do for you today ? ', ' I need to return a book . ', ' Can I do anything else for you ? ', ' I would also like to check out this video . ', ' Is that all ? ', ' Yes , just the video . ', ' May I see your library card ? ', ' Here you go . ', ' You have to take care of this video . ', ' Oh , I will . ', ' You will be fined if you damage it . ', ' I understand . Thank you very much . ']
['Good game ? ', ' Not bad . But too hot for me today . ', " Yes , I know . Kind of hard to concentrate , isn't it ? ", ' Absolutely . Who were you playing with ? ', " Oh , just on my own . I just joined , so I don't really have any partners . ", " Really ? Oh , well , in that case we should play together some time . What's your handicap ? ", ' 16 . Yours ? ', " No kidding ! I'm 16 , too . We should definitely play together some time . My name's Bob . ", ' Jane . Nice to meet you . ', ' Me too . So , do you like the course ? ', " Yes , it's fine . However , I personally think the fairways between the greens are a bit too long , especially for such a hot climate . Don't they have carts ? ", ' Well , they used to , but they got rid of them because of environmental concerns . ', " Oh , that's good . I guess the caddies were pleased . ", " Actually , in my opinion , the carts were better because you don't have to tip them . ", ' Yes , but look at it this way , getting rid of the carts probably gives more work to local people , which is a good thing , right ? ', " Possibly , but I still miss them ! What bothers me is that the heat makes the caddies ' life quite hard . One member's caddy fainted last week ! ", ' How awful , poor guy . ', " Right . Luckily it was on the eighteen hole , quite near the clubhouse , so he didn't have far to carry him . ", " Oh , my God , you're kidding me ! He carried him back ? ", ' Yup . ']
['Can I get you something to drink ? ', " No , that's okay , I already have a coke.Why don't you have a seat , you look like you've been on your feet all day . ", ' I guess I could take a break.So , how do you like Denver ? ', " It's great ! The mountains here are beautiful and the skiing is spectacular.Have you been here for a long time ? ", ' About six years ... ', ' What do you do for a living ? ', " I manage one of the ski lodges.It ' s a great job , I can spend a lot of my time outdoors , and I also get to ski for free all season . ", " Wow , talk about job perks ! That's great . I would like to do something exciting like that.But I am only an accountant.Not too much excitement there.huh ? ", " That's okay.If it weren't for you accountants , nobody would have the money to go skiing ! "]
['What are you doing ? ', ' I ’ m just looking at this map of the world . I ’ m preparing for a geography class . ', ' There are no countries marked on the map . ', ' No , there aren ’ t . this map just show the geographical features . Look at the Himalayan plateau with the highest peaks in the world . ', ' The thing that I find most surprising is that most of the world is covered with water . Compared to the oceans , most countries are tiny . ', ' I find it incredible how millions of years of volcanic activity have created mountains thousands of metres tall . ', ' Rivers have created deep valleys and canyons like the grand can you . ', ' The oceans and landscapes all influence our climate . ', ' It ’ s all so interesting . I ’ ll have to find more information about it on the internet . Or perhaps I should try and attend your geography class . ']
["I'm sorry , I'm having a little trouble understanding your accent . ", " I'll try to speak more clearly . "]
["What's your favourite steps ? ", " It's hard to say . But I do love waltz very much . ", ' How about rumba ? ', " To tell the truth , I don't like it . ", ' Really ? You must like tango , right ? ', " Oh , it's really beautiful , but I just can't dance it well . ", " Don't be so modest . I'm sure you can dance it very well . Let's dance it now . ", " OK . I'll have a try . ", ' Oh , you dance it so well . ', ' Thank you for your compliment . ', " I think I'm your lucky fellow . "]
['I heard many stories about your brother . ', " He's a hero in our town . ", ' What does he look like ? Is he handsome ? ', " Yes , indeed , People say he's the smartest young man . "]
['Do you know that Jack got divorced last month . ', ' For what reason . ', ' Jack always lives by his wits and he cannot support his family . ', ' He had better make a change . ']
['Why do you look so sad ? ', ' I ’ m in pretty bad shape . I am having an allergy all the time . ', ' Why not go and see a doctor ? ', ' I never trust those stupid doctors . ']
["I'll always remember my college days . ", ' oh yeah ? ', ' It was one of the best times in my life . It was tough , but I made it . I became a college graduate . ', ' how did you feel when you graduated ? ', " it was a round day for me . My family attend the graduation ceremony . I was so nervous . I couldn't find my cap and gown , but all worked out in the end . ", ' what did you do after graduation ? ', ' I was planning to attend gradate school , but then I was offered a good job doing marketing , so I changed my mind . ', " sounds like you're happy with your decision . ", ' I sure am . So what about you ? How did you feel when you graduated ? ', ' it was also a proud day for me , but I also felt like a kind of loss that day . ', ' how could it be ? ', " while seeing others going to work or continue their study , I didn't know what I would do . ", " you didn't have an offer ? ", " I had one , but I didn't like the job very much . I wanted to attend graduate school , but I was afraid it would be too tough . ", " I think you lack in the power of decision . Once you make your decision , don't be overtaken by misgivings and fear . Just go full steam ahead ! "]
['Ashley , what a great dinner party ! ', ' Thank you , Joe . What would you like to drink with your meal ? I can offer you wine , mango juice , or water . ', ' Just water would be fine . ', ' Excellent choice . Can I dish you up some chicken ? ', ' Yes , the chicken looks wonderful ! ', ' How about some salad to go with your chicken ? ', ' Sure , I love salad ! ', ' Would you like to have rice with your chicken ? ', ' Yes , I think that rice will go perfectly with my chicken ! ', ' Good ! Julie , if you could pass this plate down to Joe , I think we are all set . ']
['How many days do you take off for Easter ? ', ' Usually we have a month off . ', ' What will you do for this Easter ? ', " I'll stay at home and have a complete rest . "]
["Mary didn't pass the final exam in physics . ", ' She must be very sad . ', " Her parents scolded her severely and she's very depressed now . ", ' At a time like this , what she needs is a pat on the back rather than a blame . ']
['John dates her seven times a week . ', " Really ? That's a straws in the wind . ", " I think so . Maybe he's fallen for her . ", ' Yeah . They suit each other . A perfect match between a man and a girl . ']
['My uncle gave me this bicycle as a birthday present . Look ! ', ' So cool ! Can I get a load of it ? ']
['I love your bracelet . When did you get it ? ', " I got it a while ago , but I haven't worn it much . You really like it ? ", " Yeah . It's beautiful . Is it white gold or silver ? ", " It's white gold . ", ' Where did you buy it ? ', ' My boyfriend took me to the Shane Co . and he let me pick it out . ', " That's so sweet . What was the occasion ? ", " That's the best part . It wasn't for anything special . He just wanted to buy me something . ", " You're so lucky . If he bought you something for no special day , I wonder what he would buy you for your birthday . ", " My birthday is coming up . We'll find out pretty soon . ", ' What do you want ? ', " I wouldn't mind a necklace . I was at the jewelry shop looking around , and they have a couple of beautiful necklaces I want . ", ' Why not a ring ? ', " I don't think I'm ready for a ring from him yet . ", " But you're ready for everything else ? ", ' Akha . ']
['Do you like traveling , Kathy ? ', ' I like traveling for pleasure to get places for vacation for instance . But I don ’ t like traveling to work , waiting for buses , or ... ', ' Or getting stuck in traffic jams when you ’ re driving . ', ' Exactly . ']
['Hello , Jane ! ', ' Hi , Tom . How have you been ? ', " Pretty good . Actually , I'm quite busy with work . By the way , say ' hello ' to your husband . "]
['What are you doing ? ', ' What am I doing ? What am I doing ? Don ’ t you know what day it is ? ', ' Mumm . no . ', ' It ’ s only the day when the world ’ s biggest sporting event is kicking off . ', ' What ? ', ' The World Cup ! The first match is today ! It ’ s Mexico vs . South Africa ! It ’ s going to be a really good match ! Both teams have a very strong offense and have skilled players . I think that South Africa ', ' I have no idea what you ’ re talking about . The only sporting event we watch at home is the Super Bowl . ', ' This is bigger than the Super Bowl , man ! Teams from 32 countries compete against each other every four years and fight to win that trophy . They first start in a group stage with bigger groups , each g ', ' Sounds interesting , but soccer doesn ’ t really appeal to me . ', ' Are you kidding ? Over seven hundred million people watched the final match of the World Cup ! It ’ s a very exciting and nerve wracking sport ! Each nation is cheering on their team , hoping they will bec ', ' All I know about soccer is that you can ’ t use your hands and that players are always falling down , trying to get a free kick or penalty kick . It seems like a sissy sport to me ! ', ' Whatever , I ’ m going to go watch the opening match . ']
['Do you often do exercise ? ', ' Certainly . ', ' OK , and what kind of sports do you usually play ? ', ' I often play badminton with my parents . ', " You ? Play badminton ? That's unbelievable ! You are shorter than a racket . ", " Hey , I'm good at playing it . ", ' Says who ? ', ' My parents . ', ' Oh , I see . ', ' How about you , Daniel ? ', " I'm a real man , and I like football . ", ' Well , who is your favorite football player ? ', ' I like Renaldo the most . ']
['Professor , can you help me add your class ? ', ' You have to bring me an add sheet to sign . Do you have one ? ', ' No , I will have to get an add sheet . ', ' You must take the signed add slip to the Admissions and Records Office to add the class . Do you know where that is ? ', " No , I don't know where that is . ", ' The office is in front of you as you cross the quad . The signs in the hallway will tell you where you need to be . ', ' I think I can find it . ', " You'll find it easily . Make sure you add the class and then we will look at the roll sheet later to make sure that you were added on . ", ' Thank you for letting me add your class . ', ' To drop a class , you need to do the same thing with a drop slip . Good luck ! ']
['Hi , Alice , what are you doing this sunday . ', " Nothing really , why , what ' s up ? ", ' If you are free , maybe you can get having for my birthday party , it should be fun . ', " Sounds great , i ' d very much like having something thanks , when ? ", ' Around six pm . ', " Do you need help setting up or anything ? I don't mind . I like to do that kind of thing . It's fun and I have a good eye for decorating . ", ' No . thank you . I can handle it , but thanks for the offer . ', ' Ok , I will see you again . ', ' Great . I have a good day , thanks again for the offer . ']
['Did you understand question number three ? ', ' Not at all , I was totally in the dark . ']
['Excuse me , I wonder if you could help me ? ', ' Of course , what can I do for you ? ', " Well , I hate to have to say this , but I'm not happy with my room . ", ' Oh , what exactly is problem ? ', ' Well , the traffic is very loud . I got no sleep last night . ', " Oh , I'm so sorry , Sir . I'll see what I can do about that . "]
["What's the weather like in your city ? ", ' In the summer it gets very hot . The temperature is between often 37 and 40 centigrade . When it is hot we often get rains . The winters are drier . ', ' The summer temperature usually often reaches about 20 or25 in my city . The rain falls mostly in the winter . And we often get snow . ', ' What are the temperatures in winter ? In my city it is about 15 or 20 degrees . ', ' In winter temperature often falls to zero at night temperature can be below that . The streets are often icing in the morning . With high such temperatures you must get some thunderstorms . ', ' Yeah , we do . In the middle of summer there can be found storms every day usually in the afternoon . I heard your city has a lot of fog , is that true ? ', ' We do have a few fog days in winter . But I would not say we have a lot of fogs . The sky are usually clearly in your city , are they ? ', ' Yes , they are like I said we have thunderstorms . But each one usually last a few hours . Then the skys are clear again . ', ' Have you ever had snow in your city ? ', ' My grandmother said there was snow once when she was a child . But my parents and I never see it outside of my city . ', ' The river in my city sometime freeze over . People go ice-skating on it . In summer people go boating on the river . But few people go swimming because it is not very clean . ', ' As you know , my city is on the coast.the water is also not clean . But people still go swimming all year around . I prefer to sand bath on the beach when the weather is hot and sunning . ']
["Look ! It's clearing up . ", ' I can see the sun now . ', " I like summer as long as it's bright like this . ", " Anyway , I dislike summer here.There ' s too much rainfall . "]
['Hello ! Let me introduce myself . My name is Nancy . ', " Nice to meet you , I'am Seven . I don't think I ' Ve seen you around before . ", ' No , I just started working here at IBM , I am assigned sale department . ', ' What do you do there ? ', ' I main market reasearch , and you ? ', " I ' Ve beaning worked IBM for years . I am vested personnel file system , He is the after sale survise director . he such a nice boss , I like working for him . ", " Really ? I don't believe I would met him , is he here now ? ", " Yes , That's him over there-the taller , handsome one . Would you let me introduce you ? ", " Thanks , that's would be lovely . You'r right , he is kind and nice looking . "]
['How do you think should I handle this problem ? ', " You'd just let sleeping dogs lie . ", " But I'm already in a lot of trouble with my boss . ", ' Anything you say or do might make it worse . Just try to ride out the storm for a while . ', " She's always bothering me . What should I do ? ", " You'd better leave her alone . ", ' But she always harps on me . ', ' Just tell her off . ', ' Yes , great ! ']
['Well , no one could survive without water , but you see pollution has been making more and more water unable for drinking . ', ' Yeah . Water pollution has for a long time been a major concern among the environmental issues . ', ' But what are the sources of water pollution ? ', ' They could generally be divided into two categories ', ' Well , direct ones are the pollution directly from factories , refineries waste treatment plants etc . , aren ’ t they ? ', ' Yeah . They are emitted directly into urban water supplies . ', ' But what about the indirect ones ? ', ' Indirect sources include contaminants that enter the water supply from soils or groundwater systems and from the atmosphere via rainwater . ', ' I see . For the sake of us all , we should be an active participator in the prevention of it . ', " Sure . It's an issue asking for everyone's participation . "]
['Hi , Bill . I saw you yesterday with a pretty girl . ', " Yes , she is my favorite girl . I've decided to go steady with her . ", ' Are you sure she is the right girl ? ', ' Sure . She is the ideal girl , the one I had dreamed of . ', ' What type of girl is she ? ', ' She is the mature , stable , feminine type . I hope one day I can marry her . ', " Oh , that's great . You're serious this time . "]
["You're right--Italian ! Ha ! Ha ! I was trying to trick you , but you didn't fall for it ! ", " I almost did ! Actually , I don't know that much about coffee , even though I sell it . ", ' I could give you a few pointers if you want . I know a lot about coffee . ', " Thanks . Maybe if things slow down later I'll stop by your table . ", " I'm Robert , at your service . ", ' Rita . Nice to meet you . ']
['Do you use an anti-virus program to protect your computer ? ', ' Yes , I do . I also use an anti-spyware program and a firewall . There are so many nasties on the internet and so many people who are trying to use the internet to hurt other users . You have to be very careful and keep you computer clean . ', ' How often do you run your anti-virus program ? ', ' I usually run it every few days . It finds a virus about half the time . ', ' Which anti-virus program would you recommend ? ', ' How you tried this one ? It ’ s very good and you can download it for free on the internet . You can also download updates for free . ', ' That sounds very good . Which website should I visit to download it ? ', ' Just a minute ... go to this one . I ’ ll send you an email with the line in it . It only takes a few minutes to download . Then you have to go through the set up procedures . But they are not complicated . ', ' What do you use your computer for ? ', ' I use it for several things-surfing the net , word processing and creating presentations . I don ’ t play many games on my computer , but I do a lot of work with photographs . Using c computer program , you can edit and resize photographs . You can also make them brighter or darker and cut pieces from different photographs to create new ones . ', ' Computers are great , aren ’ t they ? I should download some program and learn how to use them . ']
['I like pop music very much . ', ' What ? ', " I said I like pop music very much.It ' s so lovely . ", ' Is it ? ']
['John , you look pale . What happened ? ', ' I stayed up last night . ', ' Did you have something on your mind ? You look so concerned ! Maybe I can help you ! ', " Will , I'm under a lot of pressure . My manager is very pushy . He assigned me two projects . Now the deadlines are near but I have finished neither of them . ", ' Is there anything I can do for you ? ', ' Well , I guess no one can help me but myself . For the moment , I just need someone to talk to so that I can relieve my stress . ', ' I know your feeling . Take it easy and say something to me if you like . ', ' Oh , buddy , you are so kind . Thank you ! ', ' Not at all ! ']
["You don't look very well . ", " I'm not feeling too well . I've caught a cold . ", " Is it because of the bad weather ? It's been really miserable for the past tew days . ", " Hasn't it ! It's been cold and windy recently.Do you like the weather here ? ", " Not really , but I've got used to it now . ", " Oh , I'm going for a trip to New York this autumn . What's the weather like in New York ? ", " Not quite good . It's windy and dry . We have got continental climate there . It's dry all the year round . Usually autumn is the best season of the year In New York . ", ' Is it cold in autumn there ? Should I take any warm clothes with me ? ', " No , it isn't very cold at that time . You'll only need some light wool clothing with somejackets and shirts . "]
['You seem to have all the jitters about Jane . ', ' Yeah . I am on edge since she was out to the match . ', " Keep your fingers crossed . She'll bring home the bacon . ", ' I do have the confidence , but I still worry about her . ']
['Thanks for your help . ', ' No problem , anytime . ', ' Let me know if I can do anything for you . ', ' Okay , thank you . ']
['They are a nice middle-aged couple , just like us . ', ' If they are just like us , they are not middle-aged . ', ' Of course they are . ', " Middle-aged means in the middle , Ethel , middle of life . People don't live to a hundred and fifty . ", " Oh , we are the part on the edge of middle . That's all . ", " Oh , you know , we are not middle-aged . You're old , and I'm aging . ", " Oh , fool ! You're nearly seventy and I'm in the low sixties . Would you like to spend the rest of the afternoon squabbling about this ? ", ' I can if you like . ']
['How should we commemorate the centenary of the founding of the university ? We have been given quite a large budget to pay for some events . ', ' We should certainly hold a big party for the professors and students . We could have a firework display . ', ' Do you think that we should invite alumni and former professors ? ', ' If we do , too many people might attend . Perhaps we should invited all of them , but make a small charge to attend . ', ' Good idea . We should also hold a series of presentations . We could have presentations on the history of the university , the courses we offer , and our links with other universities . ', ' Good idea ! I think we could also have presentations by former students on how their experience here helped them in their lives . ', ' We could have another on the successes of graduates from here . ', ' I think that we could also produce some merchandise for the centenary-you know , T-shirts , mugs , plates , pens , and things like that . ', ' That ’ s an excellent idea . Hopefully , we would be able to make a profit ! A few professors and students are writing a book on the history of the university . ', ' I ’ m looking forward to reading that . We could have book signings by famous professors an alumni . ', ' A group of students from the art and music faculty are producing a short film . ', ' I ’ m sure that will be very popular .. OK , let ’ s think about how we can put these ideas into practice . ']
['Your knowledge of English is really surprising . ', " Oh , it's nothing to speak of . ", " No , seriously . I'm impressed . ", ' Thank you . I appreciate the compliment . ']
["What's your name ? ", ' My name is Sam . ', ' How are you , Sam ? ', " I'm fine . Thank you . ", ' Where are you from , Sam ? ', " I'm from England . ", ' What is your job ? ', " I'm a bank manager . "]
['Excuse me , are you Miss Green ? ', ' Yes . May I help you ? ', ' May I introduce myself ? ', ' Yes . ', ' I ’ m a new student in the school . My name ’ s John . ', ' Nice to meet you , John . ', ' It ’ s a pleasure to meet you , Miss Green . ']
['Have you considered upgrading your system ? ', " Yes , but I'm not sure what exactly I would need . ", ' You could consider adding a painting program to your software . It would allow you to make up your own flyers and banners for advertising . ', ' That would be a definite bonus . ', ' You might also want to upgrade your hardware because it is pretty outdated now . ', ' How can we do that ? ', " You'd probably need a faster processor , to begin with . And you also need a more powerful hard disc , more memory and a faster modem . Do you have a CD-ROM drive ? ", ' No . ', ' Then you might want to add a CD-ROM drive too , because most new software programs are coming out on Cds . ', ' That sounds great . Thanks . ']
["Hoo , I'm getting tired , Jeanine , been a long day . ", " I'm not quitting yet . You know my favourite slogan , don't you ? ", ' Yeah , I know . Shop till you drop . ', ' Right ! ', " I'm getting a little short on cash . Let's just window shop a little . ", ' Ok . ', " Hey , Jeanine , get a load of that . It's beautiful . ", ' Ahahah , and I thought you were tired . ', ' You know .. I have a weakness for long dresses . ', ' It sure looks special , looks expensive too . ', ' Sure does . Hey , can I sponge a little cash of you ? ', " Don't worry , Mary , I've got you covered . ", " Thanks , Jeanine , you are a real pal . Let's go in . "]
["Now darling , I know that we've bought this house together , but it's just going to be far too expensive to decorate it . I think we should sell it . ", " Oh , no , Nathan , I ... I really think we've bought this flat at the right time , you know . Market prices are going to go up , and I think you'll find in a year or two it will be worth a lot more . ", " But we're going to spend so much money in furnishing and decorating . I think we could get a much cheaper place that's already furnished . ", " But don't you like this place ? I remember when we came to see it we thought it would be lovely . ", ' Well , only you liked it really , darling . ', " Oh , why didn't you say so then ? But I still think we've made a good buy . "]
['I am not sure what to do during the holidays , any suggestions ? ', ' Well , going to a cinema , visiting the galleries , exhibitions and museums , finding and meeting old friends , exercising in the health club or mountain biking . There are so many good choices . ', ' The problem is that I find all of them are full of fun . I just don ’ t know what to do first . ', ' Why not start with the most interesting one ? ', ' Actually , I ’ m interested in all of them . The more choices we have , the harder to make a decision . ', ' Toss a coin to decide then . ']
['There is too much traffic in Taipei these days , I think cars should be banned . ', " I'm not sure about that . How would people get to work ? ", ' Well , why not use buses or the MET ? ', ' Well , it may not be that simple . Not everyone likes public transport . ', ' Why not ? There is nothing wrong with our buses and trains . ', " Well , I don't often use them , I wouldn't really know . "]
['I want to try my hand at the stocks . ', ' It is very hard , you know . ', ' Don ’ t worry . I know there are no pennies from heaven . I will work hard . ', ' Good luck ! ']
['What do you think of the new mayor ? ', ' No comment . ']
["Hello , is this People's Theater ? ", ' Yes , it is . May I help you ? ', " Yes , are advance tickets for ' Nut croakers ' still available ? ", ' What date , sir ? ', ' October 16th . ', ' Let me see . Yes , we still have some tickets left . Which performance ? ', ' 7:30 p . m . performance , please . ', ' OK , we have tickets at 100 yuan and 50 yuan . ', " I'd like to reserve two seats at 100 yuan , please . ", ' All right . May I have you name , please ? ', ' Du Kun . ', ' When would you like to collect the tickets ? ', ' Tomorrow . ', ' We can hold them until one day before the show . ', ' How do we cancel , just in case ? ', " Just telephone us , and let us know in advance . We don't charge for cancellation . ", ' All right , thank you very much . Good bye . ', ' You are welcome . Goodbye . ']
['Excuse me . In this museum , you are not supposed to take pictures . ', " Is that right ? I didn't know it . ", ' Will you give me your camera ? We have to confiscate your film . ', ' Will you forgive me . Could you return my camera ? ', ' We will keep and return it later . ', ' Oh , I see . Then , can I buy slides and picture postcards somewhere ? ', ' You can buy them at the souvenir shop near the exit . ']
["Mary , I've some bad news for you . ", " I have already known that . I didn't get the scholarship , right ? ", ' Yes . The board was favorably impressed with your application , but the competition was very fierce . ', ' Can you help me ? You know I do need the scholarship . ', " I'm afraid I can't I advise you to try again next year . ", ' Thank you . I will . ']
['How can I lose weight , doctor ? I seem to get fatter even when I just look at food ? ', ' Well , Jim . It is a combination of how much you eat , the type of food you eat , and when you eat your meals . ', ' I never eat breakfast though . ', " That's a big mistake , you should always have a good breakfast . You will not run your car without fuel , and as well you won't expect your body to work without food . ", ' I never thought about it that way . ', ' I bet you eat a large evening meal , then sit and watch TV or read a book . Then instead of burning off your energy , your body stores it as fat . ', ' Oh doctor , I feel so foolish . ', ' Well control is really using common sense when you plan your eating habits . ', ' I know doctor , thank you so much . ']
['I am confused . How could a golfer need so many clubs ? Seems to me , 14 altogether , right ', " I should say , a a ' set ' of golf clubs is restricted to no more than 14 clubs . ", " Then what makes a ' set ' of clubs ? ", ' In general , a set of golf clubs 3 , 4 , 5 , 6 , 7 , 8 , 9 , PW ; Woods : 1 , 3 , 5 and a putter . ', ' So many ? ', ' This is not to say you have to carry all of these clubs . It depends on your preferences . ', ' Have you heard of Tiger Woods ? ', " Of course even people who don't know anything about golf know his name . "]
['Do you remember John from head office ? ', ' Yes . ', ' Have you heard what happened to him ? ', ' No , what ? ', ' He had his car stolen . Actually he was kidnapped while he was in the car . ', ' What do you mean ? ', " Well , apparently , he was just getting into his car-he'd parked it in one of those underground multi-story things-he was just getting in and suddenly three guys with guns opened the back doors of the car and got in . ", ' Crikey . Where did this happen ? ', ' In Taichung , I think . ', ' Oh , right , I hear they have a lot of this kind of problem down there . ', " Really ? Well , anyway , they pointed their guns at him and said , you know , keep calm and drive out . ... we don't want to hurt you ... we just want your car . ", ' So what happened ? ', ' Well , he drove out , and when he got to the booth to pay the attendant , he pretended to have an epileptic fit , you know , to scare the thieves away . The attendant was no help at all , even though the guys were holding guns in plain view , he did nothing . ', " That's terrible . ", " Yes , makes you think , doesn't it ? ", ' So what happened next ? ', ' Well , he kept on pretending to have a fit , so they freaked out and just ran away . ', ' Well , he sure was lucky . ', " I'll say . "]
['Are you a newcomer ? ', ' Yeah , this is my first visit here . ', ' You speak good English , though . ', ' Thanks , but I speak English with a strong German accent . ', " But let me tell you , you're doing just fine . I couldn't do half as well as you do when I was learning German . By the way , how long have you been learning English ? ", ' On and off , for quite a few years . ']
['Do you still see the people we went to school with ? ', ' I did for a while , I suppose , until I left university , but after that not really . ', " Yeah , I've lost touch with most people as well , but I still see Rose occasionally . ", " Oh yes , how's she getting on ? ", " OK , I suppose , but she's had a rough time in the last few years , She got divorced . ", ' What , from Peter ? ', ' Oh , of course . ']
['I hear that Helen does not relate very well to her husband . ', ' Unbelievable ! I remember her husband is her former classmate . They fell in love with each other in college . ', ' So what ? Things have changed . ']
['At last ! The weekend comes again ! ', ' Yes . What will you do these two days ? ', " After five days ' hard work , I'm surely going to have some fun . ", " But I'd prefer to stay at home and have a good rest . "]
['Bill , I must tell you the truth . You failed the English exam again . ', ' Ah ? Really ? That stinks ! ', " Haha . April Fool's ! Did you forget what day it is today ? ", ' Wow , you were pulling my leg all along . I was really fooled . ', " Alright , now let's be serious . Actually , you get high marks in the exam . "]
['Did you have a good holiday ? ', ' Yes and no . ']
['How are you doing ? ', " I'm doing great . ", ' What movies have you seen lately ? ', ' I saw Forrest Gump the other day . ', ' What type of movie is that ? ', ' The movie type is drama . ', " I can't believe you are watching movies . The weather is great . You should be outside . ", " I hate the hot weather . I'd rather stay indoors with the air conditioner . ", ' What else do you like to do besides watching movies ? ', ' I like to play computer games , read books , go shopping , and play pool . ', ' Out of those what is your favorite ? ', ' My favorite is to play computer games . ', ' What is your favorite computer game ? ', ' My favorite is Diablo . It used to be Star Craft , but it is getting a little old . ', ' If you like to play so much , when do you ever exercise ? ', ' Although I hate to exercise , I go jogging at least twice a week . ', " That's pretty good . By the way , what are you doing next Saturday ? ", ' I am going to go to the bookstore . ', ' I am having a party Saturday night at my house . If you have time , you should come . ', ' That sounds like fun . ', " Great . I'll see you on Saturday . ", ' Ok . See you later . ']
['Thanks a lot for having us . We had a good time . ', " I'm glad you came . You're welcome anytime . ", ' Thanks . By the way , tell your wife she throws a great party . ', ' I will . See you later . ']
['Mike , these flowers are just gorgeous . ', ' I ’ m glad you like them . Happy birthday ! ', ' I can ’ t thank you enough . I ’ m really touched . I don ’ t know what to say . ', ' Forget it . It ’ s my pleasure . You mean a lot to me . ', ' You ’ re the best ! ']
['Shall we sing with a karaoke ? ', ' Great idea ! I do it every so often . ', ' For us , karaoke is becoming a popular entertainment . ', ' Yep . If you are a good singer , your audience will feel comfortable , right ? ', ' I can not agree with you more . And if you are an awful one , that will be funny . ', ' I remembered Tom is always out of tune . We burst into laughter . ', ' Is that true ? Shall we invite him to join with us ? ', ' So tricky ! ']
["I'm afraid I can't complete my paper on time . ", ' What happened ? ', ' I keep on meeting with difficulties in the experiment . I can hardly go on . ', ' Where there are difficulties , there are ways to get over them . Hold on ! ']
['Have you heard Jenny divorced her French husband ? ', ' Oh , really ? No wonder that she looks quite depressed recently . ', ' Yes . They used to be joined at the hip . ', ' I heard they were just married for half a year . ', ' That ’ s true . She said they often argued over nickel-and-dime things . ', ' Yeah . Mixed marriage is tempting but full of culture shock . ', ' You said it . You know , they fell in love at the first sight and quickly jumped into marriage . ', ' Maybe they were just attracted to each other but too different to be married . ', ' Definitely . Just hope Jenny can recover from the pain of divorce soon . ']
['Where do you usually do your shopping , Mrs . Lane ? ', ' I usually go to the supermarket , near the station . ', ' How do you find the prices there ? ', ' I think they are quite reasonable , and the vegetables are very fresh . ', ' I see you have bought some coffee . Would you mind telling me how much you paid for it ? ', ' Only 2 dollars and 25 cents . ']
['Hello , what can I do for you ? ', ' I am looking for a host home . ', ' How long will you stay with the host family ? ', ' Well , at least half a year . Do I have to do my own grocery shopping ? ', ' Usually the host family prepares at least two meals a day for you . ', ' That is fine . ']
['I cannot understand why she always helps and supports her brother . ', ' Why do you say so ? ', ' Because he is often in trouble . ', ' She has promised her mother that she would be with him through thick and thin . ', ' Oh , I see . ']
['Did you find what you were looking for ? ', ' I tried when you had gone , but I had no luck . ', " Okay , let's both look for it now . ", ' Okay . ']
["I think I'm going to China this vacation.How about you ? ", ' Me ? I prefer France . ', ' I went to France last summer . ', ' Oh , really ? I went to China last winter ! ']
['Jenny , I was wondering if you , um ... are you busy this Friday ? ', ' Yes , Friday I have a class right after work . ', ' Oh . What about Saturday ? Are you free then ? ', " Saturday my parents are coming to town . What's up ? ", ' What about tonight ? Do you have plans tonight ? ', ' No . Did you want to go do something ? ', ' Yes ! Yes ! I want to take you to dinner . ', " Oh ! That sounds great ! How about six o'clock ? "]
["There's a typhoon coming . ", ' Is that right ? ', " That's what the weatherman said last night . "]
['Do you want to go out for dinner tonight ? ', ' Sure . Have you got anywhere in mind ? ', " I'm starving , so maybe we could go somewhere with large portions . ", ' That Italian restaurant in the city centre always has large portions . Do you want to go there ? ', " I'm not really in the mood for Italian , actually . I was thinking of something a bit spicy . ", " If you want spicy food , then I'd recommend going to a Thai , Indian or Chinese restaurant . How about that Chinese buffet on Cowley Road ? ", " I really like that restaurant ; you get a lot for your money there . But , they've westernized their food , so it's not actually that spicy . ", " You're right . Most of their dishes have sweet sauces . We could try that Indian restaurant just down the road from us . ", " The Taj ? They're a bit expensive , but they do serve large portions of very hot food . ", ' The Taj it is then . ', ' Shall we bring our own bottle of wine to save some money ? ', " They'll still charge us a corkage fee . ", " That's right . It'll probably work out to be about the same then anyway . ", " Don't worry about money . I'll treat you tonight . ", ' Are you sure ? We could go Dutch . ', " No , I'll pay . It's my turn anyway . You paid last time . ", " I won't argue with that ! Let's go ! "]
['Hello Martin . Have you been to any events yet ? ', ' Yes I have . I went to the table tennis yesterday . ', ' Oh wow . How was it ? ', ' Oh . It was great . I love Ma Lin . He ’ s my favourite table tennis player . Have you seen anything yet ? ', ' Oh I still haven ’ t managed to get any tickets . I ’ d love to see something though . ', ' Well , let ’ s go to the marathon tomorrow then ! We can just stand by the side of the road . ', ' What a great idea . ']
["Hi ! Dear ! I'm waiting for you . ", ' I know that . ', " You know , although we've chatted twice , I've been thinking of you already . ", " Me too . I want to know more about you , eg , what's your real name and what do you look like ... ", ' & you ? ', ' Look , I am playing the piano for you . ', ' Oh , thanks . I wanna see the real you . ', ' Sorry , I have no photo in my computer . And I have no scanner . I will show you later . ', " OK ! Before that I'll take this one as you . ", ' Ha ! She is too little . ', ' Cute , like you . ', ' I want to tell you that I like you ', ' Me too . Send you a kiss ... ', ' Thx . ']
['Hello . ', ' Hi . ', ' How are you ? ', " I'm good . How are you ? ", ' Good . Do you speak English ? ', ' A little . Are you American ? ', ' Yes . ', ' Where are you from ? ', " I'm from California . ", ' Nice to meet you . ', ' Nice to meet you too . ']
['Did you hear what she said to me ? ', ' I heard it . ', ' What do you think I should do about it ? ', ' Just let it be . Her rudeness will come back to haunt her . ']
['How many persons are there in your family ? ', ' There are three , my parents and I . ', ' Do you live together ? ', ' No , I live alone in a flat near my work place . ', ' Do you often go back to see your parents . ', ' Yes , almost once a week . ']
['Ben always appears rude to the people around him . ', " But he's really kind at heart . ", " That's true . We can not judge people by appearance . "]
["I'm glad to have had the opportunity to meet you here . ", ' I trust you ’ re keeping well ? ', " I'm doing great , thank you . ", ' So we can get down to business . ']
["What do you think of the Olympic motto ' Higher , faster and stronger ' ? ", " Well , it's better than ' Friendship first , competition second ' . ", " Why ? In my opinion , it doesn't matter whether you won or not . The most important thing is participation . ", ' I still think nobody plays for nothing . ']
["So Chris , I've heard that you're from a big family . How many people ? ", ' Nine total . Seven children and my parents . ', " Seven children ? That's a lot . Why did your parents have so many ? ", " Well , my mother came from a big family , and wanted to have one of her own . My father was an only child , and didn't really care about having a large family , but my mother talked him into it . ", ' Jeez , seven children . That must have a lot of problems . We have four children in my family and my grandparents can never get our names right . ', ' It can be hard , and there are certain sacrifices you have to make . ', " Like what ? I assume that there's no privacy . ", " That's one . Another is the lack of personal property . Everything you have , from toys to clothes , is used by your brothers and sisters . Especially clothes . Three quarters of my wardrobe are hand-me-downs . ", " And the age gap is also annoying . There's a ten-year difference between my younger brother and me . We have nothing in common . ", " Same problem here . There's an 18 - year gap between the oldest and youngest child in my family . The last child was born just as the oldest was going to college . "]
["John , if you don't mind , I'd like to ask you a personal question . ", " I don't mind at all . ", ' All right.Are you married ? ', " To tell you the truth , I'm not married . I'm still single . ", ' Then , when do you plan to get married ? ', " I don't know.It ' s still up in tha air . "]
['Miss Fallen , can you tell me why you want to get a visa to the States ? ', ' To study . I am going to the University of Tampa to do a postgraduate course for three years . ', ' And do you have the Letter of Acceptance from the University with you ? ', ' Yes , here it is . ', ' Thank you very much . And do you have any proof of the financial support for the three years ? ', " I've got a letter from my bank here . It shows I am able to support myself during these three years of studies . ", ' Could I see that , please ? ', ' Yes , here it is . ', " Thanks very much . Well , I'll be able to give you a visa for one year , a student visa , that is . ", ' Oh , but mine is a three-year program . ', ' Yes , it is a three-year , but you can renew the visa each year in the States . It is our usual procedure . ', ' Okay , thank you . ']
["It's a lovely day out today , isn't it ? ", " It's beautiful . Enjoy it while it lasts . It's supposed to get cold tomorrow . ", " What's the weather forecast for tomorrow ? ", " It's supposed to snow early tomorrow morning and then tomorrow afternoon there's a chance of freezing rain . ", " That doesn't sound pretty . ", ' Do you have any plans for tomorrow ? ', ' Well , I was going to drive to Birmingham to see some friends . ', " You might want to change your plans . With the cold and wet weather that we're supposed to have tomorrow , the roads are going to be rather slippery . ", " I suppose I should . I don't like driving in dangerous weather conditions . Do you have any plans for tomorrow ? ", ' I just have to go to class tomorrow afternoon . ', " If you're lucky , it'll get cancelled and you can have a snow day ! ", " If that happens , then I'll invite you over and we can drink hot cocoa and watch movies . ", ' That sounds like fun . ', " Hey , look outside ! It's started to drizzle ! ", ' English weather is even more predictable than I had previously thought . ']
["Is there a city where it's always warm ? ", " Yes , there are many cities where it's almost always warm.San Diego , for example . ", " Are there any other cities where it's always hot ? ", ' Many.Most of the cities in the southern part of the United States are hot all year . ', ' But why do so many people live there ? ', ' Most people grow accustomed to the climate , but there are many others who complain about it all the time . ', ' Are there any cities where it rains a lot ? ', ' Several.Two good examples are Seattle , in the state of Washington , and Portland , Oregon . ', ' Tell us about some cold cities . ', ' In the north there are many cities which are very cold in the winter.Boston and Chicago are two of them . ', ' Is it always cold in Chicago and Boston ? ', ' Oh , no.On the contrary , there are many beautiful days , especially in the spring and fall . ']
['Mark , you are not telling me the truth . Now why ? ', ' Promise you are not going to be angry ? ', " Yes , all right . So why ? Go on then . Say it . Oh , really , Mark . I promise I'm not going to be angry . Now why were you late ? ", ' I forgot . ', ' You forgot ? You ... ', ' Ah , ah , you promised , and remember ? ']
['Long time no see ! ', ' Yes . It has been a long time since the last time we met . ', " It's nice to see you again . Have you changed jobs ? ", " No . I've been visiting relatives recently . ", " That's nice . Where have you been ? ", ' I went to visit an uncle in San Francisco . ', ' Are you busy now ? ', ' No . Why ? ', ' How about a coffee in that cafe ? ', " Great . Let's talk over coffee . "]
["I'm really fed up with Larry ! He's the biggest airhead I've ever met.He always makes careless mistakes , and he's a pain to work with . ", " You shouldn't be so negative.You ' ll always have some co-workers that are harder to work with than others.But if you are negative and start name-calling in the office , it will make a bad working environment for everybody . ", " You only say that because you don't have to work with him.The people in your department seem so capable and nice to be around.Take Mary for example.She ' s smart and enthusiastic . I've never met anyone as cheery as she is . ", " Everybody has their strengths and weaknesses.Even Larry.He might be a pain to be around , but he's also very good at staying in budget on projects.Mary , on the other hand , spends our project money like there's no tomorrow.Also , she's never willing to stay a little later at the office.She always leaves at 5pm sharp . ", " Isn't there anyone in the office that is a perfect co-worker ? What about Bob ? Everybody loves Bob.Even though he's flesh out of college and still a bit green , he is a great co-worker . ", " You're right.He ' s a hard worker , easy to get along with , honest , and he never steals the credit on projects.The only thing he's lacking in is experience . ", " Maybe that's why he's so nice ! "]
['You look pale recently . ', ' Yeah . I have got much pressure in the company . I have to be wrapped up in my work . ', ' Take good care of yourself . ', ' Thank you . I will . ']
["Watch your step . There's a hole in the sidewalk . ", ' Oh , I see.Thank you . ']
['I hear little Bob has recovered . ', " That's a great relief . I was worried about him . ", ' The operation was very successful . ', ' His parents must feel very happy . ']
['I can ’ t believe that Anthony is finally getting married ! ', ' Yeah well it ’ s about time ! He ’ s been living with his parents for 40 years ! ', ' Don ’ t be mean . Look here come the bridesmaids ! Their dresses look beautiful ! ', ' Who are those kids walking down the aisle ? ', ' That ’ s the flower girl and the ring bearer . I ’ m pretty sure they ’ re the groom ’ s niece and nephew.Oh , they look so cute ! ', ' I just hope the priest makes it quick . I ’ m starving . I hope the food ’ s good at the reception . ', ' That ’ s all you ever think about , food ! Oh , I think the bride ’ s coming now ! She looks gorgeous.Wait , what ’ s she doing ? Where ’ s she going ? ', ' Oh great ! Does this mean that the reception is canceled ? ']
['Hello everyone , and welcome to our CPR for beginners course.First of all , does anyone know what CPR stands for ? ', ' Cardiopulmonary resuscitation ! ', ' That ’ s right ! We apply CPR in the case of cardiac arrest or pulmonary arrest . ', ' What does that mean ? ', ' Well , basically if your heart stops pumping blood , or your lungs stop pumping air , then we need to get them going again ! That ’ s when we have to apply this procedure . Let ’ s begin ! I need a volunteer . ', ' Me ! Me ! ', ' Alright , come here and lay flat on your back . Let ’ s suppose this young woman has stopped breathing . We must lift the person ’ s chin so that we clear a pathway for air to get into the lungs . Then we place our mouth over the other person ’ s mouth and blow air two or three times , like this . ', ' Wait , what are you doing ? I ’ m a married woman ! You can ’ t just try to kiss me like this ! ', ' Madam I ’ m not trying to kiss you ! I am trying to demonstrate how to apply CPR in the case of an emergency . ', ' Well , OK . But no French kissing ! ', ' As I was saying , we blow air through the mouth in this manner . Once this is done , we must try to get the heart going again . To do this , we place our hands over the person ’ s chest , and press down firmly two or three times . ', ' Wait , what are you doing ! You can ’ t just kiss me then go for second base ! ']
['You ’ re not going to believe what happened today . You ’ Ve got to promise to keep it to yourself . ', ' Sure , what gives ? ', ' Today Mr . Leo threw Sally out of class ! ', ' On the level ? ', ' I ’ ll say . I knew Sally would finally show her true colors . When she got her final test results back from Mr . Leo , she started yelling at him . You should have heard her . I ’ Ve never seen anyone get so upset before . To make a long story short , it seems that Mr . Leo failed her because he caught her cheating . ', ' That ’ s no laughing matter . That means she ’ ll have to take the whole course again . I can ’ t believe she ’ s going to have to start from the beginning . ', ' It serves her right ! ']
['This is my uncle , Charles . ', ' He looks strong.What does he do ? ', " He's a captain . ", ' He must be very brave . ', ' Exactly ! ']
['OH , This is the famous Emperor Palace building . ', ' It ’ s huge . ', ' Would you like to go to the top ? ', ' Yes , of course . ', ' The view is breath-taking . ']
['I really should be on my way . ', ' Oh , not yet . At least have one for the road . ', ' No , thanks all the same . ', ' Well , I am sorry you have to leave so early . ', ' Thank you very much . I really had a good time . ', ' Well , thank you for coming . ', ' So see you . ', ' Bye . ']
['Hi , how ’ re you doing ? ', ' Terrible . ', ' Oh , what ’ s the matter ? ', ' I ’ Ve got a fever and really a bad headache . ', ' Oh , that ’ s too bad . Why don ’ t you take some aspirin ? ', ' I ’ Ve already tried some but it didn ’ t help . ', ' Well , it ’ s necessary for you to see a doctor . ', ' Yeah , I guess I should . ', ' Well , you ’ d better get some rest . ', ' Thank you very much . ', ' Bye . ']
['Valerie ! Hi ! Wow how have you been ? It ’ s been such a long time ! ', ' Darlene ! Indeed , it ’ s been a while ! How have you been ? Wow , you look amazing ! I love what you ’ Ve done with your hair ! ', ' Really ? Thanks ! I went to that hair salon that you told me about , but enough about me ! Look at you ! You haven ’ t aged a day since the last time I saw you ! What is your secret ! ', ' Ha ha , come on ! Well , I ’ Ve been watching what I eat , and working out three times a week . By the way , I heard your son recently graduated ! ', ' Yes , my little Paul is finally a doctor . They grow up so fast you know . ', ' He is such a handsome guy . He gets his looks from his mother of course ! ', ' Thank you ! What about your daughter , Pamela ? I heard she has passed the bar exam and married recently . ', ' Oh yes . She had a beautiful wedding in Cozumel Mexico and we all attended . ', ' Such a lovely girl . I hope my Paul is lucky enough to find a girl like that someday ! ', ' But of course ! Well , it ’ s been great talking to you , but I have to get going . ', ' Same here ! We will catch up soon , maybe over coffee ! ', ' That would be great ! Give me a call ! ', ' See you soon ! Bye ! Egg ... I can ’ t stand that woman or her obnoxious daughter . ']
['I need help preparing for my presentation on Friday . ', ' I could help you with that . ', ' Are you sure you have the time ? ', " I promise you that I have the time to do this . If I didn't , I wouldn't offer to help . ", ' What would be the best time for you to help me ? ', ' Tomorrow night would work for me . ', ' Should we just meet here ? ', " OK , and I'll bring some information that helped me with my presentation . ", " I'll see you then . ", ' See you tomorrow night . ']
["I'm so angry . I feel like killing someone . ", ' Calm down . ']
['Let me see . How much should I pay for you ? ', ' Don ’ t think about it ! ', ' No , this will not do . Let me see . ', ' You pay for the taxi and dinner , then to even things up . ', ' Good ideas . ']
["Do you know that John isn't going to come back to our school ? ", ' Really ? Why ? ', ' He had moved and held a party on July 1st . ', " It's a pity that I was traveling around Europe at that time . ", " Even he's not coming back to school anymore , you still can call him and meet him on weekends . ", " You're right ! I will call him this weekend and meet him . "]
['I went to Rotes ’ , you know , Edith Roth is the author of a book about moths . ', ' Is she ? I thought she was a mathematician . ', ' I ’ m so thirsty . ', ' Are you ? I thought you had something to drink at her home . ', ' No . Edith didn ’ t give anything to drink . ', ' I ’ ll buy you a drink . ', ' Oh ! Thank you . ']
['How long will it take us to drive to London ? ', ' I think it ’ s a distance of 180 kilometers from here to London , so it should be a two-hour drive on the motorway . ', ' That ’ s unless there is a traffic jam . It could take three hours . ', ' You ’ re right . We will be able to travel at high speeds at the beginning and end of the journey , because we will be in built-up area . ', ' So , shall we allow three hours to cover the distance ? ', ' Ok . You haven ’ t seen my company car , have you ? ', ' No . let me take a look ... It ’ s longer than my car . ', ' I think it ’ s over five meters long . I can ’ t remember exactly . It has a maximum speed of over 200 kilometers an hour . ', ' Wow ! That ’ s fast ! I don ’ t think we will be traveling that fast on the motorway . ', ' We can ’ t . if we went that fast , we would break the speed limit . ']
['I ’ m Miss Sherman . What seems to be the problem ? ', ' Well , apparently I ’ Ve run up quite a bill . I was under the impression that the Junior Executive Holiday Package only cost 250 dollars per night . I ’ Ve just been informed that it ’ s actually 500 do ', ' That ’ s true . For the Junior Executive Room ... three nights ... yes , your bill should be $ 1,500 ', ' But I definitely was led to believe that a three-night stay would be $ 750 . ', ' The advertised rate is based on double occupancy . ', ' When I booked the room , your staff didn ’ t mention this . And the brochure and your promotional mailings do not mention that . ', ' Are you quite sure ? ', ' Yes . Have a look . ', ' I see . I had no idea our advertising was so misleading . It is here , but it ’ s in the fine print on the last page . ', ' Perhaps you could arrange to provide me with a new bill that reflects the advertised rate . ', ' Normally I couldn ’ t do that . But under the circumstances , I ’ ll see what I can arrange.Customer satisfaction is our primary aim . ', ' Thank you . ']
['I wish I knew who had moved our flower pots . ', ' It was me . I am so sorry . ', ' What did you think you were doing ? ', ' I had to move it , so that I can get my bike through . ', " How dare you be so inconsiderate ? That's wrong . ", " I am awfully sorry . I didn't think you would mind so much . ", ' Never do that again . ', ' I promise . ']
['Is anything the matter , sir ? ', " Yes , it's my steak . ", " What's wrong with it , sir ? ", " It's too raw . I wanted mine well done , but this one here is almost medium . ", " I am sorry you didn't enjoy it , sir . I will return it to the kitchen and bring you one that is well cooked . How is your steak this time , sir ? ", " Very good . It's done just right this time , thank you . ", ' I am glad you enjoy it . I will tell this to the chef . Would you like some more beer ? ', ' Yes , please give me another Calsberg . ', ' Can I bring you some dessert ? ', " No , thank you . I've had enough . ", ' How about some coffee or tea then ? ', ' Yes , I will have a cup of coffee . ']
['Joanne , let ’ s not make this divorce any more acrimonious than it already is , okay ? Let ’ s just get down to business and start dividing this stuff up fairly , so we can go our separate ways , alright ? ', ' Fine with me . I just want to get this over with . It ’ s important we make a clean break . I should have signed a pre-nup . ', ' What was that ? ', ' Nothing ! Anyway , you ’ re right , there ’ s no reason this has to be nasty.My lawyer tells me you ’ Ve accepted our alimony proposal and the division of property , as well as the custody agreement - I keep the cat and you get the dog . So that ’ s done ... finally . ', ' Let ’ s not go there , Joanne ! Ok , so let ’ s start with the record collection , I ’ ll take the albums I contributed and you can have your cheesy disco albums back . ', ' Fine , but I ’ m keeping the antique gramophone as my grandfather gave it to me . ', ' I believe that was a wedding present to both of us , Joanne . And you hardly ever use it ! ', ' He ’ s my grandfather , and he never really liked you anyway ! ', ' Whatever ! Alright , I ’ ll concede the silly gramophone , if you ’ ll agree that I get the silver tea set . ', ' How typical , when are you ever going to use a silver tea set ? Fine ! I don ’ t want to drag this out any longer than necessary . What ’ s next ? What about these old photographs ? ', ' Which ones ? Let me have a look.Wow , look at that ! That brings back memories ... That ? ', ' Our trip to Italy ! I remember that day . We were going to visit the Trev fountain , and we got caught in the rain ... ', ' ... and you looked so adorable with your hair all wet . I had to take a picture of you standing there in that little alley , smiling and laughing in the rain ... ', ' Oh , we really did have fun back then , didn ’ t we ? ', ' Oh , Joanne , are we making a big mistake ? I know our relationship has been on the rocks for sometime but are you sure we can ’ t reconcile and try again ? I still love you . ', ' Oh Jeff ! I love you too ! I ’ m so glad we didn ’ t have to decide who keeps the motorcycle . ', ' The motorcycle ? But that ’ s mine ! ']
["Hi ! Ed , what's up ? ", ' Nothing . ', " Doesn't look like it to me . ", ' Just get out of my face ! ', ' Woo , easy . ', ' Leave me alone ! ', ' What are you so ticked off about ? ', " I don't want to talk about it . ", ' Maybe I can help . ', ' I blew the finally exam . ', " You've got to be joking . ", " No , I'm not . ", " Well , don't get bend on a ship about it . "]
['Can I help you ? ', ' Yes , I ’ m doing some research on Roman civilization . Do you have any books on the subject ? ', ' These books over here are about ancient history . They might be helpful . ', ' Can I check this one out ? ', ' I ’ m sorry . It ’ s for reference only , so it must stay in the library . But you ’ re welcome to look through it . ', ' Ok . And I ’ d like to check these books out . ', ' All right . They ’ re due back next Wednesday . ', ' Thanks for your help . ']
['Do you think you will ever work at that company again ? ', ' When pigs fly ! ']
['Are there any seats left for Saturday night ? ', ' I still have five seats in the mezzanine . ', " I suppose there's nothing cheaper , is there ? ", " No . Nothing . I'm sorry . "]
['Hi , do you have any tickets for the show tonight ? ', ' Sorry , it ’ s all sold out . ', ' Well , do you have any for tomorrow ? ', ' We have tickets for the matinee . It starts at 3p . m . ', ' Ok . I ’ ll take it . ', ' Where would you like to sit ? ', ' Do you have anything in the middle section ? I want a good view , but sitting too close hurts my eyes . ', ' Certainly . ']
['Jenny , I want to go on a picnic . Could you come too ? ', " I'd be glad to . I love picnicking . ", ' Then , put on your casual clothes and pack some food and beverages . ', ' Can I bring my camera with me ? ', ' Sure . Bring enough films , please . ', ' I sure will . ']
['You ’ re going to set up your own law office , aren ’ t you ? ', ' Yes . After so many years of hard work , I ’ d rather I had an office of my own . ', ' If you need help , don ’ t hesitate to ask me . ', ' I ’ ll be very glad if you would help . ', ' I ’ d like to wish you every success in your new venture . ', ' Thank you . I wish I would . ', ' Good luck to you . ']
['I can look anybody in the face because I ’ Ve done nothing to make me feel guilty or something . ', ' There are not so many people like you . ', ' You are flattering me . ']
['Can I help you ? ', ' Yes , I ’ m doing some research on Roman civilization . Do you have any books on the subject ? ', ' These books over here are about ancient history . They might be helpful . ', ' Can I check this one out ? ', ' I ’ m sorry . It ’ s for reference only , so it must stay in the library . But you ’ re welcome to look through it . ', ' Ok . And I ’ d like to check these books out . ', ' All right . They ’ re due back next Wednesday . ', ' Thanks for your help . ']
['Do you have much experience with kids ? ', ' Yes . I have three sons . Actually I also have a grandson . ', ' To tell you the truth , sometimes I regret having a baby so early . I have been making so many sacrifices just because my husband insisted on keeping the baby . ', ' I understand . I was in your position before . At that time I couldn ’ t depend on anyone taking care of the children for me . My husband seldom stayed at home . ', ' What about your mother ? Did she help you ? ', ' Yes , she did a little . But you see , Americans are different from Chinese . You can ’ t depend on your own mother to be a full-time babysitter . She could baby-sit only once or twice a week . That ’ s it . I had to care for them most of the time . ', ' I see . So if my little family goes to America , I would end up taking care of my child all the time . My husband would have to make the bread for us . I just don ’ t know how I would get some education and be able to get a job some day . ', ' Don ’ t worry . You can take night classes . I did that when I had kids . And soon your child will be old enough to attend kindergarten . Then you could find a job and work . ', ' Sounds not so easy to me . When that happens , I will be too old to learn . ', ' No . You see , I went back to school to get my Master ’ s Degree when I was in my thirties . You won ’ t be older than that . ']
['Now I know why I split up with Mike . We found we were simply not good for each other . ', ' In what ways ? ', " Well , he is a typical Sagittarius guy , while I am a Cancer . We aren't really compatible ", ' Ha-ha , so you believe in astrology ? ', " What's strange about that ! As a person born under the sign of Cancer , I am home-loving and wish for a peaceful family life . But according to astrology , Sagittarius guys are too adventurous and risk-taking.They seldom think of leading a settled and peaceful life . ", " Is that so ? I'm afraid it is too narrow-minded to judge people using astrology . It's all stereotypes ! ", ' But in my case , the fact matches the theory . Mike is humorous , energetic , always as fresh as a daisy , but probably too ambitious . It frightens me ! ', ' But as far as I remember , you two caught on like a house on fire when you first met . ', " Exactly . But later on , he cares more about his career than love . Work seems to be the better all , and all for him-so much that he doesn't even grudge sparing a day out with me . "]
['What does your father do ? ', ' He is a worker . ', ' What about your mother ? ', ' She is a nurse . ']
['When is your birthday ? ', ' August 1st . ', ' Do you usually have a birthday party ? ', ' Yes , we do.My parents prepare dinner for me . ', ' What would you do at the party ? ', ' We sing " Happy Birthday " at the party and have birthday cakes . ', ' Do you know when people began to sing the song " Happy Birthday " ? ', " Well , I don't know . ", " Let me tell you the story.In 1892 , Patty Smith Hill and Mildred Hill wrote a song called ' Good Morning to you ' . But later someone added the words ' Happy Birthday ' to their tune . ", " So the ' Happy Birthday ' song has been popular since then ? ", ' Yes , actually , the song has been sung since its publication in 1932.People all over the world have sung it in many different languages . ']
['Wow ! Look at all these books ! I bet I can find a book about anything here ! ', ' Shih ! ! Please keep your voice down . There are people reading and studying here . ', " Ok , I'm sorry . Are you the librarian ? Maybe you can help me , I am looking for a book . ", ' Yes I am . You can check our online catalog to search the book you want based on the genre , title or if you know the author , I can point you towards the right direction . ', ' I am looking for a book that has nursery rhymes . ', " That would be in our children's section . That book shelf there on the right . ", ' Ok , I would like to check out these books . ', ' Do you have a library card ? ', ' No . How do I get one ? ', ' I just need to see your drivers license or utility bill to prove that you a resident of this state . ', ' Here you go . ', " So you are all set . You can have these books for two weeks . If you need to have them longer , you can bring them here to renew them . If you don't , you get charged ten cents a day for each book . ", ' Ok , thanks ! ']
['So will you come to work with us ? ', ' Can I use my green pad again to write you admiring notes ? ', " We'll have to negotiate that . It's a possibility . ", " You miss me , don't you ? ", " Don't push your luck , Dave . ", " OK , I'm in . When do I start ? ", " As soon as you can get here . We'll be waiting for you . "]
["Kim ! I'm here ! I brought all my old maternity clothes plus Dave and Alice's baby clothes ! ", " It's a little early for those , isn't it ? I still have eight months to go ... ", " Believe me , the time will fly by ! Before you know it , you'll be changing diapers ! You have to start preparing ! ", ' I thought we could turn the upstairs study into a baby room . What do you think about lavender ? ', " I'll be back tomorrow with my work clothes and a gallon of lavender paint ! You just sit back and relax ! "]
['You got a letter in the mail . ', ' Give it to me . ', ' What is it ? ', ' It ’ s my acceptance letter from UCLA . ', ' What does it say ? ', ' I ’ Ve been accepted ! ', ' Are you serious ? ', ' I ’ m serious . ', ' Good for you ! ', ' NYU was my first choice , but UCLA is just fine . ', ' I ’ m so proud of you . ', ' Thanks . I ’ m proud of myself , too . ']
['DO you have any plan for your future ? ', " I'd prefer to go abroad , if possible . ", ' Many people are striving for going abroad nowadays.It seems to be a trend . ', " I'm one of them . "]
["Too bad you missed Jane's performance . ", " How's it ? ", ' It was so perfect that it won a unanimous 10 . ']
['I went shopping without my umbrella yesterday morning . ', ' Yesterday morning was beautiful I thought the sunning was going to continue . ', " So did I . that's why I didn't take my umbrella . I got cold in the rain in the afternoon . It was raining cats and dogs . ", ' I know . I could not believe it when I got hit by that storm . It was pouring with rain all afternoon . ', ' We really have some movable weather sometime . I wish I would live somewhere which were sunning all year round . ', ' If it was sunning all year round there would be drought . You probably would not like it either . ', ' I guess you are right . Maybe I just wish the weather could be a little more predictable . ', ' The weather forecasters are not good at predicting the weather would be like . Our weather is so changeable . ']
['Your garden is looking beautiful this summer . The flowers are really colorful . ', ' Thank you . I have roses , tulips , and daffodils . Do you like the rockery with the smaller flowers ? ', ' Yes , I do . Those are violets , aren ’ t they ? ', ' Yes , they are . This afternoon , I ’ m going to prune the hedge . ', ' The lower branches on that tree are hanging very low . Would you like me to cut them off for you ? ', ' Thank you ! That would be very kind of you . I have a saw in the garden shed . ', ' When the lower branches are removed , you ’ ll be able to sit under the tree . ', ' Tomorrow , I ’ ll cut the grass . Then the garden will lock perfect . ', ' Just make sure children don ’ t play in the flower beds and destroy the flowers . ']
["You're late . ", " I know I'm late . I'm sorry . I tried to call you to tell you , but your phone seems to be disconnected . ", ' My phone ? ', ' Yes . An automatic message says your phone is not in service . ', " Really ? I had no idea . Let me check.Yes , it's dead . There's no dial tone . ", " So I couldn't get through . I knew I'd be late because my car wouldn't start.It was too cold I had to warm it up in the garage with a heater . That's why I'm late . ", " But this is terrible . I'm expecting important calls . ", ' About what ? ', " You know what.The theater guild is supposed to call me and discuss a contract for my play.They are supposed to call me this evening.If I don't have a phone . Oh , what can I do ? ", ' Well , the only thing you can do is tell the phone company and hope they fix it fast . ', ' Do you have a cell phone ? ', " No . I hate cell phones.But you could go to a neighbor's house and use their phone . ", " Can you drive me ? I will go to Ann's house . It isn't far . I can call the theater guild from there and give them her number.She will let us wait in her living room . ", " Yes , of course I can drive you.So you don't want to get your phone fixed right away ? ", " Yes , I do.At Ann's house I will call the phone company and have them check my line.If they can fix it right away without coming to my house , then we'll just return here.But if not , I need to wait at Ann's house to talk with the theater guild.It ' s very important to me . ", " Alright , let's go . ", " Yes , let's go . "]
['Linda , would you care for some candies or cookies ? ', " No , don't try to tend me . I'm becoming chubby , and I have to slender down . ", ' You are not really chubby . You are actually thin enough . ', " I don't think so . I know I've put on weight this winter . ", " So you are watching your weight , aren't you ? ", ' Yes , to tell you the truth . I am on the diet . ']
["I've come to say goodbye . ", ' When do you leave ? ', " I'm catching the 11:00 train . ", " Take care of yourself and don't forget to keep in touch . ", ' Goodbye . Hope to see you again next year . ']
['I wonder if we can change to Channel 26 . ', " Why ? I'd like to see what's on that channel . ", ' A lecture on how to make stir-fried ginger beef , not the boxing you like . ', ' I prefer boxing to beef . ']
['What happened to your brother ? ', ' It seems that he has gone ape over the girl . ', ' Your parents must be worrying about him . ', ' Yes , he ’ s been like this for two weeks . We don ’ t know what to do . ', ' Have you talked to him ? ', ' Yeah . But he just didn ’ t listen . ']
['Are you having a good time ? ', " Oh , yes . It's a great party . There are some people I don't know , though . ", " Really ? Come on , I'll introduce them to you . ", ' That would be great . ']
['This is the first time for me to have a Chinese guest . I hope you like western cooking . ', ' Yes . I like it very much . ', " Cooking is a hobby with me . I'm always trying to think up new recipes . I hope you like the soup . It's kind of a specialty of mine , so I hope you enjoy it . ", " It's excellent . ", " Thank you for your compliment.Won ' t you try this fish with white sauce ? I'm rather round of it . ", " It's delicious . ", ' What sort of western food do you like best ? ', ' I like beefsteak very much . Have you tried Chinese dishes ? ', ' I find the Chinese dishes wonderful . ', " Well , it's getting late . I have to get up early tomorrow . So I must say good night . ", " It's still early . "]
['I am not sure how to add a class . ', ' Do you have an add sheet for me to sign ? ', " I'll bring one next time . ", ' When you get the signed add slip , you must take it to the Admissions and Records Office or you will not be added . Can you find the office ? ', ' I think I know where it is . ', ' Across the courtyard on the right is the office . Follow the signs to the correct line . Is that clear ? ', " Thank you for your directions . It's clear . ", " You can't miss it . Add the class and then come back . We'll check later to make sure you are on the roll sheet . ", " That's great . Thank you so much . ", ' Do the same thing with a drop slip if you ever need to drop a class . Good luck ! ']
['Is the environment a big issues in your country ? It is in mine . ', ' It is in mine too . The biggest issue is water . The climate is dry and so water conservation is very important . ', ' What methods do you use to conserve water ? ', ' Water is rationed . We can only use a certain amount each month . It means that we cannot use some modern household items , like washing machines . They use too much water . ', ' I see . I think the biggest environment problem in my country is air pollution . ', ' Yes , I agree . The air here is much more polluted than in my country . Of course , my country is more agricultural and has much less industry . ', ' We have reduced emission of air pollutants in recent years , but cars are still a major source of them . Factories have become cleaner as stricter environment pollution law have been introduced . ', ' The problem is now on a truly global scale . I don ’ t believe that any single country can do anything about it . ', ' I think you ’ re right . There needs to be an international response to this problem . ']
['Ms Anderson , my name is Mike . I am Division Chief of ABC Company . Welcome to Toronto . ', " Thank you . It's a pleasure to meet you . ", ' A pleasure meeting you as well , the flowers are for you . ', ' Thank you , they are beautiful . ']
['hello , Jason , there is going to be a screening of Final Destination 3 at our campus cinema tomorrow . I plan to go to see it . ', ' is it a horror movie ? ', ' yeah , I love horror movies . Would you like to go with me tomorrow ? ', ' no way . I will be scared out of my wits . ', " that's funny , I didn't know a big fellow like you could be so soft and timid on the inside . ", ' Hey , how could you like to taste my fist ? ', ' alright , all joking aside , what kinds of moves do you like ? ', ' Um , let me see , romance , comedy . documentary , action , science fiction , animated and so on . ', ' that is to say , you like all genres except for horror movies . ', " yeah . It seems like we don't speak the same language as far as movies are concerned . ", ' not quite . I also greatly enjoy romance and comedy . ', ' the Notebook is this type of movie . ', " really ? I haven't heard of it . ", " well then , this could be a nice opportunity to enjoy it together . I bet you'd love it . ", " Ok . I can't wait to see it . Let's go ! "]
['Good evening.Welcome to our program . ', ' Thank you.Good evening , Mr.Dean . ', ' Would you tell us your name , please ? ', " I'm Helen Baker . ", ' Glad to meet you , Ms.Baker . ', ' Glad to meet you , too . ', ' Where are you from , Ms.Baker ? ', " I'm from New Zealand . ", ' What do you do for a living ? ', " I'm a teacher . ", ' Thank you for coming , Ms.baker . ']
['Congratulations on the new house ! ', ' Thanks ! We love it . ', " Well , you guys worked hard for it . It's really beautiful . ", " I'm just not looking forward to cleaning it ! "]
["You married Joe , didn't you ? ", " Joe ? I don't know what you mean . ", ' I remember you are in love . ', ' Oh , I took a shine to him when we met for the first time . But it comes and goes . ', " It's Greek to me . "]
['Looks like a good party , I probably know about half the people . ', ' Who ’ s that boy ? ', ' Where ? ', ' The one next to the telephone . ', ' I don ’ t know . Never saw him before . Why ? ', ' I think he ’ s the boy who just moved into my apartment building . ']
['All the soldiers in that country are armed to the teeth . ', " What's happening in that country ? ", ' The neighboring country is threatening their sovereignty with its nuclear bombs . ']
['What ’ s the matter , BOB ? ', ' I think it ’ s my ankle . ', ' What happened ? ', ' One of my snow-shoes that cause on rocks . ', ' Can you stand ? ', ' I don ’ t think so . It ’ s kind of sore . ', ' what I have to give you a hospital for an ex-treat . ', ' It ’ s that really necessary ? ', ' It maybe worse than it seems . ']
['What a brilliant smile ! ', " That's my cousin Hubert.He likes smiling . ", ' He must be very easy-going . ', " Sure , he's ready to be friendly with anyone . "]
['Which season do you like best ? ', ' I like spring best . It is neither too cold nor too hot . Freezing days make me lazy and stuffy days make me lazier . How about you ? ', ' I prefer summer , especially the summer evenings . When the sun comes down , it is so nice to take a walk and breathe . After a rain shower , the smell of the air is refreshing . It is also a best reason for ice-cream . ', ' How do you get through the stuffy daytime ? ', ' Well , I have to hide in the air-conditioned rooms . Anyway , it is all worth , just think about the cool evening time . ']
["Hi , Betty ! Where's your boyfriend ? ", ' I have no idea . ']
['Guess what ? Paul and Susan are engaged . ', ' Really ? When did that happen ? ', ' A week ago ? They met last summer and now just sink . They will be married soon . ', ' Have they set a date for the wedding ? ', ' No , not yet . But Susan says they ’ d like to get married in November or December . Then they ’ ll go to Hawaii for their honeymoon . ']
['Hello , Mary . How are you ? ', ' Not bad . How about you , John ? ', ' Fine . Thank you . ']
['When were you born may I ask ? ', ' On 20th May 1963 . ', ' Do you know what it was according to the lunar calendar ? ', ' 27th day of the fourth month . ', ' By the way , could you tell me when the film will begin ? ', ' It will begin at 5:30 . ', " I am afraid I can't be there on time . ", ' You can see it tomorrow . ', " I don't want to miss it today . "]
['When the rain stops , you ’ ll see how beautiful the beach is . ', ' But the rain has been pouring down for two days . We ’ Ve both caught colds . ', ' And this bedroom is too big and damp . But it ’ s better than a tent . ', ' How unlucky ! Let ’ s pack our bags and go home . ']
["Hi , Sue . What's up ? ", " Hey , Andrew . How's everything with work ? ", ' Ok , I guess . My boss has been on my back recently . ', " Really ? What's he been doing ? ", " You know , just giving me lots to do . I'm really busy right now . ", ' Are you ? What are you busy with ? ', ' Oh , lots of things . Mostly training new people . ']
['So Kim , have you ever had anything stolen ? ', ' Stolen ? No , why ? ', ' My uncle just had his motorcycle stolen a few nights ago . I was just thinking about how clever criminals are these days . ', ' Criminals are clever ? They ’ re only successful when people are careless . ', ' I don ’ t know . The ones who stole my uncle ’ s motorcycle were pretty good . ', ' If your uncle had an alarm system , then it wouldn ’ t have happened . ', ' He did . It was one of the best ones available . But that didn ’ t stop them from disabling it . And on a crowded street too . ', ' Didn ’ t anyone stop them ? ', ' You would think that people would be smart enough to stop something like that . No one knew his motorcycle was being stolen . The thieves came in a truck and convinced everybody that my uncle was parked illegally and they were there to tow it away . ', ' Wow , they were good . I guess criminals aren ’ t that dumb after all . ', ' That ’ s not the end . They were so good that they convinced a bystander to help them lift the motorcycle and put it in the truck . ']
['Would you and your wife care to come to our place and have tea with us some afternoon ? ', " Why , that's very kind of you , Mrs . Johnson . I'm sure my wife will be glad to . ", ' How about tomorrow afternoon ? ', ' Tomorrow afternoon would be fine . ']
['A friend of mine has been taking an online career planning course these days . He told me the other day he has learned a lot from it . He recommended me to subscribe to it . What do you say ? ', ' I think it is good if we know enough about career planning . We will make wiser choices . What else did he tell you about it ? ', ' Well , just something in general , like several key steps in planning career and how to set specific and tenable goals . ', ' Sounds practical ! To be honest , sometimes I feel puzzled about my future career . I am not sure if this job suits me the best though I work very hard on it and enjoy being a hard worker . I have always wanted to try something else and learn some new skills . ', ' Making a decision to start over is not an easy thing to do . It seems that you need this course more than I do . I love my current job . If I take this course , I hope to learn some tricks to get myself more organized at work . If they can give suggestions about how to boost work relationships , that will be great . I need these to improve my current work performance . ', ' Ok , then we can sign up for it together . ']
['Would you like any toast , dear ? ', ' Um ? ', ' Toast , dear ? ', ' As you like . ', ' Would you like any tea , dear ? ', ' It doesn ’ t make any difference to me . ', ' Oh , you ’ re not listening to me . ', ' Leave me alone . ']
['May I help you ? ', ' I need to copy some pages in my book . ', ' The copier is right over there , in the corner . ', ' Do I need to pay to use it ? ', ' You have to pay to use the copier . ', ' How much do you charge ? ', ' You need to pay ten cents for every copy . ', ' Is there a maximum number of copies I can make ? ', ' You can make as many copies as you want . ', ' I ’ m going to need you to show me how to use the machine . ', ' There are instructions posted on the copier . ', ' Thank you for your help . ']
['You seem to be very tired . ', ' Yes , I have been working for eight hours . ', " Why don't you join us to go out for a walk ? ", " No , really . I'm not in the mood for it . "]
['Simon , may I introduce you to Linda ? You don ’ t know each other , do you ? ', ' No . I ’ Ve not had the pleasure of meeting her yet . ', ' How do you do ? I ’ m pleased to meet you . ', ' How do you do ? ', ' Please sit down . Help yourself just like you are at home . ', ' What would you like to drink ? ', ' A cup of coffee , please . ']
['So , what do you think ? How do you like New York ? ', " I'm having a great time . I love it . I'm glad we came . ", ' Yeah . I really like the stores and the shopping . ', ' I love the museums , too . ', ' But the traffic is pretty bad . ', " Yeah . I hate all this traffic . It's really noisy . ", " Listen , it's almost dinnertime.There are lots of restaurant around here.What do you want to try ? Italian ? Greek ? Japanese ? Thai ? ", " I can't stand making decisions . You choose ! ", " OK . Let's go American . Where's the nearest McDonald's ? "]
['I have been very busy this year , working late , often taking work home and taking no vacation . I feel exhausted . ', ' You should ask for a holiday and relax yourself for a little bit . You worked so hard . ', ' You are right . For the past few weeks , I had no appetite and couldn ’ t sleep well . What ’ s worse my back started aching this Monday . It is time for me to take a vacation . ']
["What's that ? ", " It's a surprise ! ", ' For me ? ', " Yes . Let's go inside and you can open it up . ", " Wow ! It's big ! What could it be ? ", " I'll give you two clues . First , it cost more than $ 250 . And second , it's not big , but fat . ", " What does that mean , not big but fat ? You didn't buy ... "]
['What would you like to drink ? ', " I'll just have water . "]
["You seem depressed these days . What's the matter ? ", " I went bankrupt and I'm flat broke now . ", " If I can do anything for you , don't hesitate to let me know . ", ' Thank you . ']
["Good luck . I've got class in a few minutes . ", " Me too . I'll talk to you later . ", ' OK . See you later . ']
["Hi , Natasha , how's life ? ", ' Great . My family came to visit me . ', ' Oh , you must be very happy . How many people are there in your family ? ', " My immediate family is very large . It's my mother , my father , my two older brothers , my younger sister and me . ", ' I have a small family . They are my parents , my younger brother and me . ', " I thought you were the only child in the family . Didn't China practice the only-child policy in the early 1980s ? ", " Yes , it did . But my parents are ethnic minority people . It's a preferential policy for an ethnic minority family to have two children . ", ' Interesting . What do you think about families with only one child ? ', ' The child must feel very longly . My younger brother is 10 years younger than me . Before he was born , I used to be the only child and always dreamed that I would have a younger sister or brother one day . ', ' Do you get along well with each other ? ', ' Yes , we are very close . He is 12 years old now and very smart . He always makes us laugh a lot . ', ' You are very lucky to have such a nice family . ', ' Thank you . ']
["Don't you think it might be a good idea to hold the party outside ? ", " I don't think so . ", ' How about going to a concert ? ', ' That suits me fine . ']
['Every year , the South has the floods . It is an act of God . ', ' Do you really think so ? ', ' Yeah , you have some other ideas ? ', ' I think , in some way it is an act of God , but in another way , it just is caused by us . ', ' For example ? ', " We didn't pay attention to the environment , cut down trees and polluted the air . ", ' Oh , I see . Fortunately government has taken some action to prevent such things . ']
['Good morning , Mary ! ', ' Good morning , John ! ', ' I want to have a few friends over for a dinner party to celebrate my birthday . Would you be able to come the next weekend on Saturday ? ', " I'd be delighted to , John . Saturday did you say ? ", " Yes , if that's all right for you . ", " I'm pretty sure I'll be all right . In fact , I'd be delighted to come over and celebrate your birthday with you.What time are you planning to start ? ", " Oh , good . If you could come around six thirty or seven o'clock , that would give us some time to chat a whit over a glass of wine before dinner . ", " That sounds fine . I'll be there around seven . "]
['Bye , mom ! ', ' Wait , Jimmy , it ’ s cold outside . Put a hat on ! ', ' OK . Bye ! ', ' No , wait , you will be too cold without mittens . ', ' Alright . See ya ! ', ' Hold on , with that wind , you ’ re going to catch a cold . Wear this scarf . ', ' Ok , see you after school ... ', ' Oh ... and ear muffs ! Put these on ... here we go . ', ' Mom ? ', ' Yes , honey ... ', ' I ... I can ’ t breathe . ']
['Jane , pleases come with us . ', " I cannot dance , you know . I have't such a talent . ", ' Just for fun , not for showing . What do you worry about ? ', " Nothing . I have told you before that I won't go to the party and that's flat . ", ' But ... OK . ']
['Who is your favorite music composer ? ', " I don't have one single favorite , but these days I listen to a lot of Chopin . ", ' Then you must despise such modern music as rock ? ', ' Without doubt , rock is trash . ']
["It's a lovely day , isn't it ? ", " Yeah , and most excitingly , I met the girl living under me today . She's really nice . ", ' Is she American ? ', " Yeah , and most importantly , she's single ! Man , I could tell from the moment I saw her , she's the girl of my dreams ! ", " So I take it you two are hitting it off ? I know it's very convenient to be in a relationship with your neighbor , but what if you break up ? ", " I don't know . I am not really worried about that . I don't wanna lose before even starting . Besides I think the other two American guys have also fallen for her . ", " Sounds like you've got some competition . You made a move already ? ", ' Not yet . But I am thinking of inviting her to dinner sometime . I know some good restaurants nearby . ', " That's nice . Having been here a little while surely gives you the advantage , eh ? ", " You bet . Now that you mentioned it , I think I'll call her now and see if she is available tonight . ", ' Good luck ! ', ' Thanks ! ']
["Do you think you'll get the project ? ", " It's a chance in a million . I hear John is interested in it . ", " I see.After all , he's boss's son . ", " But anyway , I'll have a try . "]
['Are you feeling better today , Bill ? ', ' Well , it ’ s hard to say . I coughed a lot in the evening . ', ' You ’ d better give up smoking . It ’ s bad for your health . ', ' You ’ re right . But you know it ’ s so hard to give up the old habit like smoking . ', ' But you should make up your mind first . ', ' You know I often have to work far into the night . I need smoking to keep me awake . ', ' Why don ’ t you go to bed early and get up early ? You ’ ll have the same time for work . ', ' Thank you for your advice . I ’ ll try it . ']
['Oh ! ', ' What fools we were ! ', ' To think of it ! All my old silver ! It meant so much to me . ', " And my new car . To think that he simply drove off with everything in my car . That's what hurts me most . ", " What's so terrible too , is the fools we've made of ourselves . ", " I hardly dare call the police . They'll just laugh at us . ", " I'll never get over it . Oh , Harry , it was all so unnecessary . That man ! ! How could he do this to us after we'd put him up ? ", " And his story didn't even hold together . I feel such an idiot . "]
['I just saw Something About Mary last night . It was hilarious . ', ' David took me to it last week . I thought it was a little sick . ', " What do you mean sick ? It was really funny , don't you think ? ", " It was entertaining in some ways . But in general I didn't like it . ", ' Why not ? ', " I just think the humor was too gross . There were too many disgusting things in it . I don't think a comedy has to have so much smut to be funny . ", " It wasn't a dirty movie . There wasn't even any nudity . ", " No , you're right . But nudity doesn't bother me . What bothered me were all the jokes about masturbation , stuff like that . It was too sick . ", " Oh , you are too conservative . It's just realistic . ", " I don't think it's realistic . I thought it was sick . Why does a movie have to use that kind of humor ? ", " People think it's funny . "]
['Do you know how to go to the Fragrant Hills in Beijing ? I heard that they are very famous in China . ', ' Yes . Especially in autumn , the red leaves of the maple trees make the whole mountain red . ', ' That must be very beautiful . ', ' Yes , it can make people feel as if they were in the land of fairies . ', ' Really ? Have you ever been there ? ', ' A couple of times . ', " Can you go there with me ? I'd like someone who is familiar with that area to go with me . ", " Sure . I'd be very glad to be your tour guide . "]
['Have you heard that Tom and his wife divorced ? ', " I didn't hear that . But I can deduce the reason . ", ' Really ? Say it ! ', " Tom is a kind guy , but addicted to gambling . He spends all his time gambling in the casino . And his wife can't put up with his incessant gambling any longer , so she divorced him . Is that right ? ", ' Yeah , quite right . Gambling broke up a happy family . ', ' Yeah ! Gambling is often a curse . By gambling we lose time and treasure , two things most precious to a man . ', ' Besides that , many people took to gambling and got in over their heads , and gradually ruined themselves . ', ' In a word , gambling is a vice . We should be away from it . ']
['Professor , could I make an appointment with you ? ', ' I am free tomorrow afternoon between two and four ; do you have a particular time in mind ? ', " Two o'clock would be the best time . ", ' Fine , do you know where my office is ? ', " No , I'm not sure . ", ' Remember , it is in the E building on the third floor . ', ' I see . ', " Don't worry , it will work out fine once you get there . I'll see you then . ", " I'll see you then . ", ' Looking forward to meeting with you ! ']
['Have you gone bowling before ? ', ' No . Could you tell me something more about it ? I want to play well . ', ' There are 10 frames in a bowling game . Each player is allowed to bowl two balls in each frame . ', ' You just said 10 rounds . ', " ' Round ' and ' frame ' are two different terms . ", ' Perhaps you can tell me a little more about this . ', " Hey , slow down . I'll tell you more while playing . "]
["I'm told Cold Blood just finished its last cut . ", " Yeah , it'll make a hit , I think.When will it be on , do you know ? ", " Sure , it'll be on next Monday . "]
["Hectic . It's always hectic . But how was your windsurfing ? ", " I tried it for a half-hour.It was interesting , but ... well ... I couldn't really do it . ", " See ? I told you . It's very hard . ", " I couldn't even stand on it and hold the sail . I probably fell down fifty times . ", ' Fifty times ? ', ' Yes , it was really stupid . ', ' And how much did it cost to rent it ? ', ' It was fifty dollars for a half-hour . ', " Well , that's not too bad then . ", " What do you mean ? It's expensive ! ", " Yes , but you have to calculate a little.You paid fifty dollars and you fell down fifty times.So you only spent one dollar per fall . That's cheap . "]
["How's your girlfriend ? ", ' We broke up . ']
['How are you tonight , sir ? ', " Oh , not too bad . I'm just glad the weekend's finally here . ", ' I know what you mean . What can I get for you ? ', ' Give me a screwdriver on the rocks . ', ' One screwdriver , coming right up . ( He mixes the drink . ) Here you are , sir . ', ' Thanks . ']
['I think you should look over these figures again . There are some calculations that are a bit off . ', ' I apologize . This should not have to be this way . ', ' Apology is accepted . Try to do better next time . ', ' Of course , I should have been more careful . I ’ m sorry . ']
['You didn ’ t show up in the morning meeting . What ’ s up ? ', ' Well , I just came in . I worked overtime yesterday . Some statistics and very important documents seemed to be inaccurate . So I stayed to double check them . The boss was aware of my very late work of last night . So before he left office , he told me I could come one hour later this morning . ', ' But you still look a little bit tired . What time did you leave ? ', ' It was around one thirty in the morning . I guess I didn ’ t fall asleep till 3 because those numbers were involving in my mind . I just couldn ’ t stop thinking about them . ', ' That ’ s normal after a tense work evening . Working overtime is not always a pleasant experience for me either . Once , I worked overtime everyday for a whole week including the weekend . That really broke my rhythm and I got a little sick later . ', ' Working at weekend is something I hate to do most . ', ' But if the company asks , what else can we do ? ']
["Hi ! It's still seven o'clock . Are you crazy ? ", ' I got the information that there is a killer sale at the shopping mall near our block . Get up and I will wait for you at the gate of our flat . ', ' Every time when you glimpse some stylish clothes , you change into another person . ', ' Stop complaining , OK ? ', ' No wonder you are named shopaholic . ', ' No , I am not a shopaholic , but a super shopaholic . And I really enjoy smelling the gorgeous clothes and new bags . ', ' Wait a moment . And you can check where other sales are . ']
["What's wrong , Bob ? ", ' I was wondering if you could company me to the Ball ? ', ' Of course , I will . ', " That's great . I'll pick you up at eight . "]
['How do I look in this new dress ? ', ' You ’ d better change it . It ’ s ugly . ', ' How about this one ? ', ' It ’ s really elegant and it fits you really well . ']
['They must be your parents , what do they do ? ', ' My mother is a professor and my father is a manager . ', ' Do they often take you out ? ', " No , usually they're very busy . "]
['You did well on the math test . ', ' Of course . ', ' Don ’ t you always fail in the math tests ? ', ' Things were different this time . I sat by a math genius . ', ' Huh ? You mean you snuck a peek at his test ? ', ' B :: Come on ! I just took a glance . ', ' Are you crazy ? You were cheating . ']
["I can't decide whether to go to university or to get a job . ", " Well , if I were you , I'd go on studying . ", " But I don't even know what to study . ", " If I had chance again , I'd major in English . You're good at language . ", " That's what my parents want me to do . ", " You should take their advice . They know what's best for you.But my friends will have jobs and lots of fun , while I spend all my time doing reading and writing . ", " But if you go to university , you'll still have time for fun . ", ' Hm , what you say makes sense . But you know , I still have to ask my parents for pocket money , and I hate to do so at this age . ', " And if you try to find a part-time job , you'll have some money too . ", " You're right . Thank you for the advice . "]
['Well , I can ’ t believe your uncle and aunt came to stay with us for a week , and they did not even call us in advance . ', ' John , they are old-fashioned people from the Chinese countryside . That ’ s their custom . ', ' I know , but it is hard for me to get used to your relatives coming to visit us , and without warning . ', ' Don ’ t your relatives visit other relatives ? ', ' Yes , but Americans never visit without calling in advance , and they almost never stay overnight . ', ' I think that maybe Chinese families are closer than your families . ', ' I think you ’ re right ! ']
["I want to buy two tickets for tonight's concert . ", ' Sure . How do you like your seats ? ', ' Ordinary one , please . ', ' Ok , here are your tickets in Row 13 . ', ' I think they are too far from the stage . I want two in row 6 . ', " That's fine . But you have to pay another $ 10 . "]
['Is this watch yours ? ', " No , it isn't mine . I blundered upon it under the sofa . Do you know whose watch it is ? ", " Let me have a look . It's mine . I have been looking for it , but just cannot find it . It's present from my father . ", ' Well , here you are . Remember to put it in a proper place . ']
['Who are we going to play with today ? ', ' We are playing against Hainan . ', " Oh , the basketball team from No . 1 College ? I know they're a tough team . ", ' Sure they are . ', " Who's winning ? ", ' We are , 27 to 26 . ', " Really ? I thought that they'd been killing us by now . ", ' How can it be ? We are a tough team as well . ']
['Are you a smoker ? ', ' Yes , I ’ m afraid I am . My husband is a smoker too . ', ' Would you describe yourself as being a heavy smoker ? ', ' No . But my husband smokes 20 or more a day . ', ' When did you begin to smoke ? ', ' I had my first cigarette when I was 17 . ', ' Might I ask if you have tried to give up smoking ? ', ' Yes . Twice . ']
['How about the hiking ? It was freezing yesterday , are you all ok ? ', ' Can ’ t be better , it was wonderful . We had a lot of fun there . There was so much joy and walk and breathe the winter air . We arrived at the park at 9 o ’ clock in the morning and didn ’ t leave till 3 o ’ clock in the afternoon . ', ' You had been walking for 6 hours , isn ’ t that boring ? ', ' Of course not ! We built a snowman , some snow dogs and one big snow fort . We went sliding on the nice hill . It was a real work out . At noon , we had the most special winter picnic outside . Fortunately , we got it all on a video tape . You must come with us next time . I bet you will love it . ', ' Well . You know I hate walking , but I can ’ t wait to see your guys ’ video . ']
['You know them ? ', ' No , but those guys like to hit on me . ']
["Here we are , Ryan ! This is where we're going to celebrate ! ", " It's a ETV palace ! I'm glad I brought my platinum card . ", " You won't need it . Stanley , my best man , is going to treat everybody ! ", " Where is Stanley ? It was his idea to have the bachelor's party at a ETV , wasn't it ? ", " If it were up to Stanley , we'd have the wedding in the ETV ! He loves to sing . ", " Then I bet he's really good ! ", " Well , uh , I'll let you decide that for yourself . He'll be here a little later . Here's our room ! "]
['What a nice dress , Jean.You look marvelous ! ', ' You , too . Where did you get your new hat ? ', " From the Crown's . Oh , what lovely earrings you have ! Are they diamond ? ", " Yes . It's a birthday present from my husband ! ", " Well , you are lucky to have such a considerate husband . Mine hasn't brought me a single rose since we married . ", " He'll come out with surprises . Just wait and see . Look at that woman , with the white chiffon ! ", " She's chic , isn't she ? ", ' Yes . I like the dress . It must be the latest fashion . Look , the hem has lowered , and the waist narrowed . ', ' It makes me feel rather shabby . That woman has a good taste in dressing , I would say . ', ' Yes . She dressed with an individual flair . I rather envy her . ', " Most women follow fashion like sheep.They don't know any better than imitate . ", " I quite agree with you.See the woman there ? I dare say she hasn't got any eyes . How could she match the mauve gown with the green handbag ? And all that jewelry ! ", ' The gown is quite expensive , believe me . ', ' So what ? It only makes her look cheap and vulgar . ', " You know those upstarts . They're all show-offs ! I think I'd better have a diet ; otherwise I'd look like a ballon soon . ", " You're quite slim . In fact , if you were one of those starlets , the movie company would say you have a fabulous figure . ", " Thanks . I'm flattered . ", " Oh , my shoes pinch me . Let's find a seat and sit a while . "]
['Whoa , whoa , what ’ s going on ? Watch out ! ', ' Hey , watch where you ’ re going ! ', ' Oh , no ! I ’ m so sorry ! Are you all right ? ', ' Oh ... I don ’ t know . ', ' I feel terrible , I really didn ’ t mean to knock you over . My tire , just exploded , and I lost control of my bike . Really , it was an accident . Please accept my apologies . ', ' Oh , wait a second , you seem really familiar , I think I know you from somewhere . ', ' Yeah , I think we have met somewhere before . That ’ s right ! We met at Aaron ’ s place last weekend ! What a coincidence ! But anyway , I ’ m glad to see that you ’ re not too badly hurt , and I should probably get going . I have a nine o ’ clock meeting . ', ' Ouch ! My ankle ! I think it ’ s broken ! You can ’ t just leave me like this ! Are you calling an ambulance ? ', ' Nope , I ’ m canceling my appointment so that I can stay here with you . ']
['Hello , james . Come in . go through to the living room . ', ' Hi Kate ... thanks ... wow ! Look at all the furniture . You must spent a fortune on it ! I love your new three-pieces suite . ', ' I told you that I had been saving up money to buy some new furniture and do some redecorating . I finally saved enough and did everything at once . ', ' Good for you ! You ’ Ve got new curtains too . That ’ s a very nice shade of blue . This sofa is very comfortable . I could sit on it all day ! ', ' Do you like my carpet ? Be honest ! Tell me what you really think . ', ' To be honest , it looks like your old carpet . Is it really new or did you just have your old cleaned ? ', ' Well spotted ! I actually had it cleaned twice , because it was so dirty . The rug is new . You remember my trip to china ? Well , I bought is there . ']
['Oh , you are out of breath ! What ’ s happened ? ', ' A gang of bastards are wildly shooting on the next street . We must leave this place the soonest . ', ' That it easy.They get caught before they come here . ', ' Stop your nonsense ! Quick . Let ’ s leave the place ! ']
['People of different races are fit for quite different sports . For instance , Asians are especially good fattable tennis , badminton , diving and shooting . They seem to have been born with certain natural endowments in technical sports , in which flexibility , agility and quick reflexes are favorable . ', ' And a typical example has been the Chinese athletes at the Beijing Olympics , right ? ', ' Yes , in all these four sports . the Chinese Olympic dream teams led the way . They swept the floor against their opponents in table tennis and diving . ', ' Then what are the Westerners fit for ? ', ' I think they are in a better position in those sports that demand a high degree of intensity , speed and explosive force like swimming , field games , etc . ', ' Where do you think the edge is for black athletes ? ', " It's common sense that African athletes always make a clean sweep in track events , middle or long distance races , relays , hurdles , barriers , and marathon . ", ' I got you . Their competitive edge lies mainly in endurance and stamina . They are creatures from the savannah , and take to running like antelopes . ']
['This man looks very handsome.Is he married ? ', ' Sure.He has already married , a father of two boys . ', " Oh , I can't believe it.He looks very young . ", ' He took the picture when he was only 21 years old . ', ' I see . ']
['We seem to be lost here . ', ' Possibly . ', ' I suggest that we go and ask for help from the policeman . ', ' Not a bit . ']
["It's crunch time , isn't it ? I wasn't nervous before the meeting , but now I am . ", ' No kidding . Time is running out . ', ' It would help to bring in a couple more troubleshooters . ', " Vince says he can't afford anybody else . We're got to come through . ", " Do you think we'll make it ? ", " I guess we'll either make it , or we won't . "]
['Here is the song list . ', ' Do you have any English songs ? ', ' Yes , here you are . ', ' Let me have a look . Everything I do I do it for you 、 Unchained melody 、 My heart will go on . Oh , and I ’ d like to try Everything I do I do it for you . ', ' Let me play it for you . ', ' Is it easy to locate it ? ', " It's very easy . Here it is . Ready ? Excellent ! You are a good singer . You sing the bass so well . ", " I used to be a better singer . I haven't sung in the Karaoke for a long time . It's your turn . ", " I'll sing a Chinese folk song Love song of Hanging , first in Chinese then in English . ", " That's really my pleasure to listen to a Chinese song . "]
['What ’ s the plot of your new movie ? ', ' It ’ s a story about a policemen who is investigating a series of strange murders . I play the part of the detective . He has to catch the killer , but there ’ s very little evidence . It ’ s a psychological thriller with some frightening scenes , but I hope audience won ’ t be too scared to go to the movie theatres ! ', ' Did you enjoy making the movie ? We heard stories of disagreement with other actors and with the director . ', ' I have had disagreement with every director . I ’ Ve worked with . We ’ Ve always disagreed in a friendly way and we have always resolved our differences . It was the same when I made this movie . I don ’ t know where rumours of my disagreement with Rachel Kelly come from . We got on very well and I hope to work with her again . I enjoyed making the movie very much . ', ' Critics are not very happy with the movies that you ’ Ve made recently . Does that bother you ? ', ' Not at all . The feedback from audience has been great . I care about what they think more than what the critics think . ', ' Did you do you own stunts in the movie ? ', ' I wanted to , but my insurance company wouldn ’ t let me . All of my stunts were done by a stuntman . As you know , I used to do my own stunts , but I ’ ll leave that to the experts in future . ', ' Thank you very much for doing this interview . ', ' My pleasure . Have you seen the movie yet ? ', ' Yes . I have . I liked it very much . Like you , I was very impressed with Rachel ’ s performance in the movie . She ’ s going to be a star . ']
['It looks like our company trip will have to be canceled because of the typhoon . ', " That's disappointing . I was really looking forward to it . "]
["I'd like to meet you again sometime . ", " That would be great . Actually , can I get your phone number , Ella ? That's assuming you don't mind if I call you sometime . ", ' Anytime . You can reach me at 5558929 . ', ' Ok , got it . I will call you sometime next week . ', ' Fine . ', " It's time to go . Bye , Ella . Hope to see you soon . ", ' Bye , Jason . ']
['Do you mind if I ask you to practice speaking English with me ? ', ' No . Of course not . But what for ? ', " Well , I'm meeting some American friends next weekend . ", " I see . But I'm busy now . How about tomorrow ? "]
['have you ever thought about your ideal home ? ', ' I have , actually ; I ’ Ve always wanted to build my dream home myself . ', ' what would it be like ? ', ' well , it would be spacious and located next to a park , because a nice view is important to me . ', ' how many rooms would it have ? ', ' I ’ d want it to have three bedrooms on a second floor with balconies on each , and one main bedroom on the main floor with an attached en suite . I ’ d also want a large living room and kitchen connected t ', ' how many bedrooms would your dream home have ? ', ' I ’ d have one guest bathroom in the basement , one attached to the main bedroom , and one upstairs , so a total of three . ', ' how would you decorate your house ? ', ' I don ’ t like a lot of clutter , so I wouldn ’ t have lots of things out . I would have a few vases on the mantel piece and some pictures of my family on the walls , but other than that , most things would b ', ' how many TVs would your dream home have ? ', ' I think TV is a great waste of time , so I would only have one small TV in the kitchen to watch the news in the morning . ']
['Have you ever made any plan for your future ? ', " Of course I have . I'd like to marry a handsome man and have two children if possible . ", " Not me . I'd like to be a bachelor forever . ", " I don't believe you can make it when you meet your Mrs . Right . "]
['The Mountains would be a great place for the company retreat . ', " That's a wonderful choice . ", ' I have chosen January as the month for this retreat . ', ' January is a little too close to the Christmas holidays . ', ' Yes , maybe another choice might be better . ', ' I think that April would work . Spring is a lovely time to be in the mountains . ', ' Thank you for thinking of that . ', ' Maybe if we asked around we could see what people would prefer . ', ' That is a good idea . ', " I'll take care of taking the survey and get back to you with the answers . "]
['Susan has got married . ', ' Really ? How do you know that ? ', ' Her marriage was a hole and corner affair . ', ' Why ? That ’ s good news , but no one knows it ? ', ' I have no idea . Maybe she didn ’ t want to let us ... , so ... ']
["I'd love that . I'm so glad I quit . It's time for a change . ", " Does that mean you're going to take my advice ? ", " Yes . I'm looking for a position as a chef . ", ' I might be able to help ... ', " I'm sure you have great connections . ", " We'd like to open another restaurant ... with you as the head chef and manager ... ", ' Really ? You have that much faith in me ? And Giovanni agreed to it ? Does he know who I am ? ', " Yes . But you know him . He's just worried that you're not Italian ... ", " He's prejudiced , isn't he ? ", " No . He's afraid that no one will cook as good as his mother did . ", ' Ah ! I know a way to convince him that Americans can make good Italian food ! ', " How's that ? ", " You'll see next week . I'll come by one day at lunchtime . "]
['I just got sacked . ', " I'm sorry to hear that . "]
['What do you do in your spare time ? ', ' I listen to music and read . ', ' What kind of music do you like ? ', ' I think I like classical music better . ', ' Actually me , too . ']
['Hi , how is it going ? ', ' Pretty good , Sam . Only the awful weather , you know . ', ' That ’ s right . I ’ Ve never really liked it since I got here . ', ' Me either , but I ’ m dealing with it anyway . ']
['What a surprise meeting you here , Landy . ', ' I ’ m here as a tourist . ', ' It ’ s a small world , isn ’ t it ? ', ' Yes , it ’ s a small world . We never know where we ’ ll meet someone we know . ']
['Can we sit on the grass , darling ? ', " No , you can't , darling . The grass is wet . ", ' Look , darling ! I can see a bench near that tree . ', " No , you can't . The bench is wet , too . ", " It's not raining , darling . The bench isn't wet . ", " Can't you see a notice on the bench ? ", ' Yes , I can . ', ' What does the notice say ? ', " It says ' Wet paint ! ' "]
['Do you have any year-end benefits ? ', ' I don ’ t know till now . ', ' I just saw a piece of news , that a group of white color workers hold a flour war in the office because of dissatisfaction of the year-end benefits . ', ' Why they hold a flour war ? ', ' They got rice , flour and oil as presents , while the leadership got 1000 yuan shopping card . ', ' They are not feeling satisfied ? ', " It is said that the presents they got value less than 200 yuan , and it is no use for them at all , because they don't cook by themselves . ", ' But how guilty to waste food ! ']
['Now , David , can I get you a drink ? What will you have ? ', ' Coffee , please . ', ' What about you , Mary ? ', ' Coke is fine.Thank you . ']
['Hey ! I have a surprise for you . ', ' What is it ? ', ' Open this card and read . ', " A trip to China for summer vacation . Wow ! What a wonderful surprise ! Thank you . This is the best surprise I've ever had . "]
["Have you heard we'll have a pay rise ? ", ' Oh , it has nothing to do with me . ', " It's a pity , but why ? ", ' I came here only a month ago . ']
['Shall we go for a drive today ? ', " It feels like there's going to be rain later . ", " Maybe you're right . ", " We'll go tomorrow . "]
['How do you like this waltz ? ', " It's very nice . I like it very much . ", ' Well , then , may I invite you for the first dance ? ', " My pleasure . But I'm afraid I'm not much of a dancer , and I suppose you dance often . ", ' Me ? Oh , no . In fact , I only took up dancing quite recently . ', " Oh , really ? But you're doing the waltz wonderfully well . ", " I'm glad you say so . You dance beautifully too . It's lucky that I got you as a partner . ", " Thank you for your compliments . It's just you are a good leader . Do you like the foxtrot and tango ? ", ' Yes . And what dances do you like best ? ', " Disco is my favorite . I like it better than any other dances because it can release one's hidden feelings , and is a healthy exercise . But I don't do the rock and roll nor break-dancing . ", ' Oh , well , the music has stopped . Thank you for the dance . ', ' My pleasure . ']
['Are you sure it was him ? ', ' I used to date him . Of course it was him . ', " You're a nurse at New York General Hospital ? ", " Yes , on the cancer ward . And Taylor was there . He walked right by me and didn't even see me . ", ' Maybe he was just visiting someone . ', ' But you saw how skinny and pale he looks . He has " cancer patient " written all over his face . ']
["Jason , it's your turn . ", ' I hope I get an easy question like you did . ', " You rolled a four . Let's see ... you landed on Foreign Films . ", " Oh , great . That's just my luck ! I hate those arty movies . ", ' Well , too bad . So , what foreign film won an Oscar in 1993 ? ', ' Oh , please ! I have no idea . ', " The answer is Belle Opaque . It's a Spanish movie , and the title means The Age of Beauty in English . "]
["I'm leaving now , mum . ", ' Take care , sonny ! ', ' I will.Bye - bye ! ', ' Bye ! ']
['You hoo , anybody here ? ', ' Over here , Betty ! ', ' Hi , Rock Sam ! Hey , I am surprised to see you doing so well . ', ' Haha . Don ’ t worry , Betty . So tell me , what ’ s the latest gossip ? Unless you want to keep it to yourself . ', ' No way . Alisan Darling just got hitched in Vagas . ', ' No kidding ! What happened to Ad ? ', ' Darling found out he was having a fling , and one new girl found out about Darling she dumped him too . ', ' Was , talk about a double whammy . ', ' Ya . And now I can break this to you . Fanny is moving . ', ' Oh , right . What a load off my mind . I really don ’ t like her . ', ' Well I have to go , Rock Sam . You take it easy , OK . ', ' Thanks for the visit , Betty . ']
['When do we get off the bus ? ', ' I think we have a while longer . ', " I feel like we've been on this bus forever . ", " That's true . ", " Are you sure we weren't supposed to get off already ? ", " I don't know . ", ' I thought you knew where we get off at . ', " I wasn't really paying attention . I think we missed our stop . ", ' Seriously ? ', ' Yeah , we definitely missed our stop . ', " That's the last time I get on a bus with you . ", ' My bad.sorry ! ']
["I'm afraid it's a bad news for you . There are some problems in your supervised goods . ", ' Oh , no ! How did this happen . Are you sure ? ', " I overheard this information when I passed Arden's office . We got some complaints from consumers yesterday . I am terribly sorry for that . ", ' My God ! I actually checked them one by one . How could this be ? ', ' Calm down ! It is useless to act like that . Can we find some solutions ? ', ' What kind of solution can I have now ? I nearly go crazy now . ', ' But we still have to find one . Can we find Arden to check whether this is true or not ? ', ' It seems that I have nothing to do , except this . ', ' Face the reality . Maybe we can find the way to make up the loss . ']
["Then I'll have to borrow it . ", " Sure you can . But I'm only gonna keep it for a month . ", " Why ? It's in mint condition ! ", " That's why I can profit from it ! ", " You're going to re-sell it on eBay Taiwan ? ", " You bet . eBay Taiwan doesn't have it ! And bidding will start at two thousand NT . This baby's worth about six thousand to real tennis fans ... ", " I've created a monster ... you're a better bayer than me ! "]
['Hello , ABC Company . Can I help you ? ', ' Yes , of course . I am calling to apply for a job as an accountant . ', ' Can you name some courses you completed ? ', ' Sure . The main courses I took included commercial accounting , cost accounting , industrial accounting , electronic accounting , and so on . ']
['Am I allowed to check out at 14:00 ? ', ' Certainly . ', ' Will there be any late charge ? ', ' No.sir . If only you check out before 15:00 ', ' Thank you . ']
["There's going to be a highway here . ", " That's better . ", ' The traffic problem will soon be eased . ', ' I think so . ']
['Excuse me , sir ? ', ' Yes ? ', " I'm afraid you can't smoke here . ", ' Why not ? ', " Can't you see the notes here ? ", " I'm sorry . I can't . What does the note say . ", " It says ' No smoking ' . ", " Sorry , I'm very near sighted . "]
['Fred , have you made the plan for April 28th ? ', ' Yes , sir . Shall I explain the details of the plan now ? ', ' You go ! ', ' According to your schedule , you will visit the Times Company , including its office building , workshops and stores , in the morning from 8: 30 to 11 ', ' Is there anything after the meeting ? In that case , would you add one plan ? I want to visit our guest Mr . Ross after the meeting . Can you arrange it for me ? ']
['I would suggest roast beef , sir . ', " All right , roast beef , please.And I'd like to start with soup . ", ' We have clear and cream soup at your choice.Which one do you prefer ? ', ' Clear soup , please . ']
['Good . There is the information desk . How do we get to seventieth street , please ? ', ' The northern line is what you want . ', ' How much is it ? ', ' It ’ s two yuan . ', ' Which way do we go for the northern line ? ', ' Just go through the number eight to ticket barrier over there . A train will be in directly . ', ' I appreciate it , thank you . ', ' That ’ s all right . ']
['How do I set up an email account ? ', ' Oh , that ’ s easy . Go to yahoo.com . Now , click on the link with the picture of an envelope . ', ' Which link ? ', ' That one , the one that says , “ Mail . ” ', ' Oh , no . What did I do ? It ’ s asking me for a password . ', ' Don ’ t worry . See where it says , “ New User ” ? ', ' Yes . ', ' Click on that . ', ' Oh , I see . ', ' Yeah , just fill out this form and choose a password . The computer will do the rest . ']
['Excuse me . But are you Mrs . Smith from America ? ', " That's it . I am Maria Smith . You must be Zhang Lin from Tianjin Sports Facility Co.Ltd . ", ' Yes . Nice to meet you , Mrs Smith . ', ' Nice to meet you too , Mr . Zhang . ']
['Do you have any particular conditions that you would like our firm to take into consideration ? ', ' Yes . My house is far away from here . May I ask for an apartment ? ', ' No problem . We can offer you a flat with two bedrooms and a living room . ', ' That ’ s great . If you don ’ t mind my asking , does your company give bonuses ? ', ' You ’ ll get bonuses at the end of each year according to your achievements . Besides , we offer you 1 % commission on all your sales . ', ' Oh , just one more thing , could you give me some idea about holidays ? ', ' You can have Saturdays and Sundays off . In addition , you may have a paid month vacation every year . But when it is necessary , we do expect you to work overtime . Does it suit you ? ', ' No problem . ', ' If you are satisfied with the conditions here , please sign this contract and give it to me . ', ' OK . ']
['And how will you be paying for your room , Ms White ? ', ' By credit card . ', ' Both rooms on the same card ? ', ' Yes . ', ' Your card number please ? ', ' 4434 1234 5678 9902 . ', ' Double one , zero two ? ', ' No , double nine zero two . ', ' 4434 1234 5678 9902 ? ', " That's right . ", ' And the expiry date ? ', ' Eleven , ... ', ' Could you repeat that please ? ', ' November this year . ', " Thank you . I've booked two rooms for Ms White and Mr Webber from Wednesday the 25th to Saturday the 28th of September . ", ' Thank you . ', " You're welcome . We'll see you on the 25th , Ms White . ", ' Thanks a lot . Goodbye . ', ' Goodbye . ']
['Hello , room service . Can I help you ? ', ' I ordered dinner about forty minutes ago . It hasn ’ t been delivery yet . ', ' We are sorry for the delay , ma ’ am . Could you hold the line , please ? I ’ ll check your order . ', ' Okay . ', ' Your order is ready . It ’ s on the way to your room . We ’ re very sorry to have you waiting , Ma ’ am . ', ' That ’ s okay . ']
['May I help you ? ', " No , thank you . I'm just looking . Maybe later I might need your help . ", ' I hope you will ! Take your time . We have a lot more upstairs . ', ' Oh , you do ? You certainly have a large selection . ']
['Come here ! I can see the tall camphor trees from here . ', ' Yes , we can also see some yew trees . ', ' This is a great botanical garden in the city . ', " Listen to the sound of nature ! It's like music . ", ' Yeah , I agree.It makes you feel really good . ', ' What are those . Miss Liu ? ', ' Do you mean the red flowers ? They are peony flowers ? ', ' The red and yellow peony flowers are so beautiful . ', ' Yes , you like them very much . right ? ', " Sure . I'm going to take more pictures today . ", ' I can help you with it ', ' You are so kind . Thanks . ']
['Good evening , Mr . Frank . Bourbon on the rocks ? ', " No . This time I'll try Chinese wine . ", " What about Mao Tai , one of the most famous liquors in China ? It's good indeed . It never goes to the head . ", ' Do people here drink a lot of liquors ? ', " Some do , some don't . Many people in the North are fond of liquors . I think it has something to do with the climate . ", ' Yes , it has . Some Mexicans are crazy . They drink a lot of liquors even on hot days . Have you ever heard of " Tequila Sauta " ? ', " Yes , it's a very well-known kind of spirits in Mexico . People drink it with salt and lemon . ", " Right . It's very strong , just like alcohol . ( Frank sips Mao Tai . ) ", ' Yes , besides Mao Tai , we have Wu Liang Ye , Fen Jim and so on . ', " They say that Showing wine tastes quite good . What's it ? ", " It's rice wine , a kind of still wine , somewhat like Japanese Sake . Showing is a city in China . ", ' I see . ', ' By the way , we also have some good red wine and white wine , such as Great Wall White Wine . ', " Thank you for telling me so much , I'll try them next time . ", " I'm always at your service . "]
['I would like to make a reservation for tomorrow . ', " I'm sorry but we are fully booked . ", ' Well , how about 4th ? ', " That's fine , but we have only a single room , is that OK ? ", ' Yes . Please help me reserve it . ']
['Hello , this is Francis from XYZ Company . I would like to discuss with you about a new project some time next week . Do you have time to meet ? ', ' Well , I am not sure . Lets me check my agenda ', ' Ok . ', ' I am free on Tuesday afternoon from 2 PM to 4 PM , is it convenient for you ? ', ' It is ok with me . So I will be arriving at your office around two fifteen PM . ', ' Yes , there is . See you then . ']
['A woman after my own heart ... ', " OK , Mr . Coffee Connoisseur , so what's the next step in the coffee-making process ? ", " Well , step two is grinding the coffee beans . I've roasted three different types of beans . ", ' Let me guess , Mocha , Mandheling , and Santos ! ', ' Yep , my own special blend ! You can tell by just smelling them ? ', ' No , I just read the names off the packages ... Ha ! ']
['Morning , Mom . ', " I made a doctor's appointment for you . ", " No , I'm fine . I don't need to see a doctor . ", " Then I guess you're healthy enough to clean your room before school . ", " OK . I'll go see the doctor . ", " Bundle up . It's wet and rainy out there . Here's some soup . ", ' Chicken soup again ? ', " Soup does the body good , sweetie . It's what you need when you're under the weather . "]
['Would you please make a skirt for me with this material please ? ', ' What kind of style do you want ? ', ' I like miniskirt . ', ' Now let me take your measurements . ', ' When can I get it ? ', ' Three days later . ', ' Thank you , see you then . ', ' Bye-bye . ']
['Hey , Jim . Wake up ! ', ' Do I have to get up now ? ', " You'd better get up or you'll be late . ", " What are you talking about ? The alarm hasn't even gone off yet . ", ' Yes , It has . It went off 30 minutes ago . ', ' I must have slept right through it . ', ' Rise and shine , sleepyhead . ', ' Just let me sleep five more minutes . ']
['May I have my bill , please ? ', " That's $ 20 in all . ", ' Well , I am afraid you have made a mistake . Would you check it again , please ? ', ' Let me see . I am terribly sorry , sir . That should be $ 18 . ', " It doesn't matter . "]
['Mm ... How do I get this ticket machine to work ? ', ' Well first put your money in . ', ' Ok , I ’ Ve done that . ', ' Then just press this button . ', ' Oh it ’ s printed the ticket already . Thank you very much . ', ' You ’ re welcome . ']
['So how long do you plan to live here ? ', " We'd like to sign a year-long contract , if that's OK . ", ' Fine by me . Do you know how to read this kind of contract ? ', " Yes . We've signed them before . We even brought our chops . ", ' Great . When in Rome , you guys know what to do . ', " We'll sign our signatures , too . And give you our passport numbers along with our ARC numbers . ", ' That about does it . See you in a week . ']
["After probation , you'll find that our silk products feels more comfortable than others . ", ' How about this product selling from last month on ? ', " It's selling like hot cakes , and we have lots of regulars now . Would you like to place a trial order ? ", ' Am . Well , can I have a try of the sample free of charge ? ', ' Yes , we have the free samples for customers . And you can have a try . ', " Thank you . We'll order once we try the sample . ", " Please wait a moment and fill out the order form . And we'll send you our sample . ", ' OK . ']
['Is this watch yours ? ', " No , it isn't mine . I blundered upon it under the sofa . Do youknow whose watch it is ? ", " Let me have a look . It's mine . I have been looking for it , but just cannot find it . It's present from my father . ", ' Well , here you are . Remember to put it in a proper place . ']
['What would you like for your main course ? ', ' Steak , please . ', ' How would you like your steak ? Rare , medium-rare or well-done ? ', ' Well-done , please . ']
['Shall we have some soup first ? ', " No , thank you . I don't like soup . I'd rather have some fruit juice to start with . ", ' Ok , and what about the main course ? Which would you rather have fish or meat ? ', ' Meat , I think . ', " Don't you like fish then ? ", ' I do , but I want meat . ', ' Shall we have some white wine then ? ', ' Yes , but I prefer red wine with meat . ', ' What would you like for dessert ? ', ' I just want to have a coffee , I think . ', ' Fine , and after dinner , shall we go to a disco ? ', " No , thanks . I'd like to go straight home . I'm very tired . "]
["I'm calling to ask about your apartment you advertised . ", " Yes , we've got great apartments with charming environment and nice scenery.And they are all newly renovated . ", ' That sounds fantastic ! But I am looking for something closer to downtown , as I spend most of my time at the office . ', " No problem . We have a nice apartment located near the Oriental Square . It's perfect for people busy with office work . It is fully furnished with a service staff taking care of the trivial details . ", " I'm sure they are wonderful , but I need an unfurnished apartment with relatively lower cost . ", ' Ah ! I get your point . We have just what you need . Our Jinyuan apartments have several floor plans . The one bedroom apartments are very economical , but their layout makes great use of a small amount of space . I think you can find a very apartment there . ', " Great ! I'll arrange a viewing after work tomorrow afternoon . Could you tell me the detailed dress ? ", " Of course . It's just at 19 Lingual Road . You can phone me again if you can't find the right place . ", ' OK . Thank you . ']
['Mom , I want to get a motorcycle . Is that all right with you ? ', ' You mean a murder cycle ? Did you know more cyclists die in accidents than motorists ? ', " Mom ! I'll wear a helmet and I'll drive sane . I promise . ", " I'll tell you what . You can get a motorcycle on one condition . ", " What's that ? ", ' You spend two weeks with dad in his ambulance as an EMT trainee and volunteer at the emergency room for one month . ', ' And after that ? ', " After that , we'll let you decide if you still want a murder , I mean motorcycle . "]
['Hello , John . How are you ? ', " I'm fine , thanks . And you ? ", " Very well , thanks . Nice to see you again . I haven't seen you for a long time . What have you been doing lately ? ", ' Oh , nothing much really . And how is everything with you ? ', " Fine , thanks . I've been busy lately . ", ' What have you been doing ? ', " I've been studying for my exams . My school exams will begin next month . ", ' Really ? Good luck for them . ', ' Thanks . And how are your parents ? ', " They're both very well , thanks . ", ' Where are you going now ? ', " I'm going to do some shopping . Why don't you come with me ? ", " I can't . I have to meet someone . ", " It's been nice talking to you . ", ' Good-bye . See you again sometime . ']
["Good morning . I'd like to check out right now . ", ' May I have your room number 。 Sir ? ', ' Room 103 . ', ' Just a minute , Sir.Are you Mr Wang from China ? ', ' Yes.Wang Bin . ', ' Mr Wang , did you sign any bill in the last two hours in our hotel ? ', ' No . ', ' Have you used any hotel services this morning ? ', ' No , I have not . ', ' Here is your bill.It totals 3250 dollars . ', ' All right . Can I pay with credit cards ? ', ' What kind of card ? ', ' American Express . ', ' Yes , we do . Here is your bill and receipt . ']
['Oh , my god . I am so heavy now . I gain 10 kilos . ', ' I am going to the gym . Do you want to come with me ? ', ' I think I should go . I really need to lose some weight . ', " Then , I'll wait for you at the car park in 20 minutes . ", ' 0K.See you then . ', ' Do you have your member card with you ? ', ' Nope , I do not have a membership yet . ', ' Well I have a guest ticket . You can use it . ', ' That is so nice of you . If I like the service and the training equipment , I think I well join the club . ']
['Can you tell me the best way to see the city ? ', ' Sure , I advise the sightseeing buses . ', ' Travel by the buses ? That sounds interesting . ', " Yes of course.You can see the whole city on the bus . It's cheap as well as efficient . ", ' Oh , there comes the bus . ']
["I'm so hungry . Shall we go eat now , Rick ? ", ' sure . Where do you want to go ? Are you in the mood for anything in particular ? ', " how about some dumplings ? I just can't get enough of them . ", " dumplings again ? ! Oh , Amy , let's try something new ! ", ' well , what do you have in mind ? ', ' how about the Mongolian hot pot ? ', " oh , it's too spicy for me . Don't you remember last time when I tasted the lamb ? It was so spicy my eyes teared up ! ", ' maybe we can try Yuanyang pot this time . You can choose the non-spicy soup base . ', ' sounds great . Do they serve noodles ? I am in the mood for some tasty noodles as well . ', ' yes . The sliced noodles they offer are among the most authentic Shanti cuisines . ', " great . Let's go ! ", ' wait a minute . Let me throw on a sweater . ']
['Good morning . Could I speak to Frans Smith please ? ', ' Frans Smith ? I think you may have the wrong number . ', ' Is this Taiwan 8234342 2 , DS engineering ? ', ' It is . But there is no Frans Smith here . Do you know which department he works in ? ', ' The accounts department , I think . ', " The accounts department , no problem . I'm just putting you through now . "]
['What do you want to do in this company after five years ? ', ' I want to be in a higher managerial position in the field of international marketing . I ’ m very interested in the European market hopefully , in Brussels . ', ' Why do you think so ? ', ' It ’ s truly exciting to work in newly emerging unified market . Brussels will be center of the new market in the continent . ', ' What are you looking for in your next job ? ', ' My experience in my last job showed that I have the talent to motivate people . It could be seen from the low absentee rate in my team . I want to continue that kind of contribution and to further develop this potential . ', ' What is your career objective ? ', ' I want to apply my knowledge and experience to a challenging position and finally move on to management level . ', ' What do you consider important when looking for a job ? ', ' I think the most important thing is the nature of the job . One should never do anything one is not interested in . To me , pleasant working conditions with co-operative staff are also important . ']
['Hey ! Ask your mom for more old pictures , OK ? ', " Can't it wait ? She's still angry that we sent e-mail wedding invitations . ", ' But we saved your parents so much money ... ', " I know . And they're spending enough on the plane tickets to Texas ! ", " Speaking of plane tickets , don't forget to check on the reservations ! ", ' OK . ']
['How much will it be all together ? ', ' $ 200 , please . ', ' Can I pay by check ? ', " I'm afraid you can't , ma'am . We accept only traveler's checks and credit cards . ", ' OK . How about this card then ? ', ' We can take it . Just a moment ... Please sign here . ']
['Excuse me . My bag was stolen , will you help me ? ', ' When did it happen ? ', ' Just about half an hour ago . ', ' Tell me where it happened and how . ', ' Yes , it was just when I was walking in the park . I saw some children with a newspaper . ', ' That happens often these days . Well , please fill in this Report of Theft . ', ' I want to get in touch with the Chinese Embassy because my passport was in the stolen bag . ']
['I know in your resume that you have worked in your present company for 3 years , can you tell me why you want to leave your present job and join us ? ', ' Because the job I am doing in my present company is of no challenge , but I like challenge.Your firm is a young organisation with many innovative ideas . It has been very successful in an expanding market since its establishment 10 years ago . Working for you would be exactly the sort of challenge I am looking for . ', ' Why do you think you are qualified for this position ? ', ' I have excellent communication skills and I am familiar with the procedures for the last company I worked for . Besides , I am a team player and have great interpersonal skills . ']
['So , tell me about you new house . How is it different to your old one ? ', ' Well , first of all , it ’ s much bigger . It has the same number of rooms , but each room is larger . We also have a larger garden , which our dog loves , of course ! ', ' So , it ’ s a three-bedrooms detached house ? ', ' Yes . One bedroom is for my wife and I . there ’ s another for our daughter . My wife wants to use the third one as a guest room , but I ’ d like to make it into a study . Our daughter is also keen on making it a study , so that ’ s probably what will happen . ', ' What ’ s the kitchen like ? I know both you and your wife like to cook . ', ' That ’ s one of the main reason we chose that particular house . The kitchen and dining room are together . It ’ s really large . ', ' Are the rooms nice and bright ? ', ' Yes , they are . That ’ s very important to us . We like to live in a home with plenty of natural light . Each room has large windows . ', ' Do you have a balcony ? ', ' No , we don ’ t . We wish we had one . That ’ s the only thing we wanted , but don ’ t have . The area is very nice and the neighbours seem friendly . ', ' You ’ re right on the edge of the city , aren ’ t you ? There can ’ t be much noise or traffic there . Is it easy to get into city centre ? ', ' It ’ s a very quiet neighbourhood . There ’ s some traffic , but not much . It ’ s not very difficult to get to the city centre , but you must remember to turn left and right at the right places or you ’ ll get lost . So when are you going to drop by ? ']
["Come on , darling . We haven't got much time . ", " All right . I'm nearly ready . What time does the bus leave ? ", " Half past six ... and it's half past six already . ", " Oh , we've got plenty of time . ", " We haven't . Hurry up ! ", " All right . Let's go . ", ' And about time too ! ']
["I'd like to remit 5000 dollars to my friend . ", " Please show me your ID card and tell me the receiver's address . ", ' Room 20 , Suzie Building , Beijing Road , Shenzhen , China . ', " Ok , that's all . "]
['Would it be all right if I went home next weekend ? ', ' For What ? ', ' Well , I want to surprise my brother showing up for his birthday . ', ' Well , that sounds like it would be OK . Just be careful . ']
['Which kinds of meat are most popular in your country ? ', ' We eat a lot of chicken , pork and beef . You eat those meat a lot in your country too , don ’ t you ? ', ' Yes , we do . We also eat a lot of lamb . ', ' yes . I ’ Ve heard that people in your country like to eat lamb chops . ', ' That ’ s right . They tastes so good ! We eat them with mint sauce . Have you every tried them ? ', ' Yes , I have . I tried them when I visited your country last year . I thought they were very tasty . Can you cook them ? ', ' I certainly can . If I can get some from the butcher ’ s , I ’ ll cook them for you . ', " That sounds great . I'll bring a bottle of wine . "]
['Do you have any idea what time it is ? ', " My bad . I didn't realize that it was so late . ", ' Do you really think that that excuses your tardiness ? ', ' Of course not . I really did lose track of time . ', " Didn't I tell you to call when you're running late ? ", ' Yeah , you did . I just forgot to call . ', " It doesn't matter , you should have called and let me know . ", " That's true . My bad for not calling . ", " If you do this again , don't even bother coming home . ", " You're going to kick me out over this ? ", " Exactly , maybe that'll teach you to respect my rules . ", " Well , if I'm not living here anymore , then I won't have to listen to your rules . "]
['And so , that concludes my outline for our marketing strategy next year . Thank you very much for your time . ', " Hey , that was quite the presentation ! Honestly , I was completely blown away by your strategy outline . I've gotta say , Alex , you really wowed me today . ", " Aw , come on ; it was nothing . I'm just doing my job . ", ' No , I think you deserve some recognition here ; I mean , if I look back on your previous presentations , this is a huge improvement . ', " Well , Kristin did give me a hand with the slides.She ' s a real wiz on PowerPoint . ", ' And I saw that you took on board my feedback about pricing strategies . I really appreciate you taking the time to think though my suggestions . ', ' Yeah , well , that was some good advice . You made some really good points . ', ' Well , I just wanted to say well done . Really you did a great job . ']
['As you know I ’ Ve been thinking about moving my career in a new direction . I am hoping that you will be able to provide me with a reference to help me jump-start my future . ', " I realize that I ’ m not in a position to offer you the kind of promotion you deserve I'll gladly do what I can to help . ", " Thank you . I ’ Ve really enjoyed my time here . I've grown both personally and professionally with this company . ", ' And , as well as being a pleasure to work with , you ’ Ve been instrumental in helping us complete many key projects . ', ' It will be hard to say good-bye . This office has become like a second home to me . ', ' My feelings are mixed on the issue too . By helping you I ’ m losing a valuable and trusted employee . However I think you are taking a step in the right direction . ']
['Well , Peter , you have to do better than that next time , won ’ t you ? ', ' Have I really got to do those exams again , Dad ? ', ' Of course , you have . You must try harder this time . ', ' And must I go back to school ? ', ' No , you needn ’ t do that . You ’ d better get a part-time job somewhere and go to evening classes . ', ' But Dad , I should be working full-time at my age . I ’ m nearly 17 . ', ' You ought to have worked harder then you wouldn ’ t have failed your exams . You have to take a job and study . ', ' What else I ’ Ve got to do ? Join the army ? ', ' Who knows ! That might come to later . ']
['How do you use an ATM card , billy ? ', " It's easy grandpa . Insert you card into the machine here . Then wait a moment . Ok . Now you enter your PIN . It should have four numbers . ", " Oh yes . I've got it written down here . Just a minute . ", ' You really shouldn ’ t write it down . You should memorize it . You can change it to a more convenient number if you like . ', " Ok , I've entered my PIN . There are several options on the screen . I guess I just choose which service I want , don't I ? ", ' Yes . Choose the service you need to use . If you choose to withdraw money , the machine will ask you how much you want . ', ' I can just enter the amount using the keys , right ? ', " That's right . Give the machine a moment to process you request . Then take your money . ", " These machines aren't very difficult to use . In fact , I quite like them . They are much faster than dealing with a band clerk . "]
['How can I lose weight , doctor ? I seem to get fatter even when I just look at food ? ', ' Well , Jim . It is a combination of how much you eat , the type of food you eat , and when you eat your meals . ', ' I never eat breakfast though . ', " That's a big mistake , you should always have a good breakfast . You will not run your car without fuel , and yet you expect your body to work without food . ", ' I never thought about it that way . ', ' I bet you eat a large evening meal , then sit and watch TV or read a book . Then instead of burning off your energy , your body stores it as fat . ', ' Oh doctor , I feel so foolish . ', ' Way to control is really using common sense when you plan your eating habits . ', ' I know doctor , thank you so much . ']
['Hello , this is Francis . ', ' Hi , this is Monica . I was wondering when we can work on this financial report . ', ' Today , I am busy all day long . ', ' Shall I see you on Friday morning ? ', ' That ’ s not good for me at all . It ’ ll have to be another time . ', ' We must find some time to read report . ', ' I know . I am available from 1 PM to 4 PM on Friday afternoon . ', ' That ’ s all right . Then see you on Friday afternoon . ', ' See you . ']
['Shall I take a photo of you ? ', ' Could you ? Thank you . ', ' You ’ re welcome . What brings you to China ? ', ' I ’ m actually here on business . ', ' I see and what do you do for a living ? ', ' I ’ m an IT salesman . ', ' That sounds like a good job . ', ' It ’ s very interesting actually . ', ' Ok , well enjoy the rest of your stay here . ', ' Thank you very much . Bye . ']
['What can I do for you ? ', ' I need some medicine . ', ' For whom ? ', ' My younger brother . He suffers from a bad cold . ', ' What symptoms does he have ? ', ' Fever and a bad cough . ', " I got it . Don't worry , just a common cold . ", ' What kind of medicine does he need ? ', ' Patulin will do . ', ' How many pills for each time ? ', ' Six per day , and two after each meal . ', ' Thank you very much . ', ' My pleasure . ']
['Is this the class to prepare for interviews ? ', ' This is the right place . Please join us . ', ' I have an interview tomorrow , so I hope I can learn everything quickly . ', ' We are all going to have great interviews . What are some things that we need to remember in an interview ? ', ' I think that we should make sure that our looks are the best they can be . ', ' Right , and what about our friendliness and attitude ? ', ' Yes , and being friendly and having a good attitude also help me relax . ', ' Did you know that they pay as much attention to what you ask as to what you say in an interview ? ', ' No , I didn ’ t . What else should I keep in mind ? ', ' Just relax , listen carefully to the questions , and be honest in your responses . ']
['Has Mien sold his house yet ? ', ' Yes , he has . He sold it last week . ', ' Has he moved to his new house yet ? ', " No , not yet . He's still here . He's going to move tomorrow . ", ' When ? Tomorrow morning ? ', " No . Tomorrow afternoon . I'll miss him . He has always been a good neighbour . ", " He's a very nice person . We will all miss him . ", ' When will the new people move into this house ? ', ' I think that they will move in the day after tomorrow . ', ' Will you see Mien today , Janey ? ', ' Yes , I will . ', " Please give him my regards . Poor Mien ! He didn't want to leave this house . ", " No , he didn't want to leave , but his wife did ! "]
["Being a diabetic , you're not allowed to eat certain foods . ", ' Am I allowed to eat spicy food ? ', " I'm afraid not . ", ' Really , because spicy food is my favorite . ']
['Good evening , can I get you a drink ? ', ' Sure , I would like a Coke . ', ' Would you like to order anything off the appetizer menu ? ', " Let's see , can I get some fried zucchini , please ? ", ' Would you like to order anything else ? ', " No , that's it , thank you . ", " No problem , call me when you're ready to place the rest of your order . ", ' I would like to order my food now . ', ' What did you want to order ? ', ' Can I get a cheeseburger and some fries ? ', ' Can I get you anything else ? ', " That's all , thank you . "]
["This skirt is too tight . I would like to return it please . Do I need to go to the customer's service desk ? ", ' I can help you with that . Do you still have your receipt ? ', ' No , I receive this as a birthday present , but the price tag is still on the skirt though . Will that be OK ? ', ' Oh , yes , that will help me a lot . ', ' Do you have any more skirts in this style ? I would like to find a size larger . ', " I'm sorry . I think we're out of this skirt in this color . Do you want me to call another one of our store to see if it's available there ? ", " No , that's all right . I'll just look for something else . ", ' Well , your refund total is 50 dollars . ']
["Isn't it a nice day ? ", ' It really is . ', ' It seems that it may rain today . ', ' Hopefully it will . ', ' How come ? ', ' I like how clear the sky gets after it rains . ', ' I feel the same way . It smells so good after it rains . ', ' I especially love the night air when it rains . ', ' Really ? Why ? ', ' The stars look so much closer after it rains . ', ' I really want it to rain today . ', ' Yeah , so do I . ']
['Boy , come here ! ', ' Yes , sir ! What can I do for you ? ', ' Bring me a cup of coffee , please . ', ' Will you have it strong or weak ? ', ' I prefer strong . ']
["The car isn't running smoothly . I'd like to have a look at it . ", " What's the matter with it ? ", " I'm not sure . It could be the tires . Let's stop here . ", ' How about the tires ? ', ' Nothing serious . The right one needs some air . ']
['I can ’ t decide what to do today . ', ' Well . Let ’ s go swimming . ', ' Don ’ t you think it ’ s a bit cold for that ? ', ' Then why don ’ t we go for a walk in the hills . It ’ d be very good for us you know . ']
['Excuse me ! Are you Bart Simpson from Western Electronics ? ', ' Yes , I am . ', ' I am Steven . I am here to meet you . ', ' Thank you for meeting me at the airport , Steven . ', ' You must be tired after the long flight . Let me carry the bags for you . ', ' Thanks . Where is our car ? ', " Our car is in the parking lot . We've booked a room for you . I will take you to the hotel soon . Let's go . ", " OK . Let's go . "]
['Hello . May I help you ? ', ' Hi . Last month , our company , Turner Interiors of Beijing , ordered some documents under our new L / C . What I want to do is check and see if the documents have arrived yet . ', " Let me find that on my screen ... yes , the L / C is right here . I'm sorry ; the documents don't seem to be here yet . ", ' Oh , dear . When do you think they will arrive ? ', " It should be around 5 working days , but different cases take different times . Sorry I can't be more precise . "]
['Excuse me , where is the Beijing Railway Station ? ', ' You can take the subway to get there . ', ' How long will it take to get there ? ', ' It takes only ten minutes . ', ' May I take a bus or a taxi to get there ? ', ' You can take No . I bus or a taxi . ', ' Excuse me , sir . Where is the No . 1 bus stop ? ', ' Please turn right at the traffic lights . ', ' Thank you very much . ']
['Excuse me , sir . Can I help you ? ', " I'd be glad to have your help . Could you make the air-conditioner cooler ? ", " I'm sorry . We can not regulate the air-conditioner . As soon as the plane takes off we'll be able to get better ventilation , and the temperature here will drop . Let me get a wet towel for you at the moment . ", ' Good idea . ', ' Your wet towel , sir . ', ' Thank you . Could I have something cold to drink ? ', ' Yes . We have mineral water , orange juice , coke , which do you prefer ? ', ' Orange juice , please . ', ' Would you like some ice in your drink ? ', ' Yes . ', ' How much would you like ? ', ' One or two cubes will be OK . ', ' Here you are , sir . ', " I'm awfully sorry to have bothered you . ", " It's my pleasure . ", ' Please accept this tip . ']
['Did you make it to school today ? ', ' I always do . Did you go to school today ? ', " No , I didn't . ", ' You should have , but have you seen any movies lately ? ', ' That was an odd change of subject . ', ' Maybe it was , but answer the question . ', ' No , not recently . ', ' I want to go to see a movie this weekend . ', " What's stopping you then ? ", " I don't want to go alone . ", ' So , will you be at school tomorrow ? ', ' No , I want to go to the movies instead . ']
['You have the right to remain silent . Anything you say can and will be used against you in a court of law . You have the right to have an attorney present during questioning . If you cannot afford an attorney , one will be appointed for you.Do you understand ? ', ' Yes . ', " What's your name ? ", ' My name is James . ', " What's your nationality ? ", ' American . ', " What's your relationship with the victim ? ", " I don't know him . ", ' Why did you attack the victim ? ', ' Because he beat me first when I tried to stop him from grabbing my bag and running away . ', ' How many times did you stab the victim ? ', ' I stabbed his belly three times . ', ' Did you know hat your actions might cause serous injuries or death ? ', " I knew , but I couldn't myself . ", ' Was it your intention to kill the victim ? ', " No . I didn't kill him on purpose , madam . It's him who caused the incident . I need to see my attorney . ", " OK.Give me his number and we'll contact him . "]
["Well , Peter . I'm sorry you're ill . What's the matter with you ? ", " I don't know , Doctor . I'm ill . I have a headache and a stomachache . ", ' Show me your torgue.What did you eat yesterday ? ', ' Well , Doctor , I . . . ', ' Did you eat any cake ? ', ' Yes , I ate some cake . ', ' Did you eat any ice cream ? ', ' Well , yes , I did . I ate some ice cream . ', ' Did you eat any candy ? ', ' Well , yes , I did . I ate some candy . ', ' Young man , tell me everything you ate yesterday evening . ', ' weki , Doctor . I went to a birthday party . ', ' I see ! How many pieces of cake did you eat ? ', ' Three , Doctor . ', ' How many plates of ice ream did you eat , young man ? ', ' Gosh , Doctor . I had only three plates of ice cream.John had four . ']
['Excuse me . Can I ask you a question ? ', ' Sure . What is it ? ', " I don't know how to say it in English . ", " We call this a ' parking meter ' . ", ' Oh , Thank you . But how do you spell it ? ', ' P-a-r-k-i-n-g m-e-t-e-r . ']
['Excuse me . ', ' Yes ? ', ' How do I get to the Olympic Stadium , please ? ', ' It ’ s not far . Go straight on then turn right at the end of the road . ', ' Thanks . ', ' You ’ re welcome . ']
['Have you ever thought about your ideal home ? ', ' I have , actually ; I ’ Ve always wanted to build my dream home myself . ', ' What would it be like ? ', ' Well , it would be spacious and located next to a park , because a nice view is important to me . ', ' How many rooms would it have ? ', ' I ’ d want it to have three bedrooms on a second floor with balconies on each , and one main bedroom on the main floor with an attached en suite . I ’ d also want a large living room and kitchen connected to each other so that there would be one large open space for people to spend time with each other . ', ' How many bathrooms would your dream home have ? ', ' I ’ d have one guest bathroom in the basement , one attached to the main bedroom , and one upstairs , so a total of three . ', ' How would you decorate your house ? ', ' I don ’ t like a lot of clutter , so I wouldn ’ t have lots of things out . I would have a few vases on the mantel piece and some pictures of my family on the walls , but other than that , most things would be kept in closets . ', ' How many TVs would your dream home have ? ', ' I think TV is a great waste of time , so I would only have one small TV in the kitchen to watch the news in the morning . ']
['We have a variety of trousers . Which one do you like best ? ', ' I want to buy one to match my shirt.Can you give me some advice ? ', ' What about this one ? ', ' Yes , they seem to be my size and go with my shirt quite well . I will take it . ']
['Where is the bus ? ', " I think it's running late . ", " It should've been here 30 minutes ago . ", ' It should be coming soon . ', " It better , because I'm already late for work . ", " I can't stand riding the bus . ", " Me too , it's so unreliable . ", ' That is true . ', " It's also horrible having to be at a bus stop in any kind of weather . ", " Exactly.That ' s the worst part . ", " I think it's time we started driving . ", ' Yes , I agree . ']
['I don ’ t know what activity my son should take part in ? ', ' Many children are learning drawing , dancing , swimming and so on in their spare time . You can follow suit . ', ' But each children has his own interest . ', ' Well , you should talk with your son and let him make his own decision . ']
['Hello , this is Lin Tao . I am calling to inquire about my interview result last week . ', " Hi , I am sorry to say that your experience doesn't fit the job at all . ", ' Sorry to hear that , but could you inform me why I failed ? ', ' I have to say your education and experience are very outstanding , but it seems that you are not good at working in a team which we attach great importance to . ']
['What is your major ? ', ' My major is Business Administration , I am especially interested in Marketing . ', ' Which university are you attending ? ', ' I attended Suzhou University . ', ' Have you received any degrees ? ', ' Yes . I received my Bachelor degree in Business Administration . ', ' What course did you like best ? ', " Project Management . I was very interested in this course when I was a student . And I think it's very useful for my present work . ", ' Do you feel that you have received a good general training ? ', ' Yes , I have studied in an English training program and a computer training program since I graduated from university . I am currently studying Finance at a training school . ', ' English and computer skills are comparatively important to this post , especially in the starting period . Wharfs your ability in these two fields ? ', " I passed college English Test Band - 4 , with good skill in listening , speaking , reading and writing . I haven't got any certificate of computer skills , because I don ’ t think certificates are necessary if what's needed is merely operating a computer . I think , to know how to use a computer is more important . And I'm quite familiar with Microsoft Office "]
["Excuse me , what's the price of a single room ? ", " That's $ 50 for a single night . ", ' Are meals included ? ', ' Yes , of course . Can I make a reservation for you ? ', ' Fine , I want to book one for overnight . ']
['When can you get the finished product to me ? ', ' We should have it put together by the end of next week . ', " Great ! That'll be ahead of schedule ! Good work . ", ' Well , as the saying goes – we aim to please ! ']
['I like double-breasted garment with no belt.Could you show me some ? ', ' Here you are.Which size do you wear ? ', ' Medium.May I try it on ? ', ' Of course.You look terrific in it ! ']
['Hello ? ', ' Hello ? ', ' Can I speak to Li Hong , please ? ', ' Speaking . ', ' Hi , Li Hong.This is Alice . ', ' Hi , Alice.How are you ? ', ' Not bad.Li Hong , I am sorry that I can ’ t go to see Mrs.Brown with you tomorrow morning.My mother is ill . I must take care of her . ', ' I ’ m sorry to hear that.You ’ d better stay at home.After all , we can visit Mrs.Brown later ', ' OK.Bye - bye . ', ' Bye . ']
['Excuse me , is this the office of the Textile Corporation ? ', ' Yes , What can I do for you ? ', " I'm from CTC Trade Company . Here is my card . ", " Welcome to our corporation . I'm in charge of the export business . ", " I'm glad to meet you here . You're Ms . ... ", " I'm In Hui . Do sit down , won't you ? ", " Thank you , Ms . In . I'm here to discuss the possibility of establishing business relations with your corporation . ", " We'd be very glad to do so . Have you seen the exhibits displayed in the hall ? ", ' Yes , I had a look around yesterday . I wish I could have them all . Can you give me a price list with specifications ? ', ' Yes , of course . If you make an inquiry , we can make you a firm offer . ', ' Thank you very much . ']
['Please show me that hat , please . ', ' This one ? ', ' No , the one next to it . ', ' The mirror is behind you , sir . ', ' Is this a furry hat ? ', " No , sir . It's a genuine bonnet . ", ' Are you sure ? ', ' Yes , sir . ']
['Anna , Would you like to dance ? ', ' I ’ d love to , but I ’ m a terrible dancer . I ’ m afraid I may step on your toes . ', ' Don ’ t worry about it . I ’ ll show you how . It ’ s a piece of cake . ', ' Thank you . I ’ ll try my best . ']
['Mary ! I haven ’ t seen you since our dinner with Mr . Lee last week . Where have you been hiding yourself lately ? ', ' Oh , hi Mike . I ’ Ve been out of town the last few days . What did you need ? ', ' Really , nothing big . I just heard about your ideas on employee motivation and I wanted chat with you about a few things going on in my department . ', ' Well , feel free to drop by my office any time . The door ’ s always open . ', ' Actually , I was hoping to mix business with pleasure . Would you be interested in joining me for dinner some time this week ? I thought we might try out the new Italian restaurant everyone ’ s been ', ' Sure , Mike , I ’ d love to . ', ' Is this evening too soon ? ', ' No , that ’ s perfect . We can leave directly from here . ']
['Hi , Lucy , you are very popular with people around you , what are your tricks ? ', ' Thank you for saying so . I don ’ t know , probably because I like sharing my experience and knowledge with them . I think this kind of communication helps to improve our work efficiency and also helps to get along with colleagues . ', ' Sharing knowledge can be very settled and some second stances . People may think you are telling them how to do their work . If they take it personally , they feel angry at you and even become reluctant to support you at work . ', ' That is true . Some people will misunderstand your intention and lets you do it in the long threatening way . For example , it is not sensible at all to arguing with the others or correcting someone in front of other people . To show your friendliness and willingness to share is much more important than to show off . ', ' You are quite right . Thank you for sharing your experience with me . I learned a lot . ', ' You ’ re welcome . ']
['Is there anything I can do for you ? ', ' I want to have a trip to Sydney . ', ' Sure . How long is your vacation ? ', ' 3 weeks ', ' Well , how do you like this one ? You will stay there for 17 days . ', " It's good . By the way , what kind of clothes do I have to bring with me ? ", " It's summer in Sydney so you have to bring your summer wear . "]
['The new computer software is driving me crazy ! I really need a break ! ', ' I know what you mean , Carol . I ’ Ve had nothing but trouble with it . They say it ’ s supposed to be easy ! ', ' That ’ s what I ’ Ve heard . But as far as I ’ m concerned , it takes a genius to figure it out . Can you pass the sugar , please ? ', ' Sure . Why don ’ t you sit down for a minute ? You haven ’ t taken a rest all morning . ']
['Hi , I am afraid that the fax machine in my room won ’ t be working till tomorrow . A technician has just come and checked it . He will bring me a new one tomorrow . It seems there is a big problem with mine and it will take some days for repairing . Can I use the one in your office ? ', ' Of course you can . I am sure this one works very well . I just sent dozens of pages . How many pages are you sending ? Are you familiar with my fax machine ? ', ' Yes , I think you have the same model as I have . Does your fax machine print out immediately a transmission protocol ? ', ' Yes , it will print immediately . ']
["I'm looking for a white purse as a gift . Could you show what you have in stock ? ", ' You are in luck . We just receive a shipment of several different styles of white purses . ', ' They must be popular again this season . ', ' Yes , I believe they are . Here are something that might interest you . ', " Wow . this is nice . I'll take this one . I guess if she doesn't like it she can return it , right ? ", ' Sure . Let me ring this up for you at the register . If you would like , this can be gift-wrapped for free . Just take it to the customer service department . ']
['Do you mind if I get a lift in your car , please ? ', ' I don ’ t see any problem ; only the car is a bit old . ', ' Oh you ’ re so kind ! ', ' Get in . ']
["Hello , I'd like to subscribe to a magazine . ", ' What magazine do you want to subscribe for ? ', ' Fitness Consultant . ', ' OK , Fitness Consultant . How many subscriptions do you want ? ', ' Only one , please . ', ' How long do you want the subscription for ? ', ' For six months , please . ', ' Your name , please ? ', " Shirley , that's my wife's name . I subscribe to this magazine for her . ", ' I see . Please put your address here then . ', ' OK . How much is the subscription ? ', ' 650 Yuan . ', ' 650 Yuan ! You must be kidding ! I can subscribe for evening newspapers for ten years with that much ! ']
['Oh . It looks like Jack is going to make his annual speech . ', " Couldn't he wait until we're finished eating ? ", " Yeah . I'm still hungry , but I guess it's kind of rude to keep eating while he's talking , huh ? ", " Can you even hear what he's saying ? ", " No . He's so far away I can hardly see him ! Let's keep eating ! ", ' Can you turn the lazy Susan for me ? I want some more chicken . ', " All that's left is a leg . I gave the head to Tim ! "]
['Will they send me a form telling me that I have been granted unemployment ? ', ' A Notice of Unemployment Insurance Award letter will be sent to you . ', ' What information will be in that letter ? ', ' The Award Letter will inform you as to how much you will receive . ', ' What other forms will I need to turn in ? ', ' Every two weeks you will receive a Continued Claim Form that you must turn in . ', ' What will they be asking me on that form ? ', ' You must show that you were available and that you looked for work . ', ' What else will they ask me ? ', ' One of the questions they ask you is if you were well enough to work . ']
['Mr . Smith , I have been doing some industry research and was shocked to learn that the average salary for a position that is similar to mine pays on average $ 2,000 more per year than I am c ', ' What are you basing this information on ? ', ' First and secondary research . I hope that you can address this concern immediately as i find it very disturbing . ', ' Yes , I will.We are very happy with your performance and want to continue our woodworking relationship . ', ' I wish the same . As such , I hope you will seriously consider a pay increase . ', ' Let me take this up with the Director and get back to you immediately . ']
['What can I do for you ? ', ' Yes . There is something wrong with my watch . It stopped several hours ago . ', ' Let me have a look . Oh , the watch ’ s battery is worn down . ', ' How much is a battery ? ', ' $ 50 . ', ' How long will it last ? ', ' About 2 years . ', ' Here is the money . ']
['when are you going to give me those brochures ? ', ' What ’ s the rush ? You ’ re not leaving for another week . ', ' I know , but I want to make reservations this week . ', ' Okay . I ’ ll bring them in tomorrow for sure . ']
['Julia , I would like to have a word with you . Have a seat . ', ' Thank you . ', " According to your performance , I decided to give you a salary increase . From next month , there will be a 2,000 yuan raise to your salary . Although your first raise might not sound considerable , the company believes that with your ability , sooner or later you'll get a better raise . ", ' Thank you very much . Mr . George . As a newcomer , I understand that you have your consideration and I am satisfied with the raise . ', ' I think you deserved this . ', " Thank you again . I'll keep doing my best . "]
["Albert and I need a lot of things to furnish our house.But I don't know where the best place to shop is . Can you give me some advice ? ", " Sure , Carolyn . I'm happy to help you.What kinds of things do you need right now ? ", ' Well , we have most of the furniture already.We mostly need kitchen utensils , bathroom accessories , cleaning and laundry accessories--things like that.And Albert wants to set up a little off ', " Well , as for Albert , he should go to an office supply store.There ' s a very good one called Office Depot . They have everything he will need.And their prices are good too . It's very convey ", ' Can I write that down ? ', " Sure , it's spelled Office and then D - E - P - O - T.It ' s in the Yellow Pages . ", ' Thanks . ', ' And as for the kitchen things , do you want very high quality ? ', ' What do you mean ? ', ' I mean , do you want the best quality , or do you want good prices ? ', ' Probably good prices . You know we will only be in America for about a year . ', ' Then I suggest you go to K-Mart or Wal-Mart . ', ' What are those stores ? ', ' They are very large , discount department stores.That means their prices are very good.And you can find everything you need for the kitchen or bathroom . ', ' Even silverware ? ', " Yes , everything.They don't have the most expensive brands , but their quality is usually decent.The main thing is , they have good prices , and they are very convenient . ", ' I have a friend that said something about a place called Price Club.Do you know about that ? ', ' I have never shopped there , but I think Price Club is a kind of membership store . ', ' What does that mean ? ', ' That means you have to pay a membership fee to shop there . I have heard they have very good prices on electronics . ', ' Electronics ? ', ' Yes . Like stereos and televisions . ', ' How much is the membership fee ? ', " I'm not sure.But if you are only going to stay a year , I don't think Price Club is good to join.They have great deals occasionally.They are very good for people who like to buy new things all ", ' I see . Thanks for these tips . We really need to buy a lot of little things . ', ' I know how it is . Moving is very troublesome . ']
['it ’ s such a nice day outside . Let ’ s take a walk into town and do some window-shopping . ', ' you know I hate shopping more than anything else in this world . ', ' I know . But we could get some exercise in , and we could get some errands run , too . Window-shopping won ’ t cost you anything . ', ' what kind of errands do we need to run ? ', ' well , we could go to the newsagent ’ s to pick up the Sunday paper , go to the butcher ’ s to pick up a chicken for a roast dinner , and to the chemist ’ s to pick up your prescription from the doctor . ', ' I ’ ll only go if we can stop at the office-license to pick up something to drink for tonight . ', ' fine , we ’ ll do that on the way home , so we don ’ t have to carry it the whole time . ', ' sounds good . You have to promise not go into any of the stores in the mall though . I know how you like to try things on in the fitting rooms , especially if the stores have special offers . ', ' I promise . We ’ re only going for a walk to get some exercise and to get some things done that we haven ’ t had time for . ', ' ok , let ’ s go then ! ', ' do you have any money ? ', ' for what ? ', ' for our errands , and maybe a little extra for something from a vendor on the street . ', ' you said you were only going to window shop ! ', ' I agreed to not go into the mall , but I can still look at things in the market ! ', ' I should have known ... ']
['Is there a daily passenger ship to Dalian ? ', ' Yes . ', ' How many days does it take to Dalian ? ', ' About one day . It arrives in Dalian at 10:00 a . m . tomorrow . ', ' How many ports do we call at on our passage to Qingdao ? ', ' Four ports . ', ' The ship is going very fast . ', ' Perhaps she makes about 25 knots an hour . ', ' The sea is calm and peaceful . A sea trip is always enjoyable in fine weather like this . ', ' Yes . I hope it will remain fine all the way . ']
['Dad , can I have a pet ? I did what you said and passed all of my exams . ', ' Then I guess you get to have a pet . Do you know what you want ? ', " I want a dog . My friend Mindy's dog just had puppies and she said I can have one . ", ' You know who will be responsible for feeding and cleaning and all of that stuff ? ', ' I know , I know . I will do it all by myself . ', ' Have you figured out the costs involved with feeding and caring for it ? ', ' Yes . It will cost me about $ 50 a month . And I make a little more than that already . ', " Sounds like you've done your homework . I think you're ready for this . "]
["This place is great . I'm surprised there are so many things here . ", " Yes , but it takes a while to find things . It's not organized as carefully as a regular store . ", " What's the difference between an outlet and a regular store ? ", ' Usually a clothes company will send their overstock to an outlet . The prices are very low . But you may find faulty products here too . ', ' Faulty products ? ', " Yes . Sometimes the fault is very small ; if you have a needle and thread , you can fix it yourself . So it's a good deal to buy it . ", " Oh , that's easy for me . I think it's really a good deal . ", ' Yes . You can save a lot of money in this way . ', " That's great for me . Look , children's clothes ! I'd like to buy some winter clothes for my son and daughter . ", ' Why not buy the sweater ? It only costs 30 Yuan . ', " Yes , I'll take it . Are there any jeans ? Xiaohui's jeans are always dirty . I also need four pairs of slippers . ", ' How many do you want to buy ? ', " I ought to make the most of it while I'm here , don't you think ? ", " You're right . "]
['What is your great struck ? ', ' I think I ’ m very good at planning . I manage my time perfectly , so that I can always get things done on time . ', ' Why do you think you be a good fit or this job ? ', ' Because I ’ m very competent in this area . ', ' Can you working under pressure ? ', ' Yes , I work well under pressure and find it dimly . However , I believe planning and probable management of my time can reduce tight deadlines . ', ' Are you more a follower or a leader ? ', ' I don ’ t try to go ahead of people and lead them , I ’ d rather cooperate with everybody else and get the job done by working together . ']
['Ouch , it ’ s unbearable . ', ' Please keep calm . I know the pain isn ’ t what flesh and blood can stand . But be brave . ', ' All right , doctor . But it really hurts . ']
['Have you obtained any certificate of technical qualifications or license ? ', ' Yes , I have received an Engineers Qualification Certificate and a drivers license . ', ' How many years have you had the drivers license ? ', ' I have two years driving experience . ', ' That ’ s good . What special skills do you have , can you tell me ? ', ' I have experience in computer operation , proficiency in Microsoft Windows , Microsoft Word and Microsoft Excel . ', ' What computer languages have you learned ? ', ' Visual C + + , C and Delphi . ', ' Have you gotten any special training in programming ? ', ' No , but I have database programming experience and network knowledge . ']
['Hi , how are you doing ? ', " I'm fine . How about yourself ? ", " I'm pretty good . Thanks for asking . ", ' No problem . So how have you been ? ', " I've been great . What about you ? ", " I've been good . I'm in school right now . ", ' What school do you go to ? ', ' I go to PCC . ', ' Do you like it there ? ', " It's okay . It's a really big campus . ", ' Good luck with school . ', ' Thank you very much . ']
['How many languages can you speak ? ', ' Besides Chinese , I can speak English and French . ', ' You mean you can read and write both of them ? ', ' No , I can only carry on a simple conversation in French . ', ' Can you read and write English well ? ', ' I can speak the language better than I read and write . ', ' Do you speak the language well enough to communicate with people of English-speaking countries ? ', ' I think so . I used to be an interpreter . ', ' Do you think your English is good enough to do desk work ? ', ' The amount of English I know enables me to do general desk work . I believe what I know is sufficient to work in an American firm . ']
['So , Lauren , I just wanted to talk to you quickly about our new customer support representative , Jason Huntley . ', ' Sure , what ’ s up ? ', ' Basically , I ’ Ve got a few concerns about him , and the bottom line is , I don ’ t think he ’ s a good fit for our company . ', ' Okay ... what makes you say that ? I thought you were pleased with his overall performance . Didn ’ t you just tell me last week how impressed you were with his attitude ? ', ' Yeah , his attitude is great , but he ’ s really unreliable . Sometimes he ’ s really productive , but then other times ... take last Tuesday for instance , he was forty-five minutes late for our morning meeting ! ', ' Well , I ’ m sure he had a perfectly good reason ... ', ' But that ’ s not the only thing ... you know , he really doesn ’ t have the best work ethic , I ’ m constantly catching him on MSN and Facebook when he should be talking to clients . ', ' Yeah , but come on , Geoff , as if you don ’ t check Facebook at work . Look , you hired this guy , we ’ Ve invested a lot of time and money in his training , so now it ’ s up to you to coach him . Make it work , Geoff ! ']
['Hello , reservation desk . How can I help you ? ', ' I ’ d like to book a room . ', ' What kind of room would you like , Ma ’ am ? We got single rooms , double rooms , standard rooms , suites and deluxe suites . ', ' What ’ s the rate for a standard room ? ', ' $ 79 a night . ', ' I ’ d like a standard room . ', ' What date would you check in , Ma ’ am ? ', ' December 23rd , please . ', ' How long do you plan to stay ? ', ' 4 days . ', ' Could you give me your name and phone number ? ', ' Nancy Brown . My phone number ’ s 709 678 5634 . Nancy Brown 。 ', ' Thanks . What time will you arrive ? ', ' Around 3pm . ', ' Very good . Your reservation confirmation number is NB13579 . Thank you for booking in our hotel . Can I help you with anything else today ? ', ' No , that ’ s it . Thank you very much . ']
['Tyler residence . ', ' Is this Naomi ? ', ' No , this is her sister , Nancy . ', ' You sure sound like Naomi . ', ' Oh . Can I take a message ? ', ' Sure . Please tell her that Andy called . ', " Okay . I'll give her the message . ", ' Thanks . ', ' Bye . ']
["Hello , I've got a letter here that I'd like to post . ", " Yes , where's it to , madam ? ", " Well , the letter is going to a friend of mine in America and it's quite urgent . It really needs to be posted today , so here you are . ", ' You want to send it airmail , madam ? ', ' I do want to send it airmail , yes . ']
["Excuse me . I've been waiting here for 15 mins . Do you know how often does No . 3 run ? ", ' Oh , it runs every 20 mins . You must have missed it , when you came here . It should be here any minute now . ', ' It seems that you have got here at a good time . Do you have a bus schedule ? ', ' Yes , I do . You can go to the Transport Department to get yourself a bus schedule and a bus route map . ', ' I see , thank you . ']
['Excuse me . Where can I buy some cigarettes ? ', ' There is a shop on the ground floor . It sells both Chinese and foreign cigarettes . ', ' Can I also get some souvenirs there ? ', ' Yes , sir . There is a counter selling all kinds of souvenirs ', " By the way , where is the men's room ? ", ' There is one at the end of the corridor . ', ' Thank you . ', ' You are welcome . ']
["Well , that's all for the interview . Thank you for your interest in this job . ", ' You are welcome . Thank you for taking time out of your busy schedule to interview me . ', ' May I call you about our final decision ? ', ' Yes , please . My telephone number is 2974-5328 , and you can call me at any time in the daytime . ', ' We will get in touch with you by the end of next week . ', ' Great . I will look forward to hearing from you . And do I need the second interview ? ', " We'll notify you if necessary . Goodbye . ", ' Goodbye . ']
['Would you like to go sightseeing tomorrow ? ', ' Not a bad idea ! ', ' What would you like to see in Beijing ? ', " Well , let me see . I'd like to go to the Great Wall , the Summer Palace , the Forbidden City and the Temple of Heaven . ", " OK . I'll pick you up here tomorrow . "]
['You ’ re home late today , David . How was school ? ', ' Not bad . There ’ s a new English teacher . ', ' Oh , what ’ s she like ? ', ' She is beautiful . ', ' Is she old or young ? ', ' She is quite young and her hair is blond . ', ' Is she strict ? ', ' Not really . Her eyes are blue . ', ' Can she speak Chinese ? ', ' Not much . She is very tall and slim . ', ' David , stop dreaming . It ’ s time to do your homework . ']
['Can I take this bus to city center ? ', ' Can you tell me the exact place ? ', ' The Empire Hotel . ', ' Yes . But this one is full , you have to wait for the next one . ', ' Well . I think I will wait . ']
['Good afternoon , madam . May I help you ? ', ' Do you have some new perfume ? ', " I am sorry , madam . I didn't hear you . It's too noisy here . Could you please say it again ? ", ' Well , I wanna buy some new perfume . ', ' Would you please wait a minute ? I will get one for you at once . ', " That's all right . ", ' Here you are . ', ' Can I open it ? ', ' Yes , certainly , madam . ', ' It smells sweet . ', " Yes , it is . This perfume just arrived yesterday , and it's the latest products of Chanel . ", ' Really ? How much is it ? ', ' 55 dollars , madam . ', ' Ok , I will take two bottles . ', ' Thank you . Do you need something else ? ', ' No , thanks . ']
['Excuse me . Could you tell me how to get to the post office ? ', ' Of course . Turn right at the next intersection and go straight . The post office will be on your left ( side ) . ']
['Will you look at this form ? ', ' Are you having problems with it ? ', " I don't understand some things . ", ' Let me help you . ', ' What does MI mean ? ', ' MI stands for Middle Initial . ', ' What does MM / DD / YY mean ? ', ' That means Month / Day / Year . Use numbers . ', " I don't understand . ", ' For example , if your birth date is January 12 , 1987 , write 01/12 /8 7 . ', " Oh . That's simple enough . ", ' Always print clearly , and fill in the bubbles completely . ']
['How much is the video camera ? ', " $ 250 . It's Sony made in Japan . ", ' It is cute . I will take it . Please make out the receipt . ', ' OK , sir . Here you are . There is a one-year warranty . ']
['Is breakfast served here ? ', " Yes.That ' s from 6:30 to 9:00 in the dinning room . ", ' Do I have to pay extra money for it ? ', " No , it's already included in your room fare . ", ' Thank you . ']
['Good afternoon , sir . Would you like a tea ? ', " I'd rather have a cup of coffee . ", ' Of course sir , would you like milk and sugar with that ? ', ' Yes , please . Milk and two sugar . ']
['Mom , I hate eating vegetables ! ', ' You don ’ t have to eat them . I don ’ t mind . ', ' Thanks , Mom.Can I have dessert now ? I love chocolate cake . ', ' No dessert for you unless you eat all of your vegetables . ', ' But I don ’ t like them.It ’ s not fair . ', ' You can have some fruits for dessert.If you eat an apple and a banana , I might let you have a small piece of chocolate cake . ', ' Ok , actually I don ’ t mind eating peas and carrots.But I hate broccoli and cauliflower . ', " I'll remember that for next time.You ’ ll get extra peas and carrots , but no broccoli or cauliflower , ok ? ", ' Thanks , Mom ! ']
["We're sorry , but we cannot allow your claim . ", ' Why not ? ', ' The material was not damaged by us . ', " We'll have to talk this over some more . "]
['Hello , can I help you ? ', " Yes , please . I'd like to make a reservation from Hong Kong to Tampa with a stopover in Houston . ", ' When to leave ? ', ' I would like to leave Hong Kong September the first and leave Houston for Tampa on September the 12th . ', ' Ok . Can I have your name , please ? ', ' Lily Smith . ', ' And your telephone number ? ', ' Hong Kong side 3854295 . ', ' OK . Right then . ', ' Thank you . ']
['Why do you stop me ? ', ' You have gone against the traffic rules . ', " I'm sorry . ", ' Do you know this is a Onaway street ? ', " I don't know . ", ' You have to pay a fine . ']
["Good evening , ma'am . May I help you ? ", " Yes . I'd like to use a safety deposit box . ", ' Will the object fit into this size of box ? ', " Let me see . I think it's OK . ", " Could you fill out this form , please , ma'am ? ", ' Here you are . ', " Thank you , ma'am . Would you like to use it until May 20th ? ", ' Yes . ', ' This way , please . Your box number is 522 . ', ' Thank you . ', ' If you would like to use the contents during the period of use , please come here in person . After confirming your signature , we will open the box . ', ' I see . Thank you . ']
['Where are you going ? ', ' I have to go to work . ', ' Going to work where ? ', ' I ’ m working at the polling place . ', ' I didn ’ t know you were working there this year . ', ' I work at the polling place every year . ', ' How did you get that job ? ', ' I signed up for it online . ', ' That ’ s really cool . ', ' It ’ s a very cool job . ', ' Do they pay you a lot ? ', ' They pay well enough . ']
["I'd like to check in , PLS . ", ' Awfully sorry , sir . There are no rooms available now . ', ' But I ’ Ve reserved a room the day before yesterday . ', ' Sorry , may I have your name ? ', ' Tony Bush . ', " Pls wait a minute , let me check . Excuse me , but I can't seem to find your name on our list . Are you sure you have a reservation for tonight ? ", ' Of course , I did it myself . ', ' I am terribly sorry . There must have been some mistakes . Let me check it again . Oh , yes , there is a name listed as Tommy Bush . It must be the fault of the clerk who registered your name . I apologize . ', " Don't worry about that . ", ' According to the records , your reservation is for a single room with shower and air conditioners for two nights . The room rate will be 110 dollars per night , including 10 % tax and 4 % service charge . Is this right ? ', " Yes , that's right . I'd like to pay my bill by credit card . ", ' May I make a copy of your card ? ', ' Here you are . ', ' Ok , now could you fill out this registration form ? ', ' All right . ', ' Your room number is 707 . Here is your key . The bellhop will help you carry the suitcases to your room . Have a nice evening ! ']
['How do you do ? I need your help in selecting a foreign market to invest ! ', " Fine . I have your letter and I've made some notes . ", ' How can I find out what countries to invest ? ', ' We have quite a lot of import and export information and can give you figures on population , consumption , production , and foreign exchange reserves . ', ' Great . I want to get an idea for the purchasing ability in various countries . ', " But you're also going to have to give some attention to trade restrictions . You can get much information about environment of investment . "]
["Let's see if we can reach some sort of agreement over your curfew . ", " Okay . Everyone else's parents let them stay out until two or three in the morning . ", " Well . I'm not everyone else's father . I think you need to be in the house by ten o'clock . ", " That's absurd . ", ' I know some junior high kids who can stay out later than that . ', " I'll be worried if you stay out late . ", " Okay , how about a midnight curfew ? And I'll let you know where I am . "]
["Darling , can't you stay for a few more days ? ", " I can't . I've got to attend a meeting in London . ", " I'm really going to miss you.Take care of yourself . ", ' I will . ']
['Excuse me . Do you happen to have a gym here ? ', " Yes , sir . I think you'll find our gym quite satisfactory . ", ' So , where do I go to exercise ? ', " It's only one flight down , sir . Just take the elevator or the stairs . ", ' Am I going to be charged extra for using the gym ? ', ' Sir , you can use the gym for free . All you need is your room key . ', ' Great ! Now tell me , what are the hours of this gym ? ', ' Sir , our gym is open around the clock , every day of the week . ', ' Okay . Do you have a trainer to help me work out ? ', " I'm sorry , sir , but we have no trainer . "]
['Ten sheets of rice paper , 25 brushes , two boxes of oil color and two boxes of water color . All these come up to $ 35.50 , sir . ', ' Ok , here is $ 50 . Oh , can you make out an invoice for me ? ', ' Sure , just a minute . Are you an artist , sir ? ', ' No , I am a teacher . I teach art . ', ' That must be a very interesting job . ', ' It is . You must be new here . I do my shopping here regularly , once a week . ', ' Do you ? Nice to meet you ! And here is the invoice and your change . ', ' Thank you . Nice to meet you , too . ']
['Excuse me . Is this the right way to the museum ? ', " I'm afraid you're going in the opposite direction . Go back the way you came , and take the second turn on the left . The museum is straight ahead , right in front of you . ", ' Will it take me long to get there ? ', " Well , it's about fifteen minutes ' walk . ", ' Which bus goes there ? ', ' You may take a No . 34 bus . And the subway can also take you there . ', ' Thank you very much . ', ' My pleasure . ']
['What kind of food do you like ? ', ' I like Chinese food . ', ' But your American ? ', ' We have a lot of Chinese restaurants in America . ']
["I've typed the report . ", ' Well done . ', " And I've filed the letters . ", ' Excellent job . ', " And I've checked the orders . ", " I'm very impressed . ", " And I've ordered the supplies . ", ' Congratulations . You should be very proud of yourself . ']
['Are you sure that this bus will take us to Santa Anita mall ? ', ' Yes , it will . ', ' You know that for a fact ? ', ' Yeah , I take this bus all the time . ', ' Is it a very long bus ride ? ', " It's about thirty minutes long . ", ' Do you know where we get off at ? ', " There's a bus stop right behind Macy's . ", " Really , there's a bus stop right by the mall ? ", " There's a bus stop in the mall parking lot . ", " That's convenient . ", ' Absolutely . ']
['Hi , Jone , how are you ? ', ' Terrible . ', " What's wrong ? ", ' Someone robbed my apartment last week . The robber took $ 550 . ', ' Oh , no ! Did you call the police ? ', ' No . ', ' Why not ? ', " My English isn't very good . I didn't know what to say to them . ", " I'm going to give you some advice , Jone.If this happens again , you should call the police immediately . You should try to remember everything . You should explain everything to the police . "]
['This is our main service area . We do all the routine services here and have two full-time mechanics . ', ' How often do you service the vans ? ', " They're serviced regularly . We give them a basic service every 10,000 km or so and a main service once a year , or every 100,000 km . ", ' I see . What does the service involve ? ', ' Well , the same as for private vehicles really , but we do it more often because they get a lot of wear and tear . ', ' Can you carry out major repairs here ? ', " Yes , we've got all the necessary equipment . We can give the engines a major overhaul . If there's a serious problem , we strip down the engine and find the faulty component . Would you like to look around ? "]
['Do you know which stop we get off at ? ', ' We still have more to go , I think . ', " We've been on this bus for a while now . ", " You're right . ", ' Should we have gotten off the bus already ? ', " I don't think so . ", ' I thought you knew . ', ' Maybe we did miss our stop . ', ' Really ? ', " I'm positive that we missed our stop . ", " I'm never catching the bus with you again . ", ' My mistake . ']
["Well , Peter , you have to do better than that next time , won't you ? ", ' Have I really got to do those exams again , Dad ? ', ' Of course , you have . You must try harder this time . ', ' And must I go back to school ? ', " No , you needn't do that . You'd better get a part-time job somewhere and go to evening classes . ", " But Dad , I should be working full-time at my age . I'm nearly 17 . ", " You ought to have worked harder then you wouldn't have failed your exams . You have to take a job and study . ", " What else I've got to do ? Join the army ? ", ' Who knows ! That might come to later . ']
['Could I order dinner ? ', ' Of course . What would you like ? ', ' I want a bottle of champagne , lobster tail , and filet mignon , medium rare . ', " I'm so sorry . We ran out of filet mignon . May I suggest the porterhouse instead ? ", " That's too bad , but the porterhouse will be okay . ", ' May I be so bold as to suggest chocolate-covered strawberries with the champagne ? ', ' Not tonight , thank you . ', " No strawberries . We'll charge your amenities account , if that's okay . ", ' Charge it to whatever account you like . ', " Your meal will be delivered as soon as it's all ready . Enjoy ! "]
['So what did you get ? ', " It's all in the bag . ", " What's this ? Essential oil ? Wow ! This stuff is expensive . ", " I need that to relax . I'm going to put a few drops in my bath water . ", ' How is oil supposed to make you relax ? ', ' They all have essence of flowers in them . ', ' Mmmm . They smell nice . ']
['I was wondering if this is where the Resume Writing Workshop is being held . ', ' You are in the right place . Please come on in ! ', ' It ’ s been a long time since I ’ Ve had to look for work and put a resume together . ', ' It ’ s going to come together just fine . Trust me ! ', ' Where do we begin ? ', ' We start at the top with our name and contact information . Make sure the information is current . ', ' Then what do we do ? ', ' Put your job experience first , if that is more impressive than your education . ', ' What about listing my interests and affiliations next ? ', ' Yes , that would make a good ending for your resume . ']
['What ’ s the matter , dear ? ', ' Something awful happened . We went to the Portobello Road , and someone stole my handbag . ', ' Oh , dear . Did you lose a lot of money ? ', ' No . Only a few pounds . But my passport was in the bag . That ’ what I ’ m really worry about . ', ' You must tell the embassy about it . And I think they ’ ll issue you with a new one . ', ' I ’ d better go tomorrow . ', ' No . But you mustn ’ t leave it too long . Did you report it the police ? ', ' No . I couldn ’ t find a policeman . ', ' Well . You must report that it ’ s been stolen . And give the police description of your bag . You ’ d better go to the local police station tomorrow morning . ', ' Yes . I ’ ll do it tomorrow . ', ' And Lisa . ', ' Yes ? ', " Don't be too upset . It ’ s not the end of the world . "]
['Hello ! Do you have a place where I can exercise ? ', ' Yes , sir . We have a fine exercise facility . ', " I'm happy to hear that . Now , would you tell me where it is ? ", " You're actually standing above it . Just take the elevator or stairs down one level . ", ' Is the hotel going to charge me a dollar a minute for gym use ? ', " No , sir . There's no extra charge . All you need is your room key to open the door . ", ' And the gym hours are ? ', " Sir , you'll be pleased to know that our gym never closes . ", ' One more question , Do you have a trainer ? ', ' We might be getting one in the near future . But at the present time , no . ']
['Daddy , how are you going to spend your weekends ? ', ' I need to finish my research paper . ', ' Could you go with me to climb Kiang Shan ? ', ' Honey , I am sorry I have no time . ', ' Oh , Daddy , you should do more exercise . You are getting a little heavy . ', ' I am afraid you are right . Recently , even going upstairs makes me out of breath . ', ' Then go climbing with me , Daddy . Mountain climbing can build your muscles like Popeyes . ', ' Terrific ! It is also a good exercise to keep me fit . ', ' I give you my word , you must feel refreshed after mountain climbing . ', " OK , I'll go . ", " That's a deal . ", ' Sure . ']
['I think we should home school our children when we decide to have kids . ', ' What ? Why ? ', ' Well , our public schools here are not very good and private school are just too expensive . I have been reading up on home schooling and it has a lot of advantages . ', ' Like what ? I think that by doing something like that we would be isolating our children from social interaction . ', ' Well , first of all , I would be able to teach them everything they learn in school in a more relaxed and fun way . I also think that having a one-on-one class is much better since you can focus more on his or her strengths or weaknesses . ', ' I think neither your parents or mine would agree to such an idea . ', ' I will bring it up over Sunday brunch . ', ' Good luck with that ! ']
['Hey , you have been promoted to president of the department . ', ' All this is thanks to the efforts of my superiors and colleagues . ', ' You are so smart . Your efforts in the success of the plan were outstanding . ', ' I just did what I should have done . ', ' You ’ Ve got a great personality . ', ' Thank you for your compliments . I will try even harder to repay the company and your support . ', ' I believe you will . I ’ m very pleased with your work . Your promotion will contribute to the development of the company . ', ' Thanks for saying so . ']
['May I speak to Mr . Smith ? ', ' He is at the warehouse this morning . ', ' What time do you expect him back ? ', ' Sorry , I have no idea . You can call him there if you like . ', ' Ok , I have the number . Bye ! ']
["Tom , you promised to cut the lung . You won't forget , will you ? ", ' No , I assure you . ', " And you'll repair the television , won't you ? ", ' Ok . ', ' Do you promise ? ', ' Of course . ', " And Tom , you will help Johnny with his homework , won't you ? ", " I'll see . I will if I can but I won't promise . ", " But you'll promise not to be late for dinner tonight , won't you ? ", ' Yes . But only if you ask me nicely . ', " Tom , darling . You'll try not to be late for dinner tonight , won't you ? Please ! ", " Ok . I'll keep my promise . "]
['Hi , buddy ! How do you deal with your salary ? ', ' I usually put them into my bank account . I think that is a little secure , though the interest rate is low now . ', ' Look ! This stock is rising now . I am researching it , and planning to buy some shares . ', ' Have you invested in the stock market before ? ', ' No . This is my first time to buy some . You can see that its historical price data is rising now . ', ' But that is a little risky , you know . ', ' Hey ! Do you still remember our teacher of economics , Mr . Locker ? ', ' Of course ! I remember he has a part-time job as a stock analyst . ', ' I can ask for some advice from him . ']
['Hello , Helen . ', ' Hi , Steven . ', ' How are you today ? ', ' I ’ m very well , Thank you . And you ? ', ' I ’ m fine , thanks . How is Tony ? ', ' He ’ s fine , Thanks . How ’ s Emma ? ', ' She ’ s very well , too , Helen . Goodbye , Helen . Nice to see you . ', ' Nice to see you , too , Steven . Goodbye . ']
["Julia , Julia , Julia . My daring Julia , what's wrong with you ? ", ' Steven , are you talking to me ? ', ' Yes , I have called you three times . What makes you in a daze ? ', ' I was thinking about the accident I saw in the morning . I was petrified when two cars collided . I witnessed the traffic accident . ', ' Did someone get hurt ? ', ' A driver died instantly . The other one was badly hurt . A poor boy called Peter was killed in the accident too . ', ' What a terrible accident ! Who should be responsible for this traffic accident ? ', " I think both . They drove too fast . What's worse , one of them was drunk . ", ' Why do some guys like to drive so fast when they are drunk ? ', ' I don ’ t understand . Maybe they feel they are okay and driving fast seems very cool . ']
['Good morning ! My name is John White , import manager of the Garden Trading Company of New York . ', ' Oh , how do you to Mr . White ? My name is Li Ming , here is my card . ', " Nice to meet you Mr.Li . We have learned about that you specialize in the export business of electronic products . As you enjoy the highest reputation in the commercial circle , we'd be please to enter into business relations with your firm . ", ' We share the same desire . Have you seen the display of our products in the exhibition hall downstairs ? ', ' Yes , I had a look just now , I feel we can do a lot of business in this line . ', ' Sure , we can . You know , we are been in the line for more than twenty years , and I think our price are competitive comparing with those in the world market . ', ' Our company enjoys a history of more than twenty years , we have wide connection with wholesalers and retailers all over the America , and we have good reputation in the commercial circle . ', ' Thank you for your information , we can hold more talks later on business details . ', ' Sure . ']
['Miss Wang , how do you do ? I ’ m Allan James , the director of human recourse department of this company . ', ' How do you do , Mr . James ? Thank you for asking me to come in . ', ' Not at all . Please sit down , then we can begin . ', ' Thank you . ', ' As you know , Miss Wang , we are looking for an executive secretary with business background and good English skills . We looked into your resume and thought you might be a good candidate . ', ' Thank you . ', ' Today ’ s interview is for us to get to know a little about you . And the interview will last a little bit longer . So , if you ’ re comfortable , I want to ask you some questions . ']
["Well , I've got a date . Now I need to find a restaurant . Can you help me ? ", ' No problem , of course ! How much would you like to spend to impress the lady ? ', ' Nothing but the best for a pretty woman ! ', ' Sir , the restaurant you seek is right here . This hotel has a three-star restaurant . ', ' Well , I sort of suggested that we would go out on the town . Do you have another suggestion ? ', ' Gramercy Tavern is at least as good as our own hotel restaurant . Plus , they have live jazz . ', " Gramercy Tavern , eh ? I think I've heard of that before . Call to get us a table , okay ? ", ' Right away , sir . She will be impressed with your local knowledge . ']
["I'd like to reserve a room . ", ' Which date would that be ? ', ' For the night of April 18th , for one night . ', " I'm afraid our hotel is fully booked on that night . Is it possible for you to change your reservation date ? ", " No , I'm afraid not . ", ' We might have cancellations . Could you call us again some other day ? ', ' Sure , but if you do have any cancellations , could you let me know as soon as possible ? ', " I'm very sorry , sir , but we are unable to do that . We would appreciate it very much if you could call us instead . ", ' OK , thanks . ']
['Good morning , Mr . Smith . Would you like to see around the factory ? ', ' Yes , I would like to . ', ' This is our office block . We have all the administrative department here , Sales , Accounts , Personnel , Market Research and so on . ']
['Hi , sir . Come and have a look here . We have all kinds of sweaters . ', ' I ’ m looking for a sweater for my wife . Tomorrow is her birthday . And I know she needs a woolen sweater . ', ' How do you like this grey one ? It ’ s pure wool , one hundred percent of Xinjiang wool . ', ' It feels good . Are there cowl-neck pullovers with the same color ? My wife prefers a turtleneck to a V-shaped collar . ', ' Yes , we do . What size do you want ? ', ' Size one . By the way , what if I bring home this sweater and my wife doesn ’ t like it ? ', ' Well , you can always bring it back to us for a full refund . ', ' All right . Could I have it gift-wrapped , please ? ', ' Yes , just a moment , please . ']
['Why do you want to be a stewardess ? ', ' I have always enjoyed flying . And I am good with people . ', ' Could you handle flying for 24 hours straight ? ', ' Yes , I can adjust to anything . ', " That's good . ", ' I am also calm under pressure and trained in first aid . ', ' You should very qualified . ', ' Thank you . It has always been my dream to be a stewardess . ']
['Rebecca Johnson speaking . ', " I'd like to speak to someone in your Accounts Department , please . ", " Just a moment ... I'm afraid there's nobody there right now . Could I take a message ? ", " Yes , please . My name's Michael Caxton from one of your customers — Rosedale Investments . ", ' Sorry , just a moment . The name is Caxton ... ', " No , it's Caxton . ", " Fine , I've got that . And your company is ... ", ' Rosedale Investments . ', ' Could you spell that , please ? ', " It's R , O , S , E , D , A , L , E . ", ' Thank you . And the message ? ', " It's about an invoice which is wrong . ", ' Have you got the number there ? ', " Um ... yes ... it's 856674 / ros . ", ' 856674 . ', " That's right . ", " OK , I'll get someone to phone you first thing in the morning . ", ' Thank you very much . ']
['This blouse is a special offer today . You can have it at 10 % off the regular price . ', " It's nice , but still too expensive . Can you give me a 20 % discount ? ", ' No . 10 % is my last word . ', " Come on . Let's split the difference , 15 % . "]
["Who's in charge of the construction project ? ", " We've taken on a civil engineer on a nine-month temporary contract . He'll oversee the whole project . In fact we're having a project meeting at 3 p . m this afternoon allocate responsibilities and finalise the time schedule . Why don't you join us ? ", " I can ’ t I'm afraid . I've got another meeting scheduled for 2:30 p . m . "]
["Oh , no . It seems that I've lost my train ticket . ", ' Are you kidding ? The train leaves in an hour . Where did you put it ? ', " It was in my pocket , but now I can't find it . ", ' Is it in the other pocket ? ', " No , it is not here . Damn it ! I'm going to have to buy another ticket . ", " Let's go to the inquiry desk first to check whether anyone has got it and turned it in . ", ' OK . ']
['Can you tell me about a nice restaurant to go to ? ', ' Of course ! How much would you like to spend on your meal ? ', ' My date is quite sophisticated . She would expect nothing less than the best . ', " Well , how about our own hotel restaurant ? It's conveniently located and has a three-star rating . ", " That's a good idea , except I want to go out , not stay in . Something else , maybe ? ", " Well , how about Gramercy Tavern ? It's a very popular tourist spot , with great food and music . ", ' That sounds good ! Could you call them to see if I can get a reservation ? ', " Of course , sir . You've made a good choice . "]
["I'll talk to you later . ", " What's the rush ? ", ' I have to get off the phone now . ', " I'm not ready to get off the phone with you . ", ' There are other things I need to take care of . ', ' What is it that you need to do ? ', " Please don't be nosey . ", " I'm not being nosey , it's just a question . ", " You don't need to worry about that . ", ' That was mean to say . ', ' I am very sorry , but I must go . ', ' I guess . ']
['Lucy , I ’ d like to fix the light in the corridor , it keeps flashing , which drives me crazy . Would you like to help me with the ladder ? ', ' Monica , wait a moment . I think we ’ d better call the repairman to do it . ', ' I think I can handle it by myself . ', ' I ’ d like you to have a look at the safety manual of our company . ', ' I see . If I got hurt when fixing the light , even during office hours , I wouldn ’ t get compensation from our company since repairing is not my responsibility . ', ' Other company rules also need your attention . ', ' Like this one ? ', ' Never wear loose clothes or hair when operating the shredder . ', ' Yeah , thank you for telling me . ', ' Don ’ t mention it . ']
['Will you be checking in any baggage today ? ', ' Yes , I have two large suitcases and one box . ', ' If you need baggage tags , they are found in the box on your right . ', ' No , thank you.They are already tagged with my name and address . ', ' You are allowed an additional two carry-on items . ', ' Good , I have my backpack and my camera tripod . ', ' I see . All carry-on items must be able to fit under the seat or in the overhead bin . ', ' Both my items will fit under the seat or in the overhead bin . ', ' You will need to send the tripod as luggage because it is too long to fit in our gauge box for carry-on items . ', ' I cannot let anything happen to that tripod.Can you guarantee it will not be damaged if I check it in ? ', " No , I can't . Perhaps your stewardess will help you to find a place to store it . ", ' Good idea . I will ask the stewardess to help me store my tripod . ']
["I'm afraid I have lost my air ticket while I was shopping . ", " I'm sorry to hear that.Did you check your shoulder bag carefully ? ", " Yes , I checked again and again , but I can't find it . By the day after tomorrow , can I have the ticket reissued ? ", " I'm afraid you can't . ", ' I talked with the manager over the phone and he told me I can have it reissued because I have a copy of my lost ticket . ', " Oh , I see . I'll call the manager , then . "]
["I can't finish this steak . ", " That's all right . "]
['Look , the printer isn ’ t functioning well . I ’ Ve pushed the start button . It is suppose to be working now but it remains like a log . What ’ s going on ? ', ' Let me check . It has a paper jam . ', ' I didn ’ t pay attention to that . I will try to get the paper out . ', ' Be careful , the cartridge can be very hot . ']
['Good morning , sir . Do you have a reservation ? ', ' Yes . My name is Charles . ', ' I see . We have a window table reserved for you . ', " It's very kind of you . ", ' Would you like to order now or wait for a while ? ', ' Bring me the menu , please . ']
['Can you help me pick out a gift for my daughter ? ', ' She might like a laptop computer . ', ' Yes , that sounds like a good idea . ', ' Might I suggest a Mac ? ', ' Okay . How much ? ', ' Well , a 15 - inch Pro is $ 2,100 . ', " Oh , that sounds great . I'll take it . ", ' Great . How would you like to pay for it ? ', " Here's my VISA . ", ' Let me ring you up . Okay , sign here , please . ', ' Everything I need is in this box ? ', " It'll take her only a few minutes to get online . ", ' Thank you for your help . ', ' So long . Thank you for shopping here . ']
['Excuse me , are cameras allowed here ? ', ' Sorry , sir , in order to protect these paintings , taking photos are strictly forbidden here . ', ' I see . What a pity . I have to appreciate it carefully . ', ' I am really sorry for that . ']
['Hi , John Phillips ? I ’ m Rose Green . I ’ Ve been asked to handle your training and introduce a little bit of the company to you . It ’ s nice to meet you . ', ' It ’ s nice to meet you , too , Ms . Green . This company seems so big right now ; I don ’ t know how I ’ ll ever get used to it . ', ' After a week , you ’ ll be running around here like a pro . Let me give you this list of departments first , next to each department is its location and the name of the manager . ', ' Great – That ’ ll be big help . ']
['Have you bought a lot of new clothes for your vacation ? ', " No , I haven't . I've decided I ' m going to travel very light this time . ", ' What does travel light mean ? ', " Oh ! It means that I'm going to take only a few clothes , so I didn't have to carry a heavy suitcase . "]
["I'm afraid we can't increase salary this year , money is just too tight . ", " I'm not sure . I can't agree , dan . ", ' Why not ? ', ' Surely , there are other ways to save money . ', " What are you talking about , we've tried everything ! "]
['Is there anything I can do ? ', ' Yes . I am thinking of a tour to Australia . ', " May I recommend the popular route ? It's a seven days ' trip and cost $ 500 . ", " That's really cheap . What are the fees included ? ", ' Everything , sir , including the air tickets , accommodation and gate tickets . ', ' OK , I will take the tour . ']
['Could I speak to the apartment manager ? ', ' I am the apartment manager . How can I help you ? ', ' I wanted to know if that apartment on Main Street is still for rent . ', " I haven't rented it out yet . Would you like to see it ? ", ' Yes , I want to see it . ', ' How about today at 6 p . m . ? ', ' That time is okay with me . ', " Very good . We'll meet at 6 . Do you need directions ? ", ' No , thank you . I go by there on my way to work . ', " If you're interested , you can fill out an application form . ", " That's a good idea . Do I need to bring anything myself ? ", " No . The only thing I need to see is your driver's license . "]
['I don ’ t know what I ’ m going to do ! It ’ s going to be impossible to make ends meet if I lose my job ! ', " don ’ t worry . I don't think you ’ re going to lose your job over one mistake . ", ' it was a rather big mistake . When you work as an investment adviser , ONC small mistake can cost the company millions . ', ' but it wasn ’ t just you who was involved , right ? You were only doing what your supervisor told you to do . ', ' that ’ s true , but my supervisor is very dishonest . There ’ s no reason he needs to tell our boss the truth . I ’ m sure he will tell our boss that it was all my fault , and there ’ s nothing I can do about tha ', ' let ’ s think realistically about what might happen . How much money do you have in your savings ? ', " I have enough to live off of for about 3 months . But I really don't want to spend my life savings on just living ! I ’ d rather invest my money somehow . ", ' well , that ’ s good . If you lose your job , you can just move in with me until you find another job . That will save you plenty of money . ', ' that ’ s very generous of you . I guess that would work . ', ' if you lose your job , you just have to go for a few months without buying all the junk you usually buy . If you live frugally , you ’ ll save plenty of money . ', ' I guess working with so much money has made me rather greedy . Maybe losing my job would be a good thing ! ']
['Yo baby , are you satisfied with the costume show in the street ? ', ' It ’ s hard to say.Just so-so . ']
["Let's start to study how to use computers , Paubler.It ' s good to know that a computer has two major parts , the hardware and the software . ", " What's the hardware ? ", ' The hardware of computer is basically all the concrete things you can touch with your hands and see with your eyes . ', " That's seems obvious enough.then what about the software ? ", ' The software of computer is all the programmes inside the computer that allow you to use the computer to do things . ', ' I see , actually the hardware is the easy part , I do want to study how to use the software . ', ' Right you are , Paler , and since what you want to learn is how to use software , we should also learn to refer to the computer menus . ', ' Ever since I saw computer can do your project , I wanted to have a computer . ']
['Hello . ', ' Hi , Lucy , are you free to talk ? ', ' Not really , I ’ m in a meeting . Can I call you back in ... say ... 15 minutes ? ', ' Sure , speak to you later . It isn ’ t urgent . Maybe it is easier if I send you an e-mail . ', ' Ok , I ’ ll look out for it . Sorry , I can ’ t talk now . ']
['Hello , this is Li King . Can I talk to your manager ? ', ' Sorry , he has just gone out now . Can I take a message for you ? ', ' Yes . Would you please kindly tell him I want to apply for a proof-reader in your newspaper ? ', ' OK , I got it . ']
['Hello . What can we do for you today ? ', " I've just had some money sent from Germany , in Euros . ", " OK , could you give me your details and I'll see if it has cleared . We need your banking details and some ID . A passport or something like that ? ", ' I have my passport right here , and here are the account details . The name , number ... ', ' Mr Jurgen , yes , the remittance has been successful . ', " That was quick ! I didn't expect it to come through so quickly . Yes , that is good news . The full amount should be 20,000 Euros , is that right ? I'd like to withdraw 5,000 Euros worth of local currency , if that's possible . ", ' Not a problem , Sir . Please fill in this exchange form and show me your passport . ']
["Get up , it's time for you to get ready . ", ' Let me just get five more minutes of sleep . ', ' I would , but you need to start getting ready for school . ', ' I understand , but all I want is five more minutes of sleep . ', " If I let you go back to sleep , I know that you won't get up in five minutes . ", " Trust me . I'm going to wake up . ", ' You have a lot to get done this morning . ', " I already know , and I'll take care of all that when I wake up . ", ' I want you to be on time for school today . ', " I'll make it to school on time . Don't worry . ", " Okay , I'll let you sleep for a little while longer . ", ' I really appreciate that . ']
['How many rooms are you looking for ? ', ' Oh , four or five . How much is the rent for this apartment ? ', ' 150 a month . ', " 150 ? No , I'm not really interested in this place . It isn't big enough . It isn't near enough to my office . "]
["My mascara's waterproof ! ", ' Oh , how high class ! So you just wear it forever ? ', " No . There's makeup remover for waterproof mascara . ", ' Is it dry yet ? ', ' Yep . See how long and curly my lashes are ? ', ' They look fake . ', ' Thanks ! ']
["Tom ? Oh , it's been a while since we've talked to each other . Nice to hear you again . ", ' Same here . Hey , did you know Susan is going to get married . She invited me to her wedding and she wants you to attend also . ', ' Really ? ', " Definitely . I'm calling to tell you this . ", " Why didn't she call me ? ", ' She tried , but the line is always busy . ', " Well , I may have stayed on the phone too long . Can you give me her number ? I'll call her later . ", " Of course . It's 555-4653 . ", ' Thanks . So how are things with you ? ', " Pretty good . I've just bought a new house . ", ' Wow ! Great ! Where ? ', ' In the suburb . How are you and Carol ? Still living in town ? ', " Yeah , it's really convenient . The theater and Shopping Mall are within walking distance . Well , I got to go . I'll get in touch with you soon . ", " Okay . Don't forget to call Susan . ", " Don't worry . Bye . "]
['Are you okay ? ', ' No . ', " What's wrong ? ", ' I got robbed ! ', ' By who ? ', ' Some guy on the street just mugged me . ', ' Are you hurt ? ', ' No , he just stole all of my things . ', " That's crazy . ", ' I need to go to the police station . ', ' Do you want me to take you ? ', ' That would be great . Thank you . ']
['Repairman.May I come in ? ', ' Come in please . ', " What's the matter , sir ? ", " The toilet doesn't flush . ", " Let me see.En .. it's right now.You can try it . ", ' Wonderfull.Thanks a lot . ', ' You are welcome . ']
['Come in , young man . ', ' ( while shaking hands ) I am Zhang Wei , nice to meet you , sir . ', ' I am Smith , the personnel director . Please have a seat , son . ', ' Thank you . Have you received my resume ? ', ' Actually , I haven ’ t had time to look it over . Did you bring another copy with you ? ', ' Of course , here you are , sir . ', ' Call me Mr . Smith . ', ' Certainly , it would be my pleasure , Mr . Smith . ']
['Mom ! How can I help with the washing up ? ', ' You peel the onions and wash them , then chop them . ', ' OK ! Then what can I do after I finish it ? ', ' Let me see . Wash the cabbage over there . ', ' OK , got it . ', ' What is your father doing now ? ', ' Reading newspaper on the couch . ', ' How about Daniel ? ', ' Staying with Ultraman , of course . You know he likes it very much . ', " Be careful of the peeler . Don't cut your fingers . ", ' I will . ', " OK , we've finished . Can you get your father and brother ? ", ' OK ! ']
['How do you like your work ? ', " The work is rather hard , but it's interesting . ", ' What do you do ? ', ' I work in a publishing house . How about you ? ', " Mine isn't hard , but it's not interesting . ", ' What do you do then ? ', " I'm a clerk in a shop . "]
["Hi . I can't get going on my computer until I get a broadband hookup . ", " Just plug the Ethernet cable into your computer , and you'll be off and running . ", ' That would be okay if I had an Ethernet port . Unfortunately , my laptop uses wireless only . ', ' In that case , let me tell you about some alternatives . ', ' Anything to get me up and running . ', ' For starters , we have a computer lab . ', ' Fantastic ! What do I have to pay per hour ? ', ' The lab is completely free . But you do have to pay a dime a page for printing . ', " That's fine . Now tell me about the other alternatives . ", " Just bring your laptop down here to the lobby . We're set up for wireless right here . ", ' Great ! I like that suggestion , but what if I need to print something there ? ', " Unfortunately , you'll have to go to the computer lab for your printing needs . "]
["I'm not sure , is this our stop ? ", ' Yeah , get off the bus . ', ' Do you have any idea where we are ? ', " I'm really not sure . ", " This can't be the right stop . ", " I don't think this is right . ", " We got off too early , didn't we ? ", ' Yeah , we did get off too early . ', " I should've just stayed on the bus . ", ' I messed up . ', ' Great , we have to walk now . ', ' You want to wait for the next bus ? ']
['Is this the Friendship Hospital ? Please send an ambulance to 68 Hu Nan Road . ', ' Is it urgent ? Our ambulances are not enough to meet every call . ', " Of course . It's urgent . I think the partie nt is suffering from acute appendicitis . He may die if not treated in time . ", " All right , we'll come right away . ", " ( after a while ... ) Where's the patient ? ", " He's there in the room . He's very ill . ", " Don't worry . We'll put him in the stretcher . You are coming with us ? Step in please . ", ' Carry him into the emergency ward . Here we are . ', ' Help the patient bathe and change his clothes , nurse . Then bring him into the operating room . ', " ( after a while ... ) I'm his guide . What's the trouble with him , doctor ", " He had appendicitis , but is all right now that it was removed . He'll have to rest for a few weeks to recover . ", ' May I send food for him ? ', ' No , outside food is not permitted . ', ' Can I come round to see him tomorrow ? ', " Yes . But first you must observe the visiting hours , It's from 2 to 5 p . m . By the way , consult the nurse before you enter the ward . ", ' Yes . Thank you . ', ' By the way , you can bring some flowers . ', ' OK . ', " Don't worry about him . ", ' When could I take care of him ? ', ' Our nurse can take good care of him . ']
['good afternoon ! Can I help you ? ', ' could you show me where the Chinese-style clothing is located ? I want to buy a silk coat . ', " this way , please . Here they are . They're all handmade . ", ' oh , they look nice . May I try that back one on ? ', ' of course . The fitting room is right over there . ', ' do you have a medium in the same color ? This one is a little tight . ', " I'm sorry . All the back of that size are sold out . Would you like a red one ? ", ' ok , let me try it on . what do you think ? ', ' oh , that suits you very well . Besides it is believed in China that the red color brings happiness and good luck . ', " really ? I'll take it , and I'm leaving here tomorrow . Is it possible for you to send one in black to me by mail when you gte it in ? ", ' our pleasure . Please fill out this form , leaving your address and telephone number . ', ' thanks . Who much would that come to ? ', ' let me see ... ']
['Are you interested in going sightseeing , Mr . Simpson ? I think you are here not only for the negotiation but also for sightseeing . ', ' I heard that there are some beauty spots and places of historical interest in this city . ', ' Shall we go to the Tiananmen Square first ? ', " That's great . I trouble you so much . Thank you very much . ", " It's my pleasure . Shall we go there on foot ? It's very near . ", ' OK , let ’ s go . ']
['Welcome back racing fans ! My name is Rick Fields and , as always , I am joined by my partner in crime , Bob Copeland . ', ' We ’ re in the last stretch of this very exciting race , and Kimmi Rikknen is leading the pack with only four laps to go ! They are heading to turn three and Lewis Hamilton tries to pass Rikknen ! It ’ s a close one and , oh no ! Hamilton hits the wall ! ', ' He came in too fast , jammed on the breaks and spun out . We have a yellow flag and the pace car is making its way onto the track . ', ' The cleanup crew is towing the heavily damaged car and the green flag drops ! Rikknen is still in the lead with only two laps to go ! ', ' Smoke is coming out of his car ! He seems to be having engine trouble ! He makes his way into the pit , and Fernando Alonso takes the lead ! ', ' How unlucky for Rikknen , and this race is over ladies and gentlemen , Alonso takes the checkered flag ! ']
['Hello , do you remember me ? I bought some vases from you yesterday . ', ' eyes , you sent them to New York , right ? ', " That's right . I thought I'd come back to buy a few more souvenirs . ", ' What did you have in mind ? ', " Well , first , I'd like to buy a few postcards . My sister used to always send a postcard to herself whenever she went anywhere . I want to do that , too . ", ' We have plenty of postcards to choose from here . The same designs can be found on these posters . ', " Posters are difficult to travel with . I think I'll just buy the postcards . I heard that you might also have some of the masks that are made in Venice . ", " Yes , we do . They're on the wall behind you . ", ' How much do they cost ? ', ' The prices are clearly marked on the back of each mask . Would you like me to get one down for you to look at ? ', " Yes , I think I'd like the green mask in the middle . ", ' Here you go . ', " I'll take it , I'd also like to buy some chocolate . ", ' Are you looking for some homemade chocolate as a gift ? ', " Yes , it's my girlfriend's birthday today and she loves chocolate . ", " We've got plenty to choose from here . ", " They look delicious . I think she'll be pleased . "]
['Good morning , Madam . Is everything OK ? Is there something I can assist you with ? ', " Thank you , yes . I'm not sure how to use this ATM , I usually go to a clerk and use my Bank Book . But today , I thought I'd try something new . I want to take some money out . ", " Welcome to the electronic age ! I can run you through it ; it's what I'm here for . ", " Thanks so much . Right , I've put my card in . What now ? ", " Just look at the screen here . It'll give you prompts , you see ? Now you need to enter your PIN number , then press ' enter ' to confirm it . ", " Then it'll give me my money ? ", ' Not right away , you need to decide what it is you want to do . The next thing is to select the service . ', " Here we are ' withdrawal ' , so I just press here ? ", ' Yes , then enter the amount you want . ', ' Oh , as simple as that ! I shall never wait for a real person again , these machines are wonderful . ']
['The road ahead is blocked . There might have been an accident . ', ' Are there many accidents in the city every day ? ', ' Not really , but they are on the rise . ', " Please drive slowly , we've got lots of time . Safety first . "]
['Operator , can you give me any information on the call I just received ? ', ' I don ’ t know who placed the call . However , the call was from Toronto . ', ' Can you tell me the calling number , please ? ', ' Sure . 416-790-1256 . ', ' Thank you . ', ' You ’ re welcome . ']
['Was there an accident on the freeway today ? ', " You haven't heard about it ? ", " No , don't you know what happened ? ", ' This truck flipped over on the 210 . ', ' Are you serious ? ', " I'm telling you the truth . ", ' Did anyone get hurt ? ', ' Two people were injured . ', ' Are they going to be okay ? ', ' I think so . ', " Well , that's a miracle that no one was killed . ", ' Yes , they were lucky . ']
['Steven , can you give us a summary about your work ? What do you get from your work ? ', ' I have accumulated a wealth of practical experience in work as a chief advertisement designer . Moreover , I realized teamwork is the key to success . ', ' Why do you think so ? ', ' I think building team spirit among the coworkers is very important . I believe we can accomplish a miracle if we stick together . ', ' Very good . Anything else ? ', ' My advantage is that I have strong sense of responsibility . But I lack patience . ', " I must praise you for your modesty and diligence . What's your plan next ? ", ' I will listen and learn more when I start my new job . I plan to become more professional in my field . ', " I've got to commend you ; you really did a good job . ", ' Thanks for your compliment , but there is still plenty more to learn . ']
['Good afternoon . May I help you ? ', " Yes , I'd like to rent a car . ", ' What kind of car do you have in mind ? ', ' An automatic sedan . ', ' I see . How long will you need it ? ', ' About a week . ', ' Just a moment , please . ']
['Hello , do you know anywhere that sells cheap cashmere sweaters ? ', ' Outlets have cheap cashmere sweaters . ', ' What a splendid idea ! ', ' Outlets usually give you great deals . ', ' Thanks for helping me . ', " You're welcome . "]
['would you like to learn to tango Donar ? ', ' right now ? ', ' i am offering you my services . for your church . what do you say ? ', " i think i'll be a little afraid . ", ' of what ? ', ' afraid of making a mistake . ', " no mistakes in a tango Donar.not like life , simple , that will make the tango so great . if you make a mistake , you'll get all tango done . just tango along . why don't you try ? will you try it . ", " all right . i'll give it a try . "]
['I hate working on Christmas Eve ! Whoa ! Get a load of this guy ! Come in central , I think we ’ Ve got ourselves a situation here . ', ' License and registration please . Have you been drinking tonight , sir ? ', ' I had one or two glasses of eggnog , but nothing else . ', ' Step out of the vehicle , please . Sir , what do you have in the back ? ', ' Just a few Christmas gifts , to this season , after all ! ', ' Don ’ t take that tone with me . Do you have an invoice for these items ? ', ' Umm ... no ... I make these in my workshop in the North Pole ! ', ' You are under arrest , sir . You have the right to remain silent . You better not pout , you better not cry . Anything you say can and will be used against you . You have the right to an attorney , if you cannot afford one , the state will appoint one for you . ', ' You can ’ t take me to jail ! What about my sleigh ? It ’ s Christmas Eve ! I have presents to deliver ! Rudolph ! Prancer ! Dancer ! Get help ! ']
['What should I get Uncle Teddy ? ', ' You could get him a tie . ', " Are you kidding ? That's the stupidest gift one can buy . I don't want to get a tie . ", ' Why not ? ', " Everybody gets men ties for Christmas . It's too boring . Everybody buys either ties or sweaters . I want a more unique gift . ", ' Well , you can buy him a pet iguana then . ', " That's a cool idea . At least it would be a surprise.But I'm afraid he wouldn't take care of it . ", ' He would think you were crazy , Caroline . ', ' Yes . An iguana is too strange for a gift , and a tie is too normal.So I have to find something halfway between . ', ' How much do you want to spend ? ', ' Well , he was very good to me.He helped me edit my essay for the scholarship contest.So I want to spend at least 75 dollars . ', ' Alright , I have an idea.You know he carries that conservative-looking briefcase every day . ', ' Yes . ', " Well , he isn't a lawyer , so I don't think he needs to have a briefcase like that . ", ' What should he have then ? ', ' I think he would appreciate having a very fine leather bag.But more like a workbag or shoulder bag.You know , not so hard and square like a briefcase . ', " I think that's a great idea . Men look great with that kind of bag.Where can we buy one ? ", " I don't think this mall has a leather goods store.So we have to go to State Street . ", ' Alright . We can go later then . ', " We can buy something for Mom and Dad here , and then go buy Uncle Teddy's gift on State Street . ", ' Good plan . What should we get for Mom though ? ', ' She said she wants one of those automatic foot massagers . I think they sell them at Sears . ', ' Alright . We can go check at Sears and see if they have them.And what about Dad ? ', ' How about the iguana ? ', " I think it would be a great joke.But I know we'd have to take the iguana back . And the pet store might not let us.So why don't we get him something else ? Some clothes maybe . ", ' A tie ? ', ' Oh , shut up about ties ! Forget about ties , why not ? ', ' I was just kidding . ']
['The language used in this multinational company is mainly about English ; do you think you can manage to handle that ? ', ' Yes . I am sure I can . I was an English major in college . ', ' What about your second foreign language since you were an English major ? ', ' Russian is my second foreign language and I excelled the rest of my class in Russian because my father is a Russian . ']
["Anne , would you please come in for a while ? Please also bring along the minutes of yesterday's management meeting . ", " Of course , sir ... Here's the minutes of the meeting . ", ' How long did the meeting last ? ', ' The meeting was delayed by thirty minutes and it lasted for two and a half hours . ', ' Did the chairman ask for me ? ', " Yes , I told him that you were very ill and couldn't attend . ", ' All right . Have you handed in my report to him ? ', " Yes , I did . Besides , here are all the reports and materials handed out in the meeting . I think you'll have to do some replies . ", " Thank you , Anne . You've done an excellent job . Did they mention the date for the next meeting ? ", " No , they didn't . The chairman said he would send a memo to all managers by the end of this week informing them of the date of the next meeting . "]
["Hello , I'm sorry for calling this late . May I speak to Peter ? ", " I'm sorry . He's not in right now . ", ' When is he coming back ? ', ' He should be back in ten minutes . Could 1 you call back later ? ', " I'll call again in thirty minutes . "]
['What a mess , Jack ! ', ' I ’ m playing with my toys , Dad . ', ' You ’ d better tidy up the room now , or you ’ ll get your mum ’ s back up . ']
['so , your friend ’ s getting married on Saturday . What have you bought her as a wedding gift . I find is so hard to choose the right gift . ', ' my friend and her fiance had a really good idea . They have cut out pictures from catalogues and pasted them in a notebook . The picture are of things they want . People sign their name b ', ' that ’ s clever ! Then everyone knows that they are buying something the couple really want and there ’ s no chance of two people buying the same gift . What things were in the notebook ? ', ' most of the things were household appliance . You know , everything from an iron through a vacuum cleaner to a cooker . I think it ’ s an excellent way for everyone who knows the couple to help ', ' so , what did you get them ? ', ' I bought a sewing machine . I know that my friend likes making her own clothes , but her current sewing machine is quite old and has some problems . ', ' what ’ s wrong with is ? ', ' she says that after several years of use , it ’ s not working properly . When she uses it , it makes a funny noise . ', ' household appliance don ’ t seem to last for a long time nowadays . ', ' I think it ’ s because the manufactures are constantly bringing out new models . Because they know that we will buy the new models , the appliances don ’ t need to last more than five or ten year ']
['Hello , are you interested in this Honda ? ', ' Hi , I am just looking . ', " It's a good car . ", ' What year is it ? ', ' 1999 . ', ' How about the mileage ? ', ' 6,000 miles , all highway mileage . ', ' What do you mean 7B ', ' Highway miles are not as bad as local miles . They do not hurt car as much . ', ' Oh , why such a high mileage ? ', ' The owner was commuting everyday crossing the state line . ', ' Okay . Does this car have a warranty ? ', ' One month . ', ' How do I make sure I am not buying a junk ? ', " You'll check it out anyway you want . You can take it to a garage . ", ' How much is it ? ', ' $ 5,900 . ', " I'll have to think about it . ", ' Leave your phone number , and I will give you a call if the price gets reduced . ', ' Okay . ']
["It's very nice of you to invite me . ", " I'm very glad you could come , Mr . Liu . Will you take a seat at the head of the table ? It's an informal dinner , please don't stand on ceremony ... Mr . Liu , would you like to have some chicken ? ", ' Thank you . This is my first time to come to a Chinese restaurant . Could you tell me the different features of Chinese food ? ', ' Generally speaking , Cantonese food is a bit light ; Shanghai food is rather oily ; and Hunan dishes are very spicy , having a strong and hot taste . ', ' Chinese dishes are exquisitely prepared , delicious , and very palatable . They are very good in colour , flavour , and taste . ', ' Mr . Liu , would you care for another helping ? ', " No more , thank you . I'm quite full . ", ' Did you enjoy the meal ? ', " It's the most delicious dinner I've had for a long time . It's such a rich dinner . ", " I'm so glad you like it . ", ' Thank you very much for your hospitality . ']
["The demographic reports are in ... From the looks of it , we're going to have to re-evaluate some of the content for our promotional events in different venues . ", " Why , what's the lowdown ? ", " According to the report , our Boston crowd is quite different make-up from our Chicago folks . Our Boston consumers are mostly from mid-level to upper-class income levels , university or postgraduates , married no children , white collar ... You know the kind . Chicago on the other hand is mostly mid to low income levels , single parent homes , blue collar ... I think we're talking about two totally different target groups . ", ' I have no idea there was that great of deviation between the two venues ... To make our products sell , we have to take the target audience into account . ', " No kidding . We've got to come up with two completely different sales pitches to suit the needs of each groups . "]
['Excuse me , could you lend me some of your records ? ', ' Until when ? ', ' Until Monday or Tuesday next week . ', ' No problem . ']
['May I help you ? ', " Yes , I'm going to Europe on business and I need to purchase some Traveller's Cheques . ", " That's no problem . Which currency would you like to buy ? ", " I think Euros will be the best , as I'll only be in Mainland Europe . ", ' Of course . Do you have your passport with you ? How much would you like to purchase ? ', ' 5,000 Euros will be sufficient , thanks . ', ' Please fill in this form . How would you like it ? In 100 Euro cheques ? ', ' That would be perfect , thank you . ']
['Have you always been on this site ? ', ' No , we used to be on an industrial estate on the outskirts of York . ', ' Why did you move ? ', " We needed larger premises so we moved to this greenfield site last year . It's nearer the motorway so it's better for transportation . "]
['I want to open an account . ', ' What kind of account do you want to open ? ', ' I want to open a checking account . ', ' Do you know the minimum balance you ’ re required to keep ? ', ' How much is that ? ', ' You have to maintain a minimum balance of $ 100 . ', ' Really ? ', ' Yes , really . ', ' What if I can ’ t meet that requirement ? ', ' You will be fined . ', ' How much is the fine ? ', ' It ’ s going to cost you $ 25 . ']
["I'm so hungry ! Can you buy me a burrito ? ", " I don't have any money to buy you a burrito . ", " Please ? I haven't eaten anything all day . ", ' Look , I only have money to buy myself a burrito . ', " I'm so hungry , I could eat a whole cow ! ", " If you're so hungry , why don't you ask someone else for money ? ", " I get paid on Friday , I'll pay you back then . ", ' Well , I guess on Friday , then you can eat . ', " That's pretty messed up . ", " Why don't you just go home and eat ? ", " I don't want to go all the way home just to eat . ", " Well , I guess you're out of luck . "]
['Good coming . room service.What can I do for you ? ', " I'd like a hamburger and a cup of coffee.My room number is 402 . ", ' OK.sir . We will bring it to you as soon as possible . ', ' Thank you . ']
['can I get you something to drink ? ', " sure , but I don't drink much . So I don't know what to order . ", ' so how about an aperitif ? ', " it sounds good . I'd like to start with a Compare . ", ' stirred or shaken ? ', ' stirred will be fine . ', ' here you are . ', ' thanks . Does the bar have a signature drink ? ', ' sure . All of our mixed drinks are excellent . You can also try a delicious non-alcoholic cocktail . ', ' can you recommend one ? ', ' try a Singer . It has lime juice and grenadine over ice . ', " it sounds interesting . I'll take one . ", ' here we go . ', ' it tastes great . ', ' enjoy yourself . ', ' yeah . ']
['Kevin ? Hi , it ’ s Elizabeth . I have a big favor to ask you . ', ' How big , Elizabeth ? Last time you said that , I ended up working overtime 3 nights in a row ! ', ' Well , I ’ Ve got a huge load of typing and Mr . Blake has insisted I get it done by tomorrow afternoon . ', ' All right , Elizabeth . But this is the last time . ']
["I'm checking out now . Can I have my bill , please ? ", " Sure . What's your room number , sir ? ", " It's 8736 . Here is my key card . ", " A minute , please . It's 6212 yuan all together . Tax included . ", " Can I pay with traveler's check ? ", ' Sure . Can I have your passport , please ? ', ' Here you are . ', ' Thanks . Are you satisfied with your stay here with us , sir ? ', ' Very much . The room is cozy and the service is jolly good . By the way , could you deliver my luggage to the airport in advance ? ', ' Sure . It will be taken care of , sir . Which flight do you take ? ', " Flight 17 . And my luggage should be delivered there by 4 o'clock . ", " Got it , sir . It'd be great to see you again , sir . ", ' Thank you . ']
['My computer isn ’ t running at the same speed it used to be , it is testing my patience everyday . Can you tell me how to make it run faster ? ', ' If you want to speed up your system , you ’ Ve got to clean it up first . ', ' How ? ', ' You need to free your disk space . The simplest way is to use a Disk-Cleanup tool to remove temporary files and in store programs that you no longer use . Things should be fine next time you start . You also need to control what starts up . There is a program calls Start-up Delayer , It can help to set after how much time programs should be loaded after Windows boosts . For example , you can choose to set your Fox Mail program to load 30 seconds after Windows starts up . ', ' Very useful advice , I will try them right now . ']
['This suit looks nice.Can I try it on ? ', ' Yes , of course.The dressing room is over there . ']
['how was your day ? ', ' let ’ s start with you . How was yours ? ', ' it was really busy . I had to work straight through my lunch break . ', ' did you get to leave early then ? ', ' my boss told me that I could either go home early or take a long lunch break another day , so I decided to wait and take a long lunch break another time . ', ' it was nice of your boss to give you an option . My boss would never do that . ', ' let ’ s get back to you . How was your day ? ', ' it was horrible ! It was just one thing after another . ', ' you look pretty upset . Are you ok ? ', ' I ’ m fine . But I have bad news . ', ' what ’ s that ? ', ' I got sacked today . ', ' you ’ re kidding ! How did that happen ? ', ' well , I was late to work today . It was the third time I was late this week . ', ' how late were you ? ', ' only about 5 minutes . ', ' you got fired for being a few minutes late ? ', ' my boss is really picky about that . He never arrives late , usually works over-time , and always gets his work done on time . ', ' oh well . You never really liked your boss anyway , did you ? ']
['I can see by your resume here that you studied business administration . ', " That's right . ", ' So I wonder why you want to work for a newspaper . ', ' I did reporting for the university newspaper in my school.And I always be very interested in journalism . ', " But journalism , it is a very different profession from administration.You know a lot about administration.Why don't you choose to work for a company looking for managers ? ", " I study the administration.Yes.But I'm more attracted to writing articles . I want to use my knowledge of business to write financial news . ", ' A new reporter must expect to work many hours . ', " I know that starting reporters work many hours . I'm very willing to take on the challenge . "]
['I have an issue . ', ' What ’ s going on ? ', ' There is a leaking pipe in my wall . ', ' Is there any water damage ? ', ' There is mildew . ', ' I ’ ll go to your apartment tomorrow to fix the pipe . ', ' Why can ’ t I call someone to fix it today ? ', ' I ’ ll just do it myself . ', ' I need it done today . ', ' You ’ re right about that . ', ' Are you okay with me calling a plumber ? ', ' That ’ s fine . ']
["I'll have to go now . ", " Drop in if you're free.Bye for now ! ", ' See you . ']
["Excuse me , I don't feel good right now . ", ' What can I do for you ? ', ' Do you have any pills for airsickness ? ', ' Here you are . Take one at a time . ', ' Please fetch me a glass of water . Thanks . ', ' You are welcome . ']
["What's wrong ? ", " I have a headache . These past few days I've been living off painkillers . Man , I feel like my head is going to explode . ", ' You should get acupuncture treatment . My mom was always having headache issues and it was acupuncture that cured her . ', ' The results are too slow . On top of that , just the thought of smoking needles poking into my flesh frightens me . ', ' They don\'t just randomly stick you , they find your pressure points . The heat allows the body to immediately respond to the treatment , restoring the body\'s " chi " . ', ' But I get scared the moment I see a needle . How could I stand having needles in my body for hours on end ? ', " The needles are very thin , and as long as the doctor's technique is good , and the patient himself is relaxed , it won't hurt-on the contrary it will actually alleviate pain . Now there are high-tech needles that are micro thin ; they don't hurt at all . However , if you are really scared of acupuncture , scraping or cupping are also options . ", ' Scraping is too terrifying . When they finish scrapping , your body is all red , as if you were just tortured . Cupping is the same , your body ends up with red circles all over . It looks like someone beat you up . ', " This only signifies that the toxins have left the body . Actually , there is only discomfort during the treatment process . Once it's over you feel very comfortable . ", ' Chinese medicine is strange . The patients are already ill , and then the doctor makes them suffer more . ', ' This is the only way to get at the problem . Anyway , if you want to relieve the pain , you are just going to have to be tough and do it . ', " Forget it . I don't want to inflict any more pain on myself . In a little while I'll go and buy some more painkillers and take a nap . "]




### context os



The little book about OS development
Erik Helin, Adam Renberg
2015-01-19 | Commit: fe83e27dab3c39930354d2dea83f6d4ee29282122Contents
1 Introduction
7
About the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
The Reader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Credits, Thanks and Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Changes and Corrections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Issues and where to get help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9
License9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 First Steps
11
Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
Quick Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
Host Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Build System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Virtual Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Booting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
BIOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
The Bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
The Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
Hello Cafebabe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
Compiling the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
Linking the Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
Obtaining GRUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
Building an ISO Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
Running Bochs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
33 Getting to C
19
Setting Up a Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
Calling C Code From Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
Packing Structs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
Compiling C Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Build Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
4 Output
23
Interacting with the Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
The Framebuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Writing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Moving the Cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
The Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
The Serial Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
Configuring the Serial Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Configuring the Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Configuring the Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Configuring the Modem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Writing Data to the Serial Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30
Configuring Bochs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
The Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
5 Segmentation
33
Accessing Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
The Global Descriptor Table (GDT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Loading the GDT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
6 Interrupts and Input
39
Interrupts Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
Creating an Entry in the IDT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
Handling an Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
Creating a Generic Interrupt Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
Loading the IDT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
4Programmable Interrupt Controller (PIC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Reading Input from the Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
7 The Road to User Mode
47
Loading an External Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
GRUB Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Executing a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
A Very Simple Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Finding the Program in Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Jumping to the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
The Beginning of User Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
8 A Short Introduction to Virtual Memory
51
Virtual Memory Through Segmentation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
9 Paging
53
Why Paging? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Paging in x86 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Identity Paging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Enabling Paging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
A Few Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Paging and the Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Reasons to Not Identity Map the Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
The Virtual Address for the Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
Placing the Kernel at 0xC0000000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
Higher-half Linker Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Entering the Higher Half . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Running in the Higher Half . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Virtual Memory Through Paging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
510 Page Frame Allocation
61
Managing Available Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
How Much Memory is There? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Managing Available Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
How Can We Access a Page Frame? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
A Kernel Heap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
11 User Mode
65
Segments for User Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Setting Up For User Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Entering User Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66
Using C for User Mode Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
A C Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
12 File Systems
69
Why a File System? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
A Simple Read-Only File System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
Inodes and Writable File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
A Virtual File System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
13 System Calls
71
Designing System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Implementing System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
14 Multitasking
73
Creating New Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73
Cooperative Scheduling with Yielding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73
Preemptive Scheduling with Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Programmable Interval Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Separate Kernel Stacks for Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Difficulties with Preemptive Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
References
77
6Chapter 1
Introduction
This text is a practical guide to writing your own x86 operating system. It is designed to give enough help
with the technical details while at the same time not reveal too much with samples and code excerpts. We’ve
tried to collect parts of the vast (and often excellent) expanse of material and tutorials available, on the web
and otherwise, and add our own insights into the problems we encountered and struggled with.
This book is not about the theory behind operating systems, or how any specific operating system (OS)
works. For OS theory we recommend the book Modern Operating Systems by Andrew Tanenbaum [1]. Lists
and details on current operating systems are available on the Internet.
The starting chapters are quite detailed and explicit, to quickly get you into coding. Later chapters give
more of an outline of what is needed, as more and more of the implementation and design becomes up to the
reader, who should now be more familiar with the world of kernel development. At the end of some chapters
there are links for further reading, which might be interesting and give a deeper understanding of the topics
covered.
In chapter 2 and 3 we set up our development environment and boot up our OS kernel in a virtual machine,
eventually starting to write code in C. We continue in chapter 4 with writing to the screen and the serial
port, and then we dive into segmentation in chapter 5 and interrupts and input in chapter 6.
After this we have a quite functional but bare-bones OS kernel. In chapter 7 we start the road to user mode
applications, with virtual memory through paging (chapter 8 and 9), memory allocation (chapter 10), and
finally running a user application in chapter 11.
In the last three chapters we discuss the more advanced topics of file systems (chapter 12), system calls
(chapter 13), and multitasking (chapter 14).
About the Book
The OS kernel and this book were produced as part of an advanced individual course at the Royal Institute
of Technology [2], Stockholm. The authors had previously taken courses in OS theory, but had only minor
practical experience with OS kernel development. In order to get more insight and a deeper understanding
of how the theory from the previous OS courses works out in practice, the authors decided to create a new
course, which focused on the development of a small OS. Another goal of the course was writing a thorough
tutorial on how to develop a small OS basically from scratch, and this short book is the result.
The x86 architecture is, and has been for a long time, one of the most common hardware architectures. It was
not a difficult choice to use the x86 architecture as the target of the OS, with its large community, extensive
7reference material and mature emulators. The documentation and information surrounding the details of the
hardware we had to work with was not always easy to find or understand, despite (or perhaps due to) the
age of the architecture.
The OS was developed in about six weeks of full-time work. The implementation was done in many small
steps, and after each step the OS was tested manually. By developing in this incremental and iterative way,
it was often easier to find any bugs that were introduced, since only a small part of the code had changed
since the last known good state of the code. We encourage the reader to work in a similar way.
During the six weeks of development, almost every single line of code was written by the authors together
(this way of working is also called pair-programming). It is our belief that we managed to avoid a lot of bugs
due to this style of development, but this is hard to prove scientifically.
The Reader
The reader of this book should be comfortable with UNIX/Linux, systems programming, the C language and
computer systems in general (such as hexadecimal notation [3]). This book could be a way to get started
learning those things, but it will be more difficult, and developing an operating system is already challenging
on its own. Search engines and other tutorials are often helpful if you get stuck.
Credits, Thanks and Acknowledgements
We’d like to thank the OSDev community [4] for their great wiki and helpful members, and James Malloy for
his eminent kernel development tutorial [5]. We’d also like to thank our supervisor Torbjörn Granlund for his
insightful questions and interesting discussions.
Most of the CSS formatting of the book is based on the work by Scott Chacon for the book Pro Git,
http://progit.org/.
Contributors
We are very grateful for the patches that people send us. The following users have all contributed to this
book:
• alexschneider
• Avidanborisov
• nirs
• kedarmhaswade
• vamanea
• ansjob
Changes and Corrections
This book is hosted on Github - if you have any suggestions, comments or corrections, just fork the book,
write your changes, and send us a pull request. We’ll happily incorporate anything that makes this book
better.
8Issues and where to get help
If you run into problems while reading the book, please check the issues on Github for help: https://github.
com/littleosbook/littleosbook/issues.
License
All content is under the Creative Commons Attribution Non Commercial Share Alike 3.0 license, http:
//creativecommons.org/licenses/by-nc-sa/3.0/us/. The code samples are in the public domain - use them
however you want. References to this book are always received with warmth.
910Chapter 2
First Steps
Developing an operating system (OS) is no easy task, and the question “How do I even begin to solve this
problem?” is likely to come up several times during the course of the project for different problems. This
chapter will help you set up your development environment and booting a very small (and primitive) operating
system.
Tools
Quick Setup
We (the authors) have used Ubuntu [6] as the operating system for doing OS development, running it both
physically and virtually (using the virtual machine VirtualBox [7]). A quick way to get everything up and
running is to use the same setup as we did, since we know that these tools work with the samples provided in
this book.
Once Ubuntu is installed, either physical or virtual, the following packages should be installed using apt-get:
sudo apt-get install build-essential nasm genisoimage bochs bochs-sdl
Programming Languages
The operating system will be developed using the C programming language [8][9], using GCC [10]. We use C
because developing an OS requires a very precise control of the generated code and direct access to memory.
Other languages that provide the same features can also be used, but this book will only cover C.
The code will make use of one type attribute that is specific for GCC:
__attribute__((packed))
This attribute allows us to ensure that the compiler uses a memory layout for a struct exactly as we define
it in the code. This is explained in more detail in the next chapter.
Due to this attribute, the example code might be hard to compile using a C compiler other than GCC.
For writing assembly code, we have chosen NASM [11] as the assembler, since we prefer NASM’s syntax over
GNU Assembler.
Bash [12] will be used as the scripting language throughout the book.
11Host Operating System
All the code examples assumes that the code is being compiled on a UNIX like operating system. All code
examples have been successfully compiled using Ubuntu [6] versions 11.04 and 11.10.
Build System
Make [13] has been used when constructing the Makefile examples.
Virtual Machine
When developing an OS it is very convenient to be able to run your code in a virtual machine instead of on a
physical computer, since starting your OS in a virtual machine is much faster than getting your OS onto a
physical medium and then running it on a physical machine. Bochs [14] is an emulator for the x86 (IA-32)
platform which is well suited for OS development due to its debugging features. Other popular choices are
QEMU [15] and VirtualBox [7]. This book uses Bochs.
By using a virtual machine we cannot ensure that our OS works on real, physical hardware. The environment
simulated by the virtual machine is designed to be very similar to their physical counterparts, and the OS
can be tested on one by just copying the executable to a CD and finding a suitable machine.
Booting
Booting an operating system consists of transferring control along a chain of small programs, each one more
“powerful” than the previous one, where the operating system is the last “program”. See the following figure
for an example of the boot process:
Figure 2.1: An example of the boot process. Each box is a program.
BIOS
When the PC is turned on, the computer will start a small program that adheres to the Basic Input Output
System (BIOS) [16] standard. This program is usually stored on a read only memory chip on the motherboard
of the PC. The original role of the BIOS program was to export some library functions for printing to the
screen, reading keyboard input etc. Modern operating systems do not use the BIOS’ functions, they use
12drivers that interact directly with the hardware, bypassing the BIOS. Today, BIOS mainly runs some early
diagnostics (power-on-self-test) and then transfers control to the bootloader.
The Bootloader
The BIOS program will transfer control of the PC to a program called a bootloader. The bootloader’s task is
to transfer control to us, the operating system developers, and our code. However, due to some restrictions1
of the hardware and because of backward compatibility, the bootloader is often split into two parts: the first
part of the bootloader will transfer control to the second part, which finally gives control of the PC to the
operating system.
Writing a bootloader involves writing a lot of low-level code that interacts with the BIOS. Therefore, an
existing bootloader will be used: the GNU GRand Unified Bootloader (GRUB) [17].
Using GRUB, the operating system can be built as an ordinary ELF [18] executable, which will be loaded by
GRUB into the correct memory location. The compilation of the kernel requires that the code is laid out in
memory in a specific way (how to compile the kernel will be discussed later in this chapter).
The Operating System
GRUB will transfer control to the operating system by jumping to a position in memory. Before the jump,
GRUB will look for a magic number to ensure that it is actually jumping to an OS and not some random
code. This magic number is part of the multiboot specification [19] which GRUB adheres to. Once GRUB has
made the jump, the OS has full control of the computer.
Hello Cafebabe
This section will describe how to implement of the smallest possible OS that can be used together with
GRUB. The only thing the OS will do is write 0xCAFEBABE to the eax register (most people would probably
not even call this an OS).
Compiling the Operating System
This part of the OS has to be written in assembly code, since C requires a stack, which isn’t available (the
chapter “Getting to C” describes how to set one up). Save the following code in a file called loader.s:
global loader; the entry symbol for ELF
MAGIC_NUMBER equ 0x1BADB002
FLAGS
equ 0x0
CHECKSUM
equ -MAGIC_NUMBER; define the magic number constant
; multiboot flags
; calculate the checksum
; (magic number + checksum + flags should equal 0)
section .text:
align 4
dd MAGIC_NUMBER
dd FLAGS; start of the text (code) section
; the code must be 4 byte aligned
; write the magic number to the machine code,
; the flags,
1 The bootloader must fit into the master boot record (MBR) boot sector of a hard drive, which is only 512 bytes large.
13dd CHECKSUM
loader:
mov eax, 0xCAFEBABE
.loop:
jmp .loop
; and the checksum
; the loader label (defined as entry point in linker script)
; place the number 0xCAFEBABE in the register eax
; loop forever
The only thing this OS will do is write the very specific number 0xCAFEBABE to the eax register. It is very
unlikely that the number 0xCAFEBABE would be in the eax register if the OS did not put it there.
The file loader.s can be compiled into a 32 bits ELF [18] object file with the following command:
nasm -f elf32 loader.s
Linking the Kernel
The code must now be linked to produce an executable file, which requires some extra thought compared to
when linking most programs. We want GRUB to load the kernel at a memory address larger than or equal to
0x00100000 (1 megabyte (MB)), because addresses lower than 1 MB are used by GRUB itself, BIOS and
memory-mapped I/O. Therefore, the following linker script is needed (written for GNU LD [20]):
ENTRY(loader)/* the name of the entry label */
SECTIONS {
. = 0x00100000;/* the code should be loaded at 1 MB */
.text ALIGN (0x1000) :
{
*(.text)
}
/* align at 4 KB */
/* all text sections from all files */
.rodata ALIGN (0x1000) : /* align at 4 KB */
{
*(.rodata*)
/* all read-only data sections from all files */
}
.data ALIGN (0x1000) :
{
*(.data)
}/* align at 4 KB */
.bss ALIGN (0x1000) :
{
*(COMMON)
*(.bss)
}/* align at 4 KB */
/* all data sections from all files */
/* all COMMON sections from all files */
/* all bss sections from all files */
}
Save the linker script into a file called link.ld. The executable can now be linked with the following
command:
14ld -T link.ld -melf_i386 loader.o -o kernel.elf
The final executable will be called kernel.elf.
Obtaining GRUB
The GRUB version we will use is GRUB Legacy, since the OS ISO image can then be generated on
systems using both GRUB Legacy and GRUB 2. More specifically, the GRUB Legacy stage2_eltorito
bootloader will be used. This file can be built from GRUB 0.97 by downloading the source from ftp:
//alpha.gnu.org/gnu/grub/grub-0.97.tar.gz. However, the configure script doesn’t work well with Ubuntu
[21], so the binary file can be downloaded from http://littleosbook.github.com/files/stage2_eltorito. Copy
the file stage2_eltorito to the folder that already contains loader.s and link.ld.
Building an ISO Image
The executable must be placed on a media that can be loaded by a virtual or physical machine. In this book
we will use ISO [22] image files as the media, but one can also use floppy images, depending on what the
virtual or physical machine supports.
We will create the kernel ISO image with the program genisoimage. A folder must first be created that
contains the files that will be on the ISO image. The following commands create the folder and copy the files
to their correct places:
mkdir -p iso/boot/grub
cp stage2_eltorito iso/boot/grub/
cp kernel.elf iso/boot/
# create the folder structure
# copy the bootloader
# copy the kernel
A configuration file menu.lst for GRUB must be created. This file tells GRUB where the kernel is located
and configures some options:
default=0
timeout=0
title os
kernel /boot/kernel.elf
Place the file menu.lst in the folder iso/boot/grub/. The contents of the iso folder should now look like
the following figure:
iso
|-- boot
|-- grub
| |-- menu.lst
| |-- stage2_eltorito
|-- kernel.elf
The ISO image can then be generated with the following command:
15genisoimage -R
-b boot/grub/stage2_eltorito
-no-emul-boot
-boot-load-size 4
-A os
-input-charset utf8
-quiet
-boot-info-table
-o os.iso
iso
\
\
\
\
\
\
\
\
\
For more information about the flags used in the command, see the manual for genisoimage.
The ISO image os.iso now contains the kernel executable, the GRUB bootloader and the configuration file.
Running Bochs
Now we can run the OS in the Bochs emulator using the os.iso ISO image. Bochs needs a configuration file
to start and an example of a simple configuration file is given below:
megs:
32
display_library: sdl
romimage:
file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage:
file=/usr/share/bochs/VGABIOS-lgpl-latest
ata0-master:
type=cdrom, path=os.iso, status=inserted
boot:
cdrom
log:
bochslog.txt
clock:
sync=realtime, time0=local
cpu:
count=1, ips=1000000
You might need to change the path to romimage and vgaromimage depending on how you installed Bochs.
More information about the Bochs config file can be found at Boch’s website [23].
If you saved the configuration in a file named bochsrc.txt then you can run Bochs with the following
command:
bochs -f bochsrc.txt -q
The flag -f tells Bochs to use the given configuration file and the flag -q tells Bochs to skip the interactive
start menu. You should now see Bochs starting and displaying a console with some information from GRUB
on it.
After quitting Bochs, display the log produced by Boch:
cat bochslog.txt
You should now see the contents of the registers of the CPU simulated by Bochs somewhere in the output. If
you find RAX=00000000CAFEBABE or EAX=CAFEBABE (depending on if you are running Bochs with or without
64 bit support) in the output then your OS has successfully booted!
16Further Reading
• Gustavo Duertes has written an in-depth article about what actually happens when a x86 computer
boots up, http://duartes.org/gustavo/blog/post/how-computers-boot-up
• Gustavo continues to describe what the kernel does in the very early stages at http://duartes.org/
gustavo/blog/post/kernel-boot-process
• The OSDev wiki also contains a nice article about booting an x86 computer: http://wiki.osdev.org/
Boot_Sequence
1718Chapter 3
Getting to C
This chapter will show you how to use C instead of assembly code as the programming language for the OS.
Assembly is very good for interacting with the CPU and enables maximum control over every aspect of the
code. However, at least for the authors, C is a much more convenient language to use. Therefore, we would
like to use C as much as possible and use assembly code only where it make sense.
Setting Up a Stack
One prerequisite for using C is a stack, since all non-trivial C programs use a stack. Setting up a stack is not
harder than to make the esp register point to the end of an area of free memory (remember that the stack
grows towards lower addresses on the x86) that is correctly aligned (alignment on 4 bytes is recommended
from a performance perspective).
We could point esp to a random area in memory since, so far, the only thing in the memory is GRUB, BIOS,
the OS kernel and some memory-mapped I/O. This is not a good idea - we don’t know how much memory
is available or if the area esp would point to is used by something else. A better idea is to reserve a piece
of uninitialized memory in the bss section in the ELF file of the kernel. It is better to use the bss section
instead of the data section to reduce the size of the OS executable. Since GRUB understands ELF, GRUB
will allocate any memory reserved in the bss section when loading the OS.
The NASM pseudo-instruction resb [24] can be used to declare uninitialized data:
KERNEL_STACK_SIZE equ 4096; size of stack in bytes
section .bss
align 4
kernel_stack:
resb KERNEL_STACK_SIZE; align at 4 bytes
; label points to beginning of memory
; reserve stack for the kernel
There is no need to worry about the use of uninitialized memory for the stack, since it is not possible to
read a stack location that has not been written (without manual pointer fiddling). A (correct) program can
not pop an element from the stack without having pushed an element onto the stack first. Therefore, the
memory locations of the stack will always be written to before they are being read.
The stack pointer is then set up by pointing esp to the end of the kernel_stack memory:
mov esp, kernel_stack + KERNEL_STACK_SIZE
19
; point esp to the start of the
; stack (end of memory area)Calling C Code From Assembly
The next step is to call a C function from assembly code. There are many different conventions for how to
call C code from assembly code [25]. This book uses the cdecl calling convention, since that is the one used
by GCC. The cdecl calling convention states that arguments to a function should be passed via the stack (on
x86). The arguments of the function should be pushed on the stack in a right-to-left order, that is, you push
the rightmost argument first. The return value of the function is placed in the eax register. The following
code shows an example:
/* The C function */
int sum_of_three(int arg1, int arg2, int arg3)
{
return arg1 + arg2 + arg3;
}
; The assembly code
external sum_of_three; the function sum_of_three is defined elsewhere
push dword 3
push dword 2
push dword 1
call sum_of_three; arg3
; arg2
; arg1
; call the function, the result will be in eax
Packing Structs
In the rest of this book, you will often come across “configuration bytes” that are a collection of bits in a
very specific order. Below follows an example with 32 bits:
Bit:
| 31
Content: | index
24 | 23
| address
8 | 7
0 |
| config |
Instead of using an unsigned integer, unsigned int, for handling such configurations, it is much more
convenient to use “packed structures”:
struct example {
unsigned char config;
/* bit 0 - 7
*/
unsigned short address; /* bit 8 - 23 */
unsigned char index;
/* bit 24 - 31 */
};
When using the struct in the previous example there is no guarantee that the size of the struct will be
exactly 32 bits - the compiler can add some padding between elements for various reasons, for example to
speed up element access or due to requirements set by the hardware and/or compiler. When using a struct
to represent configuration bytes, it is very important that the compiler does not add any padding, because
the struct will eventually be treated as a 32 bit unsigned integer by the hardware. The attribute packed
can be used to force GCC to not add any padding:
struct example {
unsigned char config;
/* bit 0 - 7
20
*/unsigned short address; /* bit 8 - 23 */
unsigned char index;
/* bit 24 - 31 */
} __attribute__((packed));
Note that __attribute__((packed)) is not part of the C standard - it might not work with all C compilers.
Compiling C Code
When compiling the C code for the OS, a lot of flags to GCC need to be used. This is because the C code
should not assume the presence of a standard library, since there is no standard library available for our OS.
For more information about the flags, see the GCC manual.
The flags used for compiling the C code are:
-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles
-nodefaultlibs
As always when writing C programs we recommend turning on all warnings and treat warnings as errors:
-Wall -Wextra -Werror
You can now create a function kmain in a file called kmain.c that you call from loader.s. At this point,
kmain probably won’t need any arguments (but in later chapters it will).
Build Tools
Now is also probably a good time to set up some build tools to make it easier to compile and test-run the OS.
We recommend using make [13], but there are plenty of other build systems available. A simple Makefile for
the OS could look like the following example:
OBJECTS = loader.o kmain.o
CC = gcc
CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector \
-nostartfiles -nodefaultlibs -Wall -Wextra -Werror -c
LDFLAGS = -T link.ld -melf_i386
AS = nasm
ASFLAGS = -f elf
all: kernel.elf
kernel.elf: $(OBJECTS)
ld $(LDFLAGS) $(OBJECTS) -o kernel.elf
os.iso: kernel.elf
cp kernel.elf iso/boot/kernel.elf
genisoimage -R
-b boot/grub/stage2_eltorito
-no-emul-boot
21
\
\
\-boot-load-size 4
-A os
-input-charset utf8
-quiet
-boot-info-table
-o os.iso
iso
\
\
\
\
\
\
run: os.iso
bochs -f bochsrc.txt -q
%.o: %.c
$(CC) $(CFLAGS)
$< -o $@
%.o: %.s
$(AS) $(ASFLAGS) $< -o $@
clean:
rm -rf *.o kernel.elf os.iso
The contents of your working directory should now look like the following figure:
.
|-- bochsrc.txt
|-- iso
|
|-- boot
|
|-- grub
|
|-- menu.lst
|
|-- stage2_eltorito
|-- kmain.c
|-- loader.s
|-- Makefile
You should now be able to start the OS with the simple command make run, which will compile the kernel
and boot it up in Bochs (as defined in the Makefile above).
Further Reading
• Kernigan & Richie’s book, The C Programming Language, Second Edition, [8] is great for learning
about all the aspects of C.
22Chapter 4
Output
This chapter will present how to display text on the console as well as writing data to the serial port.
Furthermore, we will create our first driver, that is, code that acts as a layer between the kernel and the
hardware, providing a higher abstraction than communicating directly with the hardware. The first part of
this chapter is about creating a driver for the framebuffer [26] to be able to display text on the console. The
second part shows how to create a driver for the serial port. Bochs can store output from the serial port in a
file, effectively creating a logging mechanism for the operating system.
Interacting with the Hardware
There are usually two different ways to interact with the hardware, memory-mapped I/O and I/O ports.
If the hardware uses memory-mapped I/O then you can write to a specific memory address and the hardware
will be updated with the new data. One example of this is the framebuffer, which will be discussed in more
detail later. For example, if you write the value 0x410F to address 0x000B8000, you will see the letter A in
white color on a black background (see the section on the framebuffer for more details).
If the hardware uses I/O ports then the assembly code instructions out and in must be used to communicate
with the hardware. The instruction out takes two parameters: the address of the I/O port and the data to
send. The instruction in takes a single parameter, the address of the I/O port, and returns data from the
hardware. One can think of I/O ports as communicating with hardware the same way as you communicate
with a server using sockets. The cursor (the blinking rectangle) of the framebuffer is one example of hardware
controlled via I/O ports on a PC.
The Framebuffer
The framebuffer is a hardware device that is capable of displaying a buffer of memory on the screen [26]. The
framebuffer has 80 columns and 25 rows, and the row and column indices start at 0 (so rows are labelled 0 -
24).
Writing Text
Writing text to the console via the framebuffer is done with memory-mapped I/O. The starting address of
the memory-mapped I/O for the framebuffer is 0x000B8000 [27]. The memory is divided into 16 bit cells,
23where the 16 bits determine both the character, the foreground color and the background color. The highest
eight bits is the ASCII [28] value of the character, bit 7 - 4 the background and bit 3 - 0 the foreground, as
can be seen in the following figure:
Bit:
| 15 14 13 12 11 10 9 8 | 7 6 5 4 | 3 2 1 0 |
Content: | ASCII
| FG
| BG
|
The available colors are shown in the following table:
ColorValueColorValue
Color
Value
Color
Value
Black0Red4Dark grey8Light red12
Blue1Magenta5Light blue9Light magenta13
Green2Brown6Light green10Light brown14
Cyan3Light grey7Light cyan11White15
The first cell corresponds to row zero, column zero on the console. Using an ASCII table, one can see that A
corresponds to 65 or 0x41. Therefore, to write the character A with a green foreground (2) and dark grey
background (8) at place (0,0), the following assembly code instruction is used:
mov [0x000B8000], 0x4128
The second cell then corresponds to row zero, column one and its address is therefore:
0x000B8000 + 16 = 0x000B8010
Writing to the framebuffer can also be done in C by treating the address 0x000B8000 as a char pointer,
char *fb = (char *) 0x000B8000. Then, writing A at place (0,0) with green foreground and dark grey
background becomes:
fb[0] = ’A’;
fb[1] = 0x28;
The following code shows how this can be wrapped into a function:
/** fb_write_cell:
* Writes a character with the given foreground and background to position i
* in the framebuffer.
*
* @param i The location in the framebuffer
* @param c The character
* @param fg The foreground color
* @param bg The background color
*/
void fb_write_cell(unsigned int i, char c, unsigned char fg, unsigned char bg)
{
fb[i] = c;
fb[i + 1] = ((fg & 0x0F) << 4) | (bg & 0x0F)
}
24The function can then be used as follows:
#define FB_GREEN
2
#define FB_DARK_GREY 8
fb_write_cell(0, ’A’, FB_GREEN, FB_DARK_GREY);
Moving the Cursor
Moving the cursor of the framebuffer is done via two different I/O ports. The cursor’s position is determined
with a 16 bits integer: 0 means row zero, column zero; 1 means row zero, column one; 80 means row one,
column zero and so on. Since the position is 16 bits large, and the out assembly code instruction argument is
8 bits, the position must be sent in two turns, first 8 bits then the next 8 bits. The framebuffer has two I/O
ports, one for accepting the data, and one for describing the data being received. Port 0x3D4 [29] is the port
that describes the data and port 0x3D5 [29] is for the data itself.
To set the cursor at row one, column zero (position 80 = 0x0050), one would use the following assembly
code instructions:
out 0x3D4, 14
out 0x3D5, 0x00
out 0x3D4, 15
out 0x3D5, 0x50
; 14 tells the framebuffer to expect the highest 8 bits of the position
; sending the highest 8 bits of 0x0050
; 15 tells the framebuffer to expect the lowest 8 bits of the position
; sending the lowest 8 bits of 0x0050
The out assembly code instruction can’t be executed directly in C. Therefore it is a good idea to wrap out in
a function in assembly code which can be accessed from C via the cdecl calling standard [25]:
global outb
; make the label outb visible outside this file
; outb - send a byte to an I/O port
; stack: [esp + 8] the data byte
;
[esp + 4] the I/O port
;
[esp
] return address
outb:
mov al, [esp + 8]
; move the data to be sent into the al register
mov dx, [esp + 4]
; move the address of the I/O port into the dx register
out dx, al
; send the data to the I/O port
ret
; return to the calling function
By storing this function in a file called io.s and also creating a header io.h, the out assembly code instruction
can be conveniently accessed from C:
#ifndef INCLUDE_IO_H
#define INCLUDE_IO_H
/** outb:
* Sends the given data to the given I/O port. Defined in io.s
*
* @param port The I/O port to send the data to
* @param data The data to send to the I/O port
25*/
void outb(unsigned short port, unsigned char data);
#endif /* INCLUDE_IO_H */
Moving the cursor can now be wrapped in a C function:
#include "io.h"
/* The I/O ports */
#define FB_COMMAND_PORT
#define FB_DATA_PORT0x3D4
0x3D5
/* The I/O port commands */
#define FB_HIGH_BYTE_COMMAND
#define FB_LOW_BYTE_COMMAND14
15
/** fb_move_cursor:
* Moves the cursor of the framebuffer to the given position
*
* @param pos The new position of the cursor
*/
void fb_move_cursor(unsigned short pos)
{
outb(FB_COMMAND_PORT, FB_HIGH_BYTE_COMMAND);
outb(FB_DATA_PORT,
((pos >> 8) & 0x00FF));
outb(FB_COMMAND_PORT, FB_LOW_BYTE_COMMAND);
outb(FB_DATA_PORT,
pos & 0x00FF);
}
The Driver
The driver should provide an interface that the rest of the code in the OS will use for interacting with the
framebuffer. There is no right or wrong in what functionality the interface should provide, but a suggestion
is to have a write function with the following declaration:
int write(char *buf, unsigned int len);
The write function writes the contents of the buffer buf of length len to the screen. The write function
should automatically advance the cursor after a character has been written and scroll the screen if necessary.
The Serial Ports
The serial port [30] is an interface for communicating between hardware devices and although it is available
on almost all motherboards, it is seldom exposed to the user in the form of a DE-9 connector nowadays. The
serial port is easy to use, and, more importantly, it can be used as a logging utility in Bochs. If a computer
has support for a serial port, then it usually has support for multiple serial ports, but we will only make use
of one of the ports. This is because we will only use the serial ports for logging. Furthermore, we will only
use the serial ports for output, not input. The serial ports are completely controlled via I/O ports.
26Configuring the Serial Port
The first data that need to be sent to the serial port is configuration data. In order for two hardware devices
to be able to talk to each other they must agree upon a couple of things. These things include:
• The speed used for sending data (bit or baud rate)
• If any error checking should be used for the data (parity bit, stop bits)
• The number of bits that represent a unit of data (data bits)
Configuring the Line
Configuring the line means to configure how data is being sent over the line. The serial port has an I/O port,
the line command port, that is used for configuration.
First the speed for sending data will be set. The serial port has an internal clock that runs at 115200 Hz.
Setting the speed means sending a divisor to the serial port, for example sending 2 results in a speed of
115200 / 2 = 57600 Hz.
The divisor is a 16 bit number but we can only send 8 bits at a time. We must therefore send an instruction
telling the serial port to first expect the highest 8 bits, then the lowest 8 bits. This is done by sending 0x80
to the line command port. An example is shown below:
#include "io.h" /* io.h is implement in the section "Moving the cursor" */
/* The I/O ports */
/* All the I/O ports are calculated relative to the data port. This is because
* all serial ports (COM1, COM2, COM3, COM4) have their ports in the same
* order, but they start at different values.
*/
#define SERIAL_COM1_BASE
0x3F8
/* COM1 base port */
#define SERIAL_DATA_PORT(base)
(base)
#define SERIAL_FIFO_COMMAND_PORT(base) (base + 2)
#define SERIAL_LINE_COMMAND_PORT(base) (base + 3)
#define SERIAL_MODEM_COMMAND_PORT(base) (base + 4)
#define SERIAL_LINE_STATUS_PORT(base)
(base + 5)
/* The I/O port commands */
/* SERIAL_LINE_ENABLE_DLAB:
* Tells the serial port to expect first the highest 8 bits on the data port,
* then the lowest 8 bits will follow
*/
#define SERIAL_LINE_ENABLE_DLAB
0x80
/** serial_configure_baud_rate:
* Sets the speed of the data being sent. The default speed of a serial
* port is 115200 bits/s. The argument is a divisor of that number, hence
* the resulting speed becomes (115200 / divisor) bits/s.
27*
* @param com
The COM port to configure
* @param divisor The divisor
*/
void serial_configure_baud_rate(unsigned short com, unsigned short divisor)
{
outb(SERIAL_LINE_COMMAND_PORT(com),
SERIAL_LINE_ENABLE_DLAB);
outb(SERIAL_DATA_PORT(com),
(divisor >> 8) & 0x00FF);
outb(SERIAL_DATA_PORT(com),
divisor & 0x00FF);
}
The way that data should be sent must be configured. This is also done via the line command port by sending
a byte. The layout of the 8 bits looks like the following:
Bit:
| 7 | 6 | 5 4 3 | 2 | 1 0 |
Content: | d | b | prty | s | dl |
A description for each name can be found in the table below (and in [31]):
Name
Description
dEnables (d = 1) or disables (d = 0) DLAB
bIf break control is enabled (b = 1) or disabled (b = 0)
prty
The number of parity bits to use
sThe number of stop bits to use (s = 0 equals 1, s = 1 equals 1.5 or 2)
dlDescribes the length of the data
We will use the mostly standard value 0x03 [31], meaning a length of 8 bits, no parity bit, one stop bit and
break control disabled. This is sent to the line command port, as seen in the following example:
/** serial_configure_line:
* Configures the line of the given serial port. The port is set to have a
* data length of 8 bits, no parity bits, one stop bit and break control
* disabled.
*
* @param com The serial port to configure
*/
void serial_configure_line(unsigned short com)
{
/* Bit:
| 7 | 6 | 5 4 3 | 2 | 1 0 |
* Content: | d | b | prty | s | dl |
* Value:
| 0 | 0 | 0 0 0 | 0 | 1 1 | = 0x03
*/
outb(SERIAL_LINE_COMMAND_PORT(com), 0x03);
}
28The article on OSDev [31] has a more in-depth explanation of the values.
Configuring the Buffers
When data is transmitted via the serial port it is placed in buffers, both when receiving and sending data.
This way, if you send data to the serial port faster than it can send it over the wire, it will be buffered.
However, if you send too much data too fast the buffer will be full and data will be lost. In other words, the
buffers are FIFO queues. The FIFO queue configuration byte looks like the following figure:
Bit:
| 7 6 | 5 | 4 | 3
| 2
| 1
| 0 |
Content: | lvl | bs | r | dma | clt | clr | e |
A description for each name can be found in the table below:
Name
Description
lvlHow many bytes should be stored in the FIFO buffers
bsIf the buffers should be 16 or 64 bytes large
rReserved for future use
dma
How the serial port data should be accessed
cltClear the transmission FIFO buffer
clrClear the receiver FIFO buffer
eIf the FIFO buffer should be enabled or not
We use the value 0xC7 = 11000111 that:
• Enables FIFO
• Clear both receiver and transmission FIFO queues
• Use 14 bytes as size of queue
The WikiBook on serial programming [32] explains the values in more depth.
Configuring the Modem
The modem control register is used for very simple hardware flow control via the Ready To Transmit (RTS)
and Data Terminal Ready (DTR) pins. When configuring the serial port we want RTS and DTR to be 1,
which means that we are ready to send data.
The modem configuration byte is shown in the following figure:
Bit:
| 7 | 6 | 5 | 4 | 3
| 2
| 1
| 0
|
Content: | r | r | af | lb | ao2 | ao1 | rts | dtr |
A description for each name can be found in the table below:
29Name
Description
rReserved
afAutoflow control enabled
lbLoopback mode (used for debugging serial ports)
ao2Auxiliary output 2, used for receiving interrupts
ao1Auxiliary output 1
rtsReady To Transmit
dtrData Terminal Ready
We don’t need to enable interrupts, because we won’t handle any received data. Therefore we use the
configuration value 0x03 = 00000011 (RTS = 1 and DTS = 1).
Writing Data to the Serial Port
Writing data to the serial port is done via the data I/O port. However, before writing, the transmit FIFO
queue has to be empty (all previous writes must have finished). The transmit FIFO queue is empty if bit 5 of
the line status I/O port is equal to one.
Reading the contents of an I/O port is done via the in assembly code instruction. There is no way to use the
in assembly code instruction from C, therefore it has to be wrapped (the same way as the out assembly code
instruction):
global inb
; inb - returns a byte from the given I/O port
; stack: [esp + 4] The address of the I/O port
;
[esp
] The return address
inb:
mov dx, [esp + 4]
; move the address of the I/O port to the dx register
in al, dx
; read a byte from the I/O port and store it in the al register
ret
; return the read byte
/* in file io.h */
/** inb:
* Read a byte from an I/O port.
*
* @param port The address of the I/O port
* @return
The read byte
*/
unsigned char inb(unsigned short port);
Checking if the transmit FIFO is empty can then be done from C:
#include "io.h"
30/** serial_is_transmit_fifo_empty:
* Checks whether the transmit FIFO queue is empty or not for the given COM
* port.
*
* @param com The COM port
* @return 0 if the transmit FIFO queue is not empty
*
1 if the transmit FIFO queue is empty
*/
int serial_is_transmit_fifo_empty(unsigned int com)
{
/* 0x20 = 0010 0000 */
return inb(SERIAL_LINE_STATUS_PORT(com)) & 0x20;
}
Writing to a serial port means spinning as long as the transmit FIFO queue isn’t empty, and then writing the
data to the data I/O port.
Configuring Bochs
To save the output from the first serial serial port the Bochs configuration file bochsrc.txt must be updated.
The com1 configuration instructs Bochs how to handle first serial port:
com1: enabled=1, mode=file, dev=com1.out
The output from serial port one will now be stored in the file com1.out.
The Driver
We recommend that you implement a write function for the serial port similar to the write function in the
driver for the framebuffer. To avoid name clashes with the write function for the framebuffer it is a good
idea to name the functions fb_write and serial_write to distinguish them.
We further recommend that you try to write a printf-like function, see section 7.3 in [8]. The printf
function could take an additional argument to decide to which device to write the output (framebuffer or
serial).
A final recommendation is that you create some way of distinguishing the severeness of the log messages, for
example by prepending the messages with DEBUG, INFO or ERROR.
Further Reading
• The book “Serial programming” (available on WikiBooks) has a great section on programming the
serial port, http://en.wikibooks.org/wiki/Serial_Programming/8250_UART_Programming#UART_
Registers
• The OSDev wiki has a page with a lot of information about the serial ports, http://wiki.osdev.org/
Serial_ports
3132Chapter 5
Segmentation
Segmentation in x86 means accessing the memory through segments. Segments are portions of the address
space, possibly overlapping, specified by a base address and a limit. To address a byte in segmented memory
you use a 48-bit logical address: 16 bits that specifies the segment and 32-bits that specifies what offset within
that segment you want. The offset is added to the base address of the segment, and the resulting linear
address is checked against the segment’s limit - see the figure below. If everything works out fine (including
access-rights checks ignored for now) the result is a linear address. When paging is disabled, then the linear
address space is mapped 1:1 onto the physical address space, and the physical memory can be accessed. (See
the chapter “Paging” for how to enable paging.)
To enable segmentation you need to set up a table that describes each segment - a segment descriptor table.
In x86, there are two types of descriptor tables: the Global Descriptor Table (GDT) and Local Descriptor
Tables (LDT). An LDT is set up and managed by user-space processes, and all processes have their own LDT.
LDTs can be used if a more complex segmentation model is desired - we won’t use it. The GDT is shared by
everyone - it’s global.
As we discuss in the sections on virtual memory and paging, segmentation is rarely used more than in a
minimal setup, similar to what we do below.
Accessing Memory
Most of the time when accessing memory there is no need to explicitly specify the segment to use. The
processor has six 16-bit segment registers: cs, ss, ds, es, gs and fs. The register cs is the code segment
register and specifies the segment to use when fetching instructions. The register ss is used whenever accessing
the stack (through the stack pointer esp), and ds is used for other data accesses. The OS is free to use the
registers es, gs and fs however it want.
Below is an example showing implicit use of the segment registers:
func:
mov eax, [esp+4]
mov ebx, [eax]
add ebx, 8
mov [eax], ebx
ret
The above example can be compared with the following one that makes explicit use of the segment registers:
33Figure 5.1: Translation of logical addresses to linear addresses.
34func:
mov eax, [ss:esp+4]
mov ebx, [ds:eax]
add ebx, 8
mov [ds:eax], ebx
ret
You don’t need to use ss for storing the stack segment selector, or ds for the data segment selector. You
could store the stack segment selector in ds and vice versa. However, in order to use the implicit style shown
above, you must store the segment selectors in their indented registers.
Segment descriptors and their fields are described in figure 3-8 in the Intel manual [33].
The Global Descriptor Table (GDT)
A GDT/LDT is an array of 8-byte segment descriptors. The first descriptor in the GDT is always a null
descriptor and can never be used to access memory. At least two segment descriptors (plus the null descriptor)
are needed for the GDT, because the descriptor contains more information than just the base and limit fields.
The two most relevant fields for us are the Type field and the Descriptor Privilege Level (DPL) field.
Table 3-1 in chapter 3 of the Intel manual [33] specifies the values for the Type field. The table shows that
the Type field can’t be both writable and executable at the same time. Therefore, two segments are needed:
one segment for executing code to put in cs (Type is Execute-only or Execute-Read) and one segment for
reading and writing data (Type is Read/Write) to put in the other segment registers.
The DPL specifies the privilege levels required to use the segment. x86 allows for four privilege levels (PL), 0
to 3, where PL0 is the most privileged. In most operating systems (eg. Linux and Windows), only PL0 and
PL3 are used. However, some operating system, such as MINIX, make use of all levels. The kernel should be
able to do anything, therefore it uses segments with DPL set to 0 (also called kernel mode). The current
privilege level (CPL) is determined by the segment selector in cs.
The segments needed are described in the table below.
IndexOffsetName
Address rangeTypeDPL
00x00null descriptor
10x08kernel code segment0x00000000 - 0xFFFFFFFFRXPL0
20x10kernel data segment0x00000000 - 0xFFFFFFFFRWPL0
Table 5.1: The segment descriptors needed.
Note that the segments overlap - they both encompass the entire linear address space. In our minimal setup
we’ll only use segmentation to get privilege levels. See the Intel manual [33], chapter 3, for details on the
other descriptor fields.
35Loading the GDT
Loading the GDT into the processor is done with the lgdt assembly code instruction, which takes the address
of a struct that specifies the start and size of the GDT. It is easiest to encode this information using a “packed
struct” as shown in the following example:
struct gdt {
unsigned int address;
unsigned short size;
} __attribute__((packed));
If the content of the eax register is the address to such a struct, then the GDT can be loaded with the
assembly code shown below:
lgdt [eax]
It might be easier if you make this instruction available from C, the same way as was done with the assembly
code instructions in and out.
After the GDT has been loaded the segment registers needs to be loaded with their corresponding segment
selectors. The content of a segment selector is described in the figure and table below:
Bit:
| 15
Content: | offset (index)
3 | 2 | 1 0 |
| ti | rpl |
NameDescription
rplRequested Privilege Level - we want to execute in PL0 for now.
tiTable Indicator. 0 means that this specifies a GDT segment, 1 means an LDT
Segment.
offset (index)Offset within descriptor table.
Table 5.2: The layout of segment selectors.
The offset of the segment selector is added to the start of the GDT to get the address of the segment descriptor:
0x08 for the first descriptor and 0x10 for the second, since each descriptor is 8 bytes. The Requested Privilege
Level (RPL) should be 0 since the kernel of the OS should execute in privilege level 0.
Loading the segment selector registers is easy for the data registers - just copy the correct offsets to the
registers:
mov ds, 0x10
mov ss, 0x10
mov es, 0x10
.
.
.
36To load cs we have to do a “far jump”:
; code here uses the previous cs
jmp 0x08:flush_cs
; specify cs when jumping to flush_cs
flush_cs:
; now we’ve changed cs to 0x08
A far jump is a jump where we explicitly specify the full 48-bit logical address: the segment selector to use
and the absolute address to jump to. It will first set cs to 0x08 and then jump to flush_cs using its absolute
address.
Further Reading
• Chapter 3 of the Intel manual [33] is filled with low-level and technical details about segmentation.
• The OSDev wiki has a page about segmentation: http://wiki.osdev.org/Segmentation
• The Wikipedia page on x86 segmentation might be worth looking into: http://en.wikipedia.org/wiki/
X86_memory_segmentation
3738Chapter 6
Interrupts and Input
Now that the OS can produce output it would be nice if it also could get some input. (The operating system
must be able to handle interrupts in order to read information from the keyboard). An interrupt occurs
when a hardware device, such as the keyboard, the serial port or the timer, signals the CPU that the state of
the device has changed. The CPU itself can also send interrupts due to program errors, for example when a
program references memory it doesn’t have access to, or when a program divides a number by zero. Finally,
there are also software intterupts, which are interrupts that are caused by the int assembly code instruction,
and they are often used for system calls.
Interrupts Handlers
Interrupts are handled via the Interrupt Descriptor Table (IDT). The IDT describes a handler for each
interrupt. The interrupts are numbered (0 - 255) and the handler for interrupt i is defined at the ith position
in the table. There are three different kinds of handlers for interrupts:
• Task handler
• Interrupt handler
• Trap handler
The task handlers use functionality specific to the Intel version of x86, so they won’t be covered here (see the
Intel manual [33], chapter 6, for more info). The only difference between an interrupt handler and a trap
handler is that the interrupt handler disables interrupts, which means you cannot get an interrupt while at
the same time handling an interrupt. In this book, we will use trap handlers and disable interrupts manually
when we need to.
Creating an Entry in the IDT
An entry in the IDT for an interrupt handler consists of 64 bits. The highest 32 bits are shown in the figure
below:
Bit:
| 31
Content: | offset high
16 | 15 | 14 13 | 12 | 11 | 10 9 8 | 7 6 5 | 4 3 2 1 0 |
| P | DPL
| 0 | D | 1 1 0 | 0 0 0 | reserved |
39The lowest 32 bits are presented in the following figure:
Bit:
| 31
16 | 15
Content: | segment selector
| offset low
0 |
|
A description for each name can be found in the table below:
Name
Description
offset highThe 16 highest bits of the 32 bit address in the segment.
offset lowThe 16 lowest bits of the 32 bits address in the segment.
p
DPL
D
segment selector
r
If the handler is present in memory or not (1 = present, 0 = not present).
Descriptor Privilige Level, the privilege level the handler can be called from (0, 1, 2, 3).
Size of gate, (1 = 32 bits, 0 = 16 bits).
The offset in the GDT.
Reserved.
The offset is a pointer to code (preferably an assembly code label). For example, to create an entry for a
handler whose code starts at 0xDEADBEEF and that runs in privilege level 0 (therefore using the same code
segment selector as the kernel) the following two bytes would be used:
0xDEAD8E00
0x0008BEEF
If the IDT is represented as an unsigned integer idt[512] then to register the above example as an
handler for interrupt 0 (divide-by-zero), the following code would be used:
idt[0] = 0xDEAD8E00
idt[1] = 0x0008BEEF
As written in the chapter “Getting to C”, we recommend that you instead of using bytes (or unsigned integers)
use packed structures to make the code more readable.
Handling an Interrupt
When an interrupt occurs the CPU will push some information about the interrupt onto the stack, then look
up the appropriate interrupt hander in the IDT and jump to it. The stack at the time of the interrupt will
look like the following:
[esp + 12] eflags
[esp + 8] cs
[esp + 4] eip
[esp]
error code?
40The reason for the question mark behind error code is that not all interrupts create an error code. The specific
CPU interrupts that put an error code on the stack are 8, 10, 11, 12, 13, 14 and 17. The error code can be
used by the interrupt handler to get more information on what has happened. Also, note that the interrupt
number is not pushed onto the stack. We can only determine what interrupt has occurred by knowing what
code is executing - if the handler registered for interrupt 17 is executing, then interrupt 17 has occurred.
Once the interrupt handler is done, it uses the iret instruction to return. The instruction iret expects the
stack to be the same as at the time of the interrupt (see the figure above). Therefore, any values pushed onto
the stack by the interrupt handler must be popped. Before returning, iret restores eflags by popping the
value from the stack and then finally jumps to cs:eip as specified by the values on the stack.
The interrupt handler has to be written in assembly code, since all registers that the interrupt handlers use
must be preserved by pushing them onto the stack. This is because the code that was interrupted doesn’t
know about the interrupt and will therefore expect that its registers stay the same. Writing all the logic of
the interrupt handler in assembly code will be tiresome. Creating a handler in assembly code that saves the
registers, calls a C function, restores the registers and finally executes iret is a good idea!
The C handler should get the state of the registers, the state of the stack and the number of the interrupt as
arguments. The following definitions can for example be used:
struct cpu_state {
unsigned int eax;
unsigned int ebx;
unsigned int ecx;
.
.
.
unsigned int esp;
} __attribute__((packed));
struct stack_state {
unsigned int error_code;
unsigned int eip;
unsigned int cs;
unsigned int eflags;
} __attribute__((packed));
void interrupt_handler(struct cpu_state cpu, struct stack_state stack, unsigned int interrupt);
Creating a Generic Interrupt Handler
Since the CPU does not push the interrupt number on the stack it is a little tricky to write a generic interrupt
handler. This section will use macros to show how it can be done. Writing one version for each interrupt is
tedious - it is better to use the macro functionality of NASM [34]. And since not all interrupts produce an
error code the value 0 will be added as the “error code” for interrupts without an error code. The following
code shows an example of how this can be done:
%macro no_error_code_interrupt_handler %1
global interrupt_handler_%1
interrupt_handler_%1:
push
dword 0
; push 0 as error code
41push
jmp
%endmacro
dword %1
common_interrupt_handler
; push the interrupt number
; jump to the common handler
%macro error_code_interrupt_handler %1
global interrupt_handler_%1
interrupt_handler_%1:
push
dword %1
jmp
common_interrupt_handler
%endmacro
; push the interrupt number
; jump to the common handler
common_interrupt_handler:
; save the registers
push
eax
push
ebx
.
.
.
push
ebp
; the common parts of the generic interrupt handler
; call the C function
call
interrupt_handler
; restore the registers
pop
ebp
.
.
.
pop
ebx
pop
eax
; restore the esp
add
esp, 8
; return to the code that got interrupted
iret
no_error_code_interrupt_handler 0
no_error_code_interrupt_handler 1
.
.
.
error_code_handler
7
.
.
.
; create handler for interrupt 0
; create handler for interrupt 1
; create handler for interrupt 7
The common_interrupt_handler does the following:
• Push the registers on the stack.
• Call the C function interrupt_handler.
• Pop the registers from the stack.
42• Add 8 to esp (because of the error code and the interrupt number pushed earlier).
• Execute iret to return to the interrupted code.
Since the macros declare global labels the addresses of the interrupt handlers can be accessed from C or
assembly code when creating the IDT.
Loading the IDT
The IDT is loaded with the lidt assembly code instruction which takes the address of the first element in
the table. It is easiest to wrap this instruction and use it from C:
global
load_idt
; load_idt - Loads the interrupt descriptor table (IDT).
; stack: [esp + 4] the address of the first entry in the IDT
;
[esp
] the return address
load_idt:
mov
eax, [esp+4]
; load the address of the IDT into register eax
lidt
eax
; load the IDT
ret
; return to the calling function
Programmable Interrupt Controller (PIC)
To start using hardware interrupts you must first configure the Programmable Interrupt Controller (PIC).
The PIC makes it possible to map signals from the hardware to interrupts. The reasons for configuring the
PIC are:
• Remap the interrupts. The PIC uses interrupts 0 - 15 for hardware interrupts by default, which conflicts
with the CPU interrupts. Therefore the PIC interrupts must be remapped to another interval.
• Select which interrupts to receive. You probably don’t want to receive interrupts from all devices since
you don’t have code that handles these interrupts anyway.
• Set up the correct mode for the PIC.
In the beginning there was only one PIC (PIC 1) and eight interrupts. As more hardware were added, 8
interrupts were too few. The solution chosen was to chain on another PIC (PIC 2) on the first PIC (see
interrupt 2 on PIC 1).
The hardware interrupts are shown in the table below:
PIC 1
Hardware
PIC 2
Hardware
0Timer8Real Time Clock
1Keyboard9General I/O
2PIC 210General I/O
3COM 211General I/O
4COM 112General I/O
43PIC 1
Hardware
PIC 2
Hardware
5LPT 213Coprocessor
6Floppy disk14IDE Bus
7LPT 115IDE Bus
A great tutorial for configuring the PIC can be found at the SigOPS website [35]. We won’t repeat that
information here.
Every interrupt from the PIC has to be acknowledged - that is, sending a message to the PIC confirming
that the interrupt has been handled. If this isn’t done the PIC won’t generate any more interrupts.
Acknowledging a PIC interrupt is done by sending the byte 0x20 to the PIC that raised the interrupt.
Implementing a pic_acknowledge function can thus be done as follows:
#include "io.h"
#define PIC1_PORT_A 0x20
#define PIC2_PORT_A 0xA0
/* The PIC interrupts have been remapped */
#define PIC1_START_INTERRUPT 0x20
#define PIC2_START_INTERRUPT 0x28
#define PIC2_END_INTERRUPT
PIC2_START_INTERRUPT + 7
#define PIC_ACK
0x20
/** pic_acknowledge:
* Acknowledges an interrupt from either PIC 1 or PIC 2.
*
* @param num The number of the interrupt
*/
void pic_acknowledge(unsigned integer interrupt)
{
if (interrupt < PIC1_START_INTERRUPT || interrupt > PIC2_END_INTERRUPT) {
return;
}
if (interrupt < PIC2_START_INTERRUPT) {
outb(PIC1_PORT_A, PIC_ACK);
} else {
outb(PIC2_PORT_A, PIC_ACK);
}
}
Reading Input from the Keyboard
The keyboard does not generate ASCII characters, it generates scan codes. A scan code represents a button -
both presses and releases. The scan code representing the just pressed button can be read from the keyboard’s
data I/O port which has address 0x60. How this can be done is shown in the following example:
44#include "io.h"
#define KBD_DATA_PORT
0x60
/** read_scan_code:
* Reads a scan code from the keyboard
*
* @return The scan code (NOT an ASCII character!)
*/
unsigned char read_scan_code(void)
{
return inb(KBD_DATA_PORT);
}
The next step is to write a function that translates a scan code to the corresponding ASCII character. If you
want to map the scan codes to ASCII characters as is done on an American keyboard then Andries Brouwer
has a great tutorial [36].
Remember, since the keyboard interrupt is raised by the PIC, you must call pic_acknowledge at the end of
the keyboard interrupt handler. Also, the keyboard will not send you any more interrupts until you read the
scan code from the keyboard.
Further Reading
• The OSDev wiki has a great page on interrupts, http://wiki.osdev.org/Interrupts
• Chapter 6 of Intel Manual 3a [33] describes everything there is to know about interrupts.
4546Chapter 7
The Road to User Mode
Now that the kernel boots, prints to screen and reads from keyboard - what do we do? Usually, a kernel is
not supposed to do the application logic itself, but leave that for applications. The kernel creates the proper
abstractions (for memory, files, devices) to make application development easier, performs tasks on behalf of
applications (system calls) and schedules processes.
User mode, in contrast with kernel mode, is the environment in which the user’s programs execute. This
environment is less privileged than the kernel, and will prevent (badly written) user programs from messing
with other programs or the kernel. Badly written kernels are free to mess up what they want.
There’s quite a way to go until the OS created in this book can execute programs in user mode, but this
chapter will show how to easily execute a small program in kernel mode.
Loading an External Program
Where do we get the external program from? Somehow we need to load the code we want to execute into
memory. More feature-complete operating systems usually have drivers and file systems that enable them to
load the software from a CD-ROM drive, a hard disk or other persistent media.
Instead of creating all these drivers and file systems we will use a feature in GRUB called modules to load
the program.
GRUB Modules
GRUB can load arbitrary files into memory from the ISO image, and these files are usually referred to as
modules. To make GRUB load a module, edit the file iso/boot/grub/menu.lst and add the following line
at the end of the file:
module /modules/program
Now create the folder iso/modules:
mkdir -p iso/modules
47The application program will be created later in this chapter.
The code that calls kmain must be updated to pass information to kmain about where it can find the modules.
We also want to tell GRUB that it should align all the modules on page boundaries when loading them (see
the chapter “Paging” for details about page alignment).
To instruct GRUB how to load our modules, the “multiboot header” - the first bytes of the kernel - must be
updated as follows:
; in file ‘loader.s‘
MAGIC_NUMBER
ALIGN_MODULES
equ 0x1BADB002
equ 0x00000001
; define the magic number constant
; tell GRUB to align modules
; calculate the checksum (all options + checksum should equal 0)
CHECKSUM
equ -(MAGIC_NUMBER + ALIGN_MODULES)
section .text:
align 4
dd MAGIC_NUMBER
dd ALIGN_MODULES
dd CHECKSUM
; start of the text (code) section
; the code must be 4 byte aligned
; write the magic number
; write the align modules instruction
; write the checksum
GRUB will also store a pointer to a struct in the register ebx that, among other things, describes at which
addresses the modules are loaded. Therefore, you probably want to push ebx on the stack before calling
kmain to make it an argument for kmain.
Executing a Program
A Very Simple Program
A program written at this stage can only perform a few actions. Therefore, a very short program that writes
a value to a register suffices as a test program. Halting Bochs after a while and then check that register
contains the correct number by looking in the Bochs log will verify that the program has run. This is an
example of such a short program:
; set eax to some distinguishable number, to read from the log afterwards
mov eax, 0xDEADBEEF
; enter infinite loop, nothing more to do
; $ means "beginning of line", ie. the same instruction
jmp $
Compiling
Since our kernel cannot parse advanced executable formats we need to compile the code into a flat binary.
NASM can do this with the flag -f:
nasm -f bin program.s -o program
This is all we need. You must now move the file program to the folder iso/modules.
48Finding the Program in Memory
Before jumping to the program we must find where it resides in memory. Assuming that the contents of ebx
is passed as an argument to kmain, we can do this entirely from C.
The pointer in ebx points to a multiboot structure [19]. Download the multiboot.h file from http://www.
gnu.org/software/grub/manual/multiboot/html_node/multiboot.h.html, which describes the structure.
The pointer passed to kmain in the ebx register can be cast to a multiboot_info_t pointer. The address of
the first module is in the field mods_addr. The following code shows an example:
int kmain(/* additional arguments */ unsigned int ebx)
{
multiboot_info_t *mbinfo = (multiboot_info_t *) ebx;
unsigned int address_of_module = mbinfo->mods_addr;
}
However, before just blindly following the pointer, you should check that the module got loaded correctly by
GRUB. This can be done by checking the flags field of the multiboot_info_t structure. You should also
check the field mods_count to make sure it is exactly 1. For more details about the multiboot structure, see
the multiboot documentation [19].
Jumping to the Code
The only thing left to do is to jump to the code loaded by GRUB. Since it is easier to parse the multiboot
structure in C than assembly code, calling the code from C is more convenient (it can of course be done with
jmp or call in assembly code as well). The C code could look like this:
typedef void (*call_module_t)(void);
/* ... */
call_module_t start_program = (call_module_t) address_of_module;
start_program();
/* we’ll never get here, unless the module code returns */
If we start the kernel, wait until it has run and entered the infinite loop in the program, and then halt Bochs,
we should see 0xDEADBEEF in the register eax via the Bochs log. We have successfully started a program in
our OS!
The Beginning of User Mode
The program we’ve written now runs at the same privilege level as the kernel - we’ve just entered it in a
somewhat peculiar way. To enable applications to execute at a different privilege level we’ll need to, beside
segmentation, do paging and page frame allocation.
It’s quite a lot of work and technical details to go through, but in a few chapters you’ll have working user
mode programs.
4950Chapter 8
A Short Introduction to Virtual
Memory
Virtual memory is an abstraction of physical memory. The purpose of virtual memory is generally to simplify
application development and to let processes address more memory than what is actually physically present
in the machine. We also don’t want applications messing with the kernel or other applications’ memory due
to security.
In the x86 architecture, virtual memory can be accomplished in two ways: segmentation and paging. Paging
is by far the most common and versatile technique, and we’ll implement it the next chapter. Some use of
segmentation is still necessary to allow for code to execute under different privilege levels.
Managing memory is a big part of what an operating system does. Paging and page frame allocation deals
with that.
Segmentation and paging is described in the [33], chapter 3 and 4.
Virtual Memory Through Segmentation?
You could skip paging entirely and just use segmentation for virtual memory. Each user mode process would
get its own segment, with base address and limit properly set up. This way no process can see the memory of
another process. A problem with this is that the physical memory for a process needs to be contiguous (or at
least it is very convenient if it is). Either we need to know in advance how much memory the program will
require (unlikely), or we can move the memory segments to places where they can grow when the limit is
reached (expensive, causes fragmentation - can result in “out of memory” even though enough memory is
available). Paging solves both these problems.
It is interesting to note that in x86_64 (the 64-bit version of the x86 architecture), segmentation is almost
completely removed.
Further Reading
• LWN.net has an article on virtual memory: http://lwn.net/Articles/253361/
• Gustavo Duarte has also written an article about virtual memory: http://duartes.org/gustavo/blog/
post/memory-translation-and-segmentation
5152Chapter 9
Paging
Segmentation translates a logical address into a linear address. Paging translates these linear addresses onto
the physical address space, and determines access rights and how the memory should be cached.
Why Paging?
Paging is the most common technique used in x86 to enable virtual memory. Virtual memory through paging
means that each process will get the impression that the available memory range is 0x00000000 - 0xFFFFFFFF
even though the actual size of the memory might be much less. It also means that when a process addresses
a byte of memory it will use a virtual (linear) address instead of physical one. The code in the user process
won’t notice any difference (except for execution delays). The linear address gets translated to a physical
address by the MMU and the page table. If the virtual address isn’t mapped to a physical address, the CPU
will raise a page fault interrupt.
Paging is optional, and some operating systems do not make use of it. But if we want to mark certain areas
of memory accessible only to code running at a certain privilege level (to be able to have processes running
at different privilege levels), paging is the neatest way to do it.
Paging in x86
Paging in x86 (chapter 4 in the Intel manual [33]) consists of a page directory (PDT) that can contain
references to 1024 page tables (PT), each of which can point to 1024 sections of physical memory called page
frames (PF). Each page frame is 4096 byte large. In a virtual (linear) address, the highest 10 bits specifies
the offset of a page directory entry (PDE) in the current PDT, the next 10 bits the offset of a page table
entry (PTE) within the page table pointed to by that PDE. The lowest 12 bits in the address is the offset
within the page frame to be addressed.
All page directories, page tables and page frames need to be aligned on 4096 byte addresses. This makes it
possible to address a PDT, PT or PF with just the highest 20 bits of a 32 bit address, since the lowest 12
need to be zero.
The PDE and PTE structure is very similar to each other: 32 bits (4 bytes), where the highest 20 bits points
to a PTE or PF, and the lowest 12 bits control access rights and other configurations. 4 bytes times 1024
equals 4096 bytes, so a page directory and page table both fit in a page frame themselves.
The translation of linear addresses to physical addresses is described in the figure below.
53While pages are normally 4096 bytes, it is also possible to use 4 MB pages. A PDE then points directly to a
4 MB page frame, which needs to be aligned on a 4 MB address boundary. The address translation is almost
the same as in the figure, with just the page table step removed. It is possible to mix 4 MB and 4 KB pages.
Figure 9.1: Translating virtual addresses (linear addresses) to physical addresses.
The 20 bits pointing to the current PDT is stored in the register cr3. The lower 12 bits of cr3 are used for
configuration.
For more details on the paging structures, see chapter 4 in the Intel manual [33]. The most interesting bits
are U/S, which determine what privilege levels can access this page (PL0 or PL3), and R/W, which makes
the memory in the page read-write or read-only.
54Identity Paging
The simplest kind of paging is when we map each virtual address onto the same physical address, called
identity paging. This can be done at compile time by creating a page directory where each entry points to its
corresponding 4 MB frame. In NASM this can be done with macros and commands (%rep, times and dd). It
can of course also be done at run-time by using ordinary assembly code instructions.
Enabling Paging
Paging is enabled by first writing the address of a page directory to cr3 and then setting bit 31 (the PG
“paging-enable” bit) of cr0 to 1. To use 4 MB pages, set the PSE bit (Page Size Extensions, bit 4) of cr4.
The following assembly code shows an example:
; eax has the address of the page directory
mov cr3, eax
mov ebx, cr4
; read current cr4
or ebx, 0x00000010 ; set PSE
mov cr4, ebx
; update cr4
mov ebx, cr0
; read current cr0
or ebx, 0x80000000 ; set PG
mov cr0, ebx
; update cr0
; now paging is enabled
A Few Details
It is important to note that all addresses within the page directory, page tables and in cr3 need to be physical
addresses to the structures, never virtual. This will be more relevant in later sections where we dynamically
update the paging structures (see the chapter “User Mode”).
An instruction that is useful when an updating a PDT or PT is invlpg. It invalidates the Translation
Lookaside Buffer (TLB) entry for a virtual address. The TLB is a cache for translated addresses, mapping
physical addresses corresponding to virtual addresses. This is only required when changing a PDE or PTE
that was previously mapped to something else. If the PDE or PTE had previously been marked as not
present (bit 0 was set to 0), executing invlpg is unnecessary. Changing the value of cr3 will cause all entries
in the TLB to be invalidated.
An example of invalidating a TLB entry is shown below:
; invalidate any TLB references to virtual address 0
invlpg [0]
Paging and the Kernel
This section will describe how paging affects the OS kernel. We encourage you to run your OS using
identity paging before trying to implement a more advanced paging setup, since it can be hard to debug a
malfunctioning page table that is set up via assembly code.
55Reasons to Not Identity Map the Kernel
If the kernel is placed at the beginning of the virtual address space - that is, the virtual address space
(0x00000000, "size of kernel") maps to the location of the kernel in memory - there will be issues when
linking the user mode process code. Normally, during linking, the linker assumes that the code will be loaded
into the memory position 0x00000000. Therefore, when resolving absolute references, 0x00000000 will be
the base address for calculating the exact position. But if the kernel is mapped onto the virtual address space
(0x00000000, "size of kernel"), the user mode process cannot be loaded at virtual address 0x00000000 -
it must be placed somewhere else. Therefore, the assumption from the linker that the user mode process is
loaded into memory at position 0x00000000 is wrong. This can be corrected by using a linker script which
tells the linker to assume a different starting address, but that is a very cumbersome solution for the users of
the operating system.
This also assumes that we want the kernel to be part of the user mode process’ address space. As we will see
later, this is a nice feature, since during system calls we don’t have to change any paging structures to get
access to the kernel’s code and data. The kernel pages will of course require privilege level 0 for access, to
prevent a user process from reading or writing kernel memory.
The Virtual Address for the Kernel
Preferably, the kernel should be placed at a very high virtual memory address, for example 0xC0000000 (3
GB). The user mode process is not likely to be 3 GB large, which is now the only way that it can conflict
with the kernel. When the kernel uses virtual addresses at 3 GB and above it is called a higher-half kernel.
0xC0000000 is just an example, the kernel can be placed at any address higher than 0 to get the same benefits.
Choosing the correct address depends on how much virtual memory should be available for the kernel (it is
easiest if all memory above the kernel virtual address should belong to the kernel) and how much virtual
memory should be available for the process.
If the user mode process is larger than 3 GB, some pages will need to be swapped out by the kernel. Swapping
pages is not part of this book.
Placing the Kernel at 0xC0000000
To start with, it is better to place the kernel at 0xC0100000 than 0xC0000000, since this makes it possible
to map (0x00000000, 0x00100000) to (0xC0000000, 0xC0100000). This way, the entire range (0x00000000,
"size of kernel") of memory is mapped to the range (0xC0000000, 0xC0000000 + "size of kernel").
Placing the kernel at 0xC0100000 isn’t hard, but it does require some thought. This is once again a linking
problem. When the linker resolves all absolute references in the kernel, it will assume that our kernel is
loaded at physical memory location 0x00100000, not 0x00000000, since relocation is used in the linker script
(see the section “Linking the kernel”). However, we want the jumps to be resolved using 0xC0100000 as base
address, since otherwise a kernel jump will jump straight into the user mode process code (remember that
the user mode process is loaded at virtual memory 0x00000000).
However, we can’t simply tell the linker to assume that the kernel starts (is loaded) at 0xC01000000, since
we want it to be loaded at the physical address 0x00100000. The reason for having the kernel loaded at 1
MB is because it can’t be loaded at 0x00000000, since there is BIOS and GRUB code loaded below 1 MB.
Furthermore, we cannot assume that we can load the kernel at 0xC0100000, since the machine might not
have 3 GB of physical memory.
This can be solved by using both relocation (.=0xC0100000) and the AT instruction in the linker script.
Relocation specifies that non-relative memory-references should should use the relocation address as base in
address calculations. AT specifies where the kernel should be loaded into memory. Relocation is done at link
56time by GNU ld [37], the load address specified by AT is handled by GRUB when loading the kernel, and is
part of the ELF format [18].
Higher-half Linker Script
We can modify the first linker script to implement this:
ENTRY(loader)/* the name of the entry symbol */
. = 0xC0100000/* the code should be relocated to 3GB + 1MB */
/* align at 4 KB and load at 1 MB */
.text ALIGN (0x1000) : AT(ADDR(.text)-0xC0000000)
{
*(.text)
/* all text sections from all files */
}
/* align at 4 KB and load at 1 MB + . */
.rodata ALIGN (0x1000) : AT(ADDR(.text)-0xC0000000)
{
*(.rodata*)
/* all read-only data sections from all files */
}
/* align at 4 KB and load at 1 MB + . */
.data ALIGN (0x1000) : AT(ADDR(.text)-0xC0000000)
{
*(.data)
/* all data sections from all files */
}
/* align at 4 KB and load at 1 MB + . */
.bss ALIGN (0x1000) : AT(ADDR(.text)-0xC0000000)
{
*(COMMON)
/* all COMMON sections from all files */
*(.bss)
/* all bss sections from all files */
}
Entering the Higher Half
When GRUB jumps to the kernel code, there is no paging table. Therefore, all references to 0xC0100000 +
X won’t be mapped to the correct physical address, and will therefore cause a general protection exception
(GPE) at the very best, otherwise (if the computer has more than 3 GB of memory) the computer will just
crash.
Therefore, assembly code that doesn’t use relative jumps or relative memory addressing must be used to do
the following:
• Set up a page table.
• Add identity mapping for the first 4 MB of the virtual address space.
• Add an entry for 0xC0100000 that maps to 0x0010000
57If we skip the identity mapping for the first 4 MB, the CPU would generate a page fault immediately after
paging was enabled when trying to fetch the next instruction from memory. After the table has been created,
an jump can be done to a label to make eip point to a virtual address in the higher half:
; assembly code executing at around 0x00100000
; enable paging for both actual location of kernel
; and its higher-half virtual location
lea ebx, [higher_half] ; load the address of the label in ebx
jmp ebx
; jump to the label
higher_half:
; code here executes in the higher half kernel
; eip is larger than 0xC0000000
; can continue kernel initialisation, calling C code, etc.
The register eip will now point to a memory location somewhere right after 0xC0100000 - all the code can
now execute as if it were located at 0xC0100000, the higher-half. The entry mapping of the first 4 MB
of virtual memory to the first 4 MB of physical memory can now be removed from the page table and its
corresponding entry in the TLB invalidated with invlpg [0].
Running in the Higher Half
There are a few more details we must deal with when using a higher-half kernel. We must be careful when
using memory-mapped I/O that uses specific memory locations. For example, the frame buffer is located at
0x000B8000, but since there is no entry in the page table for the address 0x000B8000 any longer, the address
0xC00B8000 must be used, since the virtual address 0xC0000000 maps to the physical address 0x00000000.
Any explicit references to addresses within the multiboot structure needs to be changed to reflect the new
virtual addresses as well.
Mapping 4 MB pages for the kernel is simple, but wastes memory (unless you have a really big kernel).
Creating a higher-half kernel mapped in as 4 KB pages saves memory but is harder to set up. Memory
for the page directory and one page table can be reserved in the .data section, but one needs to configure
the mappings from virtual to physical addresses at run-time. The size of the kernel can be determined by
exporting labels from the linker script [37], which we’ll need to do later anyway when writing the page frame
allocator (see the chapter “Page Frame Allocation).
Virtual Memory Through Paging
Paging enables two things that are good for virtual memory. First, it allows for fine-grained access control to
memory. You can mark pages as read-only, read-write, only for PL0 etc. Second, it creates the illusion of
contiguous memory. User mode processes, and the kernel, can access memory as if it were contiguous, and
the contiguous memory can be extended without the need to move data around in memory. We can also
allow the user mode programs access to all memory below 3 GB, but unless they actually use it, we don’t
have to assign page frames to the pages. This allows processes to have code located near 0x00000000 and
the stack at just below 0xC0000000, and still not require more than two actual pages.
58Further Reading
• Chapter 4 (and to some extent chapter 3) of the Intel manual [33] are your definitive sources for the
details about paging.
• Wikipedia has an article on paging: http://en.wikipedia.org/wiki/Paging
• The OSDev wiki has a page on paging: http://wiki.osdev.org/Paging and a tutorial for making a
higher-half kernel: http://wiki.osdev.org/Higher_Half_bare_bones
• Gustavo Duarte’s article on how a kernel manages memory is well worth a read: http://duartes.org/
gustavo/blog/post/anatomy-of-a-program-in-memory
• Details on the linker command language can be found at Steve Chamberlain’s website [37].
• More details on the ELF format can be found in this presentation: http://flint.cs.yale.edu/cs422/doc/
ELF_Format.pdf
5960Chapter 10
Page Frame Allocation
When using virtual memory, how does the OS know which parts of memory are free to use? That is the role
of the page frame allocator.
Managing Available Memory
How Much Memory is There?
First we need to know how much memory is available on the computer the OS is running on. The easiest
way to do this is to read it from the multiboot structure [19] passed to us by GRUB. GRUB collects the
information we need about the memory - what is reserved, I/O mapped, read-only etc. We must also make
sure that we don’t mark the part of memory used by the kernel as free (since GRUB doesn’t mark this
memory as reserved). One way to know how much memory the kernel uses is to export labels at the beginning
and the end of the kernel binary from the linker script:
ENTRY(loader)/* the name of the entry symbol */
. = 0xC0100000/* the code should be relocated to 3 GB + 1 MB */
/* these labels get exported to the code files */
kernel_virtual_start = .;
kernel_physical_start = . - 0xC0000000;
/* align at 4 KB and load at 1 MB */
.text ALIGN (0x1000) : AT(ADDR(.text)-0xC0000000)
{
*(.text)
/* all text sections from all files */
}
/* align at 4 KB and load at 1 MB + . */
.rodata ALIGN (0x1000) : AT(ADDR(.rodata)-0xC0000000)
{
*(.rodata*)
/* all read-only data sections from all files */
}
61/* align at 4 KB and load at 1 MB + . */
.data ALIGN (0x1000) : AT(ADDR(.data)-0xC0000000)
{
*(.data)
/* all data sections from all files */
}
/* align at 4 KB and load at 1 MB + . */
.bss ALIGN (0x1000) : AT(ADDR(.bss)-0xC0000000)
{
*(COMMON)
/* all COMMON sections from all files */
*(.bss)
/* all bss sections from all files */
}
kernel_virtual_end = .;
kernel_physical_end = . - 0xC0000000;
These labels can directly be read from assembly code and pushed on the stack to make them available to C
code:
extern kernel_virtual_start
extern kernel_virtual_end
extern kernel_physical_start
extern kernel_physical_end
; ...
push kernel_physical_end
push kernel_physical_start
push kernel_virtual_end
push kernel_virtual_start
call kmain
This way we get the labels as arguments to kmain. If you want to use C instead of assembly code, one way to
do it is to declare the labels as functions and take the addresses of these functions:
void kernel_virtual_start(void);
/* ... */
unsigned int vaddr = (unsigned int) &kernel_virtual_start;
If you use GRUB modules you need to make sure the memory they use is marked as reserved as well.
Note that the available memory does not need to be contiguous. In the first 1 MB there are several I/O-
mapped memory sections, as well as memory used by GRUB and the BIOS. Other parts of the memory
might be similarly unavailable.
It’s convenient to divide the memory sections into complete page frames, as we can’t map part of pages into
memory.
62Managing Available Memory
How do we know which page frames are in use? The page frame allocator needs to keep track of which are
free and which aren’t. There are several ways to do this: bitmaps, linked lists, trees, the Buddy System (used
by Linux) etc. For more information about the different algorithms see the article on OSDev [38].
Bitmaps are quite easy to implement. One bit is used for each page frame and one (or more) page frames are
dedicated to store the bitmap. (Note that this is just one way to do it, other designs might be better and/or
more fun to implement.)
How Can We Access a Page Frame?
The page frame allocator returns the physical start address of the page frame. This page frame is not mapped
in - no page table points to this page frame. How can we read and write data to the frame?
We need to map the page frame into virtual memory, by updating the PDT and/or PT used by the kernel.
What if all available page tables are full? Then we can’t map the page frame into memory, because we’d
need a new page table - which takes up an entire page frame - and to write to this page frame we’d need to
map its page frame. . . Somehow this circular dependency must be broken.
One solution is to reserve a part of the first page table used by the kernel (or some other higher-half page
table) for temporarily mapping page frames to make them accessible. If the kernel is mapped at 0xC0000000
(page directory entry with index 768), and 4 KB page frames are used, then the kernel has at least one page
table. If we assume - or limit us to - a kernel of size at most 4 MB minus 4 KB we can dedicate the last entry
(entry 1023) of this page table for temporary mappings. The virtual address of pages mapped in using the
last entry of the kernel’s PT will be:
(768 << 22) | (1023 << 12) | 0x000 = 0xC03FF000
After we’ve temporarily mapped the page frame we want to use as a page table, and set it up to map in our
first page frame, we can add it to the paging directory, and remove the temporary mapping.
A Kernel Heap
So far we’ve only been able to work with fixed-size data, or directly with raw memory. Now that we have a
page frame allocator we can implement malloc and free to use in the kernel.
Kernighan and Ritchie [8] have an example implementation in their book [8] that we can draw inspiration
from. The only modification we need to do is to replace calls to sbrk/brk with calls to the page frame
allocator when more memory is needed. We must also make sure to map the page frames returned by the
page frame allocator to virtual addresses. A correct implementation should also return page frames to the
page frame allocator on call to free, whenever sufficiently large blocks of memory are freed.
Further reading
• The OSDev wiki page on page frame allocation: http://wiki.osdev.org/Page_Frame_Allocation
6364Chapter 11
User Mode
User mode is now almost within our reach, there are just a few more steps required to get there. Although
these steps might seem easy they way they are presented in this chapter, they can be tricky to implement,
since there are a lot of places where small errors will cause bugs that are hard to find.
Segments for User Mode
To enable user mode we need to add two more segments to the GDT. They are very similar to the kernel
segments we added when we set up the GDT in the chapter about segmentation:
IndexOffsetNameAddress rangeTypeDPL
30x18user code segment0x00000000 - 0xFFFFFFFFRXPL3
40x20user data segment0x00000000 - 0xFFFFFFFFRWPL3
Table 11.1: The segment descriptors needed for user mode.
The difference is the DPL, which now allows code to execute in PL3. The segments can still be used to
address the entire address space, just using these segments for user mode code will not protect the kernel.
For that we need paging.
Setting Up For User Mode
There are a few things every user mode process needs:
• Page frames for code, data and stack. At the moment it suffices to allocate one page frame for the
stack and enough page frames to fit the program’s code. Don’t worry about setting up a stack that can
be grow and shrink at this point in time, focus on getting a basic implementation work first.
• The binary from the GRUB module has to be copied to the page frames used for the programs code.
• A page directory and page tables are needed to map the page frames described above into memory.
At least two page tables are needed, because the code and data should be mapped in at 0x00000000
65and increasing, and the stack should start just below the kernel, at 0xBFFFFFFB, growing towards lower
addresses. The U/S flag has to be set to allow PL3 access.
It might be convenient to store this information in a struct representing a process. This process struct can
be dynamically allocated with the kernel’s malloc function.
Entering User Mode
The only way to execute code with a lower privilege level than the current privilege level (CPL) is to execute
an iret or lret instruction - interrupt return or long return, respectively.
To enter user mode we set up the stack as if the processor had raised an inter-privilege level interrupt. The
stack should look like the following:
[esp + 16]
[esp + 12]
[esp + 8]
[esp + 4]
[esp + 0]
ss
esp
eflags
cs
eip
; the stack segment selector we want for user mode
; the user mode stack pointer
; the control flags we want to use in user mode
; the code segment selector
; the instruction pointer of user mode code to execute
See the Intel manual [33], section 6.2.1, figure 6-4 for more information.
The instruction iret will then read these values from the stack and fill in the corresponding registers. Before
we execute iret we need to change to the page directory we setup for the user mode process. It is important
to remember that to continue executing kernel code after we’ve switched PDT, the kernel needs to be mapped
in. One way to accomplish this is to have a separate PDT for the kernel, which maps all data at 0xC0000000
and above, and merge it with the user PDT (which only maps below 0xC0000000) when performing the
switch. Remember that physical address of the PDT has to be used when setting the register cr3.
The register eflags contains a set of different flags, specified in section 2.3 of the Intel manual [33]. Most
important for us is the interrupt enable (IF) flag. The assembly code instruction sti can’t be used in privilege
level 3 for enabling interrupts. If interrupts are disabled when entering user mode, then interrupts can’t
enabled once user mode is entered. Setting the IF flag in the eflags entry on the stack will enable interrupts
in user mode, since the assembly code instruction iret will set the register eflags to the corresponding
value on the stack.
For now, we should have interrupts disabled, as it requires a little more work to get inter-privilege level
interrupts to work properly (see the section “System calls”).
The value eip on the stack should point to the entry point for the user code - 0x00000000 in our case. The
value esp on the stack should be where the stack starts - 0xBFFFFFFB (0xC0000000 - 4).
The values cs and ss on the stack should be the segment selectors for the user code and user data segments,
respectively. As we saw in the segmentation chapter, the lowest two bits of a segment selector is the RPL -
the Requested Privilege Level. When using iret to enter PL3, the RPL of cs and ss should be 0x3. The
following code shows an example:
USER_MODE_CODE_SEGMENT_SELECTOR equ 0x18
USER_MODE_DATA_SEGMENT_SELECTOR equ 0x20
mov cs, USER_MODE_CODE_SEGMENT_SELECTOR | 0x3
mov ss, USER_MODE_DATA_SEGMENT_SELECTOR | 0x3
66The register ds, and the other data segment registers, should be set to the same segment selector as ss. They
can be set the ordinary way, with the mov assembly code instruction.
We are now ready to execute iret. If everything has been set up right, we should now have a kernel that can
enter user mode.
Using C for User Mode Programs
When C is used as the programming language for user mode programs, it is important to think about the
structure of the file that will be the result of the compilation.
The reason we can use ELF [18] as the file format for for the kernel executable is because GRUB knows how
to parse and interpret the ELF file format. If we implemented an ELF parser, we could compile the user
mode programs into ELF binaries as well. We leave this as an exercise for the reader.
One thing we can do to make it easier to develop user mode programs is to allow the programs to be written
in C, but compile them to flat binaries instead of ELF binaries. In C the layout of the generated code is
more unpredictable and the entry point, main, might not be at offset 0 in the binary. One common way to
work around this is to add a few assembly code lines placed at offset 0 which calls main:
extern main
section .text
; push argv
; push argc
call main
; main has returned, eax is return value
jmp $
; loop forever
If this code is saved in a file called start.s, then the following code show an example of a linker script that
places these instructions first in executable (remember that start.s gets compiled to start.o):
OUTPUT_FORMAT("binary")/* output flat binary */
SECTIONS
{
. = 0;/* relocate to address 0 */
.text ALIGN(4):
{
start.o(.text)
*(.text)
}
/* include the .text section of start.o */
/* include all other .text sections */
.data ALIGN(4):
{
*(.data)
}
.rodata ALIGN(4):
{
67*(.rodata*)
}
}
Note: *(.text) will not include the .text section of start.o again.
With this script we can write programs in C or assembler (or any other language that compiles to object files
linkable with ld), and it is easy to load and map for the kernel (.rodata will be mapped in as writeable,
though).
When we compile user programs we want the following GCC flags:
-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles
-nodefaultlibs
For linking, the followings flags should be used:
-T link.ld -melf_i386
# emulate 32 bits ELF, the binary output is specified
# in the linker script
The option -T instructs the linker to use the linker script link.ld.
A C Library
It might now be interesting to start thinking about writing a small “standard library” for your programs.
Some of the functionality requires system calls to work, but some, such as the functions in string.h, does
not.
Further Reading
• Gustavo Duarte has an article on privilege levels:
cpu-rings-privilege-and-protection
68
http://duartes.org/gustavo/blog/post/Chapter 12
File Systems
We are not required to have file systems in our operating system, but it is a very usable abstraction, and it
often plays a central part of many operating systems, especially UNIX-like operating systems. Before we
start the process of supporting multiple processes and system calls we might want to consider implementing
a simple file system.
Why a File System?
How do we specify what programs to run in our OS? Which is the first program to run? How do programs
output data or read input?
In UNIX-like systems, with their almost-everything-is-a-file convention, these problems are solved by the file
system. (It might also be interesting to read a bit about the Plan 9 project, which takes this idea one step
further.)
A Simple Read-Only File System
The simplest file system might be what we already have - one file, existing only in RAM, loaded by GRUB
before the kernel starts. When the kernel and operating system grows this is probably too limiting.
A file system that is slightly more advanced than just the bits of one file is a file with metadata. The
metadata can describe the type of the file, the size of the file and so on. A utility program can be created
that runs at build time, adding this metadata to a file. This way, a “file system in a file” can be constructed
by concatenating several files with metadata into one large file. The result of this technique is a read-only file
system that resides in memory (once GRUB has loaded the file).
The program constructing the file system can traverse a directory on the host system and add all subdirectories
and files as part of the target file system. Each object in the file system (directory or file) can consist of a
header and a body, where the body of a file is the actual file and the body of a directory is a list of entries -
names and “addresses” of other files and directories.
Each object in this file system will become contiguous, so they will be easy to read from memory for the
kernel. All objects will also have a fixed size (except for the last one, which can grow), therefore it is difficult
to add new files or modify existing ones.
69Inodes and Writable File Systems
When the need for a writable file system arises, then it is a good idea to look into the concept of an inode.
See the section “Further Reading” for recommended reading.
A Virtual File System
What abstraction should be used for reading and writing to devices such as the screen and the keyboard?
A virtual file system (VFS) creates an abstraction on top of the concrete file systems. A VFS mainly supplies
the path system and file hierarchy, it delegates operations on files to the underlying file systems. The original
paper on VFS is succinct and well worth a read. See the section “Further Reading” for a reference.
With a VFS we could mount a special file system on the path /dev. This file system would handle all devices
such as keyboards and the console. However, one could also take the traditional UNIX approach, with
major/minor device numbers and mknod to create special files for devices. Which approach you think is the
most appropriate is up to you, there is no right or wrong when building abstraction layers (although some
abstractions turn out way more useful than others).
Further Reading
• The ideas behind the Plan 9 operating systems is worth taking a look at: http://plan9.bell-labs.com/
plan9/index.html
• Wikipedia’s page on inodes: http://en.wikipedia.org/wiki/Inode and the inode pointer structure:
http://en.wikipedia.org/wiki/Inode_pointer_structure.
• The original paper on the concept of vnodes and a virtual file system is quite interesting: http:
//www.arl.wustl.edu/~fredk/Courses/cs523/fall01/Papers/kleiman86vnodes.pdf
• Poul-Henning Kamp discusses the idea of a special file system for /dev in http://static.usenix.org/
publications/library/proceedings/bsdcon02/full_papers/kamp/kamp_html/index.html
70Chapter 13
System Calls
System calls is the way user-mode applications interact with the kernel - to ask for resources, request
operations to be performed, etc. The system call API is the part of the kernel that is most exposed to the
users, therefore its design requires some thought.
Designing System Calls
It is up to us, the kernel developers, to design the system calls that application developers can use. We can
draw inspiration from the POSIX standards or, if they seem like too much work, just look at the ones for
Linux, and pick and choose. See the section “Further Reading” at the end of the chapter for references.
Implementing System Calls
System calls are traditionally invoked with software interrupts. The user applications put the appropriate
values in registers or on the stack and then initiates a pre-defined interrupt which transfers execution to the
kernel. The interrupt number used is dependent on the kernel, Linux uses the number 0x80 to identify that
an interrupt is intended as a system call.
When system calls are executed, the current privilege level is typically changed from PL3 to PL0 (if the
application is running in user mode). To allow this, the DPL of the entry in the IDT for the system call
interrupt needs to allow PL3 access.
Whenever inter-privilege level interrupts occur, the processor pushes a few important registers onto the stack -
the same ones we used to enter user mode before, see figure 6-4, section 6.12.1, in the Intel manual [33]. What
stack is used? The same section in [33] specifies that if an interrupt leads to code executing at a numerically
lower privilege level, a stack switch occurs. The new values for the registers ss and esp is loaded from the
current Task State Segment (TSS). The TSS structure is specified in figure 7-2, section 7.2.1 of the Intel
manual [33].
To enable system calls we need to setup a TSS before entering user mode. Setting it up can be done in C by
setting the ss0 and esp0 fields of a “packed struct” that represents a TSS. Before loading the “packed struct”
into the processor, a TSS descriptor has to be added to the GDT. The structure of the TSS descriptor is
described in section 7.2.2 in [33].
71You specify the current TSS segment selector by loading it into the tr register with the ltr assembly code
instruction. If the TSS segment descriptor has index 5, and thus offset 5 * 8 = 40 = 0x28, this is the value
that should be loaded into the register tr.
When we entered user mode before in the chapter “Entering User Mode” we disabled interrupts when
executing in PL3. Since system calls are implemented using interrupts, interrupts must be enabled in user
mode. Setting the IF flag bit in the eflags value on the stack will make iret enable interrupts (since the
eflags value on the stack will be loaded into the eflags register by the assembly code instruction iret).
Further Reading
• The Wikipedia page on POSIX, with links to the specifications: http://en.wikipedia.org/wiki/POSIX
• A list of system calls used in Linux: http://bluemaster.iu.hio.no/edu/dark/lin-asm/syscalls.html
• The Wikipedia page on system calls: http://en.wikipedia.org/wiki/System_call
• The Intel manual [33] sections on interrupts (chapter 6) and TSS (chapter 7) are where you get all the
details you need.
72Chapter 14
Multitasking
How do you make multiple processes appear to run at the same time? Today, this question has two answers:
• With the availability of multi-core processors, or on system with multiple processors, two processes can
actually run at the same time by running two processes on different cores or processors.
• Fake it. That is, switch rapidly (faster than a human can notice) between the processes. At any given
moment there is only one process executing, but the rapid switching gives the impression that they are
running “at the same time”.
Since the operating system created in this book does not support multi-core processors or multiple processors
the only option is to fake it. The part of the operating system responsible for rapidly switching between the
processes is called the scheduling algorithm.
Creating New Processes
Creating new processes is usually done with two different system calls: fork and exec. fork creates an exact
copy of the currently running process, while exec replaces the current process with one that is specified by a
path to the location of a program in the file system. Of these two we recommend that you start implementing
exec, since this system call will do almost exactly the same steps as described in the section “Setting up for
user mode” in the chapter “User Mode”.
Cooperative Scheduling with Yielding
The easiest way to achieve rapid switching between processes is if the processes themselves are responsible
for the switching. The processes run for a while and then tell the OS (via a system call) that it can now
switch to another process. Giving up the control of CPU to another process is called yielding and when
the processes themselves are responsible for the scheduling it’s called cooperative scheduling, since all the
processes must cooperate with each other.
When a process yields the process’ entire state must be saved (all the registers), preferably on the kernel heap
in a structure that represents a process. When changing to a new process all the registers must be restored
from the saved values.
73Scheduling can be implemented by keeping a list of which processes are running. The system call yield
should then run the next process in the list and put the current one last (other schemes are possible, but this
is a simple one).
The transfer of control to the new process is done via the iret assembly code instruction in exactly the same
way as explained in the section “Entering user mode” in the chapter “User Mode”.
We strongly recommend that you start to implement support for multiple processes by implementing
cooperative scheduling. We further recommend that you have a working solution for both exec, fork and
yield before implementing preemptive scheduling. Since cooperative scheduling is deterministic, it is much
easier to debug than preemptive scheduling.
Preemptive Scheduling with Interrupts
Instead of letting the processes themselves manage when to change to another process the OS can switch
processes automatically after a short period of time. The OS can set up the programmable interval timer
(PIT) to raise an interrupt after a short period of time, for example 20 ms. In the interrupt handler for the
PIT interrupt the OS will change the running process to a new one. This way the processes themselves don’t
need to worry about scheduling. This kind of scheduling is called preemptive scheduling.
Programmable Interval Timer
To be able to do preemptive scheduling the PIT must first be configured to raise interrupts every x milliseconds,
where x should be configurable.
The configuration of the PIT is very similar to the configuration of other hardware devices: a byte is sent to
an I/O port. The command port of the PIT is 0x43. To read about all the configuration options, see the
article about the PIT on OSDev [39]. We use the following options:
• Raise interrupts (use channel 0)
• Send the divider as low byte then high byte (see next section for an explanation)
• Use a square wave
• Use binary mode
This results in the configuration byte 00110110.
Setting the interval for how often interrupts are to be raised is done via a divider, the same way as for the
serial port. Instead of sending the PIT a value (e.g. in milliseconds) that says how often an interrupt should
be raised you send the divider. The PIT operates at 1193182 Hz as default. Sending the divider 10 results in
the PIT running at 1193182 / 10 = 119318 Hz. The divider can only be 16 bits, so it is only possible to
configure the timer’s frequency between 1193182 Hz and 1193182 / 65535 = 18.2 Hz. We recommend that
you create a function that takes an interval in milliseconds and converts it to the correct divider.
The divider is sent to the channel 0 data I/O port of the PIT, but since only one byte can be sent at at a
time, the lowest 8 bits of the divider has to sent first, then the highest 8 bits of the divider can be sent. The
channel 0 data I/O port is located at 0x40. Again, see the article on OSDev [39] for more details.
Separate Kernel Stacks for Processes
If all processes uses the same kernel stack (the stack exposed by the TSS) there will be trouble if a process is
interrupted while still in kernel mode. The process that is being switched to will now use the same kernel
74stack and will overwrite what the previous process have written on the stack (remember that TSS data
structure points to the beginning of the stack).
To solve this problem every process should have it’s own kernel stack, the same way that each process have
their own user mode stack. When switching process the TSS must be updated to point to the new process’
kernel stack.
Difficulties with Preemptive Scheduling
When using preemptive scheduling one problem arises that doesn’t exist with cooperative scheduling. With
cooperative scheduling every time a process yields, it must be in user mode (privilege level 3), since yield is
a system call. With preemptive scheduling, the processes can be interrupted in either user mode or kernel
mode (privilege level 0), since the process itself does not control when it gets interrupted.
Interrupting a process in kernel mode is a little bit different than interrupting a process in user mode, due
to the way the CPU sets up the stack at interrupts. If a privilege level change occurred (the process was
interrupted in user mode) the CPU will push the value of the process ss and esp register on the stack. If
no privilege level change occurs (the process was interrupted in kernel mode) the CPU won’t push the esp
register on the stack. Furthermore, if there was no privilege level change, the CPU won’t change stack to the
one defined it the TSS.
This problem is solved by calculating what the value of esp was before the interrupt. Since you know that
the CPU pushes 3 things on the stack when no privilege change happens and you know how much you have
pushed on the stack, you can calculate what the value of esp was at the time of the interrupt. This is possible
since the CPU won’t change stacks if there is no privilege level change, so the content of esp will be the
same as at the time of the interrupt.
To further complicate things, one must think of how to handle case when switching to a new process that
should be running in kernel mode. Since iret is being used without a privilege level change the CPU won’t
update the value of esp with the one placed on the stack - you must update esp yourself.
Further Reading
• For more information about different scheduling algorithms, see http://wiki.osdev.org/Scheduling_
Algorithms
7576References
[1] Andrew Tanenbaum, 2007. Modern operating systems, 3rd edition. Prentice Hall, Inc.,
[2] The royal institute of technology, http://www.kth.se,
[3] Wikipedia, Hexadecimal, http://en.wikipedia.org/wiki/Hexadecimal,
[4] OSDev, OSDev, http://wiki.osdev.org/Main_Page,
[5] James Molloy, James m’s kernel development tutorial, http://www.jamesmolloy.co.uk/tutorial_html/,
[6] Canonical Ltd, Ubuntu, http://www.ubuntu.com/,
[7] Oracle, Oracle vM virtualBox, http://www.virtualbox.org/,
[8] Dennis M. Ritchie Brian W. Kernighan, 1988. The c programming language, second edition. Prentice Hall,
Inc.,
[9] Wikipedia, C (programming language), http://en.wikipedia.org/wiki/C_(programming_language),
[10] Free Software Foundation, GCC, the gNU compiler collection, http://gcc.gnu.org/,
[11] NASM, NASM: The netwide assembler, http://www.nasm.us/,
[12] Wikipedia, Bash, http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29,
[13] Free Software Foundation, GNU make, http://www.gnu.org/software/make/,
[14] Volker Ruppert, bochs: The open souce iA-32 emulation project, http://bochs.sourceforge.net/,
[15] QEMU, QEMU, http://wiki.qemu.org/Main_Page,
[16] Wikipedia, BIOS, https://en.wikipedia.org/wiki/BIOS,
[17] Free Software Foundation, GNU gRUB, http://www.gnu.org/software/grub/,
[18] Wikipedia, Executable and linkable format, http://en.wikipedia.org/wiki/Executable_and_Linkable_
Format,
[19] Free Software Foundation, Multiboot specification version 0.6.96, http://www.gnu.org/software/grub/
manual/multiboot/multiboot.html,
[20] GNU, GNU binutils, http://www.gnu.org/software/binutils/,
[21] Lars Nodeen, Bug #426419: configure: error: GRUB requires a working absolute objcopy, https:
//bugs.launchpad.net/ubuntu/+source/grub/+bug/426419,
[22] Wikipedia, ISO image, http://en.wikipedia.org/wiki/ISO_image,
[23] Bochs, bochsrc, http://bochs.sourceforge.net/doc/docbook/user/bochsrc.html,
[24] NASM, RESB and friends: Declaring uninitialized data, http://www.nasm.us/doc/nasmdoc3.htm,
77[25] Wikipedia, x86 calling conventions, http://en.wikipedia.org/wiki/X86_calling_conventions,
[26] Wikipedia, Framebuffer, http://en.wikipedia.org/wiki/Framebuffer,
[27] Wikipedia, VGA-compatible text mode, http://en.wikipedia.org/wiki/VGA-compatible_text_mode,
[28] Wikipedia, ASCII, https://en.wikipedia.org/wiki/Ascii,
[29] OSDev, VGA hardware, http://wiki.osdev.org/VGA_Hardware,
[30] Wikipedia, Serial port, http://en.wikipedia.org/wiki/Serial_port,
[31] OSDev, Serial ports, http://wiki.osdev.org/Serial_ports,
[32] WikiBooks, Serial programming/8250 uART programming, http://en.wikibooks.org/wiki/Serial_
Programming/8250_UART_Programming,
[33] Intel, Intel 64 and iA-32 architectures software developer’s manual vol. 3A, http://www.intel.com/content/
www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.
html/,
[34] NASM, Multi-line macros, http://www.nasm.us/doc/nasmdoc4.html#section-4.3,
[35] SIGOPS, i386 interrupt handling, http://www.acm.uiuc.edu/sigops/roll_your_own/i386/irq.html,
[36] Andries Brouwer, Keyboard scancodes, http://www.win.tue.nl/,
[37] Steve Chamberlain, Using ld, the gNU linker, http://www.math.utah.edu/docs/info/ld_toc.html,
[38] OSDev, Page frame allocation, http://wiki.osdev.org/Page_Frame_Allocation,
[39] OSDev, Programmable interval timer, http://wiki.osdev.org/Programmable_Interval_Timer,
78


### context python

Python
Python
Notes for Professionals
®
Notes for Professionals
800+ pages
of professional hints and tricks
GoalKicker.com
Free Programming Books
Disclaimer
This is an unocial free book created for educational purposes and is
not aliated with ocial Python® group(s) or company(s).
All trademarks and registered trademarks are
the property of their respective ownersContents
About ................................................................................................................................................................................... 1
Chapter 1: Getting started with Python Language ...................................................................................... 2
Section 1.1: Getting Started ........................................................................................................................................... 2
Section 1.2: Creating variables and assigning values ................................................................................................ 6
Section 1.3: Block Indentation ..................................................................................................................................... 10
Section 1.4: Datatypes ................................................................................................................................................. 11
Section 1.5: Collection Types ...................................................................................................................................... 15
Section 1.6: IDLE - Python GUI .................................................................................................................................... 19
Section 1.7: User Input ................................................................................................................................................. 21
Section 1.8: Built in Modules and Functions .............................................................................................................. 21
Section 1.9: Creating a module ................................................................................................................................... 25
Section 1.10: Installation of Python 2.7.x and 3.x ....................................................................................................... 26
Section 1.11: String function - str() and repr() ........................................................................................................... 28
Section 1.12: Installing external modules using pip ................................................................................................... 29
Section 1.13: Help Utility ............................................................................................................................................... 31
Chapter 2: Python Data Types ............................................................................................................................ 33
Section 2.1: String Data Type ..................................................................................................................................... 33
Section 2.2: Set Data Types ....................................................................................................................................... 33
Section 2.3: Numbers data type ................................................................................................................................ 33
Section 2.4: List Data Type ......................................................................................................................................... 34
Section 2.5: Dictionary Data Type ............................................................................................................................. 34
Section 2.6: Tuple Data Type ..................................................................................................................................... 34
Chapter 3: Indentation ............................................................................................................................................. 35
Section 3.1: Simple example ....................................................................................................................................... 35
Section 3.2: How Indentation is Parsed ..................................................................................................................... 35
Section 3.3: Indentation Errors ................................................................................................................................... 36
Chapter 4: Comments and Documentation .................................................................................................. 37
Section 4.1: Single line, inline and multiline comments ............................................................................................ 37
Section 4.2: Programmatically accessing docstrings .............................................................................................. 37
Section 4.3: Write documentation using docstrings ................................................................................................ 38
Chapter 5: Date and Time ...................................................................................................................................... 42
Section 5.1: Parsing a string into a timezone aware datetime object .................................................................... 42
Section 5.2: Constructing timezone-aware datetimes ............................................................................................ 42
Section 5.3: Computing time dierences .................................................................................................................. 44
Section 5.4: Basic datetime objects usage ............................................................................................................... 44
Section 5.5: Switching between time zones .............................................................................................................. 45
Section 5.6: Simple date arithmetic ........................................................................................................................... 45
Section 5.7: Converting timestamp to datetime ...................................................................................................... 46
Section 5.8: Subtracting months from a date accurately ....................................................................................... 46
Section 5.9: Parsing an arbitrary ISO 8601 timestamp with minimal libraries ...................................................... 46
Section 5.10: Get an ISO 8601 timestamp .................................................................................................................. 47
Section 5.11: Parsing a string with a short time zone name into a timezone aware datetime object ................ 47
Section 5.12: Fuzzy datetime parsing (extracting datetime out of a text) ............................................................ 48
Section 5.13: Iterate over dates .................................................................................................................................. 49
Chapter 6: Date Formatting .................................................................................................................................. 50
Section 6.1: Time between two date-times ............................................................................................................... 50
Section 6.2: Outputting datetime object to string .................................................................................................... 50Section 6.3: Parsing string to datetime object ......................................................................................................... 50
Chapter 7: Enum .......................................................................................................................................................... 51
Section 7.1: Creating an enum (Python 2.4 through 3.3) ......................................................................................... 51
Section 7.2: Iteration ................................................................................................................................................... 51
Chapter 8: Set ............................................................................................................................................................... 52
Section 8.1: Operations on sets .................................................................................................................................. 52
Section 8.2: Get the unique elements of a list .......................................................................................................... 53
Section 8.3: Set of Sets ................................................................................................................................................ 53
Section 8.4: Set Operations using Methods and Builtins ......................................................................................... 53
Section 8.5: Sets versus multisets .............................................................................................................................. 55
Chapter 9: Simple Mathematical Operators ................................................................................................. 57
Section 9.1: Division ..................................................................................................................................................... 57
Section 9.2: Addition .................................................................................................................................................... 58
Section 9.3: Exponentiation ........................................................................................................................................ 59
Section 9.4: Trigonometric Functions ........................................................................................................................ 60
Section 9.5: Inplace Operations ................................................................................................................................. 61
Section 9.6: Subtraction .............................................................................................................................................. 61
Section 9.7: Multiplication ........................................................................................................................................... 61
Section 9.8: Logarithms .............................................................................................................................................. 62
Section 9.9: Modulus ................................................................................................................................................... 62
Chapter 10: Bitwise Operators ............................................................................................................................. 65
Section 10.1: Bitwise NOT ............................................................................................................................................ 65
Section 10.2: Bitwise XOR (Exclusive OR) .................................................................................................................. 66
Section 10.3: Bitwise AND ............................................................................................................................................ 67
Section 10.4: Bitwise OR .............................................................................................................................................. 67
Section 10.5: Bitwise Left Shift .................................................................................................................................... 67
Section 10.6: Bitwise Right Shift .................................................................................................................................. 68
Section 10.7: Inplace Operations ................................................................................................................................ 68
Chapter 11: Boolean Operators ............................................................................................................................ 69
Section 11.1: `and` and `or` are not guaranteed to return a boolean ...................................................................... 69
Section 11.2: A simple example ................................................................................................................................... 69
Section 11.3: Short-circuit evaluation ......................................................................................................................... 69
Section 11.4: and ........................................................................................................................................................... 70
Section 11.5: or .............................................................................................................................................................. 70
Section 11.6: not ............................................................................................................................................................ 71
Chapter 12: Operator Precedence ...................................................................................................................... 72
Section 12.1: Simple Operator Precedence Examples in python ............................................................................. 72
Chapter 13: Variable Scope and Binding ......................................................................................................... 73
Section 13.1: Nonlocal Variables ................................................................................................................................. 73
Section 13.2: Global Variables .................................................................................................................................... 73
Section 13.3: Local Variables ...................................................................................................................................... 74
Section 13.4: The del command ................................................................................................................................. 75
Section 13.5: Functions skip class scope when looking up names ......................................................................... 76
Section 13.6: Local vs Global Scope ........................................................................................................................... 77
Section 13.7: Binding Occurrence ............................................................................................................................... 79
Chapter 14: Conditionals ......................................................................................................................................... 80
Section 14.1: Conditional Expression (or "The Ternary Operator") ......................................................................... 80
Section 14.2: if, elif, and else ....................................................................................................................................... 80
Section 14.3: Truth Values ........................................................................................................................................... 80Section 14.4: Boolean Logic Expressions ................................................................................................................... 81
Section 14.5: Using the cmp function to get the comparison result of two objects ............................................. 83
Section 14.6: Else statement ....................................................................................................................................... 83
Section 14.7: Testing if an object is None and assigning it ...................................................................................... 84
Section 14.8: If statement ............................................................................................................................................ 84
Chapter 15: Comparisons ........................................................................................................................................ 86
Section 15.1: Chain Comparisons ................................................................................................................................ 86
Section 15.2: Comparison by `is` vs `==` ...................................................................................................................... 87
Section 15.3: Greater than or less than ...................................................................................................................... 88
Section 15.4: Not equal to ........................................................................................................................................... 88
Section 15.5: Equal To ................................................................................................................................................. 89
Section 15.6: Comparing Objects ............................................................................................................................... 89
Chapter 16: Loops ....................................................................................................................................................... 91
Section 16.1: Break and Continue in Loops ................................................................................................................ 91
Section 16.2: For loops ................................................................................................................................................ 93
Section 16.3: Iterating over lists .................................................................................................................................. 93
Section 16.4: Loops with an "else" clause .................................................................................................................. 94
Section 16.5: The Pass Statement .............................................................................................................................. 96
Section 16.6: Iterating over dictionaries .................................................................................................................... 97
Section 16.7: The "half loop" do-while ........................................................................................................................ 98
Section 16.8: Looping and Unpacking ....................................................................................................................... 98
Section 16.9: Iterating dierent portion of a list with dierent step size ............................................................... 99
Section 16.10: While Loop .......................................................................................................................................... 100
Chapter 17: Arrays .................................................................................................................................................... 102
Section 17.1: Access individual elements through indexes ..................................................................................... 102
Section 17.2: Basic Introduction to Arrays .............................................................................................................. 102
Section 17.3: Append any value to the array using append() method ................................................................ 103
Section 17.4: Insert value in an array using insert() method ................................................................................ 103
Section 17.5: Extend python array using extend() method ................................................................................... 103
Section 17.6: Add items from list into array using fromlist() method .................................................................. 104
Section 17.7: Remove any array element using remove() method ..................................................................... 104
Section 17.8: Remove last array element using pop() method ............................................................................ 104
Section 17.9: Fetch any element through its index using index() method ........................................................... 104
Section 17.10: Reverse a python array using reverse() method ........................................................................... 104
Section 17.11: Get array buer information through buer_info() method ........................................................ 105
Section 17.12: Check for number of occurrences of an element using count() method .................................... 105
Section 17.13: Convert array to string using tostring() method ............................................................................ 105
Section 17.14: Convert array to a python list with same elements using tolist() method .................................. 105
Section 17.15: Append a string to char array using fromstring() method ........................................................... 105
Chapter 18: Multidimensional arrays .............................................................................................................. 106
Section 18.1: Lists in lists ............................................................................................................................................ 106
Section 18.2: Lists in lists in lists in.. .......................................................................................................................... 106
Chapter 19: Dictionary ............................................................................................................................................ 108
Section 19.1: Introduction to Dictionary ................................................................................................................... 108
Section 19.2: Avoiding KeyError Exceptions ........................................................................................................... 109
Section 19.3: Iterating Over a Dictionary ................................................................................................................. 109
Section 19.4: Dictionary with default values ........................................................................................................... 110
Section 19.5: Merging dictionaries ........................................................................................................................... 111
Section 19.6: Accessing keys and values ................................................................................................................ 111
Section 19.7: Accessing values of a dictionary ....................................................................................................... 112Section 19.8: Creating a dictionary .......................................................................................................................... 112
Section 19.9: Creating an ordered dictionary ......................................................................................................... 113
Section 19.10: Unpacking dictionaries using the ** operator ................................................................................. 113
Section 19.11: The trailing comma ............................................................................................................................ 114
Section 19.12: The dict() constructor ........................................................................................................................ 114
Section 19.13: Dictionaries Example ......................................................................................................................... 114
Section 19.14: All combinations of dictionary values .............................................................................................. 115
Chapter 20: List ......................................................................................................................................................... 117
Section 20.1: List methods and supported operators ............................................................................................ 117
Section 20.2: Accessing list values .......................................................................................................................... 122
Section 20.3: Checking if list is empty ..................................................................................................................... 123
Section 20.4: Iterating over a list ............................................................................................................................. 123
Section 20.5: Checking whether an item is in a list ................................................................................................ 124
Section 20.6: Any and All .......................................................................................................................................... 124
Section 20.7: Reversing list elements ...................................................................................................................... 125
Section 20.8: Concatenate and Merge lists ............................................................................................................ 125
Section 20.9: Length of a list .................................................................................................................................... 126
Section 20.10: Remove duplicate values in list ....................................................................................................... 126
Section 20.11: Comparison of lists ............................................................................................................................ 127
Section 20.12: Accessing values in nested list ........................................................................................................ 127
Section 20.13: Initializing a List to a Fixed Number of Elements ........................................................................... 128
Chapter 21: List comprehensions ...................................................................................................................... 130
Section 21.1: List Comprehensions ........................................................................................................................... 130
Section 21.2: Conditional List Comprehensions ...................................................................................................... 132
Section 21.3: Avoid repetitive and expensive operations using conditional clause ............................................ 134
Section 21.4: Dictionary Comprehensions ............................................................................................................... 135
Section 21.5: List Comprehensions with Nested Loops .......................................................................................... 136
Section 21.6: Generator Expressions ........................................................................................................................ 138
Section 21.7: Set Comprehensions ........................................................................................................................... 140
Section 21.8: Refactoring ﬁlter and map to list comprehensions ......................................................................... 140
Section 21.9: Comprehensions involving tuples ...................................................................................................... 141
Section 21.10: Counting Occurrences Using Comprehension ............................................................................... 142
Section 21.11: Changing Types in a List .................................................................................................................... 142
Section 21.12: Nested List Comprehensions ............................................................................................................ 142
Section 21.13: Iterate two or more list simultaneously within list comprehension .............................................. 143
Chapter 22: List slicing (selecting parts of lists) ....................................................................................... 144
Section 22.1: Using the third "step" argument ........................................................................................................ 144
Section 22.2: Selecting a sublist from a list ............................................................................................................ 144
Section 22.3: Reversing a list with slicing ................................................................................................................ 144
Section 22.4: Shifting a list using slicing .................................................................................................................. 144
Chapter 23: groupby() ............................................................................................................................................ 146
Section 23.1: Example 4 ............................................................................................................................................. 146
Section 23.2: Example 2 ............................................................................................................................................ 146
Section 23.3: Example 3 ............................................................................................................................................ 147
Chapter 24: Linked lists ......................................................................................................................................... 149
Section 24.1: Single linked list example ................................................................................................................... 149
Chapter 25: Linked List Node ............................................................................................................................. 154
Section 25.1: Write a simple Linked List Node in python ....................................................................................... 154
Chapter 26: Filter ...................................................................................................................................................... 155Section 26.1: Basic use of ﬁlter ................................................................................................................................. 155
Section 26.2: Filter without function ........................................................................................................................ 155
Section 26.3: Filter as short-circuit check ............................................................................................................... 156
Section 26.4: Complementary function: ﬁlterfalse, iﬁlterfalse .............................................................................. 156
Chapter 27: Heapq ................................................................................................................................................... 158
Section 27.1: Largest and smallest items in a collection ....................................................................................... 158
Section 27.2: Smallest item in a collection .............................................................................................................. 158
Chapter 28: Tuple ..................................................................................................................................................... 160
Section 28.1: Tuple ..................................................................................................................................................... 160
Section 28.2: Tuples are immutable ........................................................................................................................ 161
Section 28.3: Packing and Unpacking Tuples ........................................................................................................ 161
Section 28.4: Built-in Tuple Functions ..................................................................................................................... 162
Section 28.5: Tuple Are Element-wise Hashable and Equatable ......................................................................... 163
Section 28.6: Indexing Tuples ................................................................................................................................... 164
Section 28.7: Reversing Elements ............................................................................................................................ 164
Chapter 29: Basic Input and Output ............................................................................................................... 165
Section 29.1: Using the print function ...................................................................................................................... 165
Section 29.2: Input from a File ................................................................................................................................. 165
Section 29.3: Read from stdin .................................................................................................................................. 167
Section 29.4: Using input() and raw_input() .......................................................................................................... 167
Section 29.5: Function to prompt user for a number ............................................................................................ 167
Section 29.6: Printing a string without a newline at the end ................................................................................. 168
Chapter 30: Files & Folders I/O ......................................................................................................................... 171
Section 30.1: File modes ............................................................................................................................................ 171
Section 30.2: Reading a ﬁle line-by-line .................................................................................................................. 172
Section 30.3: Iterate ﬁles (recursively) .................................................................................................................... 173
Section 30.4: Getting the full contents of a ﬁle ...................................................................................................... 173
Section 30.5: Writing to a ﬁle ................................................................................................................................... 174
Section 30.6: Check whether a ﬁle or path exists .................................................................................................. 175
Section 30.7: Random File Access Using mmap .................................................................................................... 176
Section 30.8: Replacing text in a ﬁle ....................................................................................................................... 176
Section 30.9: Checking if a ﬁle is empty ................................................................................................................. 176
Section 30.10: Read a ﬁle between a range of lines .............................................................................................. 177
Section 30.11: Copy a directory tree ........................................................................................................................ 177
Section 30.12: Copying contents of one ﬁle to a dierent ﬁle .............................................................................. 177
Chapter 31: os.path .................................................................................................................................................. 178
Section 31.1: Join Paths ............................................................................................................................................. 178
Section 31.2: Path Component Manipulation .......................................................................................................... 178
Section 31.3: Get the parent directory ..................................................................................................................... 178
Section 31.4: If the given path exists ........................................................................................................................ 178
Section 31.5: check if the given path is a directory, ﬁle, symbolic link, mount point etc .................................... 179
Section 31.6: Absolute Path from Relative Path ..................................................................................................... 179
Chapter 32: Iterables and Iterators ................................................................................................................ 180
Section 32.1: Iterator vs Iterable vs Generator ....................................................................................................... 180
Section 32.2: Extract values one by one ................................................................................................................. 181
Section 32.3: Iterating over entire iterable ............................................................................................................. 181
Section 32.4: Verify only one element in iterable .................................................................................................. 181
Section 32.5: What can be iterable .......................................................................................................................... 182
Section 32.6: Iterator isn't reentrant! ....................................................................................................................... 182Chapter 33: Functions ............................................................................................................................................. 183
Section 33.1: Deﬁning and calling simple functions ............................................................................................... 183
Section 33.2: Deﬁning a function with an arbitrary number of arguments ........................................................ 184
Section 33.3: Lambda (Inline/Anonymous) Functions .......................................................................................... 187
Section 33.4: Deﬁning a function with optional arguments .................................................................................. 189
Section 33.5: Deﬁning a function with optional mutable arguments ................................................................... 190
Section 33.6: Argument passing and mutability .................................................................................................... 191
Section 33.7: Returning values from functions ....................................................................................................... 192
Section 33.8: Closure ................................................................................................................................................. 192
Section 33.9: Forcing the use of named parameters ............................................................................................ 193
Section 33.10: Nested functions ............................................................................................................................... 194
Section 33.11: Recursion limit .................................................................................................................................... 194
Section 33.12: Recursive Lambda using assigned variable ................................................................................... 195
Section 33.13: Recursive functions ........................................................................................................................... 195
Section 33.14: Deﬁning a function with arguments ................................................................................................ 196
Section 33.15: Iterable and dictionary unpacking .................................................................................................. 196
Section 33.16: Deﬁning a function with multiple arguments ................................................................................. 198
Chapter 34: Deﬁning functions with list arguments .............................................................................. 199
Section 34.1: Function and Call ................................................................................................................................. 199
Chapter 35: Functional Programming in Python ...................................................................................... 201
Section 35.1: Lambda Function ................................................................................................................................ 201
Section 35.2: Map Function ...................................................................................................................................... 201
Section 35.3: Reduce Function ................................................................................................................................. 201
Section 35.4: Filter Function ..................................................................................................................................... 201
Chapter 36: Partial functions .............................................................................................................................. 202
Section 36.1: Raise the power ................................................................................................................................... 202
Chapter 37: Decorators ......................................................................................................................................... 203
Section 37.1: Decorator function .............................................................................................................................. 203
Section 37.2: Decorator class ................................................................................................................................... 204
Section 37.3: Decorator with arguments (decorator factory) .............................................................................. 205
Section 37.4: Making a decorator look like the decorated function .................................................................... 207
Section 37.5: Using a decorator to time a function ............................................................................................... 207
Section 37.6: Create singleton class with a decorator .......................................................................................... 208
Chapter 38: Classes ................................................................................................................................................. 209
Section 38.1: Introduction to classes ........................................................................................................................ 209
Section 38.2: Bound, unbound, and static methods .............................................................................................. 210
Section 38.3: Basic inheritance ................................................................................................................................ 212
Section 38.4: Monkey Patching ................................................................................................................................ 214
Section 38.5: New-style vs. old-style classes .......................................................................................................... 214
Section 38.6: Class methods: alternate initializers ................................................................................................. 215
Section 38.7: Multiple Inheritance ............................................................................................................................ 217
Section 38.8: Properties ............................................................................................................................................ 219
Section 38.9: Default values for instance variables ............................................................................................... 220
Section 38.10: Class and instance variables ........................................................................................................... 221
Section 38.11: Class composition .............................................................................................................................. 222
Section 38.12: Listing All Class Members ................................................................................................................. 223
Section 38.13: Singleton class ................................................................................................................................... 224
Section 38.14: Descriptors and Dotted Lookups .................................................................................................... 225
Chapter 39: Metaclasses ....................................................................................................................................... 226Section 39.1: Basic Metaclasses ............................................................................................................................... 226
Section 39.2: Singletons using metaclasses ........................................................................................................... 227
Section 39.3: Using a metaclass .............................................................................................................................. 227
Section 39.4: Introduction to Metaclasses .............................................................................................................. 227
Section 39.5: Custom functionality with metaclasses ........................................................................................... 228
Section 39.6: The default metaclass ....................................................................................................................... 229
Chapter 40: String Formatting ......................................................................................................................... 232
Section 40.1: Basics of String Formatting ............................................................................................................... 232
Section 40.2: Alignment and padding ..................................................................................................................... 233
Section 40.3: Format literals (f-string) .................................................................................................................... 234
Section 40.4: Float formatting ................................................................................................................................. 234
Section 40.5: Named placeholders ......................................................................................................................... 235
Section 40.6: String formatting with datetime ....................................................................................................... 236
Section 40.7: Formatting Numerical Values ........................................................................................................... 236
Section 40.8: Nested formatting .............................................................................................................................. 237
Section 40.9: Format using Getitem and Getattr ................................................................................................... 237
Section 40.10: Padding and truncating strings, combined .................................................................................... 237
Section 40.11: Custom formatting for a class ......................................................................................................... 238
Chapter 41: String Methods ................................................................................................................................ 240
Section 41.1: Changing the capitalization of a string ............................................................................................. 240
Section 41.2: str.translate: Translating characters in a string ............................................................................... 241
Section 41.3: str.format and f-strings: Format values into a string ...................................................................... 242
Section 41.4: String module's useful constants ....................................................................................................... 243
Section 41.5: Stripping unwanted leading/trailing characters from a string ...................................................... 244
Section 41.6: Reversing a string ............................................................................................................................... 245
Section 41.7: Split a string based on a delimiter into a list of strings ................................................................... 245
Section 41.8: Replace all occurrences of one substring with another substring ................................................ 246
Section 41.9: Testing what a string is composed of ............................................................................................... 247
Section 41.10: String Contains ................................................................................................................................... 249
Section 41.11: Join a list of strings into one string ................................................................................................... 249
Section 41.12: Counting number of times a substring appears in a string .......................................................... 250
Section 41.13: Case insensitive string comparisons ................................................................................................ 250
Section 41.14: Justify strings ..................................................................................................................................... 251
Section 41.15: Test the starting and ending characters of a string ...................................................................... 252
Section 41.16: Conversion between str or bytes data and unicode characters .................................................. 253
Chapter 42: Using loops within functions .................................................................................................... 255
Section 42.1: Return statement inside loop in a function ...................................................................................... 255
Chapter 43: Importing modules ........................................................................................................................ 256
Section 43.1: Importing a module ............................................................................................................................ 256
Section 43.2: The __all__ special variable ............................................................................................................ 257
Section 43.3: Import modules from an arbitrary ﬁlesystem location .................................................................. 258
Section 43.4: Importing all names from a module ................................................................................................ 258
Section 43.5: Programmatic importing ................................................................................................................... 259
Section 43.6: PEP8 rules for Imports ....................................................................................................................... 259
Section 43.7: Importing speciﬁc names from a module ........................................................................................ 260
Section 43.8: Importing submodules ....................................................................................................................... 260
Section 43.9: Re-importing a module ...................................................................................................................... 260
Section 43.10: __import__() function ..................................................................................................................... 261
Chapter 44: Dierence between Module and Package ...................................................................... 262
Section 44.1: Modules ................................................................................................................................................ 262Section 44.2: Packages ............................................................................................................................................. 262
Chapter 45: Math Module .................................................................................................................................... 264
Section 45.1: Rounding: round, ﬂoor, ceil, trunc ...................................................................................................... 264
Section 45.2: Trigonometry ...................................................................................................................................... 265
Section 45.3: Pow for faster exponentiation ........................................................................................................... 266
Section 45.4: Inﬁnity and NaN ("not a number") ................................................................................................... 266
Section 45.5: Logarithms .......................................................................................................................................... 269
Section 45.6: Constants ............................................................................................................................................ 269
Section 45.7: Imaginary Numbers ........................................................................................................................... 270
Section 45.8: Copying signs ..................................................................................................................................... 270
Section 45.9: Complex numbers and the cmath module ...................................................................................... 270
Chapter 46: Complex math ................................................................................................................................. 273
Section 46.1: Advanced complex arithmetic ........................................................................................................... 273
Section 46.2: Basic complex arithmetic .................................................................................................................. 274
Chapter 47: Collections module ....................................................................................................................... 275
Section 47.1: collections.Counter .............................................................................................................................. 275
Section 47.2: collections.OrderedDict ...................................................................................................................... 276
Section 47.3: collections.defaultdict ......................................................................................................................... 277
Section 47.4: collections.namedtuple ...................................................................................................................... 278
Section 47.5: collections.deque ................................................................................................................................ 279
Section 47.6: collections.ChainMap .......................................................................................................................... 280
Chapter 48: Operator module ........................................................................................................................... 282
Section 48.1: Itemgetter ............................................................................................................................................ 282
Section 48.2: Operators as alternative to an inﬁx operator ................................................................................. 282
Section 48.3: Methodcaller ....................................................................................................................................... 282
Chapter 49: JSON Module .................................................................................................................................... 284
Section 49.1: Storing data in a ﬁle ............................................................................................................................ 284
Section 49.2: Retrieving data from a ﬁle ................................................................................................................ 284
Section 49.3: Formatting JSON output ................................................................................................................... 284
Section 49.4: `load` vs `loads`, `dump` vs `dumps` ................................................................................................... 285
Section 49.5: Calling `json.tool` from the command line to pretty-print JSON output ...................................... 286
Section 49.6: JSON encoding custom objects ........................................................................................................ 286
Section 49.7: Creating JSON from Python dict ...................................................................................................... 287
Section 49.8: Creating Python dict from JSON ...................................................................................................... 287
Chapter 50: Sqlite3 Module ................................................................................................................................. 289
Section 50.1: Sqlite3 - Not require separate server process ................................................................................. 289
Section 50.2: Getting the values from the database and Error handling ........................................................... 289
Chapter 51: The os Module ................................................................................................................................... 291
Section 51.1: makedirs - recursive directory creation ............................................................................................ 291
Section 51.2: Create a directory ............................................................................................................................... 292
Section 51.3: Get current directory .......................................................................................................................... 292
Section 51.4: Determine the name of the operating system ................................................................................ 292
Section 51.5: Remove a directory ............................................................................................................................ 292
Section 51.6: Follow a symlink (POSIX) .................................................................................................................... 292
Section 51.7: Change permissions on a ﬁle ............................................................................................................. 292
Chapter 52: The locale Module .......................................................................................................................... 293
Section 52.1: Currency Formatting US Dollars Using the locale Module ............................................................. 293
Chapter 53: Itertools Module .............................................................................................................................. 294
Section 53.1: Combinations method in Itertools Module ....................................................................................... 294Section 53.2: itertools.dropwhile .............................................................................................................................. 294
Section 53.3: Zipping two iterators until they are both exhausted ...................................................................... 295
Section 53.4: Take a slice of a generator ............................................................................................................... 295
Section 53.5: Grouping items from an iterable object using a function .............................................................. 296
Section 53.6: itertools.takewhile ............................................................................................................................... 297
Section 53.7: itertools.permutations ........................................................................................................................ 297
Section 53.8: itertools.repeat .................................................................................................................................... 298
Section 53.9: Get an accumulated sum of numbers in an iterable ...................................................................... 298
Section 53.10: Cycle through elements in an iterator ............................................................................................ 298
Section 53.11: itertools.product ................................................................................................................................. 298
Section 53.12: itertools.count .................................................................................................................................... 299
Section 53.13: Chaining multiple iterators together ............................................................................................... 300
Chapter 54: Asyncio Module ............................................................................................................................... 301
Section 54.1: Coroutine and Delegation Syntax ..................................................................................................... 301
Section 54.2: Asynchronous Executors ................................................................................................................... 302
Section 54.3: Using UVLoop ..................................................................................................................................... 303
Section 54.4: Synchronization Primitive: Event ....................................................................................................... 303
Section 54.5: A Simple Websocket .......................................................................................................................... 304
Section 54.6: Common Misconception about asyncio .......................................................................................... 304
Chapter 55: Random module ............................................................................................................................. 307
Section 55.1: Creating a random user password ................................................................................................... 307
Section 55.2: Create cryptographically secure random numbers ....................................................................... 307
Section 55.3: Random and sequences: shue, choice and sample .................................................................... 308
Section 55.4: Creating random integers and ﬂoats: randint, randrange, random, and uniform ...................... 309
Section 55.5: Reproducible random numbers: Seed and State ............................................................................ 310
Section 55.6: Random Binary Decision ................................................................................................................... 311
Chapter 56: Functools Module ........................................................................................................................... 312
Section 56.1: partial ................................................................................................................................................... 312
Section 56.2: cmp_to_key ....................................................................................................................................... 312
Section 56.3: lru_cache ............................................................................................................................................. 312
Section 56.4: total_ordering ..................................................................................................................................... 313
Section 56.5: reduce .................................................................................................................................................. 314
Chapter 57: The dis module ................................................................................................................................ 315
Section 57.1: What is Python bytecode? ................................................................................................................. 315
Section 57.2: Constants in the dis module .............................................................................................................. 315
Section 57.3: Disassembling modules ..................................................................................................................... 315
Chapter 58: The base64 Module ....................................................................................................................... 317
Section 58.1: Encoding and Decoding Base64 ....................................................................................................... 318
Section 58.2: Encoding and Decoding Base32 ....................................................................................................... 319
Section 58.3: Encoding and Decoding Base16 ........................................................................................................ 320
Section 58.4: Encoding and Decoding ASCII85 ...................................................................................................... 320
Section 58.5: Encoding and Decoding Base85 ....................................................................................................... 321
Chapter 59: Queue Module .................................................................................................................................. 322
Section 59.1: Simple example ................................................................................................................................... 322
Chapter 60: Deque Module .................................................................................................................................. 324
Section 60.1: Basic deque using ............................................................................................................................... 324
Section 60.2: Available methods in deque .............................................................................................................. 324
Section 60.3: limit deque size ................................................................................................................................... 325
Section 60.4: Breadth First Search .......................................................................................................................... 325Chapter 61: Webbrowser Module ...................................................................................................................... 326
Section 61.1: Opening a URL with Default Browser ................................................................................................ 326
Section 61.2: Opening a URL with Dierent Browsers ........................................................................................... 327
Chapter 62: tkinter ................................................................................................................................................... 328
Section 62.1: Geometry Managers ........................................................................................................................... 328
Section 62.2: A minimal tkinter Application ............................................................................................................ 329
Chapter 63: pyautogui module .......................................................................................................................... 331
Section 63.1: Mouse Functions .................................................................................................................................. 331
Section 63.2: Keyboard Functions ........................................................................................................................... 331
Section 63.3: Screenshot And Image Recognition ................................................................................................. 331
Chapter 64: Indexing and Slicing ...................................................................................................................... 332
Section 64.1: Basic Slicing ......................................................................................................................................... 332
Section 64.2: Reversing an object ........................................................................................................................... 333
Section 64.3: Slice assignment ................................................................................................................................. 333
Section 64.4: Making a shallow copy of an array .................................................................................................. 333
Section 64.5: Indexing custom classes: __getitem__, __setitem__ and __delitem__ ................................... 334
Section 64.6: Basic Indexing ..................................................................................................................................... 335
Chapter 65: Plotting with Matplotlib .............................................................................................................. 337
Section 65.1: Plots with Common X-axis but dierent Y-axis : Using twinx() ....................................................... 337
Section 65.2: Plots with common Y-axis and dierent X-axis using twiny() ....................................................... 338
Section 65.3: A Simple Plot in Matplotlib ................................................................................................................. 340
Section 65.4: Adding more features to a simple plot : axis labels, title, axis ticks, grid, and legend ................ 341
Section 65.5: Making multiple plots in the same ﬁgure by superimposition similar to MATLAB ...................... 342
Section 65.6: Making multiple Plots in the same ﬁgure using plot superimposition with separate plot
commands ......................................................................................................................................................... 343
Chapter 66: graph-tool .......................................................................................................................................... 345
Section 66.1: PyDotPlus ............................................................................................................................................. 345
Section 66.2: PyGraphviz .......................................................................................................................................... 345
Chapter 67: Generators ......................................................................................................................................... 347
Section 67.1: Introduction .......................................................................................................................................... 347
Section 67.2: Inﬁnite sequences ............................................................................................................................... 349
Section 67.3: Sending objects to a generator ........................................................................................................ 350
Section 67.4: Yielding all values from another iterable ......................................................................................... 351
Section 67.5: Iteration ............................................................................................................................................... 351
Section 67.6: The next() function ............................................................................................................................. 351
Section 67.7: Coroutines ........................................................................................................................................... 352
Section 67.8: Refactoring list-building code ........................................................................................................... 352
Section 67.9: Yield with recursion: recursively listing all ﬁles in a directory ........................................................ 353
Section 67.10: Generator expressions ...................................................................................................................... 354
Section 67.11: Using a generator to ﬁnd Fibonacci Numbers ............................................................................... 354
Section 67.12: Searching ........................................................................................................................................... 354
Section 67.13: Iterating over generators in parallel ............................................................................................... 355
Chapter 68: Reduce ................................................................................................................................................. 356
Section 68.1: Overview .............................................................................................................................................. 356
Section 68.2: Using reduce ....................................................................................................................................... 356
Section 68.3: Cumulative product ............................................................................................................................ 357
Section 68.4: Non short-circuit variant of any/all ................................................................................................. 357
Chapter 69: Map Function .................................................................................................................................... 358
Section 69.1: Basic use of map, itertools.imap and future_builtins.map ............................................................. 358Section 69.2: Mapping each value in an iterable ................................................................................................... 358
Section 69.3: Mapping values of dierent iterables .............................................................................................. 359
Section 69.4: Transposing with Map: Using "None" as function argument (python 2.x only) .......................... 361
Section 69.5: Series and Parallel Mapping .............................................................................................................. 361
Chapter 70: Exponentiation ................................................................................................................................ 365
Section 70.1: Exponentiation using builtins: ** and pow() ...................................................................................... 365
Section 70.2: Square root: math.sqrt() and cmath.sqrt ......................................................................................... 365
Section 70.3: Modular exponentiation: pow() with 3 arguments .......................................................................... 366
Section 70.4: Computing large integer roots ......................................................................................................... 366
Section 70.5: Exponentiation using the math module: math.pow() ..................................................................... 367
Section 70.6: Exponential function: math.exp() and cmath.exp() ......................................................................... 368
Section 70.7: Exponential function minus 1: math.expm1() .................................................................................... 368
Section 70.8: Magic methods and exponentiation: builtin, math and cmath ...................................................... 369
Section 70.9: Roots: nth-root with fractional exponents ....................................................................................... 370
Chapter 71: Searching ............................................................................................................................................ 371
Section 71.1: Searching for an element .................................................................................................................... 371
Section 71.2: Searching in custom classes: __contains__ and __iter__ ........................................................... 371
Section 71.3: Getting the index for strings: str.index(), str.rindex() and str.ﬁnd(), str.rﬁnd() ............................... 372
Section 71.4: Getting the index list and tuples: list.index(), tuple.index() .............................................................. 373
Section 71.5: Searching key(s) for a value in dict ................................................................................................... 373
Section 71.6: Getting the index for sorted sequences: bisect.bisect_left() .......................................................... 374
Section 71.7: Searching nested sequences ............................................................................................................. 374
Chapter 72: Sorting, Minimum and Maximum ............................................................................................ 376
Section 72.1: Make custom classes orderable ........................................................................................................ 376
Section 72.2: Special case: dictionaries ................................................................................................................... 378
Section 72.3: Using the key argument .................................................................................................................... 379
Section 72.4: Default Argument to max, min ......................................................................................................... 379
Section 72.5: Getting a sorted sequence ................................................................................................................ 380
Section 72.6: Extracting N largest or N smallest items from an iterable ............................................................ 380
Section 72.7: Getting the minimum or maximum of several values .................................................................... 381
Section 72.8: Minimum and Maximum of a sequence ........................................................................................... 381
Chapter 73: Counting .............................................................................................................................................. 382
Section 73.1: Counting all occurrence of all items in an iterable: collections.Counter ........................................ 382
Section 73.2: Getting the most common value(-s): collections.Counter.most_common() ................................ 382
Section 73.3: Counting the occurrences of one item in a sequence: list.count() and tuple.count() .................. 382
Section 73.4: Counting the occurrences of a substring in a string: str.count() ................................................... 383
Section 73.5: Counting occurrences in numpy array ............................................................................................ 383
Chapter 74: The Print Function ......................................................................................................................... 384
Section 74.1: Print basics ........................................................................................................................................... 384
Section 74.2: Print parameters ................................................................................................................................ 385
Chapter 75: Regular Expressions (Regex) ................................................................................................... 388
Section 75.1: Matching the beginning of a string ................................................................................................... 388
Section 75.2: Searching ............................................................................................................................................ 389
Section 75.3: Precompiled patterns ......................................................................................................................... 389
Section 75.4: Flags .................................................................................................................................................... 390
Section 75.5: Replacing ............................................................................................................................................. 391
Section 75.6: Find All Non-Overlapping Matches ................................................................................................... 391
Section 75.7: Checking for allowed characters ...................................................................................................... 392
Section 75.8: Splitting a string using regular expressions ..................................................................................... 392
Section 75.9: Grouping .............................................................................................................................................. 392Section 75.10: Escaping Special Characters ........................................................................................................... 393
Section 75.11: Match an expression only in speciﬁc locations ............................................................................... 394
Section 75.12: Iterating over matches using `re.ﬁnditer` ........................................................................................ 395
Chapter 76: Copying data .................................................................................................................................... 396
Section 76.1: Copy a dictionary ................................................................................................................................ 396
Section 76.2: Performing a shallow copy ............................................................................................................... 396
Section 76.3: Performing a deep copy .................................................................................................................... 396
Section 76.4: Performing a shallow copy of a list .................................................................................................. 396
Section 76.5: Copy a set ........................................................................................................................................... 396
Chapter 77: Context Managers (“with” Statement) ............................................................................... 398
Section 77.1: Introduction to context managers and the with statement ............................................................ 398
Section 77.2: Writing your own context manager ................................................................................................. 398
Section 77.3: Writing your own contextmanager using generator syntax ......................................................... 399
Section 77.4: Multiple context managers ................................................................................................................ 400
Section 77.5: Assigning to a target .......................................................................................................................... 400
Section 77.6: Manage Resources ............................................................................................................................. 401
Chapter 78: The __name__ special variable ........................................................................................... 402
Section 78.1: __name__ == '__main__' ................................................................................................................. 402
Section 78.2: Use in logging ..................................................................................................................................... 402
Section 78.3: function_class_or_module.__name__ .......................................................................................... 402
Chapter 79: Checking Path Existence and Permissions ......................................................................... 404
Section 79.1: Perform checks using os.access ........................................................................................................ 404
Chapter 80: Creating Python packages ....................................................................................................... 406
Section 80.1: Introduction ......................................................................................................................................... 406
Section 80.2: Uploading to PyPI .............................................................................................................................. 406
Section 80.3: Making package executable ............................................................................................................. 408
Chapter 81: Usage of "pip" module: PyPI Package Manager ............................................................. 410
Section 81.1: Example use of commands ................................................................................................................ 410
Section 81.2: Handling ImportError Exception ........................................................................................................ 410
Section 81.3: Force install .......................................................................................................................................... 411
Chapter 82: pip: PyPI Package Manager ...................................................................................................... 412
Section 82.1: Install Packages .................................................................................................................................. 412
Section 82.2: To list all packages installed using `pip` ........................................................................................... 412
Section 82.3: Upgrade Packages ............................................................................................................................ 412
Section 82.4: Uninstall Packages ............................................................................................................................. 413
Section 82.5: Updating all outdated packages on Linux ...................................................................................... 413
Section 82.6: Updating all outdated packages on Windows ................................................................................ 413
Section 82.7: Create a requirements.txt ﬁle of all packages on the system ....................................................... 413
Section 82.8: Using a certain Python version with pip .......................................................................................... 414
Section 82.9: Create a requirements.txt ﬁle of packages only in the current virtualenv .................................. 414
Section 82.10: Installing packages not yet on pip as wheels ................................................................................ 415
Chapter 83: Parsing Command Line arguments ...................................................................................... 418
Section 83.1: Hello world in argparse ...................................................................................................................... 418
Section 83.2: Using command line arguments with argv ..................................................................................... 418
Section 83.3: Setting mutually exclusive arguments with argparse .................................................................... 419
Section 83.4: Basic example with docopt ............................................................................................................... 420
Section 83.5: Custom parser error message with argparse ................................................................................. 420
Section 83.6: Conceptual grouping of arguments with argparse.add_argument_group() ............................. 421
Section 83.7: Advanced example with docopt and docopt_dispatch ................................................................. 422Chapter 84: Subprocess Library ...................................................................................................................... 424
Section 84.1: More ﬂexibility with Popen ................................................................................................................. 424
Section 84.2: Calling External Commands .............................................................................................................. 425
Section 84.3: How to create the command list argument .................................................................................... 425
Chapter 85: setup.py .............................................................................................................................................. 427
Section 85.1: Purpose of setup.py ............................................................................................................................ 427
Section 85.2: Using source control metadata in setup.py .................................................................................... 427
Section 85.3: Adding command line scripts to your python package ................................................................. 428
Section 85.4: Adding installation options ................................................................................................................ 428
Chapter 86: Recursion ............................................................................................................................................ 430
Section 86.1: The What, How, and When of Recursion .......................................................................................... 430
Section 86.2: Tree exploration with recursion ........................................................................................................ 433
Section 86.3: Sum of numbers from 1 to n .............................................................................................................. 434
Section 86.4: Increasing the Maximum Recursion Depth ...................................................................................... 434
Section 86.5: Tail Recursion - Bad Practice ............................................................................................................ 435
Section 86.6: Tail Recursion Optimization Through Stack Introspection ............................................................ 435
Chapter 87: Type Hints .......................................................................................................................................... 437
Section 87.1: Adding types to a function ................................................................................................................. 437
Section 87.2: NamedTuple ....................................................................................................................................... 438
Section 87.3: Generic Types ..................................................................................................................................... 438
Section 87.4: Variables and Attributes .................................................................................................................... 438
Section 87.5: Class Members and Methods ............................................................................................................ 439
Section 87.6: Type hints for keyword arguments .................................................................................................. 439
Chapter 88: Exceptions .......................................................................................................................................... 440
Section 88.1: Catching Exceptions ............................................................................................................................ 440
Section 88.2: Do not catch everything! ................................................................................................................... 440
Section 88.3: Re-raising exceptions ......................................................................................................................... 441
Section 88.4: Catching multiple exceptions ............................................................................................................ 441
Section 88.5: Exception Hierarchy ........................................................................................................................... 442
Section 88.6: Else ....................................................................................................................................................... 444
Section 88.7: Raising Exceptions .............................................................................................................................. 444
Section 88.8: Creating custom exception types ..................................................................................................... 445
Section 88.9: Practical examples of exception handling ....................................................................................... 445
Section 88.10: Exceptions are Objects too .............................................................................................................. 446
Section 88.11: Running clean-up code with ﬁnally .................................................................................................. 446
Section 88.12: Chain exceptions with raise from .................................................................................................... 447
Chapter 89: Raise Custom Errors / Exceptions ......................................................................................... 448
Section 89.1: Custom Exception ............................................................................................................................... 448
Section 89.2: Catch custom Exception .................................................................................................................... 448
Chapter 90: Commonwealth Exceptions ....................................................................................................... 450
Section 90.1: Other Errors ......................................................................................................................................... 450
Section 90.2: NameError: name '???' is not deﬁned .............................................................................................. 451
Section 90.3: TypeErrors .......................................................................................................................................... 452
Section 90.4: Syntax Error on good code ............................................................................................................... 453
Section 90.5: IndentationErrors (or indentation SyntaxErrors) ............................................................................ 454
Chapter 91: urllib ....................................................................................................................................................... 456
Section 91.1: HTTP GET .............................................................................................................................................. 456
Section 91.2: HTTP POST .......................................................................................................................................... 456
Section 91.3: Decode received bytes according to content type encoding ........................................................ 457Chapter 92: Web scraping with Python ......................................................................................................... 458
Section 92.1: Scraping using the Scrapy framework ............................................................................................. 458
Section 92.2: Scraping using Selenium WebDriver ................................................................................................ 458
Section 92.3: Basic example of using requests and lxml to scrape some data ................................................. 459
Section 92.4: Maintaining web-scraping session with requests ........................................................................... 459
Section 92.5: Scraping using BeautifulSoup4 ......................................................................................................... 460
Section 92.6: Simple web content download with urllib.request .......................................................................... 460
Section 92.7: Modify Scrapy user agent ................................................................................................................. 460
Section 92.8: Scraping with curl ............................................................................................................................... 460
Chapter 93: HTML Parsing .................................................................................................................................... 462
Section 93.1: Using CSS selectors in BeautifulSoup ................................................................................................ 462
Section 93.2: PyQuery ............................................................................................................................................... 462
Section 93.3: Locate a text after an element in BeautifulSoup ............................................................................ 463
Chapter 94: Manipulating XML .......................................................................................................................... 464
Section 94.1: Opening and reading using an ElementTree ................................................................................... 464
Section 94.2: Create and Build XML Documents .................................................................................................... 464
Section 94.3: Modifying an XML File ........................................................................................................................ 465
Section 94.4: Searching the XML with XPath .......................................................................................................... 465
Section 94.5: Opening and reading large XML ﬁles using iterparse (incremental parsing) ............................. 466
Chapter 95: Python Requests Post .................................................................................................................. 468
Section 95.1: Simple Post .......................................................................................................................................... 468
Section 95.2: Form Encoded Data ........................................................................................................................... 469
Section 95.3: File Upload .......................................................................................................................................... 469
Section 95.4: Responses ........................................................................................................................................... 470
Section 95.5: Authentication ..................................................................................................................................... 470
Section 95.6: Proxies ................................................................................................................................................. 471
Chapter 96: Distribution ........................................................................................................................................ 473
Section 96.1: py2app ................................................................................................................................................. 473
Section 96.2: cx_Freeze ............................................................................................................................................ 474
Chapter 97: Property Objects ............................................................................................................................ 475
Section 97.1: Using the @property decorator for read-write properties ............................................................. 475
Section 97.2: Using the @property decorator ....................................................................................................... 475
Section 97.3: Overriding just a getter, setter or a deleter of a property object ................................................. 476
Section 97.4: Using properties without decorators ................................................................................................ 476
Chapter 98: Overloading ...................................................................................................................................... 479
Section 98.1: Operator overloading ......................................................................................................................... 479
Section 98.2: Magic/Dunder Methods .................................................................................................................... 480
Section 98.3: Container and sequence types ......................................................................................................... 481
Section 98.4: Callable types ..................................................................................................................................... 482
Section 98.5: Handling unimplemented behaviour ................................................................................................ 482
Chapter 99: Polymorphism .................................................................................................................................. 484
Section 99.1: Duck Typing ......................................................................................................................................... 484
Section 99.2: Basic Polymorphism .......................................................................................................................... 484
Chapter 100: Method Overriding ...................................................................................................................... 488
Section 100.1: Basic method overriding ................................................................................................................... 488
Chapter 101: User-Deﬁned Methods ................................................................................................................ 489
Section 101.1: Creating user-deﬁned method objects ............................................................................................ 489
Section 101.2: Turtle example ................................................................................................................................... 490
Chapter 102: String representations of class instances: __str__ and __repr__methods ........................................................................................................................................................................ 491
Section 102.1: Motivation ........................................................................................................................................... 491
Section 102.2: Both methods implemented, eval-round-trip style __repr__() .................................................. 495
Chapter 103: Debugging ........................................................................................................................................ 496
Section 103.1: Via IPython and ipdb ......................................................................................................................... 496
Section 103.2: The Python Debugger: Step-through Debugging with _pdb_ .................................................... 496
Section 103.3: Remote debugger ............................................................................................................................. 498
Chapter 104: Reading and Writing CSV ........................................................................................................ 499
Section 104.1: Using pandas ..................................................................................................................................... 499
Section 104.2: Writing a TSV ﬁle .............................................................................................................................. 499
Chapter 105: Writing to CSV from String or List ...................................................................................... 501
Section 105.1: Basic Write Example .......................................................................................................................... 501
Section 105.2: Appending a String as a newline in a CSV ﬁle ............................................................................... 501
Chapter 106: Dynamic code execution with `exec` and `eval` ............................................................. 502
Section 106.1: Executing code provided by untrusted user using exec, eval, or ast.literal_eval ....................... 502
Section 106.2: Evaluating a string containing a Python literal with ast.literal_eval ........................................... 502
Section 106.3: Evaluating statements with exec ..................................................................................................... 502
Section 106.4: Evaluating an expression with eval ................................................................................................. 503
Section 106.5: Precompiling an expression to evaluate it multiple times ............................................................ 503
Section 106.6: Evaluating an expression with eval using custom globals ........................................................... 503
Chapter 107: PyInstaller - Distributing Python Code .............................................................................. 504
Section 107.1: Installation and Setup ........................................................................................................................ 504
Section 107.2: Using Pyinstaller ................................................................................................................................ 504
Section 107.3: Bundling to One Folder ..................................................................................................................... 505
Section 107.4: Bundling to a Single File ................................................................................................................... 505
Chapter 108: Data Visualization with Python ............................................................................................. 506
Section 108.1: Seaborn .............................................................................................................................................. 506
Section 108.2: Matplotlib ........................................................................................................................................... 508
Section 108.3: Plotly ................................................................................................................................................... 509
Section 108.4: MayaVI ............................................................................................................................................... 511
Chapter 109: The Interpreter (Command Line Console) ....................................................................... 513
Section 109.1: Getting general help .......................................................................................................................... 513
Section 109.2: Referring to the last expression ...................................................................................................... 513
Section 109.3: Opening the Python console ............................................................................................................ 514
Section 109.4: The PYTHONSTARTUP variable ...................................................................................................... 514
Section 109.5: Command line arguments ............................................................................................................... 514
Section 109.6: Getting help about an object ........................................................................................................... 515
Chapter 110: *args and **kwargs ....................................................................................................................... 518
Section 110.1: Using **kwargs when writing functions ............................................................................................ 518
Section 110.2: Using *args when writing functions .................................................................................................. 518
Section 110.3: Populating kwarg values with a dictionary ..................................................................................... 519
Section 110.4: Keyword-only and Keyword-required arguments ........................................................................ 519
Section 110.5: Using **kwargs when calling functions ............................................................................................ 519
Section 110.6: **kwargs and default values ............................................................................................................. 519
Section 110.7: Using *args when calling functions .................................................................................................. 520
Chapter 111: Garbage Collection ........................................................................................................................ 521
Section 111.1: Reuse of primitive objects .................................................................................................................. 521
Section 111.2: Eects of the del command .............................................................................................................. 521
Section 111.3: Reference Counting ............................................................................................................................ 522Section 111.4: Garbage Collector for Reference Cycles ......................................................................................... 522
Section 111.5: Forcefully deallocating objects ......................................................................................................... 523
Section 111.6: Viewing the refcount of an object ..................................................................................................... 524
Section 111.7: Do not wait for the garbage collection to clean up ........................................................................ 524
Section 111.8: Managing garbage collection ........................................................................................................... 524
Chapter 112: Pickle data serialisation ............................................................................................................. 526
Section 112.1: Using Pickle to serialize and deserialize an object .......................................................................... 526
Section 112.2: Customize Pickled Data .................................................................................................................... 526
Chapter 113: Binary Data ...................................................................................................................................... 528
Section 113.1: Format a list of values into a byte object ........................................................................................ 528
Section 113.2: Unpack a byte object according to a format string ...................................................................... 528
Section 113.3: Packing a structure ............................................................................................................................ 528
Chapter 114: Idioms .................................................................................................................................................. 530
Section 114.1: Dictionary key initializations .............................................................................................................. 530
Section 114.2: Switching variables ............................................................................................................................ 530
Section 114.3: Use truth value testing ...................................................................................................................... 530
Section 114.4: Test for "__main__" to avoid unexpected code execution .......................................................... 531
Chapter 115: Data Serialization .......................................................................................................................... 533
Section 115.1: Serialization using JSON .................................................................................................................... 533
Section 115.2: Serialization using Pickle ................................................................................................................... 533
Chapter 116: Multiprocessing ............................................................................................................................... 535
Section 116.1: Running Two Simple Processes ......................................................................................................... 535
Section 116.2: Using Pool and Map ........................................................................................................................... 535
Chapter 117: Multithreading ................................................................................................................................. 537
Section 117.1: Basics of multithreading .................................................................................................................... 537
Section 117.2: Communicating between threads .................................................................................................... 538
Section 117.3: Creating a worker pool ...................................................................................................................... 539
Section 117.4: Advanced use of multithreads .......................................................................................................... 539
Section 117.5: Stoppable Thread with a while Loop ............................................................................................... 541
Chapter 118: Processes and Threads .............................................................................................................. 542
Section 118.1: Global Interpreter Lock ...................................................................................................................... 542
Section 118.2: Running in Multiple Threads ............................................................................................................. 543
Section 118.3: Running in Multiple Processes .......................................................................................................... 544
Section 118.4: Sharing State Between Threads ....................................................................................................... 544
Section 118.5: Sharing State Between Processes .................................................................................................... 545
Chapter 119: Python concurrency ..................................................................................................................... 546
Section 119.1: The multiprocessing module ............................................................................................................. 546
Section 119.2: The threading module ....................................................................................................................... 547
Section 119.3: Passing data between multiprocessing processes ........................................................................ 547
Chapter 120: Parallel computation .................................................................................................................. 550
Section 120.1: Using the multiprocessing module to parallelise tasks ................................................................. 550
Section 120.2: Using a C-extension to parallelize tasks ........................................................................................ 550
Section 120.3: Using Parent and Children scripts to execute code in parallel .................................................... 550
Section 120.4: Using PyPar module to parallelize .................................................................................................. 551
Chapter 121: Sockets ................................................................................................................................................ 552
Section 121.1: Raw Sockets on Linux ......................................................................................................................... 552
Section 121.2: Sending data via UDP ....................................................................................................................... 552
Section 121.3: Receiving data via UDP ..................................................................................................................... 553
Section 121.4: Sending data via TCP ........................................................................................................................ 553Section 121.5: Multi-threaded TCP Socket Server ................................................................................................... 553
Chapter 122: Websockets ...................................................................................................................................... 556
Section 122.1: Simple Echo with aiohttp ................................................................................................................... 556
Section 122.2: Wrapper Class with aiohttp ............................................................................................................. 556
Section 122.3: Using Autobahn as a Websocket Factory ...................................................................................... 557
Chapter 123: Sockets And Message Encryption/Decryption Between Client and Server
............................................................................................................................................................................................ 559
Section 123.1: Server side Implementation .............................................................................................................. 559
Section 123.2: Client side Implementation .............................................................................................................. 561
Chapter 124: Python Networking ..................................................................................................................... 563
Section 124.1: Creating a Simple Http Server .......................................................................................................... 563
Section 124.2: Creating a TCP server ...................................................................................................................... 563
Section 124.3: Creating a UDP Server ..................................................................................................................... 564
Section 124.4: Start Simple HttpServer in a thread and open the browser ......................................................... 564
Section 124.5: The simplest Python socket client-server example ....................................................................... 565
Chapter 125: Python HTTP Server .................................................................................................................... 567
Section 125.1: Running a simple HTTP server ......................................................................................................... 567
Section 125.2: Serving ﬁles ........................................................................................................................................ 567
Section 125.3: Basic handling of GET, POST, PUT using BaseHTTPRequestHandler ......................................... 568
Section 125.4: Programmatic API of SimpleHTTPServer ....................................................................................... 569
Chapter 126: Flask .................................................................................................................................................... 571
Section 126.1: Files and Templates ........................................................................................................................... 571
Section 126.2: The basics .......................................................................................................................................... 571
Section 126.3: Routing URLs ..................................................................................................................................... 572
Section 126.4: HTTP Methods ................................................................................................................................... 573
Section 126.5: Jinja Templating ............................................................................................................................... 573
Section 126.6: The Request Object .......................................................................................................................... 574
Chapter 127: Introduction to RabbitMQ using AMQPStorm ................................................................ 576
Section 127.1: How to consume messages from RabbitMQ .................................................................................. 576
Section 127.2: How to publish messages to RabbitMQ ......................................................................................... 577
Section 127.3: How to create a delayed queue in RabbitMQ ................................................................................ 577
Chapter 128: Descriptor ......................................................................................................................................... 580
Section 128.1: Simple descriptor ............................................................................................................................... 580
Section 128.2: Two-way conversions ....................................................................................................................... 581
Chapter 129: tempﬁle NamedTemporaryFile ............................................................................................. 582
Section 129.1: Create (and write to a) known, persistent temporary ﬁle ............................................................. 582
Chapter 130: Input, Subset and Output External Data Files using Pandas ................................. 584
Section 130.1: Basic Code to Import, Subset and Write External Data Files Using Pandas ............................... 584
Chapter 131: Unzipping Files ................................................................................................................................ 586
Section 131.1: Using Python ZipFile.extractall() to decompress a ZIP ﬁle ............................................................ 586
Section 131.2: Using Python TarFile.extractall() to decompress a tarball ........................................................... 586
Chapter 132: Working with ZIP archives ........................................................................................................ 587
Section 132.1: Examining Zipﬁle Contents ............................................................................................................... 587
Section 132.2: Opening Zip Files ............................................................................................................................... 587
Section 132.3: Extracting zip ﬁle contents to a directory ....................................................................................... 588
Section 132.4: Creating new archives ...................................................................................................................... 588
Chapter 133: Getting start with GZip .............................................................................................................. 589
Section 133.1: Read and write GNU zip ﬁles ............................................................................................................ 589Chapter 134: Stack ................................................................................................................................................... 590
Section 134.1: Creating a Stack class with a List Object ........................................................................................ 590
Section 134.2: Parsing Parentheses ......................................................................................................................... 591
Chapter 135: Working around the Global Interpreter Lock (GIL) ..................................................... 593
Section 135.1: Multiprocessing.Pool .......................................................................................................................... 593
Section 135.2: Cython nogil: ...................................................................................................................................... 594
Chapter 136: Deployment ..................................................................................................................................... 595
Section 136.1: Uploading a Conda Package ............................................................................................................ 595
Chapter 137: Logging .............................................................................................................................................. 597
Section 137.1: Introduction to Python Logging ........................................................................................................ 597
Section 137.2: Logging exceptions ........................................................................................................................... 598
Chapter 138: Web Server Gateway Interface (WSGI) ............................................................................. 601
Section 138.1: Server Object (Method) ..................................................................................................................... 601
Chapter 139: Python Server Sent Events ...................................................................................................... 602
Section 139.1: Flask SSE ............................................................................................................................................. 602
Section 139.2: Asyncio SSE ........................................................................................................................................ 602
Chapter 140: Alternatives to switch statement from other languages ....................................... 604
Section 140.1: Use what the language oers: the if/else construct ..................................................................... 604
Section 140.2: Use a dict of functions ...................................................................................................................... 604
Section 140.3: Use class introspection ..................................................................................................................... 605
Section 140.4: Using a context manager ................................................................................................................ 606
Chapter 141: List destructuring (aka packing and unpacking) ......................................................... 607
Section 141.1: Destructuring assignment ................................................................................................................. 607
Section 141.2: Packing function arguments ............................................................................................................ 608
Section 141.3: Unpacking function arguments ........................................................................................................ 610
Chapter 142: Accessing Python source code and bytecode .............................................................. 611
Section 142.1: Display the bytecode of a function .................................................................................................. 611
Section 142.2: Display the source code of an object ............................................................................................. 611
Section 142.3: Exploring the code object of a function .......................................................................................... 612
Chapter 143: Mixins .................................................................................................................................................. 613
Section 143.1: Mixin ..................................................................................................................................................... 613
Section 143.2: Overriding Methods in Mixins ........................................................................................................... 614
Chapter 144: Attribute Access ........................................................................................................................... 615
Section 144.1: Basic Attribute Access using the Dot Notation ............................................................................... 615
Section 144.2: Setters, Getters & Properties ............................................................................................................ 615
Chapter 145: ArcPy .................................................................................................................................................. 618
Section 145.1: createDissolvedGDB to create a ﬁle gdb on the workspace ........................................................ 618
Section 145.2: Printing one ﬁeld's value for all rows of feature class in ﬁle geodatabase using Search
Cursor ................................................................................................................................................................. 618
Chapter 146: Abstract Base Classes (abc) ................................................................................................... 619
Section 146.1: Setting the ABCMeta metaclass ....................................................................................................... 619
Section 146.2: Why/How to use ABCMeta and @abstractmethod ...................................................................... 619
Chapter 147: Plugin and Extension Classes ................................................................................................. 621
Section 147.1: Mixins ................................................................................................................................................... 621
Section 147.2: Plugins with Customized Classes ..................................................................................................... 622
Chapter 148: Immutable datatypes(int, ﬂoat, str, tuple and frozensets) .................................. 624
Section 148.1: Individual characters of strings are not assignable ....................................................................... 624
Section 148.2: Tuple's individual members aren't assignable ............................................................................... 624Section 148.3: Frozenset's are immutable and not assignable ............................................................................. 624
Chapter 149: Incompatibilities moving from Python 2 to Python 3 ................................................ 625
Section 149.1: Integer Division ................................................................................................................................... 625
Section 149.2: Unpacking Iterables .......................................................................................................................... 626
Section 149.3: Strings: Bytes versus Unicode .......................................................................................................... 628
Section 149.4: Print statement vs. Print function .................................................................................................... 630
Section 149.5: Dierences between range and xrange functions ........................................................................ 631
Section 149.6: Raising and handling Exceptions ..................................................................................................... 632
Section 149.7: Leaked variables in list comprehension .......................................................................................... 634
Section 149.8: True, False and None ........................................................................................................................ 635
Section 149.9: User Input ........................................................................................................................................... 635
Section 149.10: Comparison of dierent types ....................................................................................................... 636
Section 149.11: .next() method on iterators renamed ............................................................................................. 636
Section 149.12: ﬁlter(), map() and zip() return iterators instead of sequences ................................................... 637
Section 149.13: Renamed modules ........................................................................................................................... 637
Section 149.14: Removed operators <> and ``, synonymous with != and repr() ................................................... 638
Section 149.15: long vs. int ......................................................................................................................................... 638
Section 149.16: All classes are "new-style classes" in Python 3 ............................................................................ 639
Section 149.17: Reduce is no longer a built-in ......................................................................................................... 640
Section 149.18: Absolute/Relative Imports .............................................................................................................. 640
Section 149.19: map() ................................................................................................................................................ 642
Section 149.20: The round() function tie-breaking and return type .................................................................... 643
Section 149.21: File I/O .............................................................................................................................................. 644
Section 149.22: cmp function removed in Python 3 ............................................................................................... 644
Section 149.23: Octal Constants ............................................................................................................................... 645
Section 149.24: Return value when writing to a ﬁle object .................................................................................... 645
Section 149.25: exec statement is a function in Python 3 ...................................................................................... 645
Section 149.26: encode/decode to hex no longer available ................................................................................. 646
Section 149.27: Dictionary method changes .......................................................................................................... 647
Section 149.28: Class Boolean Value ....................................................................................................................... 647
Section 149.29: hasattr function bug in Python 2 ................................................................................................... 648
Chapter 150: 2to3 tool ............................................................................................................................................ 650
Section 150.1: Basic Usage ........................................................................................................................................ 650
Chapter 151: Non-ocial Python implementations ................................................................................ 652
Section 151.1: IronPython ........................................................................................................................................... 652
Section 151.2: Jython ................................................................................................................................................. 652
Section 151.3: Transcrypt .......................................................................................................................................... 653
Chapter 152: Abstract syntax tree ................................................................................................................... 656
Section 152.1: Analyze functions in a python script ................................................................................................ 656
Chapter 153: Unicode and bytes ....................................................................................................................... 658
Section 153.1: Encoding/decoding error handling .................................................................................................. 658
Section 153.2: File I/O ................................................................................................................................................ 658
Section 153.3: Basics .................................................................................................................................................. 659
Chapter 154: Python Serial Communication (pyserial) ......................................................................... 661
Section 154.1: Initialize serial device ......................................................................................................................... 661
Section 154.2: Read from serial port ....................................................................................................................... 661
Section 154.3: Check what serial ports are available on your machine .............................................................. 661
Chapter 155: Neo4j and Cypher using Py2Neo ......................................................................................... 664
Section 155.1: Adding Nodes to Neo4j Graph .......................................................................................................... 664Section 155.2: Importing and Authenticating .......................................................................................................... 664
Section 155.3: Adding Relationships to Neo4j Graph ............................................................................................. 664
Section 155.4: Query 1 : Autocomplete on News Titles .......................................................................................... 664
Section 155.5: Query 2 : Get News Articles by Location on a particular date ..................................................... 665
Section 155.6: Cypher Query Samples .................................................................................................................... 665
Chapter 156: Basic Curses with Python .......................................................................................................... 666
Section 156.1: The wrapper() helper function ......................................................................................................... 666
Section 156.2: Basic Invocation Example ................................................................................................................ 666
Chapter 157: Templates in python ................................................................................................................... 667
Section 157.1: Simple data output program using template ................................................................................. 667
Section 157.2: Changing delimiter ............................................................................................................................ 667
Chapter 158: Pillow ................................................................................................................................................... 668
Section 158.1: Read Image File ................................................................................................................................. 668
Section 158.2: Convert ﬁles to JPEG ........................................................................................................................ 668
Chapter 159: The pass statement .................................................................................................................... 669
Section 159.1: Ignore an exception ........................................................................................................................... 669
Section 159.2: Create a new Exception that can be caught .................................................................................. 669
Chapter 160: CLI subcommands with precise help output .................................................................. 671
Section 160.1: Native way (no libraries) ................................................................................................................... 671
Section 160.2: argparse (default help formatter) .................................................................................................. 671
Section 160.3: argparse (custom help formatter) .................................................................................................. 672
Chapter 161: Database Access ............................................................................................................................ 674
Section 161.1: SQLite ................................................................................................................................................... 674
Section 161.2: Accessing MySQL database using MySQLdb ................................................................................. 679
Section 161.3: Connection .......................................................................................................................................... 680
Section 161.4: PostgreSQL Database access using psycopg2 .............................................................................. 681
Section 161.5: Oracle database ................................................................................................................................ 682
Section 161.6: Using sqlalchemy ............................................................................................................................... 684
Chapter 162: Connecting Python to SQL Server ....................................................................................... 685
Section 162.1: Connect to Server, Create Table, Query Data ................................................................................ 685
Chapter 163: PostgreSQL ...................................................................................................................................... 686
Section 163.1: Getting Started ................................................................................................................................... 686
Chapter 164: Python and Excel .......................................................................................................................... 687
Section 164.1: Read the excel data using xlrd module ........................................................................................... 687
Section 164.2: Format Excel ﬁles with xlsxwriter ..................................................................................................... 687
Section 164.3: Put list data into a Excel's ﬁle ........................................................................................................... 688
Section 164.4: OpenPyXL .......................................................................................................................................... 689
Section 164.5: Create excel charts with xlsxwriter .................................................................................................. 689
Chapter 165: Turtle Graphics .............................................................................................................................. 693
Section 165.1: Ninja Twist (Turtle Graphics) ............................................................................................................ 693
Chapter 166: Python Persistence ...................................................................................................................... 694
Section 166.1: Python Persistence ............................................................................................................................ 694
Section 166.2: Function utility for save and load .................................................................................................... 695
Chapter 167: Design Patterns ............................................................................................................................. 696
Section 167.1: Introduction to design patterns and Singleton Pattern ................................................................. 696
Section 167.2: Strategy Pattern ................................................................................................................................ 698
Section 167.3: Proxy ................................................................................................................................................... 699
Chapter 168: hashlib ................................................................................................................................................ 701Section 168.1: MD5 hash of a string ......................................................................................................................... 701
Section 168.2: algorithm provided by OpenSSL ..................................................................................................... 702
Chapter 169: Creating a Windows service using Python ....................................................................... 703
Section 169.1: A Python script that can be run as a service .................................................................................. 703
Section 169.2: Running a Flask web application as a service ............................................................................... 704
Chapter 170: Mutable vs Immutable (and Hashable) in Python ....................................................... 706
Section 170.1: Mutable vs Immutable ....................................................................................................................... 706
Section 170.2: Mutable and Immutable as Arguments .......................................................................................... 708
Chapter 171: conﬁgparser .................................................................................................................................... 710
Section 171.1: Creating conﬁguration ﬁle programmatically ................................................................................. 710
Section 171.2: Basic usage ......................................................................................................................................... 710
Chapter 172: Optical Character Recognition .............................................................................................. 711
Section 172.1: PyTesseract ........................................................................................................................................ 711
Section 172.2: PyOCR ................................................................................................................................................ 711
Chapter 173: Virtual environments .................................................................................................................. 713
Section 173.1: Creating and using a virtual environment ....................................................................................... 713
Section 173.2: Specifying speciﬁc python version to use in script on Unix/Linux ............................................... 715
Section 173.3: Creating a virtual environment for a dierent version of python ............................................... 715
Section 173.4: Making virtual environments using Anaconda .............................................................................. 715
Section 173.5: Managing multiple virtual environments with virtualenvwrapper ............................................... 716
Section 173.6: Installing packages in a virtual environment ................................................................................. 717
Section 173.7: Discovering which virtual environment you are using .................................................................. 718
Section 173.8: Checking if running inside a virtual environment .......................................................................... 719
Section 173.9: Using virtualenv with ﬁsh shell ......................................................................................................... 719
Chapter 174: Python Virtual Environment - virtualenv ......................................................................... 721
Section 174.1: Installation .......................................................................................................................................... 721
Section 174.2: Usage ................................................................................................................................................. 721
Section 174.3: Install a package in your Virtualenv ............................................................................................... 721
Section 174.4: Other useful virtualenv commands ................................................................................................. 722
Chapter 175: Virtual environment with virtualenvwrapper ................................................................ 724
Section 175.1: Create virtual environment with virtualenvwrapper ...................................................................... 724
Chapter 176: Create virtual environment with virtualenvwrapper in windows ........................ 726
Section 176.1: Virtual environment with virtualenvwrapper for windows ............................................................. 726
Chapter 177: sys ........................................................................................................................................................ 727
Section 177.1: Command line arguments ................................................................................................................ 727
Section 177.2: Script name ........................................................................................................................................ 727
Section 177.3: Standard error stream ...................................................................................................................... 727
Section 177.4: Ending the process prematurely and returning an exit code ....................................................... 727
Chapter 178: ChemPy - python package ...................................................................................................... 728
Section 178.1: Parsing formulae ............................................................................................................................... 728
Section 178.2: Balancing stoichiometry of a chemical reaction ........................................................................... 728
Section 178.3: Balancing reactions .......................................................................................................................... 728
Section 178.4: Chemical equilibria ............................................................................................................................ 729
Section 178.5: Ionic strength ..................................................................................................................................... 729
Section 178.6: Chemical kinetics (system of ordinary dierential equations) .................................................... 729
Chapter 179: pygame .............................................................................................................................................. 731
Section 179.1: Pygame's mixer module .................................................................................................................... 731
Section 179.2: Installing pygame .............................................................................................................................. 732Chapter 180: Pyglet ................................................................................................................................................. 734
Section 180.1: Installation of Pyglet .......................................................................................................................... 734
Section 180.2: Hello World in Pyglet ........................................................................................................................ 734
Section 180.3: Playing Sound in Pyglet .................................................................................................................... 734
Section 180.4: Using Pyglet for OpenGL ................................................................................................................. 734
Section 180.5: Drawing Points Using Pyglet and OpenGL ..................................................................................... 734
Chapter 181: Audio .................................................................................................................................................... 736
Section 181.1: Working with WAV ﬁles ...................................................................................................................... 736
Section 181.2: Convert any soundﬁle with python and mpeg ............................................................................ 736
Section 181.3: Playing Windows' beeps .................................................................................................................... 736
Section 181.4: Audio With Pyglet .............................................................................................................................. 737
Chapter 182: pyaudio .............................................................................................................................................. 738
Section 182.1: Callback Mode Audio I/O .................................................................................................................. 738
Section 182.2: Blocking Mode Audio I/O ................................................................................................................. 739
Chapter 183: shelve .................................................................................................................................................. 741
Section 183.1: Creating a new Shelf .......................................................................................................................... 741
Section 183.2: Sample code for shelve .................................................................................................................... 742
Section 183.3: To summarize the interface (key is a string, data is an arbitrary object): .................................. 742
Section 183.4: Write-back ......................................................................................................................................... 742
Chapter 184: IoT Programming with Python and Raspberry PI ....................................................... 744
Section 184.1: Example - Temperature sensor ........................................................................................................ 744
Chapter 185: kivy - Cross-platform Python Framework for NUI Development ....................... 748
Section 185.1: First App .............................................................................................................................................. 748
Chapter 186: Pandas Transform: Preform operations on groups and concatenate the
results ............................................................................................................................................................................. 750
Section 186.1: Simple transform ............................................................................................................................... 750
Section 186.2: Multiple results per group ................................................................................................................ 751
Chapter 187: Similarities in syntax, Dierences in meaning: Python vs. JavaScript ............. 752
Section 187.1: `in` with lists ......................................................................................................................................... 752
Chapter 188: Call Python from C# ................................................................................................................... 753
Section 188.1: Python script to be called by C# application .................................................................................. 753
Section 188.2: C# code calling Python script .......................................................................................................... 753
Chapter 189: ctypes ................................................................................................................................................. 755
Section 189.1: ctypes arrays ..................................................................................................................................... 755
Section 189.2: Wrapping functions for ctypes ........................................................................................................ 755
Section 189.3: Basic usage ........................................................................................................................................ 756
Section 189.4: Common pitfalls ................................................................................................................................ 756
Section 189.5: Basic ctypes object ........................................................................................................................... 757
Section 189.6: Complex usage .................................................................................................................................. 758
Chapter 190: Writing extensions ........................................................................................................................ 760
Section 190.1: Hello World with C Extension ............................................................................................................ 760
Section 190.2: C Extension Using c++ and Boost .................................................................................................... 760
Section 190.3: Passing an open ﬁle to C Extensions .............................................................................................. 762
Chapter 191: Python Lex-Yacc ............................................................................................................................. 763
Section 191.1: Getting Started with PLY .................................................................................................................... 763
Section 191.2: The "Hello, World!" of PLY - A Simple Calculator ............................................................................ 763
Section 191.3: Part 1: Tokenizing Input with Lex ....................................................................................................... 765
Section 191.4: Part 2: Parsing Tokenized Input with Yacc ...................................................................................... 768Chapter 192: Unit Testing ...................................................................................................................................... 772
Section 192.1: Test Setup and Teardown within a unittest.TestCase .................................................................... 772
Section 192.2: Asserting on Exceptions ................................................................................................................... 772
Section 192.3: Testing Exceptions ............................................................................................................................ 773
Section 192.4: Choosing Assertions Within Unittests ............................................................................................. 774
Section 192.5: Unit tests with pytest ........................................................................................................................ 775
Section 192.6: Mocking functions with unittest.mock.create_autospec ............................................................... 778
Chapter 193: py.test ................................................................................................................................................. 780
Section 193.1: Setting up py.test ............................................................................................................................... 780
Section 193.2: Intro to Test Fixtures ......................................................................................................................... 780
Section 193.3: Failing Tests ....................................................................................................................................... 783
Chapter 194: Proﬁling ............................................................................................................................................. 785
Section 194.1: %%timeit and %timeit in IPython ...................................................................................................... 785
Section 194.2: Using cProﬁle (Preferred Proﬁler) ................................................................................................... 785
Section 194.3: timeit() function ................................................................................................................................. 785
Section 194.4: timeit command line ......................................................................................................................... 786
Section 194.5: line_proﬁler in command line .......................................................................................................... 786
Chapter 195: Python speed of program ....................................................................................................... 788
Section 195.1: Deque operations .............................................................................................................................. 788
Section 195.2: Algorithmic Notations ....................................................................................................................... 788
Section 195.3: Notation .............................................................................................................................................. 789
Section 195.4: List operations ................................................................................................................................... 790
Section 195.5: Set operations ................................................................................................................................... 790
Chapter 196: Performance optimization ....................................................................................................... 792
Section 196.1: Code proﬁling ..................................................................................................................................... 792
Chapter 197: Security and Cryptography .................................................................................................... 794
Section 197.1: Secure Password Hashing ................................................................................................................. 794
Section 197.2: Calculating a Message Digest ......................................................................................................... 794
Section 197.3: Available Hashing Algorithms .......................................................................................................... 794
Section 197.4: File Hashing ....................................................................................................................................... 795
Section 197.5: Generating RSA signatures using pycrypto ................................................................................... 795
Section 197.6: Asymmetric RSA encryption using pycrypto ................................................................................. 796
Section 197.7: Symmetric encryption using pycrypto ............................................................................................ 797
Chapter 198: Secure Shell Connection in Python ...................................................................................... 798
Section 198.1: ssh connection ................................................................................................................................... 798
Chapter 199: Python Anti-Patterns .................................................................................................................. 799
Section 199.1: Overzealous except clause ............................................................................................................... 799
Section 199.2: Looking before you leap with processor-intensive function ........................................................ 799
Chapter 200: Common Pitfalls ........................................................................................................................... 802
Section 200.1: List multiplication and common references .................................................................................. 802
Section 200.2: Mutable default argument .............................................................................................................. 805
Section 200.3: Changing the sequence you are iterating over ............................................................................ 806
Section 200.4: Integer and String identity .............................................................................................................. 809
Section 200.5: Dictionaries are unordered ............................................................................................................. 810
Section 200.6: Variable leaking in list comprehensions and for loops ................................................................ 811
Section 200.7: Chaining of or operator ................................................................................................................... 811
Section 200.8: sys.argv[0] is the name of the ﬁle being executed ...................................................................... 812
Section 200.9: Accessing int literals' attributes ...................................................................................................... 812
Section 200.10: Global Interpreter Lock (GIL) and blocking threads ................................................................... 813Section 200.11: Multiple return .................................................................................................................................. 814
Section 200.12: Pythonic JSON keys ....................................................................................................................... 814
Chapter 201: Hidden Features ............................................................................................................................ 816
Section 201.1: Operator Overloading ....................................................................................................................... 816
Credits ............................................................................................................................................................................ 817
You may also like ...................................................................................................................................................... 831About
Please feel free to share this PDF with anyone for free,
latest version of this book can be downloaded from:
https://GoalKicker.com/PythonBook
This Python® Notes for Professionals book is compiled from Stack Overﬂow
Documentation, the content is written by the beautiful people at Stack Overﬂow.
Text content is released under Creative Commons BY-SA, see credits at the end
of this book whom contributed to the various chapters. Images may be copyright
of their respective owners unless otherwise speciﬁed
This is an unoﬃcial free book created for educational purposes and is not
aﬃliated with oﬃcial Python® group(s) or company(s) nor Stack Overﬂow. All
trademarks and registered trademarks are the property of their respective
company owners
The information presented in this book is not guaranteed to be correct nor
accurate, use at your own risk
Please send feedback and corrections to web@petercv.com
GoalKicker.com – Python® Notes for Professionals
1Chapter 1: Getting started with Python
Language
Python 3.x
Version Release Date
3.8
2020-04-29
3.72018-06-27
3.62016-12-23
3.52015-09-13
3.42014-03-17
3.32012-09-29
3.22011-02-20
3.12009-06-26
3.02008-12-03
Python 2.x
Version Release Date
2.7
2010-07-03
2.62008-10-02
2.52006-09-19
2.42004-11-30
2.32003-07-29
2.22001-12-21
2.12001-04-15
2.02000-10-16
Section 1.1: Getting Started
Python is a widely used high-level programming language for general-purpose programming, created by Guido van
Rossum and ﬁrst released in 1991. Python features a dynamic type system and automatic memory management
and supports multiple programming paradigms, including object-oriented, imperative, functional programming,
and procedural styles. It has a large and comprehensive standard library.
Two major versions of Python are currently in active use:
Python 3.x is the current version and is under active development.
Python 2.x is the legacy version and will receive only security updates until 2020. No new features will be
implemented. Note that many projects still use Python 2, although migrating to Python 3 is getting easier.
You can download and install either version of Python here. See Python 3 vs. Python 2 for a comparison between
them. In addition, some third-parties oﬀer re-packaged versions of Python that add commonly used libraries and
other features to ease setup for common use cases, such as math, data analysis or scientiﬁc use. See the list at the
oﬃcial site.
Verify if Python is installed
To conﬁrm that Python was installed correctly, you can verify that by running the following command in your
favorite terminal (If you are using Windows OS, you need to add path of python to the environment variable before
using it in command prompt):
GoalKicker.com – Python® Notes for Professionals
2$ python --version
Python 3.x Version ≥ 3.0
If you have Python 3 installed, and it is your default version (see Troubleshooting for more details) you should see
something like this:
$ python --version
Python 3.6.0
Python 2.x Version ≤ 2.7
If you have Python 2 installed, and it is your default version (see Troubleshooting for more details) you should see
something like this:
$ python --version
Python 2.7.13
If you have installed Python 3, but $ python --version outputs a Python 2 version, you also have Python 2
installed. This is often the case on MacOS, and many Linux distributions. Use $ python3 instead to explicitly use the
Python 3 interpreter.
Hello, World in Python using IDLE
IDLE is a simple editor for Python, that comes bundled with Python.
How to create Hello, World program in IDLE
Open IDLE on your system of choice.
In older versions of Windows, it can be found at All Programs under the Windows menu.
In Windows 8+, search for IDLE or ﬁnd it in the apps that are present in your system.
On Unix-based (including Mac) systems you can open it from the shell by typing $ idle
python_file.py.
It will open a shell with options along the top.
In the shell, there is a prompt of three right angle brackets:
>>>
Now write the following code in the prompt:
>>> print("Hello, World")
Hit Enter .
>>> print("Hello, World")
Hello, World
Hello World Python ﬁle
Create a new ﬁle hello.py that contains the following line:
Python 3.x Version ≥ 3.0
print('Hello, World')
Python 2.x Version ≥ 2.6
GoalKicker.com – Python® Notes for Professionals
3You can use the Python 3 print function in Python 2 with the following import statement:
from __future__ import print_function
Python 2 has a number of functionalities that can be optionally imported from Python 3 using the __future__
module, as discussed here.
Python 2.x Version ≤ 2.7
If using Python 2, you may also type the line below. Note that this is not valid in Python 3 and thus not
recommended because it reduces cross-version code compatibility.
print 'Hello, World'
In your terminal, navigate to the directory containing the ﬁle hello.py.
Type python hello.py, then hit the Enter key.
$ python hello.py
Hello, World
You should see Hello, World printed to the console.
You can also substitute hello.py with the path to your ﬁle. For example, if you have the ﬁle in your home directory
and your user is "user" on Linux, you can type python /home/user/hello.py.
Launch an interactive Python shell
By executing (running) the python command in your terminal, you are presented with an interactive Python shell.
This is also known as the Python Interpreter or a REPL (for 'Read Evaluate Print Loop').
$ python
Python 2.7.12 (default, Jun 28 2016, 08:46:01)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'Hello, World'
Hello, World
>>>
If you want to run Python 3 from your terminal, execute the command python3.
$ python3
Python 3.6.0 (default, Jan 13 2017, 00:00:00)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('Hello, World')
Hello, World
>>>
Alternatively, start the interactive prompt and load ﬁle with python -i <file.py>.
In command line, run:
$ python -i hello.py
"Hello World"
>>>
GoalKicker.com – Python® Notes for Professionals
4There are multiple ways to close the Python shell:
>>> exit()
or
>>> quit()
Alternatively, CTRL + D will close the shell and put you back on your terminal's command line.
If you want to cancel a command you're in the middle of typing and get back to a clean command prompt, while
staying inside the Interpreter shell, use CTRL + C .
Try an interactive Python shell online.
Other Online Shells
Various websites provide online access to Python shells.
Online shells may be useful for the following purposes:
Run a small code snippet from a machine which lacks python installation(smartphones, tablets etc).
Learn or teach basic Python.
Solve online judge problems.
Examples:
Disclaimer: documentation author(s) are not aﬃliated with any resources listed below.
https://www.python.org/shell/ - The online Python shell hosted by the oﬃcial Python website.
https://ideone.com/ - Widely used on the Net to illustrate code snippet behavior.
https://repl.it/languages/python3 - Powerful and simple online compiler, IDE and interpreter. Code, compile,
and run code in Python.
https://www.tutorialspoint.com/execute_python_online.php - Full-featured UNIX shell, and a user-friendly
project explorer.
http://rextester.com/l/python3_online_compiler - Simple and easy to use IDE which shows execution time
Run commands as a string
Python can be passed arbitrary code as a string in the shell:
$ python -c 'print("Hello, World")'
Hello, World
This can be useful when concatenating the results of scripts together in the shell.
Shells and Beyond
Package Management - The PyPA recommended tool for installing Python packages is PIP. To install, on your
command line execute pip install <the package name>. For instance, pip install numpy. (Note: On windows
you must add pip to your PATH environment variables. To avoid this, use python -m pip install <the package
name>)
Shells - So far, we have discussed diﬀerent ways to run code using Python's native interactive shell. Shells use
GoalKicker.com – Python® Notes for Professionals
5Python's interpretive power for experimenting with code real-time. Alternative shells include IDLE - a pre-bundled
GUI, IPython - known for extending the interactive experience, etc.
Programs - For long-term storage you can save content to .py ﬁles and edit/execute them as scripts or programs
with external tools e.g. shell, IDEs (such as PyCharm), Jupyter notebooks, etc. Intermediate users may use these
tools; however, the methods discussed here are suﬃcient for getting started.
Python tutor allows you to step through Python code so you can visualize how the program will ﬂow, and helps you
to understand where your program went wrong.
PEP8 deﬁnes guidelines for formatting Python code. Formatting code well is important so you can quickly read what
the code does.
Section 1.2: Creating variables and assigning values
To create a variable in Python, all you need to do is specify the variable name, and then assign a value to it.
<variable name> = <value>
Python uses = to assign values to variables. There's no need to declare a variable in advance (or to assign a data
type to it), assigning a value to a variable itself declares and initializes the variable with that value. There's no way to
declare a variable without assigning it an initial value.
# Integer
a = 2
print(a)
# Output: 2
# Integer
b = 9223372036854775807
print(b)
# Output: 9223372036854775807
# Floating point
pi = 3.14
print(pi)
# Output: 3.14
# String
c = 'A'
print(c)
# Output: A
# String
name = 'John Doe'
print(name)
# Output: John Doe
# Boolean
q = True
print(q)
# Output: True
# Empty value or null data type
x = None
print(x)
# Output: None
GoalKicker.com – Python® Notes for Professionals
6Variable assignment works from left to right. So the following will give you an syntax error.
0 = x
=> Output: SyntaxError: can't assign to literal
You can not use python's keywords as a valid variable name. You can see the list of keyword by:
import keyword
print(keyword.kwlist)
Rules for variable naming:
1. Variables names must start with a letter or an underscore.
x = True
_y = True
# valid
# valid
9x = False # starts with numeral
=> SyntaxError: invalid syntax
$y = False # starts with symbol
=> SyntaxError: invalid syntax
2. The remainder of your variable name may consist of letters, numbers and underscores.
has_0_in_it = "Still Valid"
3. Names are case sensitive.
x = 9
y = X*5
=>NameError: name 'X' is not defined
Even though there's no need to specify a data type when declaring a variable in Python, while allocating the
necessary area in memory for the variable, the Python interpreter automatically picks the most suitable built-in
type for it:
a = 2
print(type(a))
# Output: <type 'int'>
b = 9223372036854775807
print(type(b))
# Output: <type 'int'>
pi = 3.14
print(type(pi))
# Output: <type 'float'>
c = 'A'
print(type(c))
# Output: <type 'str'>
name = 'John Doe'
print(type(name))
# Output: <type 'str'>
q = True
print(type(q))
GoalKicker.com – Python® Notes for Professionals
7# Output: <type 'bool'>
x = None
print(type(x))
# Output: <type 'NoneType'>
Now you know the basics of assignment, let's get this subtlety about assignment in python out of the way.
When you use = to do an assignment operation, what's on the left of = is a name for the object on the right. Finally,
what = does is assign the reference of the object on the right to the name on the left.
That is:
a_name = an_object
# "a_name" is now a name for the reference to the object "an_object"
So, from many assignment examples above, if we pick pi = 3.14, then pi is a name (not the name, since an object
can have multiple names) for the object 3.14. If you don't understand something below, come back to this point
and read this again! Also, you can take a look at this for a better understanding.
You can assign multiple values to multiple variables in one line. Note that there must be the same number of
arguments on the right and left sides of the = operator:
a, b, c = 1, 2, 3
print(a, b, c)
# Output: 1 2 3
a, b, c = 1, 2
=> Traceback (most recent call last):
=>
File "name.py", line N, in <module>
=>
a, b, c = 1, 2
=> ValueError: need more than 2 values to unpack
a, b = 1, 2, 3
=> Traceback (most recent call last):
=>
File "name.py", line N, in <module>
=>
a, b = 1, 2, 3
=> ValueError: too many values to unpack
The error in last example can be obviated by assigning remaining values to equal number of arbitrary variables.
This dummy variable can have any name, but it is conventional to use the underscore (_) for assigning unwanted
values:
a, b, _ = 1, 2, 3
print(a, b)
# Output: 1, 2
Note that the number of _ and number of remaining values must be equal. Otherwise 'too many values to unpack
error' is thrown as above:
a, b, _ = 1,2,3,4
=>Traceback (most recent call last):
=>File "name.py", line N, in <module>
=>a, b, _ = 1,2,3,4
=>ValueError: too many values to unpack (expected 3)
You can also assign a single value to several variables simultaneously.
GoalKicker.com – Python® Notes for Professionals
8a = b = c = 1
print(a, b, c)
# Output: 1 1 1
When using such cascading assignment, it is important to note that all three variables a, b and c refer to the same
object in memory, an int object with the value of 1. In other words, a, b and c are three diﬀerent names given to the
same int object. Assigning a diﬀerent object to one of them afterwards doesn't change the others, just as expected:
a = b = c = 1
print(a, b, c)
# Output: 1 1 1
b = 2
print(a, b, c)
# Output: 1 2 1
# all three names a, b and c refer to same int object with value 1
# b now refers to another int object, one with a value of 2
# so output is as expected.
The above is also true for mutable types (like list, dict, etc.) just as it is true for immutable types (like int, string,
tuple, etc.):
x = y = [7, 8, 9]
# x and y refer to the same list object just created, [7, 8, 9]
x = [13, 8, 9]
# x now refers to a different list object just created, [13, 8, 9]
print(y)
# y still refers to the list it was first assigned
# Output: [7, 8, 9]
So far so good. Things are a bit diﬀerent when it comes to modifying the object (in contrast to assigning the name to
a diﬀerent object, which we did above) when the cascading assignment is used for mutable types. Take a look
below, and you will see it ﬁrst hand:
x = y = [7, 8, 9]
8, 9]
x[0] = 13
in this case
print(y)
# Output: [13, 8, 9]
# x and y are two different names for the same list object just created, [7,
# we are updating the value of the list [7, 8, 9] through one of its names, x
# printing the value of the list using its other name
# hence, naturally the change is reflected
Nested lists are also valid in python. This means that a list can contain another list as an element.
x = [1, 2, [3, 4, 5], 6, 7] # this is nested list
print x[2]
# Output: [3, 4, 5]
print x[2][1]
# Output: 4
Lastly, variables in Python do not have to stay the same type as which they were ﬁrst deﬁned -- you can simply use
= to assign a new value to a variable, even if that value is of a diﬀerent type.
a = 2
print(a)
# Output: 2
a = "New value"
print(a)
# Output: New value
If this bothers you, think about the fact that what's on the left of = is just a name for an object. First you call the int
object with value 2 a, then you change your mind and decide to give the name a to a string object, having value
'New value'. Simple, right?
GoalKicker.com – Python® Notes for Professionals
9Section 1.3: Block Indentation
Python uses indentation to deﬁne control and loop constructs. This contributes to Python's readability, however, it
requires the programmer to pay close attention to the use of whitespace. Thus, editor miscalibration could result in
code that behaves in unexpected ways.
Python uses the colon symbol (:) and indentation for showing where blocks of code begin and end (If you come
from another language, do not confuse this with somehow being related to the ternary operator). That is, blocks in
Python, such as functions, loops, if clauses and other constructs, have no ending identiﬁers. All blocks start with a
colon and then contain the indented lines below it.
For example:
def my_function():
a = 2
return a
print(my_function())
# This is a function definition. Note the colon (:)
# This line belongs to the function because it's indented
# This line also belongs to the same function
# This line is OUTSIDE the function block
or
if a > b:
print(a)
else:
print(b)
# If block starts here
# This is part of the if block
# else must be at the same level as if
# This line is part of the else block
Blocks that contain exactly one single-line statement may be put on the same line, though this form is generally not
considered good style:
if a > b: print(a)
else: print(b)
Attempting to do this with more than a single statement will not work:
if x > y: y = x
print(y) # IndentationError: unexpected indent
if x > y: while y != z: y -= 1
# SyntaxError: invalid syntax
An empty block causes an IndentationError. Use pass (a command that does nothing) when you have a block with
no content:
def will_be_implemented_later():
pass
Spaces vs. Tabs
In short: always use 4 spaces for indentation.
Using tabs exclusively is possible but PEP 8, the style guide for Python code, states that spaces are preferred.
Python 3.x Version ≥ 3.0
Python 3 disallows mixing the use of tabs and spaces for indentation. In such case a compile-time error is
generated: Inconsistent use of tabs and spaces in indentation and the program will not run.
Python 2.x Version ≤ 2.7
GoalKicker.com – Python® Notes for Professionals
10Python 2 allows mixing tabs and spaces in indentation; this is strongly discouraged. The tab character completes
the previous indentation to be a multiple of 8 spaces. Since it is common that editors are conﬁgured to show tabs
as multiple of 4 spaces, this can cause subtle bugs.
Citing PEP 8:
When invoking the Python 2 command line interpreter with the -t option, it issues warnings about code
that illegally mixes tabs and spaces. When using -tt these warnings become errors. These options are
highly recommended!
Many editors have "tabs to spaces" conﬁguration. When conﬁguring the editor, one should diﬀerentiate between
the tab character ('\t') and the Tab key.
The tab character should be conﬁgured to show 8 spaces, to match the language semantics - at least in cases
when (accidental) mixed indentation is possible. Editors can also automatically convert the tab character to
spaces.
However, it might be helpful to conﬁgure the editor so that pressing the Tab key will insert 4 spaces,
instead of inserting a tab character.
Python source code written with a mix of tabs and spaces, or with non-standard number of indentation spaces can
be made pep8-conformant using autopep8. (A less powerful alternative comes with most Python installations:
reindent.py)
Section 1.4: Datatypes
Built-in Types
Booleans
bool: A boolean value of either True or False. Logical operations like and, or, not can be performed on booleans.
x or y
x and y
not x
# if x is False then y otherwise x
# if x is False then x otherwise y
# if x is True then False, otherwise True
In Python 2.x and in Python 3.x, a boolean is also an int. The bool type is a subclass of the int type and True and
False are its only instances:
issubclass(bool, int) # True
isinstance(True, bool) # True
isinstance(False, bool) # True
If boolean values are used in arithmetic operations, their integer values (1 and 0 for True and False) will be used to
return an integer result:
True + False == 1 # 1 + 0 == 1
True * True == 1 # 1 * 1 == 1
Numbers
int: Integer number
GoalKicker.com – Python® Notes for Professionals
11a = 2
b = 100
c = 123456789
d = 38563846326424324
Integers in Python are of arbitrary sizes.
Note: in older versions of Python, a long type was available and this was distinct from int. The two have
been uniﬁed.
float: Floating point number; precision depends on the implementation and system architecture, for
CPython the float datatype corresponds to a C double.
a = 2.0
b = 100.e0
c = 123456789.e1
complex: Complex numbers
a = 2 + 1j
b = 100 + 10j
The <, <=, > and >= operators will raise a TypeError exception when any operand is a complex number.
Strings
Python 3.x Version ≥ 3.0
str: a unicode string. The type of 'hello'
bytes: a byte string. The type of b'hello'
Python 2.x Version ≤ 2.7
str: a byte string. The type of 'hello'
bytes: synonym for str
unicode: a unicode string. The type of u'hello'
Sequences and collections
Python diﬀerentiates between ordered sequences and unordered collections (such as set and dict).
strings (str, bytes, unicode) are sequences
reversed: A reversed order of str with reversed function
a = reversed('hello')
tuple: An ordered collection of n values of any type (n >= 0).
a = (1, 2, 3)
b = ('a', 1, 'python', (1, 2))
b[2] = 'something else' # returns a TypeError
Supports indexing; immutable; hashable if all its members are hashable
GoalKicker.com – Python® Notes for Professionals
12list: An ordered collection of n values (n >= 0)
a = [1, 2, 3]
b = ['a', 1, 'python', (1, 2), [1, 2]]
b[2] = 'something else' # allowed
Not hashable; mutable.
set: An unordered collection of unique values. Items must be hashable.
a = {1, 2, 'a'}
dict: An unordered collection of unique key-value pairs; keys must be hashable.
a = {1: 'one',
2: 'two'}
b = {'a': [1, 2, 3],
'b': 'a string'}
An object is hashable if it has a hash value which never changes during its lifetime (it needs a __hash__()
method), and can be compared to other objects (it needs an __eq__() method). Hashable objects which
compare equality must have the same hash value.
Built-in constants
In conjunction with the built-in datatypes there are a small number of built-in constants in the built-in namespace:
True: The true value of the built-in type bool
False: The false value of the built-in type bool
None: A singleton object used to signal that a value is absent.
Ellipsis or ...: used in core Python3+ anywhere and limited usage in Python2.7+ as part of array notation.
numpy and related packages use this as a 'include everything' reference in arrays.
NotImplemented: a singleton used to indicate to Python that a special method doesn't support the speciﬁc
arguments, and Python will try alternatives if available.
a = None # No value will be assigned. Any valid datatype can be assigned later
Python 3.x Version ≥ 3.0
None doesn't have any natural ordering. Using ordering comparison operators (<, <=, >=, >) isn't supported anymore
and will raise a TypeError.
Python 2.x Version ≤ 2.7
None is always less than any number (None < -32 evaluates to True).
Testing the type of variables
In python, we can check the datatype of an object using the built-in function type.
a = '123'
print(type(a))
GoalKicker.com – Python® Notes for Professionals
13# Out: <class 'str'>
b = 123
print(type(b))
# Out: <class 'int'>
In conditional statements it is possible to test the datatype with isinstance. However, it is usually not encouraged
to rely on the type of the variable.
i = 7
if isinstance(i, int):
i += 1
elif isinstance(i, str):
i = int(i)
i += 1
For information on the diﬀerences between type() and isinstance() read: Diﬀerences between isinstance and
type in Python
To test if something is of NoneType:
x = None
if x is None:
print('Not a surprise, I just defined x as None.')
Converting between datatypes
You can perform explicit datatype conversion.
For example, '123' is of str type and it can be converted to integer using int function.
a = '123'
b = int(a)
Converting from a ﬂoat string such as '123.456' can be done using float function.
a = '123.456'
b = float(a)
c = int(a)
# ValueError: invalid literal for int() with base 10: '123.456'
d = int(b)
# 123
You can also convert sequence or collection types
a = 'hello'
list(a) # ['h', 'e', 'l', 'l', 'o']
set(a)
# {'o', 'e', 'l', 'h'}
tuple(a) # ('h', 'e', 'l', 'l', 'o')
Explicit string type at deﬁnition of literals
With one letter labels just in front of the quotes you can tell what type of string you want to deﬁne.
b'foo bar': results bytes in Python 3, str in Python 2
u'foo bar': results str in Python 3, unicode in Python 2
'foo bar': results str
r'foo bar': results so called raw string, where escaping special characters is not necessary, everything is
taken verbatim as you typed
normal
= 'foo\nbar'
# foo
GoalKicker.com – Python® Notes for Professionals
14escaped = 'foo\\nbar'
raw
= r'foo\nbar'
# bar
# foo\nbar
# foo\nbar
Mutable and Immutable Data Types
An object is called mutable if it can be changed. For example, when you pass a list to some function, the list can be
changed:
def f(m):
m.append(3)
x = [1, 2]
f(x)
x == [1, 2]
# adds a number to the list. This is a mutation.
# False now, since an item was added to the list
An object is called immutable if it cannot be changed in any way. For example, integers are immutable, since there's
no way to change them:
def bar():
x = (1, 2)
g(x)
x == (1, 2)
# Will always be True, since no function can change the object (1, 2)
Note that variables themselves are mutable, so we can reassign the variable x, but this does not change the object
that x had previously pointed to. It only made x point to a new object.
Data types whose instances are mutable are called mutable data types, and similarly for immutable objects and
datatypes.
Examples of immutable Data Types:
int, long, float, complex
str
bytes
tuple
frozenset
Examples of mutable Data Types:
bytearray
list
set
dict
Section 1.5: Collection Types
There are a number of collection types in Python. While types such as int and str hold a single value, collection
types hold multiple values.
Lists
The list type is probably the most commonly used collection type in Python. Despite its name, a list is more like an
array in other languages, mostly JavaScript. In Python, a list is merely an ordered collection of valid Python values. A
list can be created by enclosing values, separated by commas, in square brackets:
GoalKicker.com – Python® Notes for Professionals
15int_list = [1, 2, 3]
string_list = ['abc', 'defghi']
A list can be empty:
empty_list = []
The elements of a list are not restricted to a single data type, which makes sense given that Python is a dynamic
language:
mixed_list = [1, 'abc', True, 2.34, None]
A list can contain another list as its element:
nested_list = [['a', 'b', 'c'], [1, 2, 3]]
The elements of a list can be accessed via an index, or numeric representation of their position. Lists in Python are
zero-indexed meaning that the ﬁrst element in the list is at index 0, the second element is at index 1 and so on:
names = ['Alice', 'Bob', 'Craig', 'Diana', 'Eric']
print(names[0]) # Alice
print(names[2]) # Craig
Indices can also be negative which means counting from the end of the list (-1 being the index of the last element).
So, using the list from the above example:
print(names[-1]) # Eric
print(names[-4]) # Bob
Lists are mutable, so you can change the values in a list:
names[0] = 'Ann'
print(names)
# Outputs ['Ann', 'Bob', 'Craig', 'Diana', 'Eric']
Besides, it is possible to add and/or remove elements from a list:
Append object to end of list with L.append(object), returns None.
names = ['Alice', 'Bob', 'Craig', 'Diana', 'Eric']
names.append("Sia")
print(names)
# Outputs ['Alice', 'Bob', 'Craig', 'Diana', 'Eric', 'Sia']
Add a new element to list at a speciﬁc index. L.insert(index, object)
names.insert(1, "Nikki")
print(names)
# Outputs ['Alice', 'Nikki', 'Bob', 'Craig', 'Diana', 'Eric', 'Sia']
Remove the ﬁrst occurrence of a value with L.remove(value), returns None
names.remove("Bob")
print(names) # Outputs ['Alice', 'Nikki', 'Craig', 'Diana', 'Eric', 'Sia']
GoalKicker.com – Python® Notes for Professionals
16Get the index in the list of the ﬁrst item whose value is x. It will show an error if there is no such item.
name.index("Alice")
0
Count length of list
len(names)
6
count occurrence of any item in list
a = [1, 1, 1, 2, 3, 4]
a.count(1)
3
Reverse the list
a.reverse()
[4, 3, 2, 1, 1, 1]
# or
a[::-1]
[4, 3, 2, 1, 1, 1]
Remove and return item at index (defaults to the last item) with L.pop([index]), returns the item
names.pop() # Outputs 'Sia'
You can iterate over the list elements like below:
for element in my_list:
print (element)
Tuples
A tuple is similar to a list except that it is ﬁxed-length and immutable. So the values in the tuple cannot be changed
nor the values be added to or removed from the tuple. Tuples are commonly used for small collections of values
that will not need to change, such as an IP address and port. Tuples are represented with parentheses instead of
square brackets:
ip_address = ('10.20.30.40', 8080)
The same indexing rules for lists also apply to tuples. Tuples can also be nested and the values can be any valid
Python valid.
A tuple with only one member must be deﬁned (note the comma) this way:
one_member_tuple = ('Only member',)
or
one_member_tuple = 'Only member',
# No brackets
or just using tuple syntax
GoalKicker.com – Python® Notes for Professionals
17one_member_tuple = tuple(['Only member'])
Dictionaries
A dictionary in Python is a collection of key-value pairs. The dictionary is surrounded by curly braces. Each pair is
separated by a comma and the key and value are separated by a colon. Here is an example:
state_capitals = {
'Arkansas': 'Little Rock',
'Colorado': 'Denver',
'California': 'Sacramento',
'Georgia': 'Atlanta'
}
To get a value, refer to it by its key:
ca_capital = state_capitals['California']
You can also get all of the keys in a dictionary and then iterate over them:
for k in state_capitals.keys():
print('{} is the capital of {}'.format(state_capitals[k], k))
Dictionaries strongly resemble JSON syntax. The native json module in the Python standard library can be used to
convert between JSON and dictionaries.
set
A set is a collection of elements with no repeats and without insertion order but sorted order. They are used in
situations where it is only important that some things are grouped together, and not what order they were
included. For large groups of data, it is much faster to check whether or not an element is in a set than it is to do
the same for a list.
Deﬁning a set is very similar to deﬁning a dictionary:
first_names = {'Adam', 'Beth', 'Charlie'}
Or you can build a set using an existing list:
my_list = [1,2,3]
my_set = set(my_list)
Check membership of the set using in:
if name in first_names:
print(name)
You can iterate over a set exactly like a list, but remember: the values will be in an arbitrary, implementation-
deﬁned order.
defaultdict
A defaultdict is a dictionary with a default value for keys, so that keys for which no value has been explicitly
deﬁned can be accessed without errors. defaultdict is especially useful when the values in the dictionary are
collections (lists, dicts, etc) in the sense that it does not need to be initialized every time when a new key is used.
GoalKicker.com – Python® Notes for Professionals
18A defaultdict will never raise a KeyError. Any key that does not exist gets the default value returned.
For example, consider the following dictionary
>>> state_capitals = {
'Arkansas': 'Little Rock',
'Colorado': 'Denver',
'California': 'Sacramento',
'Georgia': 'Atlanta'
}
If we try to access a non-existent key, python returns us an error as follows
>>> state_capitals['Alabama']
Traceback (most recent call last):
File "<ipython-input-61-236329695e6f>", line 1, in <module>
state_capitals['Alabama']
KeyError: 'Alabama'
Let us try with a defaultdict. It can be found in the collections module.
>>> from collections import defaultdict
>>> state_capitals = defaultdict(lambda: 'Boston')
What we did here is to set a default value (Boston) in case the give key does not exist. Now populate the dict as
before:
>>> state_capitals['Arkansas'] = 'Little Rock'
>>> state_capitals['California'] = 'Sacramento'
>>> state_capitals['Colorado'] = 'Denver'
>>> state_capitals['Georgia'] = 'Atlanta'
If we try to access the dict with a non-existent key, python will return us the default value i.e. Boston
>>> state_capitals['Alabama']
'Boston'
and returns the created values for existing key just like a normal dictionary
>>> state_capitals['Arkansas']
'Little Rock'
Section 1.6: IDLE - Python GUI
IDLE is Python’s Integrated Development and Learning Environment and is an alternative to the command line. As
the name may imply, IDLE is very useful for developing new code or learning python. On Windows this comes with
the Python interpreter, but in other operating systems you may need to install it through your package manager.
The main purposes of IDLE are:
Multi-window text editor with syntax highlighting, autocompletion, and smart indent
Python shell with syntax highlighting
Integrated debugger with stepping, persistent breakpoints, and call stack visibility
Automatic indentation (useful for beginners learning about Python's indentation)
GoalKicker.com – Python® Notes for Professionals
19Saving the Python program as .py ﬁles and run them and edit them later at any them using IDLE.
In IDLE, hit F5 or run Python Shell to launch an interpreter. Using IDLE can be a better learning experience for
new users because code is interpreted as the user writes.
Note that there are lots of alternatives, see for example this discussion or this list.
Troubleshooting
Windows
If you're on Windows, the default command is python. If you receive a "'python' is not recognized" error,
the most likely cause is that Python's location is not in your system's PATH environment variable. This can be
accessed by right-clicking on 'My Computer' and selecting 'Properties' or by navigating to 'System' through
'Control Panel'. Click on 'Advanced system settings' and then 'Environment Variables...'. Edit the PATH variable
to include the directory of your Python installation, as well as the Script folder (usually
C:\Python27;C:\Python27\Scripts). This requires administrative privileges and may require a restart.
When using multiple versions of Python on the same machine, a possible solution is to rename one of the
python.exe ﬁles. For example, naming one version python27.exe would cause python27 to become the
Python command for that version.
You can also use the Python Launcher for Windows, which is available through the installer and comes by
default. It allows you to select the version of Python to run by using py -[x.y] instead of python[x.y]. You
can use the latest version of Python 2 by running scripts with py -2 and the latest version of Python 3 by
running scripts with py -3.
Debian/Ubuntu/MacOS
This section assumes that the location of the python executable has been added to the PATH environment
variable.
If you're on Debian/Ubuntu/MacOS, open the terminal and type python for Python 2.x or python3 for Python
3.x.
Type which python to see which Python interpreter will be used.
Arch Linux
The default Python on Arch Linux (and descendants) is Python 3, so use python or python3 for Python 3.x and
python2 for Python 2.x.
Other systems
Python 3 is sometimes bound to python instead of python3. To use Python 2 on these systems where it is
installed, you can use python2.
GoalKicker.com – Python® Notes for Professionals
20Section 1.7: User Input
Interactive input
To get input from the user, use the input function (note: in Python 2.x, the function is called raw_input instead,
although Python 2.x has its own version of input that is completely diﬀerent):
Python 2.x Version ≥ 2.3
name = raw_input("What is your name? ")
# Out: What is your name? _
Security Remark Do not use input() in Python2 - the entered text will be evaluated as if it were a
Python expression (equivalent to eval(input()) in Python3), which might easily become a vulnerability.
See this article for further information on the risks of using this function.
Python 3.x Version ≥ 3.0
name = input("What is your name? ")
# Out: What is your name? _
The remainder of this example will be using Python 3 syntax.
The function takes a string argument, which displays it as a prompt and returns a string. The above code provides a
prompt, waiting for the user to input.
name = input("What is your name? ")
# Out: What is your name?
If the user types "Bob" and hits enter, the variable name will be assigned to the string "Bob":
name = input("What is your name? ")
# Out: What is your name? Bob
print(name)
# Out: Bob
Note that the input is always of type str, which is important if you want the user to enter numbers. Therefore, you
need to convert the str before trying to use it as a number:
x = input("Write a number:")
# Out: Write a number: 10
x / 2
# Out: TypeError: unsupported operand type(s) for /: 'str' and 'int'
float(x) / 2
# Out: 5.0
NB: It's recommended to use try/except blocks to catch exceptions when dealing with user inputs. For instance, if
your code wants to cast a raw_input into an int, and what the user writes is uncastable, it raises a ValueError.
Section 1.8: Built in Modules and Functions
A module is a ﬁle containing Python deﬁnitions and statements. Function is a piece of code which execute some
logic.
>>> pow(2,3)
#8
GoalKicker.com – Python® Notes for Professionals
21To check the built in function in python we can use dir(). If called without an argument, return the names in the
current scope. Else, return an alphabetized list of names comprising (some of) the attribute of the given object, and
of attributes reachable from it.
>>> dir(__builtins__)
[
'ArithmeticError',
'AssertionError',
'AttributeError',
'BaseException',
'BufferError',
'BytesWarning',
'DeprecationWarning',
'EOFError',
'Ellipsis',
'EnvironmentError',
'Exception',
'False',
'FloatingPointError',
'FutureWarning',
'GeneratorExit',
'IOError',
'ImportError',
'ImportWarning',
'IndentationError',
'IndexError',
'KeyError',
'KeyboardInterrupt',
'LookupError',
'MemoryError',
'NameError',
'None',
'NotImplemented',
'NotImplementedError',
'OSError',
'OverflowError',
'PendingDeprecationWarning',
'ReferenceError',
'RuntimeError',
'RuntimeWarning',
'StandardError',
'StopIteration',
'SyntaxError',
'SyntaxWarning',
'SystemError',
'SystemExit',
'TabError',
'True',
'TypeError',
'UnboundLocalError',
'UnicodeDecodeError',
'UnicodeEncodeError',
'UnicodeError',
'UnicodeTranslateError',
'UnicodeWarning',
'UserWarning',
'ValueError',
'Warning',
'ZeroDivisionError',
'__debug__',
'__doc__',
GoalKicker.com – Python® Notes for Professionals
22'__import__',
'__name__',
'__package__',
'abs',
'all',
'any',
'apply',
'basestring',
'bin',
'bool',
'buffer',
'bytearray',
'bytes',
'callable',
'chr',
'classmethod',
'cmp',
'coerce',
'compile',
'complex',
'copyright',
'credits',
'delattr',
'dict',
'dir',
'divmod',
'enumerate',
'eval',
'execfile',
'exit',
'file',
'filter',
'float',
'format',
'frozenset',
'getattr',
'globals',
'hasattr',
'hash',
'help',
'hex',
'id',
'input',
'int',
'intern',
'isinstance',
'issubclass',
'iter',
'len',
'license',
'list',
'locals',
'long',
'map',
'max',
'memoryview',
'min',
'next',
'object',
'oct',
'open',
'ord',
GoalKicker.com – Python® Notes for Professionals
23'pow',
'print',
'property',
'quit',
'range',
'raw_input',
'reduce',
'reload',
'repr',
'reversed',
'round',
'set',
'setattr',
'slice',
'sorted',
'staticmethod',
'str',
'sum',
'super',
'tuple',
'type',
'unichr',
'unicode',
'vars',
'xrange',
'zip'
]
To know the functionality of any function, we can use built in function help .
>>> help(max)
Help on built-in function max in module __builtin__:
max(...)
max(iterable[, key=func]) -> value
max(a, b, c, ...[, key=func]) -> value
With a single iterable argument, return its largest item.
With two or more arguments, return the largest argument.
Built in modules contains extra functionalities. For example to get square root of a number we need to include math
module.
>>> import math
>>> math.sqrt(16) # 4.0
To know all the functions in a module we can assign the functions list to a variable, and then print the variable.
>>> import math
>>> dir(math)
['__doc__', '__name__', '__package__', 'acos', 'acosh',
'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign',
'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1',
'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma',
'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10',
'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt',
'tan', 'tanh', 'trunc']
it seems __doc__ is useful to provide some documentation in, say, functions
GoalKicker.com – Python® Notes for Professionals
24>>> math.__doc__
'This module is always available. It provides access to the\nmathematical
functions defined by the C standard.'
In addition to functions, documentation can also be provided in modules. So, if you have a ﬁle named
helloWorld.py like this:
"""This is the module docstring."""
def sayHello():
"""This is the function docstring."""
return 'Hello World'
You can access its docstrings like this:
>>> import helloWorld
>>> helloWorld.__doc__
'This is the module docstring.'
>>> helloWorld.sayHello.__doc__
'This is the function docstring.'
For any user deﬁned type, its attributes, its class's attributes, and recursively the attributes of its class's base
classes can be retrieved using dir()
>>> class MyClassObject(object):
...
pass
...
>>> dir(MyClassObject)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__',
'__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subclasshook__', '__weakref__']
Any data type can be simply converted to string using a builtin function called str. This function is called by default
when a data type is passed to print
>>> str(123)
# "123"
Section 1.9: Creating a module
A module is an importable ﬁle containing deﬁnitions and statements.
A module can be created by creating a .py ﬁle.
# hello.py
def say_hello():
print("Hello!")
Functions in a module can be used by importing the module.
For modules that you have made, they will need to be in the same directory as the ﬁle that you are importing them
into. (However, you can also put them into the Python lib directory with the pre-included modules, but should be
avoided if possible.)
$ python
>>> import hello
>>> hello.say_hello()
GoalKicker.com – Python® Notes for Professionals
25=> "Hello!"
Modules can be imported by other modules.
# greet.py
import hello
hello.say_hello()
Speciﬁc functions of a module can be imported.
# greet.py
from hello import say_hello
say_hello()
Modules can be aliased.
# greet.py
import hello as ai
ai.say_hello()
A module can be stand-alone runnable script.
# run_hello.py
if __name__ == '__main__':
from hello import say_hello
say_hello()
Run it!
$ python run_hello.py
=> "Hello!"
If the module is inside a directory and needs to be detected by python, the directory should contain a ﬁle named
__init__.py.
Section 1.10: Installation of Python 2.7.x and 3.x
Note: Following instructions are written for Python 2.7 (unless speciﬁed): instructions for Python 3.x are
similar.
Windows
First, download the latest version of Python 2.7 from the oﬃcial Website (https://www.python.org/downloads/).
Version is provided as an MSI package. To install it manually, just double-click the ﬁle.
By default, Python installs to a directory:
C:\Python27\
Warning: installation does not automatically modify the PATH environment variable.
Assuming that your Python installation is in C:\Python27, add this to your PATH:
GoalKicker.com – Python® Notes for Professionals
26C:\Python27\;C:\Python27\Scripts\
Now to check if Python installation is valid write in cmd:
python --version
Python 2.x and 3.x Side-By-Side
To install and use both Python 2.x and 3.x side-by-side on a Windows machine:
1. Install Python 2.x using the MSI installer.
Ensure Python is installed for all users.
Optional: add Python to PATH to make Python 2.x callable from the command-line using python.
2. Install Python 3.x using its respective installer.
Again, ensure Python is installed for all users.
Optional: add Python to PATH to make Python 3.x callable from the command-line using python. This
may override Python 2.x PATH settings, so double-check your PATH and ensure it's conﬁgured to your
preferences.
Make sure to install the py launcher for all users.
Python 3 will install the Python launcher which can be used to launch Python 2.x and Python 3.x interchangeably
from the command-line:
P:\>py -3
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
C:\>py -2
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
To use the corresponding version of pip for a speciﬁc Python version, use:
C:\>py -3 -m pip -V
pip 9.0.1 from C:\Python36\lib\site-packages (python 3.6)
C:\>py -2 -m pip -V
pip 9.0.1 from C:\Python27\lib\site-packages (python 2.7)
Linux
The latest versions of CentOS, Fedora, Red Hat Enterprise (RHEL) and Ubuntu come with Python 2.7.
To install Python 2.7 on linux manually, just do the following in terminal:
wget --no-check-certificate https://www.python.org/ftp/python/2.7.X/Python-2.7.X.tgz
tar -xzf Python-2.7.X.tgz
cd Python-2.7.X
./configure
make
GoalKicker.com – Python® Notes for Professionals
27sudo make install
Also add the path of new python in PATH environment variable. If new python is in /root/python-2.7.X then run
export PATH = $PATH:/root/python-2.7.X
Now to check if Python installation is valid write in terminal:
python --version
Ubuntu (From Source)
If you need Python 3.6 you can install it from source as shown below (Ubuntu 16.10 and 17.04 have 3.6 version in
the universal repository). Below steps have to be followed for Ubuntu 16.04 and lower versions:
sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-
dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xvf Python-3.6.1.tar.xz
cd Python-3.6.1/
./configure --enable-optimizations
sudo make altinstall
macOS
As we speak, macOS comes installed with Python 2.7.10, but this version is outdated and slightly modiﬁed from the
regular Python.
The version of Python that ships with OS X is great for learning but it’s not good for development. The
version shipped with OS X may be out of date from the oﬃcial current Python release, which is
considered the stable production version. (source)
Install Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Python 2.7:
brew install python
For Python 3.x, use the command brew install python3 instead.
Section 1.11: String function - str() and repr()
There are two functions that can be used to obtain a readable representation of an object.
repr(x) calls x.__repr__(): a representation of x. eval will usually convert the result of this function back to the
original object.
str(x) calls x.__str__(): a human-readable string that describes the object. This may elide some technical detail.
repr()
GoalKicker.com – Python® Notes for Professionals
28For many types, this function makes an attempt to return a string that would yield an object with the same value
when passed to eval(). Otherwise, the representation is a string enclosed in angle brackets that contains the name
of the type of the object along with additional information. This often includes the name and address of the object.
str()
For strings, this returns the string itself. The diﬀerence between this and repr(object) is that str(object) does
not always attempt to return a string that is acceptable to eval(). Rather, its goal is to return a printable or 'human
readable' string. If no argument is given, this returns the empty string, ''.
Example 1:
s = """w'o"w"""
repr(s) # Output: '\'w\\\'o"w\''
str(s) # Output: 'w\'o"w'
eval(str(s)) == s # Gives a SyntaxError
eval(repr(s)) == s # Output: True
Example 2:
import datetime
today = datetime.datetime.now()
str(today) # Output: '2016-09-15 06:58:46.915000'
repr(today) # Output: 'datetime.datetime(2016, 9, 15, 6, 58, 46, 915000)'
When writing a class, you can override these methods to do whatever you want:
class Represent(object):
def __init__(self, x, y):
self.x, self.y = x, y
def __repr__(self):
return "Represent(x={},y=\"{}\")".format(self.x, self.y)
def __str__(self):
return "Representing x as {} and y as {}".format(self.x, self.y)
Using the above class we can see the results:
r = Represent(1, "Hopper")
print(r) # prints __str__
print(r.__repr__) # prints __repr__: '<bound method Represent.__repr__ of
Represent(x=1,y="Hopper")>'
rep = r.__repr__() # sets the execution of __repr__ to a new variable
print(rep) # prints 'Represent(x=1,y="Hopper")'
r2 = eval(rep) # evaluates rep
print(r2) # prints __str__ from new object
print(r2 == r) # prints 'False' because they are different objects
Section 1.12: Installing external modules using pip
pip is your friend when you need to install any package from the plethora of choices available at the python
package index (PyPI). pip is already installed if you're using Python 2 >= 2.7.9 or Python 3 >= 3.4 downloaded from
python.org. For computers running Linux or another *nix with a native package manager, pip must often be
manually installed.
GoalKicker.com – Python® Notes for Professionals
29On instances with both Python 2 and Python 3 installed, pip often refers to Python 2 and pip3 to Python 3. Using
pip will only install packages for Python 2 and pip3 will only install packages for Python 3.
Finding / installing a package
Searching for a package is as simple as typing
$ pip search <query>
# Searches for packages whose name or summary contains <query>
Installing a package is as simple as typing (in a terminal / command-prompt, not in the Python interpreter)
$ pip install [package_name]# latest version of the package
$ pip install [package_name]==x.x.x# specific version of the package
$ pip install '[package_name]>=x.x.x'# minimum version of the package
where x.x.x is the version number of the package you want to install.
When your server is behind proxy, you can install package by using below command:
$ pip --proxy http://<server address>:<port> install
Upgrading installed packages
When new versions of installed packages appear they are not automatically installed to your system. To get an
overview of which of your installed packages have become outdated, run:
$ pip list --outdated
To upgrade a speciﬁc package use
$ pip install [package_name] --upgrade
Updating all outdated packages is not a standard functionality of pip.
Upgrading pip
You can upgrade your existing pip installation by using the following commands
On Linux or macOS X:
$ pip install -U pip
You may need to use sudo with pip on some Linux Systems
On Windows:
py -m pip install -U pip
or
python -m pip install -U pip
GoalKicker.com – Python® Notes for Professionals
30For more information regarding pip do read here.
Section 1.13: Help Utility
Python has several functions built into the interpreter. If you want to get information of keywords, built-in
functions, modules or topics open a Python console and enter:
>>> help()
You will receive information by entering keywords directly:
>>> help(help)
or within the utility:
help> help
which will show an explanation:
Help on _Helper in module _sitebuiltins object:
class _Helper(builtins.object)
| Define the builtin 'help'.
|
| This is a wrapper around pydoc.help that provides a helpful message
| when 'help' is typed at the Python interactive prompt.
|
| Calling help() at the Python prompt starts an interactive help session.
| Calling help(thing) prints help for the python object 'thing'.
|
| Methods defined here:
|
| __call__(self, *args, **kwds)
|
| __repr__(self)
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
You can also request subclasses of modules:
help(pymysql.connections)
You can use help to access the docstrings of the diﬀerent modules you have imported, e.g., try the following:
>>> help(math)
and you'll get an error
>>> import math
GoalKicker.com – Python® Notes for Professionals
31>>> help(math)
And now you will get a list of the available methods in the module, but only AFTER you have imported it.
Close the helper with quit
GoalKicker.com – Python® Notes for Professionals
32Chapter 2: Python Data Types
Data types are nothing but variables you use to reserve some space in memory. Python variables do not need an
explicit declaration to reserve memory space. The declaration happens automatically when you assign a value to a
variable.
Section 2.1: String Data Type
String are identiﬁed as a contiguous set of characters represented in the quotation marks. Python allows for either
pairs of single or double quotes. Strings are immutable sequence data type, i.e each time one makes any changes
to a string, completely new string object is created.
a_str = 'Hello World'
print(a_str)
#output will be whole string. Hello World
print(a_str[0])
#output will be first character. H
print(a_str[0:5])
#output will be first five characters. Hello
Section 2.2: Set Data Types
Sets are unordered collections of unique objects, there are two types of set:
1. Sets - They are mutable and new elements can be added once sets are deﬁned
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
print(basket)
# duplicates will be removed
> {'orange', 'banana', 'pear', 'apple'}
a = set('abracadabra')
print(a)
# unique letters in a
> {'a', 'r', 'b', 'c', 'd'}
a.add('z')
print(a)
> {'a', 'c', 'r', 'b', 'z', 'd'}
2. Frozen Sets - They are immutable and new elements cannot added after its deﬁned.
b = frozenset('asdfagsa')
print(b)
> frozenset({'f', 'g', 'd', 'a', 's'})
cities = frozenset(["Frankfurt", "Basel","Freiburg"])
print(cities)
> frozenset({'Frankfurt', 'Basel', 'Freiburg'})
Section 2.3: Numbers data type
Numbers have four types in Python. Int, ﬂoat, complex, and long.
int_num = 10
#int value
float_num = 10.2
#float value
complex_num = 3.14j
#complex value
long_num = 1234567L
#long value
GoalKicker.com – Python® Notes for Professionals
33Section 2.4: List Data Type
A list contains items separated by commas and enclosed within square brackets [].lists are almost similar to arrays
in C. One diﬀerence is that all the items belonging to a list can be of diﬀerent data type.
list = [123,'abcd',10.2,'d']
#can be an array of any data type or single data type.
list1 = ['hello','world']
print(list)
#will output whole list. [123,'abcd',10.2,'d']
print(list[0:2])
#will output first two element of list. [123,'abcd']
print(list1 * 2)
#will gave list1 two times. ['hello','world','hello','world']
print(list + list1)
#will gave concatenation of both the lists.
[123,'abcd',10.2,'d','hello','world']
Section 2.5: Dictionary Data Type
Dictionary consists of key-value pairs. It is enclosed by curly braces {} and values can be assigned and accessed
using square brackets[].
dic={'name':'red','age':10}
print(dic)
#will output all the key-value pairs. {'name':'red','age':10}
print(dic['name'])
#will output only value with 'name' key. 'red'
print(dic.values())
#will output list of values in dic. ['red',10]
print(dic.keys())
#will output list of keys. ['name','age']
Section 2.6: Tuple Data Type
Lists are enclosed in brackets [ ] and their elements and size can be changed, while tuples are enclosed in
parentheses ( ) and cannot be updated. Tuples are immutable.
tuple = (123,'hello')
tuple1 = ('world')
print(tuple)
#will output whole tuple. (123,'hello')
print(tuple[0])
#will output first value. (123)
print(tuple + tuple1)
#will output (123,'hello','world')
tuple[1]='update'
#this will give you error.
GoalKicker.com – Python® Notes for Professionals
34Chapter 3: Indentation
Section 3.1: Simple example
For Python, Guido van Rossum based the grouping of statements on indentation. The reasons for this are explained
in the ﬁrst section of the "Design and History Python FAQ". Colons, :, are used to declare an indented code block,
such as the following example:
class ExampleClass:
#Every function belonging to a class must be indented equally
def __init__(self):
name = "example"
def someFunction(self, a):
#Notice everything belonging to a function must be indented
if a > 5:
return True
else:
return False
#If a function is not indented to the same level it will not be considers as part of the parent class
def separateFunction(b):
for i in b:
#Loops are also indented and nested conditions start a new indentation
if i == 1:
return True
return False
separateFunction([2,3,5,6,1])
Spaces or Tabs?
The recommended indentation is 4 spaces but tabs or spaces can be used so long as they are consistent. Do not
mix tabs and spaces in Python as this will cause an error in Python 3 and can causes errors in Python 2.
Section 3.2: How Indentation is Parsed
Whitespace is handled by the lexical analyzer before being parsed.
The lexical analyzer uses a stack to store indentation levels. At the beginning, the stack contains just the value 0,
which is the leftmost position. Whenever a nested block begins, the new indentation level is pushed on the stack,
and an "INDENT" token is inserted into the token stream which is passed to the parser. There can never be more
than one "INDENT" token in a row (IndentationError).
When a line is encountered with a smaller indentation level, values are popped from the stack until a value is on top
which is equal to the new indentation level (if none is found, a syntax error occurs). For each value popped, a
"DEDENT" token is generated. Obviously, there can be multiple "DEDENT" tokens in a row.
The lexical analyzer skips empty lines (those containing only whitespace and possibly comments), and will never
generate either "INDENT" or "DEDENT" tokens for them.
At the end of the source code, "DEDENT" tokens are generated for each indentation level left on the stack, until just
the 0 is left.
For example:
GoalKicker.com – Python® Notes for Professionals
35if foo:
if bar:
x = 42
else:
print foo
is analyzed as:
<if> <foo> <:>
<INDENT> <if> <bar> <:>
<INDENT> <x> <=> <42>
<DEDENT> <DEDENT> <else> <:>
<INDENT> <print> <foo>
<DEDENT>
[0]
[0, 4]
[0, 4, 8]
[0]
[0, 2]
The parser than handles the "INDENT" and "DEDENT" tokens as block delimiters.
Section 3.3: Indentation Errors
The spacing should be even and uniform throughout. Improper indentation can cause an IndentationError or
cause the program to do something unexpected. The following example raises an IndentationError:
a = 7
if a > 5:
print "foo"
else:
print "bar"
print "done"
Or if the line following a colon is not indented, an IndentationError will also be raised:
if True:
print "true"
If you add indentation where it doesn't belong, an IndentationError will be raised:
if
True:
a = 6
b = 5
If you forget to un-indent functionality could be lost. In this example None is returned instead of the expected False:
def isEven(a):
if a%2 ==0:
return True
#this next line should be even with the if
return False
print isEven(7)
GoalKicker.com – Python® Notes for Professionals
36Chapter 4: Comments and Documentation
Section 4.1: Single line, inline and multiline comments
Comments are used to explain code when the basic code itself isn't clear.
Python ignores comments, and so will not execute code in there, or raise syntax errors for plain English sentences.
Single-line comments begin with the hash character (#) and are terminated by the end of line.
Single line comment:
# This is a single line comment in Python
Inline comment:
print("Hello World")
# This line prints "Hello World"
Comments spanning multiple lines have """ or ''' on either end. This is the same as a multiline string, but
they can be used as comments:
"""
This type of comment spans multiple lines.
These are mostly used for documentation of functions, classes and modules.
"""
Section 4.2: Programmatically accessing docstrings
Docstrings are - unlike regular comments - stored as an attribute of the function they document, meaning that you
can access them programmatically.
An example function
def func():
"""This is a function that does nothing at all"""
return
The docstring can be accessed using the __doc__ attribute:
print(func.__doc__)
This is a function that does nothing at all
help(func)
Help on function func in module __main__:
func()
This is a function that does nothing at all
Another example function
GoalKicker.com – Python® Notes for Professionals
37function.__doc__ is just the actual docstring as a string, while the help function provides general information
about a function, including the docstring. Here's a more helpful example:
def greet(name, greeting="Hello"):
"""Print a greeting to the user `name`
Optional parameter `greeting` can change what they're greeted with."""
print("{} {}".format(greeting, name))
help(greet)
Help on function greet in module __main__:
greet(name, greeting='Hello')
Print a greeting to the user name
Optional parameter greeting can change what they're greeted with.
Advantages of docstrings over regular comments
Just putting no docstring or a regular comment in a function makes it a lot less helpful.
def greet(name, greeting="Hello"):
# Print a greeting to the user `name`
# Optional parameter `greeting` can change what they're greeted with.
print("{} {}".format(greeting, name))
print(greet.__doc__)
None
help(greet)
Help on function greet in module main:
greet(name, greeting='Hello')
Section 4.3: Write documentation using docstrings
A docstring is a multi-line comment used to document modules, classes, functions and methods. It has to be the
ﬁrst statement of the component it describes.
def hello(name):
"""Greet someone.
Print a greeting ("Hello") for the person with the given name.
"""
print("Hello "+name)
class Greeter:
"""An object used to greet people.
GoalKicker.com – Python® Notes for Professionals
38It contains multiple greeting functions for several languages
and times of the day.
"""
The value of the docstring can be accessed within the program and is - for example - used by the help command.
Syntax conventions
PEP 257
PEP 257 deﬁnes a syntax standard for docstring comments. It basically allows two types:
One-line Docstrings:
According to PEP 257, they should be used with short and simple functions. Everything is placed in one line, e.g:
def hello():
"""Say hello to your friends."""
print("Hello my friends!")
The docstring shall end with a period, the verb should be in the imperative form.
Multi-line Docstrings:
Multi-line docstring should be used for longer, more complex functions, modules or classes.
def hello(name, language="en"):
"""Say hello to a person.
Arguments:
name: the name of the person
language: the language in which the person should be greeted
"""
print(greeting[language]+" "+name)
They start with a short summary (equivalent to the content of a one-line docstring) which can be on the same line
as the quotation marks or on the next line, give additional detail and list parameters and return values.
Note PEP 257 deﬁnes what information should be given within a docstring, it doesn't deﬁne in which format it
should be given. This was the reason for other parties and documentation parsing tools to specify their own
standards for documentation, some of which are listed below and in this question.
Sphinx
Sphinx is a tool to generate HTML based documentation for Python projects based on docstrings. Its markup
language used is reStructuredText. They deﬁne their own standards for documentation, pythonhosted.org hosts a
very good description of them. The Sphinx format is for example used by the pyCharm IDE.
A function would be documented like this using the Sphinx/reStructuredText format:
def hello(name, language="en"):
"""Say hello to a person.
:param name: the name of the person
:type name: str
:param language: the language in which the person should be greeted
:type language: str
GoalKicker.com – Python® Notes for Professionals
39:return: a number
:rtype: int
"""
print(greeting[language]+" "+name)
return 4
Google Python Style Guide
Google has published Google Python Style Guide which deﬁnes coding conventions for Python, including
documentation comments. In comparison to the Sphinx/reST many people say that documentation according to
Google's guidelines is better human-readable.
The pythonhosted.org page mentioned above also provides some examples for good documentation according to
the Google Style Guide.
Using the Napoleon plugin, Sphinx can also parse documentation in the Google Style Guide-compliant format.
A function would be documented like this using the Google Style Guide format:
def hello(name, language="en"):
"""Say hello to a person.
Args:
name: the name of the person as string
language: the language code string
Returns:
A number.
"""
print(greeting[language]+" "+name)
return 4
GoalKicker.com – Python® Notes for Professionals
40VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 5: Date and Time
Section 5.1: Parsing a string into a timezone aware datetime
object
Python 3.2+ has support for %z format when parsing a string into a datetime object.
UTC oﬀset in the form +HHMM or -HHMM (empty string if the object is naive).
Python 3.x Version ≥ 3.2
import datetime
dt = datetime.datetime.strptime("2016-04-15T08:27:18-0500", "%Y-%m-%dT%H:%M:%S%z")
For other versions of Python, you can use an external library such as dateutil, which makes parsing a string with
timezone into a datetime object is quick.
import dateutil.parser
dt = dateutil.parser.parse("2016-04-15T08:27:18-0500")
The dt variable is now a datetime object with the following value:
datetime.datetime(2016, 4, 15, 8, 27, 18, tzinfo=tzoffset(None, -18000))
Section 5.2: Constructing timezone-aware datetimes
By default all datetime objects are naive. To make them timezone-aware, you must attach a tzinfo object, which
provides the UTC oﬀset and timezone abbreviation as a function of date and time.
Fixed Oﬀset Time Zones
For time zones that are a ﬁxed oﬀset from UTC, in Python 3.2+, the datetime module provides the timezone class, a
concrete implementation of tzinfo, which takes a timedelta and an (optional) name parameter:
Python 3.x Version ≥ 3.2
from datetime import datetime, timedelta, timezone
JST = timezone(timedelta(hours=+9))
dt = datetime(2015, 1, 1, 12, 0, 0, tzinfo=JST)
print(dt)
# 2015-01-01 12:00:00+09:00
print(dt.tzname())
# UTC+09:00
dt = datetime(2015, 1, 1, 12, 0, 0, tzinfo=timezone(timedelta(hours=9), 'JST'))
print(dt.tzname)
# 'JST'
For Python versions before 3.2, it is necessary to use a third party library, such as dateutil. dateutil provides an
equivalent class, tzoffset, which (as of version 2.5.3) takes arguments of the form dateutil.tz.tzoffset(tzname,
offset), where offset is speciﬁed in seconds:
Python 3.x Version < 3.2
GoalKicker.com – Python® Notes for Professionals
42Python 2.x Version < 2.7
from datetime import datetime, timedelta
from dateutil import tz
JST = tz.tzoffset('JST', 9 * 3600) # 3600 seconds per hour
dt = datetime(2015, 1, 1, 12, 0, tzinfo=JST)
print(dt)
# 2015-01-01 12:00:00+09:00
print(dt.tzname)
# 'JST'
Zones with daylight savings time
For zones with daylight savings time, python standard libraries do not provide a standard class, so it is necessary to
use a third party library. pytz and dateutil are popular libraries providing time zone classes.
In addition to static time zones, dateutil provides time zone classes that use daylight savings time (see the
documentation for the tz module). You can use the tz.gettz() method to get a time zone object, which can then
be passed directly to the datetime constructor:
from datetime import datetime
from dateutil import tz
local = tz.gettz() # Local time
PT = tz.gettz('US/Pacific') # Pacific time
dt_l = datetime(2015, 1, 1, 12, tzinfo=local) # I am in EST
dt_pst = datetime(2015, 1, 1, 12, tzinfo=PT)
dt_pdt = datetime(2015, 7, 1, 12, tzinfo=PT) # DST is handled automatically
print(dt_l)
# 2015-01-01 12:00:00-05:00
print(dt_pst)
# 2015-01-01 12:00:00-08:00
print(dt_pdt)
# 2015-07-01 12:00:00-07:00
CAUTION: As of version 2.5.3, dateutil does not handle ambiguous datetimes correctly, and will always default to
the later date. There is no way to construct an object with a dateutil timezone representing, for example
2015-11-01 1:30 EDT-4, since this is during a daylight savings time transition.
All edge cases are handled properly when using pytz, but pytz time zones should not be directly attached to time
zones through the constructor. Instead, a pytz time zone should be attached using the time zone's localize
method:
from datetime import datetime, timedelta
import pytz
PT = pytz.timezone('US/Pacific')
dt_pst = PT.localize(datetime(2015, 1, 1, 12))
dt_pdt = PT.localize(datetime(2015, 11, 1, 0, 30))
print(dt_pst)
# 2015-01-01 12:00:00-08:00
print(dt_pdt)
# 2015-11-01 00:30:00-07:00
Be aware that if you perform datetime arithmetic on a pytz-aware time zone, you must either perform the
calculations in UTC (if you want absolute elapsed time), or you must call normalize() on the result:
GoalKicker.com – Python® Notes for Professionals
43dt_new = dt_pdt + timedelta(hours=3) # This should be 2:30 AM PST
print(dt_new)
# 2015-11-01 03:30:00-07:00
dt_corrected = PT.normalize(dt_new)
print(dt_corrected)
# 2015-11-01 02:30:00-08:00
Section 5.3: Computing time dierences
the timedelta module comes in handy to compute diﬀerences between times:
from datetime import datetime, timedelta
now = datetime.now()
then = datetime(2016, 5, 23)
# datetime.datetime(2016, 05, 23, 0, 0, 0)
Specifying time is optional when creating a new datetime object
delta = now-then
delta is of type timedelta
print(delta.days)
# 60
print(delta.seconds)
# 40826
To get n day's after and n day's before date we could use:
n day's after date:
def get_n_days_after_date(date_format="%d %B %Y", add_days=120):
date_n_days_after = datetime.datetime.now() + timedelta(days=add_days)
return date_n_days_after.strftime(date_format)
n day's before date:
def get_n_days_before_date(self, date_format="%d %B %Y", days_before=120):
date_n_days_ago = datetime.datetime.now() - timedelta(days=days_before)
return date_n_days_ago.strftime(date_format)
Section 5.4: Basic datetime objects usage
The datetime module contains three primary types of objects - date, time, and datetime.
import datetime
# Date object
today = datetime.date.today()
new_year = datetime.date(2017, 01, 01) #datetime.date(2017, 1, 1)
# Time object
noon = datetime.time(12, 0, 0) #datetime.time(12, 0)
# Current datetime
now = datetime.datetime.now()
GoalKicker.com – Python® Notes for Professionals
44# Datetime object
millenium_turn = datetime.datetime(2000, 1, 1, 0, 0, 0) #datetime.datetime(2000, 1, 1, 0, 0)
Arithmetic operations for these objects are only supported within same datatype and performing simple arithmetic
with instances of diﬀerent types will result in a TypeError.
# subtraction of noon from today
noon-today
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.date'
However, it is straightforward to convert between types.
# Do this instead
print('Time since the millenium at midnight: ',
datetime.datetime(today.year, today.month, today.day) - millenium_turn)
# Or this
print('Time since the millenium at noon: ',
datetime.datetime.combine(today, noon) - millenium_turn)
Section 5.5: Switching between time zones
To switch between time zones, you need datetime objects that are timezone-aware.
from datetime import datetime
from dateutil import tz
utc = tz.tzutc()
local = tz.tzlocal()
utc_now = datetime.utcnow()
utc_now # Not timezone-aware.
utc_now = utc_now.replace(tzinfo=utc)
utc_now # Timezone-aware.
local_now = utc_now.astimezone(local)
local_now # Converted to local time.
Section 5.6: Simple date arithmetic
Dates don't exist in isolation. It is common that you will need to ﬁnd the amount of time between dates or
determine what the date will be tomorrow. This can be accomplished using timedelta objects
import datetime
today = datetime.date.today()
print('Today:', today)
yesterday = today - datetime.timedelta(days=1)
print('Yesterday:', yesterday)
tomorrow = today + datetime.timedelta(days=1)
print('Tomorrow:', tomorrow)
print('Time between tomorrow and yesterday:', tomorrow - yesterday)
GoalKicker.com – Python® Notes for Professionals
45This will produce results similar to:
Today: 2016-04-15
Yesterday: 2016-04-14
Tomorrow: 2016-04-16
Difference between tomorrow and yesterday: 2 days, 0:00:00
Section 5.7: Converting timestamp to datetime
The datetime module can convert a POSIX timestamp to a ITC datetime object.
The Epoch is January 1st, 1970 midnight.
import time
from datetime import datetime
seconds_since_epoch=time.time()
#1469182681.709
utc_date=datetime.utcfromtimestamp(seconds_since_epoch) #datetime.datetime(2016, 7, 22, 10, 18, 1,
709000)
Section 5.8: Subtracting months from a date accurately
Using the calendar module
import calendar
from datetime import date
def monthdelta(date, delta):
m, y = (date.month+delta) % 12, date.year + ((date.month)+delta-1) // 12
if not m: m = 12
d = min(date.day, calendar.monthrange(y, m)[1])
return date.replace(day=d,month=m, year=y)
next_month = monthdelta(date.today(), 1) #datetime.date(2016, 10, 23)
Using the dateutils module
import datetime
import dateutil.relativedelta
d = datetime.datetime.strptime("2013-03-31", "%Y-%m-%d")
d2 = d - dateutil.relativedelta.relativedelta(months=1) #datetime.datetime(2013, 2, 28, 0, 0)
Section 5.9: Parsing an arbitrary ISO 8601 timestamp with
minimal libraries
Python has only limited support for parsing ISO 8601 timestamps. For strptime you need to know exactly what
format it is in. As a complication the stringiﬁcation of a datetime is an ISO 8601 timestamp, with space as a
separator and 6 digit fraction:
str(datetime.datetime(2016, 7, 22, 9, 25, 59, 555555))
# '2016-07-22 09:25:59.555555'
but if the fraction is 0, no fractional part is output
GoalKicker.com – Python® Notes for Professionals
46str(datetime.datetime(2016, 7, 22, 9, 25, 59, 0))
# '2016-07-22 09:25:59'
But these 2 forms need a diﬀerent format for strptime. Furthermore, strptime' does not support at all
parsing minute timezones that have a:in it, thus2016-07-22 09:25:59+0300can be parsed, but the
standard format2016-07-22 09:25:59+03:00` cannot.
There is a single-ﬁle library called iso8601 which properly parses ISO 8601 timestamps and only them.
It supports fractions and timezones, and the T separator all with a single function:
import iso8601
iso8601.parse_date('2016-07-22 09:25:59')
# datetime.datetime(2016, 7, 22, 9, 25, 59, tzinfo=<iso8601.Utc>)
iso8601.parse_date('2016-07-22 09:25:59+03:00')
# datetime.datetime(2016, 7, 22, 9, 25, 59, tzinfo=<FixedOffset '+03:00' ...>)
iso8601.parse_date('2016-07-22 09:25:59Z')
# datetime.datetime(2016, 7, 22, 9, 25, 59, tzinfo=<iso8601.Utc>)
iso8601.parse_date('2016-07-22T09:25:59.000111+03:00')
# datetime.datetime(2016, 7, 22, 9, 25, 59, 111, tzinfo=<FixedOffset '+03:00' ...>)
If no timezone is set, iso8601.parse_date defaults to UTC. The default zone can be changed with default_zone
keyword argument. Notably, if this is None instead of the default, then those timestamps that do not have an
explicit timezone are returned as naive datetimes instead:
iso8601.parse_date('2016-07-22T09:25:59', default_timezone=None)
# datetime.datetime(2016, 7, 22, 9, 25, 59)
iso8601.parse_date('2016-07-22T09:25:59Z', default_timezone=None)
# datetime.datetime(2016, 7, 22, 9, 25, 59, tzinfo=<iso8601.Utc>)
Section 5.10: Get an ISO 8601 timestamp
Without timezone, with microseconds
from datetime import datetime
datetime.now().isoformat()
# Out: '2016-07-31T23:08:20.886783'
With timezone, with microseconds
from datetime import datetime
from dateutil.tz import tzlocal
datetime.now(tzlocal()).isoformat()
# Out: '2016-07-31T23:09:43.535074-07:00'
With timezone, without microseconds
from datetime import datetime
from dateutil.tz import tzlocal
datetime.now(tzlocal()).replace(microsecond=0).isoformat()
# Out: '2016-07-31T23:10:30-07:00'
See ISO 8601 for more information about the ISO 8601 format.
Section 5.11: Parsing a string with a short time zone name into
GoalKicker.com – Python® Notes for Professionals
47a timezone aware datetime object
Using the dateutil library as in the previous example on parsing timezone-aware timestamps, it is also possible to
parse timestamps with a speciﬁed "short" time zone name.
For dates formatted with short time zone names or abbreviations, which are generally ambiguous (e.g. CST, which
could be Central Standard Time, China Standard Time, Cuba Standard Time, etc - more can be found here) or not
necessarily available in a standard database, it is necessary to specify a mapping between time zone abbreviation
and tzinfo object.
from dateutil import tz
from dateutil.parser import parse
ET = tz.gettz('US/Eastern')
CT = tz.gettz('US/Central')
MT = tz.gettz('US/Mountain')
PT = tz.gettz('US/Pacific')
us_tzinfos = {'CST': CT, 'CDT': CT,
'EST': ET, 'EDT': ET,
'MST': MT, 'MDT': MT,
'PST': PT, 'PDT': PT}
dt_est = parse('2014-01-02 04:00:00 EST', tzinfos=us_tzinfos)
dt_pst = parse('2016-03-11 16:00:00 PST', tzinfos=us_tzinfos)
After running this:
dt_est
# datetime.datetime(2014, 1, 2, 4, 0, tzinfo=tzfile('/usr/share/zoneinfo/US/Eastern'))
dt_pst
# datetime.datetime(2016, 3, 11, 16, 0, tzinfo=tzfile('/usr/share/zoneinfo/US/Pacific'))
It is worth noting that if using a pytz time zone with this method, it will not be properly localized:
from dateutil.parser import parse
import pytz
EST = pytz.timezone('America/New_York')
dt = parse('2014-02-03 09:17:00 EST', tzinfos={'EST': EST})
This simply attaches the pytz time zone to the datetime:
dt.tzinfo # Will be in Local Mean Time!
# <DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD>
If using this method, you should probably re-localize the naive portion of the datetime after parsing:
dt_fixed = dt.tzinfo.localize(dt.replace(tzinfo=None))
dt_fixed.tzinfo # Now it's EST.
# <DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>)
Section 5.12: Fuzzy datetime parsing (extracting datetime out
of a text)
It is possible to extract a date out of a text using the dateutil parser in a "fuzzy" mode, where components of the
GoalKicker.com – Python® Notes for Professionals
48string not recognized as being part of a date are ignored.
from dateutil.parser import parse
dt = parse("Today is January 1, 2047 at 8:21:00AM", fuzzy=True)
print(dt)
dt is now a datetime object and you would see datetime.datetime(2047, 1, 1, 8, 21) printed.
Section 5.13: Iterate over dates
Sometimes you want to iterate over a range of dates from a start date to some end date. You can do it using
datetime library and timedelta object:
import datetime
# The size of each step in days
day_delta = datetime.timedelta(days=1)
start_date = datetime.date.today()
end_date = start_date + 7*day_delta
for i in range((end_date - start_date).days):
print(start_date + i*day_delta)
Which produces:
2016-07-21
2016-07-22
2016-07-23
2016-07-24
2016-07-25
2016-07-26
2016-07-27
GoalKicker.com – Python® Notes for Professionals
49Chapter 6: Date Formatting
Section 6.1: Time between two date-times
from datetime import datetime
a = datetime(2016,10,06,0,0,0)
b = datetime(2016,10,01,23,59,59)
a-b
# datetime.timedelta(4, 1)
(a-b).days
# 4
(a-b).total_seconds()
# 518399.0
Section 6.2: Outputting datetime object to string
Uses C standard format codes.
from datetime import datetime
datetime_for_string = datetime(2016,10,1,0,0)
datetime_string_format = '%b %d %Y, %H:%M:%S'
datetime.strftime(datetime_for_string,datetime_string_format)
# Oct 01 2016, 00:00:00
Section 6.3: Parsing string to datetime object
Uses C standard format codes.
from datetime import datetime
datetime_string = 'Oct 1 2016, 00:00:00'
datetime_string_format = '%b %d %Y, %H:%M:%S'
datetime.strptime(datetime_string, datetime_string_format)
# datetime.datetime(2016, 10, 1, 0, 0)
GoalKicker.com – Python® Notes for Professionals
50Chapter 7: Enum
Section 7.1: Creating an enum (Python 2.4 through 3.3)
Enums have been backported from Python 3.4 to Python 2.4 through Python 3.3. You can get this the enum34
backport from PyPI.
pip install enum34
Creation of an enum is identical to how it works in Python 3.4+
from enum import Enum
class Color(Enum):
red = 1
green = 2
blue = 3
print(Color.red) # Color.red
print(Color(1)) # Color.red
print(Color['red']) # Color.red
Section 7.2: Iteration
Enums are iterable:
class Color(Enum):
red = 1
green = 2
blue = 3
[c for c in Color]
# [<Color.red: 1>, <Color.green: 2>, <Color.blue: 3>]
GoalKicker.com – Python® Notes for Professionals
51Chapter 8: Set
Section 8.1: Operations on sets
with other sets
# Intersection
{1, 2, 3, 4, 5}.intersection({3, 4, 5, 6})
{1, 2, 3, 4, 5} & {3, 4, 5, 6}
# {3, 4, 5}
# {3, 4, 5}
# Union
{1, 2, 3, 4, 5}.union({3, 4, 5, 6})
{1, 2, 3, 4, 5} | {3, 4, 5, 6}# {1, 2, 3, 4, 5, 6}
# {1, 2, 3, 4, 5, 6}
# Difference
{1, 2, 3, 4}.difference({2, 3, 5})
{1, 2, 3, 4} - {2, 3, 5}# {1, 4}
# {1, 4}
# Symmetric difference with
{1, 2, 3, 4}.symmetric_difference({2, 3, 5})
{1, 2, 3, 4} ^ {2, 3, 5}
# Superset check
{1, 2}.issuperset({1, 2, 3})
{1, 2} >= {1, 2, 3}
# {1, 4, 5}
# {1, 4, 5}
# False
# False
# Subset check
{1, 2}.issubset({1, 2, 3})
{1, 2} <= {1, 2, 3}# True
# True
# Disjoint check
{1, 2}.isdisjoint({3, 4})
{1, 2}.isdisjoint({1, 4})# True
# False
with single elements
# Existence check
2 in {1,2,3}
# True
4 in {1,2,3}
# False
4 not in {1,2,3} # True
# Add and Remove
s = {1,2,3}
s.add(4)
# s == {1,2,3,4}
s.discard(3)
s.discard(5)# s == {1,2,4}
# s == {1,2,4}
s.remove(2)
s.remove(2)# s == {1,4}
# KeyError!
Set operations return new sets, but have the corresponding in-place versions:
method
unionin-place operation
in-place method
s |= t
update
intersections &= t
intersection_update
diﬀerences -= t
diﬀerence_update
GoalKicker.com – Python® Notes for Professionals
52symmetric_diﬀerence s ^= t
symmetric_diﬀerence_update
For example:
s = {1, 2}
s.update({3, 4})
# s == {1, 2, 3, 4}
Section 8.2: Get the unique elements of a list
Let's say you've got a list of restaurants -- maybe you read it from a ﬁle. You care about the unique restaurants in
the list. The best way to get the unique elements from a list is to turn it into a set:
restaurants = ["McDonald's", "Burger King", "McDonald's", "Chicken Chicken"]
unique_restaurants = set(restaurants)
print(unique_restaurants)
# prints {'Chicken Chicken', "McDonald's", 'Burger King'}
Note that the set is not in the same order as the original list; that is because sets are unordered, just like dicts.
This can easily be transformed back into a List with Python's built in list function, giving another list that is the
same list as the original but without duplicates:
list(unique_restaurants)
# ['Chicken Chicken', "McDonald's", 'Burger King']
It's also common to see this as one line:
# Removes all duplicates and returns another list
list(set(restaurants))
Now any operations that could be performed on the original list can be done again.
Section 8.3: Set of Sets
{{1,2}, {3,4}}
leads to:
TypeError: unhashable type: 'set'
Instead, use frozenset:
{frozenset({1, 2}), frozenset({3, 4})}
Section 8.4: Set Operations using Methods and Builtins
We deﬁne two sets a and b
>>> a = {1, 2, 2, 3, 4}
>>> b = {3, 3, 4, 4, 5}
NOTE: {1} creates a set of one element, but {} creates an empty dict. The correct way to create an
empty set is set().
GoalKicker.com – Python® Notes for Professionals
53Intersection
a.intersection(b) returns a new set with elements present in both a and b
>>> a.intersection(b)
{3, 4}
Union
a.union(b) returns a new set with elements present in either a and b
>>> a.union(b)
{1, 2, 3, 4, 5}
Diﬀerence
a.difference(b) returns a new set with elements present in a but not in b
>>> a.difference(b)
{1, 2}
>>> b.difference(a)
{5}
Symmetric Diﬀerence
a.symmetric_difference(b) returns a new set with elements present in either a or b but not in both
>>> a.symmetric_difference(b)
{1, 2, 5}
>>> b.symmetric_difference(a)
{1, 2, 5}
NOTE: a.symmetric_difference(b) == b.symmetric_difference(a)
Subset and superset
c.issubset(a) tests whether each element of c is in a.
a.issuperset(c) tests whether each element of c is in a.
>>> c = {1, 2}
>>> c.issubset(a)
True
>>> a.issuperset(c)
True
The latter operations have equivalent operators as shown below:
Method
Operator
a.intersection(b)a & b
a.union(b)a|b
a.difference(b)a - b
a.symmetric_difference(b) a ^ b
a.issubset(b)a <= b
a.issuperset(b)a >= b
Disjoint sets
GoalKicker.com – Python® Notes for Professionals
54Sets a and d are disjoint if no element in a is also in d and vice versa.
>>> d = {5, 6}
>>> a.isdisjoint(b) # {2, 3, 4} are in both sets
False
>>> a.isdisjoint(d)
True
# This is an equivalent check, but less efficient
>>> len(a & d) == 0
True
# This is even less efficient
>>> a & d == set()
True
Testing membership
The builtin in keyword searches for occurances
>>> 1 in a
True
>>> 6 in a
False
Length
The builtin len() function returns the number of elements in the set
>>> len(a)
4
>>> len(b)
3
Section 8.5: Sets versus multisets
Sets are unordered collections of distinct elements. But sometimes we want to work with unordered collections of
elements that are not necessarily distinct and keep track of the elements' multiplicities.
Consider this example:
>>> setA = {'a','b','b','c'}
>>> setA
set(['a', 'c', 'b'])
By saving the strings 'a', 'b', 'b', 'c' into a set data structure we've lost the information on the fact that 'b'
occurs twice. Of course saving the elements to a list would retain this information
>>> listA = ['a','b','b','c']
>>> listA
['a', 'b', 'b', 'c']
but a list data structure introduces an extra unneeded ordering that will slow down our computations.
For implementing multisets Python provides the Counter class from the collections module (starting from version
2.7):
Python 2.x Version ≥ 2.7
GoalKicker.com – Python® Notes for Professionals
55>>> from collections import Counter
>>> counterA = Counter(['a','b','b','c'])
>>> counterA
Counter({'b': 2, 'a': 1, 'c': 1})
Counter is a dictionary where where elements are stored as dictionary keys and their counts are stored as
dictionary values. And as all dictionaries, it is an unordered collection.
GoalKicker.com – Python® Notes for Professionals
56Chapter 9: Simple Mathematical Operators
Numerical types and their metaclasses
The numbers module contains the abstract metaclasses for the numerical types:
subclasses
boolnumbers.Number numbers.Integral numbers.Rational numbers.Real numbers.Complex
✓
✓
✓
✓
✓
int✓
✓
✓
✓
✓
fractions.Fraction ✓
―
✓
✓
✓
ﬂoat✓
―
―
✓
✓
complex✓
―
―
―
✓
decimal.Decimal ✓
―
―
―
―
Python does common mathematical operators on its own, including integer and ﬂoat division, multiplication,
exponentiation, addition, and subtraction. The math module (included in all standard Python versions) oﬀers
expanded functionality like trigonometric functions, root operations, logarithms, and many more.
Section 9.1: Division
Python does integer division when both operands are integers. The behavior of Python's division operators have
changed from Python 2.x and 3.x (see also Integer Division ).
a, b, c, d, e = 3, 2, 2.0, -3, 10
Python 2.x Version ≤ 2.7
In Python 2 the result of the ' / ' operator depends on the type of the numerator and denominator.
a / b# = 1
a / c# = 1.5
d / b# = -2
b / a# = 0
d / e# = -1
Note that because both a and b are ints, the result is an int.
The result is always rounded down (ﬂoored).
Because c is a ﬂoat, the result of a / c is a float.
You can also use the operator module:
import operator
# the operator module provides 2-argument arithmetic functions
operator.div(a, b)
# = 1
operator.__div__(a, b) # = 1
Python 2.x Version ≥ 2.2
What if you want ﬂoat division:
Recommended:
GoalKicker.com – Python® Notes for Professionals
57from __future__ import division # applies Python 3 style division to the entire module
a / b
# = 1.5
a // b
# = 1
Okay (if you don't want to apply to the whole module):
a / (b * 1.0)
1.0 * a / b
a / b * 1.0
# = 1.5
# = 1.5
# = 1.0
(careful with order of operations)
from operator import truediv
truediv(a, b)
# = 1.5
Not recommended (may raise TypeError, eg if argument is complex):
float(a) / b
a / float(b)
# = 1.5
# = 1.5
Python 2.x Version ≥ 2.2
The ' // ' operator in Python 2 forces ﬂoored division regardless of type.
a // b
a // c
# = 1
# = 1.0
Python 3.x Version ≥ 3.0
In Python 3 the / operator performs 'true' division regardless of types. The // operator performs ﬂoor division and
maintains type.
a / b
e / b
a // b
a // c
# = 1.5
# = 5.0
# = 1
# = 1.0
import operator
operator.truediv(a, b)
operator.floordiv(a, b)
operator.floordiv(a, c)
# the operator module provides 2-argument arithmetic functions
# = 1.5
# = 1
# = 1.0
Possible combinations (builtin types):
int and int (gives an int in Python 2 and a float in Python 3)
int and float (gives a float)
int and complex (gives a complex)
float and float (gives a float)
float and complex (gives a complex)
complex and complex (gives a complex)
See PEP 238 for more information.
Section 9.2: Addition
a, b = 1, 2
# Using the "+" operator:
a + b
# = 3
GoalKicker.com – Python® Notes for Professionals
58# Using the "in-place" "+=" operator to add and assign:
a += b
# a = 3 (equivalent to a = a + b)
import operator# contains 2 argument arithmetic functions for the examples
operator.add(a, b)# = 5
since a is set to 3 right before this line
# The "+=" operator is equivalent to:
a = operator.iadd(a, b)
# a = 5 since a is set to 3 right before this line
Possible combinations (builtin types):
int and int (gives an int)
int and float (gives a float)
int and complex (gives a complex)
float and float (gives a float)
float and complex (gives a complex)
complex and complex (gives a complex)
Note: the + operator is also used for concatenating strings, lists and tuples:
"first string " + "second string"# = 'first string second string'
[1, 2, 3] + [4, 5, 6]# = [1, 2, 3, 4, 5, 6]
Section 9.3: Exponentiation
a, b = 2, 3
(a ** b)
pow(a, b)# = 8
# = 8
import math
math.pow(a, b)# = 8.0 (always float; does not allow complex results)
import operator
operator.pow(a, b)# = 8
Another diﬀerence between the built-in pow and math.pow is that the built-in pow can accept three arguments:
a, b, c = 2, 3, 2
pow(2, 3, 2)
# 0, calculates (2 ** 3) % 2, but as per Python docs,
#
does so more efficiently
Special functions
The function math.sqrt(x) calculates the square root of x.
import math
import cmath
c = 4
math.sqrt(c)
cmath.sqrt(c)
# = 2.0 (always float; does not allow complex results)
# = (2+0j) (always complex)
To compute other roots, such as a cube root, raise the number to the reciprocal of the degree of the root. This
could be done with any of the exponential functions or operator.
GoalKicker.com – Python® Notes for Professionals
59import math
x = 8
math.pow(x, 1/3) # evaluates to 2.0
x**(1/3) # evaluates to 2.0
The function math.exp(x) computes e ** x.
math.exp(0)
math.exp(1)
# 1.0
# 2.718281828459045 (e)
The function math.expm1(x) computes e ** x - 1. When x is small, this gives signiﬁcantly better precision than
math.exp(x) - 1.
math.expm1(0)
# 0.0
math.exp(1e-6) - 1 # 1.0000004999621837e-06
math.expm1(1e-6)
# 1.0000005000001665e-06
# exact result
# 1.000000500000166666708333341666...
Section 9.4: Trigonometric Functions
a, b = 1, 2
import math
math.sin(a) # returns the sine of 'a' in radians
# Out: 0.8414709848078965
math.cosh(b) # returns the inverse hyperbolic cosine of 'b' in radians
# Out: 3.7621956910836314
math.atan(math.pi) # returns the arc tangent of 'pi' in radians
# Out: 1.2626272556789115
math.hypot(a, b) # returns the Euclidean norm, same as math.sqrt(a*a + b*b)
# Out: 2.23606797749979
Note that math.hypot(x, y) is also the length of the vector (or Euclidean distance) from the origin (0, 0)
to the point (x, y).
To compute the Euclidean distance between two points (x1, y1) & (x2, y2) you can use math.hypot as
follows
math.hypot(x2-x1, y2-y1)
To convert from radians -> degrees and degrees -> radians respectively use math.degrees and math.radians
math.degrees(a)
# Out: 57.29577951308232
math.radians(57.29577951308232)
# Out: 1.0
GoalKicker.com – Python® Notes for Professionals
60Section 9.5: Inplace Operations
It is common within applications to need to have code like this:
a = a + 1
or
a = a * 2
There is an eﬀective shortcut for these in place operations:
a += 1
# and
a *= 2
Any mathematic operator can be used before the '=' character to make an inplace operation:
-= decrement the variable in place
+= increment the variable in place
*= multiply the variable in place
/= divide the variable in place
//= ﬂoor divide the variable in place # Python 3
%= return the modulus of the variable in place
**= raise to a power in place
Other in place operators exist for the bitwise operators (^, | etc)
Section 9.6: Subtraction
a, b = 1, 2
# Using the "-" operator:
b - a
# = 1
import operator
operator.sub(b, a)
# contains 2 argument arithmetic functions
# = 1
Possible combinations (builtin types):
int and int (gives an int)
int and float (gives a float)
int and complex (gives a complex)
float and float (gives a float)
float and complex (gives a complex)
complex and complex (gives a complex)
Section 9.7: Multiplication
a, b = 2, 3
a * b
# = 6
import operator
GoalKicker.com – Python® Notes for Professionals
61operator.mul(a, b)
# = 6
Possible combinations (builtin types):
int and int (gives an int)
int and float (gives a float)
int and complex (gives a complex)
float and float (gives a float)
float and complex (gives a complex)
complex and complex (gives a complex)
Note: The * operator is also used for repeated concatenation of strings, lists, and tuples:
3 * 'ab' # = 'ababab'
3 * ('a', 'b') # = ('a', 'b', 'a', 'b', 'a', 'b')
Section 9.8: Logarithms
By default, the math.log function calculates the logarithm of a number, base e. You can optionally specify a base as
the second argument.
import math
import cmath
math.log(5)
# = 1.6094379124341003
# optional base argument. Default is math.e
math.log(5, math.e) # = 1.6094379124341003
cmath.log(5)
# = (1.6094379124341003+0j)
math.log(1000, 10)
# 3.0 (always returns float)
cmath.log(1000, 10) # (3+0j)
Special variations of the math.log function exist for diﬀerent bases.
# Logarithm base e - 1 (higher precision for low values)
math.log1p(5)
# = 1.791759469228055
# Logarithm base 2
math.log2(8)
# = 3.0
# Logarithm base 10
math.log10(100)
# = 2.0
cmath.log10(100)
# = (2+0j)
Section 9.9: Modulus
Like in many other languages, Python uses the % operator for calculating modulus.
3 % 4
10 % 2
6 % 4
# 3
# 0
# 2
Or by using the operator module:
import operator
operator.mod(3 , 4)
# 3
GoalKicker.com – Python® Notes for Professionals
62operator.mod(10 , 2)
operator.mod(6 , 4)
# 0
# 2
You can also use negative numbers.
-9 % 7
9 % -7
-9 % -7
# 5
# -5
# -2
If you need to ﬁnd the result of integer division and modulus, you can use the divmod function as a shortcut:
quotient, remainder = divmod(9, 4)
# quotient = 2, remainder = 1 as 4 * 2 + 1 == 9
GoalKicker.com – Python® Notes for Professionals
63VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 10: Bitwise Operators
Bitwise operations alter binary strings at the bit level. These operations are incredibly basic and are directly
supported by the processor. These few operations are necessary in working with device drivers, low-level graphics,
cryptography, and network communications. This section provides useful knowledge and examples of Python's
bitwise operators.
Section 10.1: Bitwise NOT
The ~ operator will ﬂip all of the bits in the number. Since computers use signed number representations — most
notably, the two's complement notation to encode negative binary numbers where negative numbers are written
with a leading one (1) instead of a leading zero (0).
This means that if you were using 8 bits to represent your two's-complement numbers, you would treat patterns
from 0000 0000 to 0111 1111 to represent numbers from 0 to 127 and reserve 1xxx xxxx to represent negative
numbers.
Eight-bit two's-complement numbers
Bits
Unsigned Value Two's-complement Value
0
0000 0000 0
0000 0001 11
0000 0010 22
0111 1110 126126
0111 1111 127127
1000 0000 128-128
1000 0001 129-127
1000 0010 130-126
1111 1110 254-2
1111 1111 255-1
In essence, this means that whereas 1010 0110 has an unsigned value of 166 (arrived at by adding (128 * 1) +
(64 * 0) + (32 * 1) + (16 * 0) + (8 * 0) + (4 * 1) + (2 * 1) + (1 * 0)), it has a two's-complement value
of -90 (arrived at by adding (128 * 1) - (64 * 0) - (32 * 1) - (16 * 0) - (8 * 0) - (4 * 1) - (2 * 1) -
(1 * 0), and complementing the value).
In this way, negative numbers range down to -128 (1000 0000). Zero (0) is represented as 0000 0000, and minus
one (-1) as 1111 1111.
In general, though, this means ~n = -n - 1.
# 0 = 0b0000 0000
~0
# Out: -1
# -1 = 0b1111 1111
# 1 = 0b0000 0001
~1
# Out: -2
# -2 = 1111 1110
# 2 = 0b0000 0010
~2
GoalKicker.com – Python® Notes for Professionals
65# Out: -3
# -3 = 0b1111 1101
# 123 = 0b0111 1011
~123
# Out: -124
# -124 = 0b1000 0100
Note, the overall eﬀect of this operation when applied to positive numbers can be summarized:
~n -> -|n+1|
And then, when applied to negative numbers, the corresponding eﬀect is:
~-n -> |n-1|
The following examples illustrate this last rule...
# -0 = 0b0000 0000
~-0
# Out: -1
# -1 = 0b1111 1111
# 0 is the obvious exception to this rule, as -0 == 0 always
# -1 = 0b1000 0001
~-1
# Out: 0
# 0 = 0b0000 0000
# -2 = 0b1111 1110
~-2
# Out: 1
# 1 = 0b0000 0001
# -123 = 0b1111 1011
~-123
# Out: 122
# 122 = 0b0111 1010
Section 10.2: Bitwise XOR (Exclusive OR)
The ^ operator will perform a binary XOR in which a binary 1 is copied if and only if it is the value of exactly one
operand. Another way of stating this is that the result is 1 only if the operands are diﬀerent. Examples include:
# 0 ^ 0 = 0
# 0 ^ 1 = 1
# 1 ^ 0 = 1
# 1 ^ 1 = 0
# 60 = 0b111100
# 30 = 0b011110
60 ^ 30
# Out: 34
# 34 = 0b100010
bin(60 ^ 30)
GoalKicker.com – Python® Notes for Professionals
66# Out: 0b100010
Section 10.3: Bitwise AND
The & operator will perform a binary AND, where a bit is copied if it exists in both operands. That means:
# 0 & 0 = 0
# 0 & 1 = 0
# 1 & 0 = 0
# 1 & 1 = 1
# 60 = 0b111100
# 30 = 0b011110
60 & 30
# Out: 28
# 28 = 0b11100
bin(60 & 30)
# Out: 0b11100
Section 10.4: Bitwise OR
The | operator will perform a binary "or," where a bit is copied if it exists in either operand. That means:
# 0 | 0 = 0
# 0 | 1 = 1
# 1 | 0 = 1
# 1 | 1 = 1
# 60 = 0b111100
# 30 = 0b011110
60 | 30
# Out: 62
# 62 = 0b111110
bin(60 | 30)
# Out: 0b111110
Section 10.5: Bitwise Left Shift
The << operator will perform a bitwise "left shift," where the left operand's value is moved left by the number of bits
given by the right operand.
# 2 = 0b10
2 << 2
# Out: 8
# 8 = 0b1000
bin(2 << 2)
# Out: 0b1000
Performing a left bit shift of 1 is equivalent to multiplication by 2:
7 << 1
# Out: 14
Performing a left bit shift of n is equivalent to multiplication by 2**n:
GoalKicker.com – Python® Notes for Professionals
673 << 4
# Out: 48
Section 10.6: Bitwise Right Shift
The >> operator will perform a bitwise "right shift," where the left operand's value is moved right by the number of
bits given by the right operand.
# 8 = 0b1000
8 >> 2
# Out: 2
# 2 = 0b10
bin(8 >> 2)
# Out: 0b10
Performing a right bit shift of 1 is equivalent to integer division by 2:
36 >> 1
# Out: 18
15 >> 1
# Out: 7
Performing a right bit shift of n is equivalent to integer division by 2**n:
48 >> 4
# Out: 3
59 >> 3
# Out: 7
Section 10.7: Inplace Operations
All of the Bitwise operators (except ~) have their own in place versions
a = 0b001
a &= 0b010
# a = 0b000
a = 0b001
a |= 0b010
# a = 0b011
a = 0b001
a <<= 2
# a = 0b100
a = 0b100
a >>= 2
# a = 0b001
a = 0b101
a ^= 0b011
# a = 0b110
GoalKicker.com – Python® Notes for Professionals
68Chapter 11: Boolean Operators
Section 11.1: `and` and `or` are not guaranteed to return a
boolean
When you use or, it will either return the ﬁrst value in the expression if it's true, else it will blindly return the second
value. I.e. or is equivalent to:
def or_(a, b):
if a:
return a
else:
return b
For and, it will return its ﬁrst value if it's false, else it returns the last value:
def and_(a, b):
if not a:
return a
else:
return b
Section 11.2: A simple example
In Python you can compare a single element using two binary operators--one on either side:
if 3.14 < x < 3.142:
print("x is near pi")
In many (most?) programming languages, this would be evaluated in a way contrary to regular math: (3.14 < x) <
3.142, but in Python it is treated like 3.14 < x and x < 3.142, just like most non-programmers would expect.
Section 11.3: Short-circuit evaluation
Python minimally evaluates Boolean expressions.
>>> def true_func():
...
print("true_func()")
...
return True
...
>>> def false_func():
...
print("false_func()")
...
return False
...
>>> true_func() or false_func()
true_func()
True
>>> false_func() or true_func()
false_func()
true_func()
True
>>> true_func() and false_func()
true_func()
false_func()
False
>>> false_func() and false_func()
GoalKicker.com – Python® Notes for Professionals
69false_func()
False
Section 11.4: and
Evaluates to the second argument if and only if both of the arguments are truthy. Otherwise evaluates to the ﬁrst
falsey argument.
x = True
y = True
z = x and y # z = True
x = True
y = False
z = x and y # z = False
x = False
y = True
z = x and y # z = False
x = False
y = False
z = x and y # z = False
x = 1
y = 1
z = x and y # z = y, so z = 1, see `and` and `or` are not guaranteed to be a boolean
x = 0
y = 1
z = x and y # z = x, so z = 0 (see above)
x = 1
y = 0
z = x and y # z = y, so z = 0 (see above)
x = 0
y = 0
z = x and y # z = x, so z = 0 (see above)
The 1's in the above example can be changed to any truthy value, and the 0's can be changed to any falsey value.
Section 11.5: or
Evaluates to the ﬁrst truthy argument if either one of the arguments is truthy. If both arguments are falsey,
evaluates to the second argument.
x = True
y = True
z = x or y # z = True
x = True
y = False
z = x or y # z = True
x = False
y = True
z = x or y # z = True
GoalKicker.com – Python® Notes for Professionals
70x = False
y = False
z = x or y # z = False
x = 1
y = 1
z = x or y # z = x, so z = 1, see `and` and `or` are not guaranteed to be a boolean
x = 1
y = 0
z = x or y # z = x, so z = 1 (see above)
x = 0
y = 1
z = x or y # z = y, so z = 1 (see above)
x = 0
y = 0
z = x or y # z = y, so z = 0 (see above)
The 1's in the above example can be changed to any truthy value, and the 0's can be changed to any falsey value.
Section 11.6: not
It returns the opposite of the following statement:
x = True
y = not x # y = False
x = False
y = not x # y = True
GoalKicker.com – Python® Notes for Professionals
71Chapter 12: Operator Precedence
Python operators have a set order of precedence, which determines what operators are evaluated ﬁrst in a
potentially ambiguous expression. For instance, in the expression 3 * 2 + 7, ﬁrst 3 is multiplied by 2, and then the
result is added to 7, yielding 13. The expression is not evaluated the other way around, because * has a higher
precedence than +.
Below is a list of operators by precedence, and a brief description of what they (usually) do.
Section 12.1: Simple Operator Precedence Examples in python
Python follows PEMDAS rule. PEMDAS stands for Parentheses, Exponents, Multiplication and Division, and Addition
and Subtraction.
Example:
>>> a, b, c, d = 2, 3, 5, 7
>>> a ** (b + c) # parentheses
256
>>> a * b ** c # exponent: same as `a * (b ** c)`
7776
>>> a + b * c / d # multiplication / division: same as `a + (b * c / d)`
4.142857142857142
Extras: mathematical rules hold, but not always:
>>> 300 / 300 * 200
200.0
>>> 300 * 200 / 300
200.0
>>> 1e300 / 1e300 * 1e200
1e+200
>>> 1e300 * 1e200 / 1e300
inf
GoalKicker.com – Python® Notes for Professionals
72Chapter 13: Variable Scope and Binding
Section 13.1: Nonlocal Variables
Python 3.x Version ≥ 3.0
Python 3 added a new keyword called nonlocal. The nonlocal keyword adds a scope override to the inner scope.
You can read all about it in PEP 3104. This is best illustrated with a couple of code examples. One of the most
common examples is to create function that can increment:
def counter():
num = 0
def incrementer():
num += 1
return num
return incrementer
If you try running this code, you will receive an UnboundLocalError because the num variable is referenced before
it is assigned in the innermost function. Let's add nonlocal to the mix:
def counter():
num = 0
def incrementer():
nonlocal num
num += 1
return num
return incrementer
c = counter()
c() # = 1
c() # = 2
c() # = 3
Basically nonlocal will allow you to assign to variables in an outer scope, but not a global scope. So you can't use
nonlocal in our counter function because then it would try to assign to a global scope. Give it a try and you will
quickly get a SyntaxError. Instead you must use nonlocal in a nested function.
(Note that the functionality presented here is better implemented using generators.)
Section 13.2: Global Variables
In Python, variables inside functions are considered local if and only if they appear in the left side of an assignment
statement, or some other binding occurrence; otherwise such a binding is looked up in enclosing functions, up to
the global scope. This is true even if the assignment statement is never executed.
x = 'Hi'
def read_x():
print(x)# x is just referenced, therefore assumed global
read_x()# prints Hi
def read_y():
print(y)# here y is just referenced, therefore assumed global
GoalKicker.com – Python® Notes for Professionals
73read_y()# NameError: global name 'y' is not defined
def read_y():
y = 'Hey'
print(y)# y appears in an assignment, therefore it's local
# will find the local y
read_y()# prints Hey
def read_x_local_fail():
if False:
x = 'Hey' # x appears in an assignment, therefore it's local
print(x)
# will look for the _local_ z, which is not assigned, and will not be found
read_x_local_fail()
# UnboundLocalError: local variable 'x' referenced before assignment
Normally, an assignment inside a scope will shadow any outer variables of the same name:
x = 'Hi'
def change_local_x():
x = 'Bye'
print(x)
change_local_x() # prints Bye
print(x) # prints Hi
Declaring a name global means that, for the rest of the scope, any assignments to the name will happen at the
module's top level:
x = 'Hi'
def change_global_x():
global x
x = 'Bye'
print(x)
change_global_x() # prints Bye
print(x) # prints Bye
The global keyword means that assignments will happen at the module's top level, not at the program's top level.
Other modules will still need the usual dotted access to variables within the module.
To summarize: in order to know whether a variable x is local to a function, you should read the entire function:
1. if you've found global x, then x is a global variable
2. If you've found nonlocal x, then x belongs to an enclosing function, and is neither local nor global
3. If you've found x = 5 or for x in range(3) or some other binding, then x is a local variable
4. Otherwise x belongs to some enclosing scope (function scope, global scope, or builtins)
Section 13.3: Local Variables
If a name is bound inside a function, it is by default accessible only within the function:
def foo():
a = 5
print(a) # ok
print(a) #
NameError: name 'a' is not defined
GoalKicker.com – Python® Notes for Professionals
74Control ﬂow constructs have no impact on the scope (with the exception of except), but accessing variable that was
not assigned yet is an error:
def foo():
if True:
a = 5
print(a) # ok
b = 3
def bar():
if False:
b = 5
print(b) # UnboundLocalError: local variable 'b' referenced before assignment
Common binding operations are assignments, for loops, and augmented assignments such as a += 5
Section 13.4: The del command
This command has several related yet distinct forms.
del v
If v is a variable, the command del v removes the variable from its scope. For example:
x = 5
print(x) # out: 5
del x
print(x) # NameError: name 'f' is not defined
Note that del is a binding occurrence, which means that unless explicitly stated otherwise (using nonlocal
or global), del v will make v local to the current scope. If you intend to delete v in an outer scope, use
nonlocal v or global v in the same scope of the del v statement.
In all the following, the intention of a command is a default behavior but is not enforced by the language. A class
might be written in a way that invalidates this intention.
del v.name
This command triggers a call to v.__delattr__(name).
The intention is to make the attribute name unavailable. For example:
class A:
pass
a = A()
a.x = 7
print(a.x) # out: 7
del a.x
print(a.x) # error: AttributeError: 'A' object has no attribute 'x'
del v[item]
This command triggers a call to v.__delitem__(item).
The intention is that item will not belong in the mapping implemented by the object v. For example:
GoalKicker.com – Python® Notes for Professionals
75x = {'a': 1, 'b': 2}
del x['a']
print(x) # out: {'b': 2}
print(x['a']) # error: KeyError: 'a'
del v[a:b]
This actually calls v.__delslice__(a, b).
The intention is similar to the one described above, but with slices - ranges of items instead of a single item. For
example:
x = [0, 1, 2, 3, 4]
del x[1:3]
print(x) # out: [0, 3, 4]
See also Garbage Collection#The del command.
Section 13.5: Functions skip class scope when looking up
names
Classes have a local scope during deﬁnition, but functions inside the class do not use that scope when looking up
names. Because lambdas are functions, and comprehensions are implemented using function scope, this can lead
to some surprising behavior.
a = 'global'
class Fred:
a = 'class' # class scope
b = (a for i in range(10)) # function scope
c = [a for i in range(10)] # function scope
d = a # class scope
e = lambda: a # function scope
f = lambda a=a: a # default argument uses class scope
@staticmethod # or @classmethod, or regular instance method
def g(): # function scope
return a
print(Fred.a) # class
print(next(Fred.b)) # global
print(Fred.c[0]) # class in Python 2, global in Python 3
print(Fred.d) # class
print(Fred.e()) # global
print(Fred.f()) # class
print(Fred.g()) # global
Users unfamiliar with how this scope works might expect b, c, and e to print class.
From PEP 227:
Names in class scope are not accessible. Names are resolved in the innermost enclosing function scope.
If a class deﬁnition occurs in a chain of nested scopes, the resolution process skips class deﬁnitions.
From Python's documentation on naming and binding:
GoalKicker.com – Python® Notes for Professionals
76The scope of names deﬁned in a class block is limited to the class block; it does not extend to the code
blocks of methods – this includes comprehensions and generator expressions since they are
implemented using a function scope. This means that the following will fail:
class A:
a = 42
b = list(a + i for i in range(10))
This example uses references from this answer by Martijn Pieters, which contains more in depth analysis of this
behavior.
Section 13.6: Local vs Global Scope
What are local and global scope?
All Python variables which are accessible at some point in code are either in local scope or in global scope.
The explanation is that local scope includes all variables deﬁned in the current function and global scope includes
variables deﬁned outside of the current function.
foo = 1
# global
def func():
bar = 2 # local
print(foo) # prints variable foo from global scope
print(bar) # prints variable bar from local scope
One can inspect which variables are in which scope. Built-in functions locals() and globals() return the whole
scopes as dictionaries.
foo = 1
def func():
bar = 2
print(globals().keys()) # prints all variable names in global scope
print(locals().keys()) # prints all variable names in local scope
What happens with name clashes?
foo = 1
def func():
foo = 2
# creates a new variable foo in local scope, global foo is not affected
print(foo)
# prints 2
# global variable foo still exists, unchanged:
print(globals()['foo']) # prints 1
print(locals()['foo']) # prints 2
To modify a global variable, use keyword global:
foo = 1
def func():
global foo
foo = 2 # this modifies the global foo, rather than creating a local variable
GoalKicker.com – Python® Notes for Professionals
77The scope is deﬁned for the whole body of the function!
What it means is that a variable will never be global for a half of the function and local afterwards, or vice-versa.
foo = 1
def func():
# This function has a local variable foo, because it is defined down below.
# So, foo is local from this point. Global foo is hidden.
print(foo) # raises UnboundLocalError, because local foo is not yet initialized
foo = 7
print(foo)
Likewise, the opposite:
foo = 1
def func():
# In this function, foo is a global variable from the beginning
foo = 7
# global foo is modified
print(foo) # 7
print(globals()['foo'])
global foo
print(foo)
# 7
# this could be anywhere within the function
# 7
Functions within functions
There may be many levels of functions nested within functions, but within any one function there is only one local
scope for that function and the global scope. There are no intermediate scopes.
foo = 1
def f1():
bar = 1
def f2():
baz = 2
# here, foo is a global variable, baz is a local variable
# bar is not in either scope
print(locals().keys()) # ['baz']
print('bar' in locals()) # False
print('bar' in globals()) # False
def f3():
baz = 3
print(bar) # bar from f1 is referenced so it enters local scope of f3 (closure)
print(locals().keys()) # ['bar', 'baz']
print('bar' in locals()) # True
print('bar' in globals()) # False
def f4():
bar = 4 # a new local bar which hides bar from local scope of f1
baz = 4
print(bar)
print(locals().keys()) # ['bar', 'baz']
print('bar' in locals()) # True
GoalKicker.com – Python® Notes for Professionals
78print('bar' in globals())
# False
global vs nonlocal (Python 3 only)
Both these keywords are used to gain write access to variables which are not local to the current functions.
The global keyword declares that a name should be treated as a global variable.
foo = 0
# global foo
def f1():
foo = 1
# a new foo local in f1
def f2():
foo = 2
# a new foo local in f2
def f3():
foo = 3 # a new foo local in f3
print(foo) # 3
foo = 30 # modifies local foo in f3 only
def f4():
global foo
print(foo) # 0
foo = 100 # modifies global foo
On the other hand, nonlocal (see Nonlocal Variables ), available in Python 3, takes a local variable from an
enclosing scope into the local scope of current function.
From the Python documentation on nonlocal:
The nonlocal statement causes the listed identiﬁers to refer to previously bound variables in the nearest
enclosing scope excluding globals.
Python 3.x Version ≥ 3.0
def f1():
def f2():
foo = 2
# a new foo local in f2
def f3():
nonlocal foo # foo from f2, which is the nearest enclosing scope
print(foo) # 2
foo = 20 # modifies foo from f2!
Section 13.7: Binding Occurrence
x = 5
x += 7
for x in iterable: pass
Each of the above statements is a binding occurrence - x become bound to the object denoted by 5. If this statement
appears inside a function, then x will be function-local by default. See the "Syntax" section for a list of binding
statements.
GoalKicker.com – Python® Notes for Professionals
79Chapter 14: Conditionals
Conditional expressions, involving keywords such as if, elif, and else, provide Python programs with the ability to
perform diﬀerent actions depending on a boolean condition: True or False. This section covers the use of Python
conditionals, boolean logic, and ternary statements.
Section 14.1: Conditional Expression (or "The Ternary
Operator")
The ternary operator is used for inline conditional expressions. It is best used in simple, concise operations that are
easily read.
The order of the arguments is diﬀerent from many other languages (such as C, Ruby, Java, etc.), which may
lead to bugs when people unfamiliar with Python's "surprising" behaviour use it (they may reverse the order).
Some ﬁnd it "unwieldy", since it goes contrary to the normal ﬂow of thought (thinking of the condition ﬁrst
and then the eﬀects).
n = 5
"Greater than 2" if n > 2 else "Smaller than or equal to 2"
# Out: 'Greater than 2'
The result of this expression will be as it is read in English - if the conditional expression is True, then it will evaluate
to the expression on the left side, otherwise, the right side.
Ternary operations can also be nested, as here:
n = 5
"Hello" if n > 10 else "Goodbye" if n > 5 else "Good day"
They also provide a method of including conditionals in lambda functions.
Section 14.2: if, elif, and else
In Python you can deﬁne a series of conditionals using if for the ﬁrst one, elif for the rest, up until the ﬁnal
(optional) else for anything not caught by the other conditionals.
number = 5
if number > 2:
print("Number is bigger than 2.")
elif number < 2: # Optional clause (you can have multiple elifs)
print("Number is smaller than 2.")
else: # Optional clause (you can only have one else)
print("Number is 2.")
Outputs Number is bigger than 2
Using else if instead of elif will trigger a syntax error and is not allowed.
Section 14.3: Truth Values
The following values are considered falsey, in that they evaluate to False when applied to a boolean operator.
GoalKicker.com – Python® Notes for Professionals
80None
False
0, or any numerical value equivalent to zero, for example 0L, 0.0, 0j
Empty sequences: '', "", (), []
Empty mappings: {}
User-deﬁned types where the __bool__ or __len__ methods return 0 or False
All other values in Python evaluate to True.
Note: A common mistake is to simply check for the Falseness of an operation which returns diﬀerent Falsey values
where the diﬀerence matters. For example, using if foo() rather than the more explicit if foo() is None
Section 14.4: Boolean Logic Expressions
Boolean logic expressions, in addition to evaluating to True or False, return the value that was interpreted as True
or False. It is Pythonic way to represent logic that might otherwise require an if-else test.
And operator
The and operator evaluates all expressions and returns the last expression if all expressions evaluate to True.
Otherwise it returns the ﬁrst value that evaluates to False:
>>> 1 and 2
2
>>> 1 and 0
0
>>> 1 and "Hello World"
"Hello World"
>>> "" and "Pancakes"
""
Or operator
The or operator evaluates the expressions left to right and returns the ﬁrst value that evaluates to True or the last
value (if none are True).
>>> 1 or 2
1
>>> None or 1
1
>>> 0 or []
[]
Lazy evaluation
When you use this approach, remember that the evaluation is lazy. Expressions that are not required to be
evaluated to determine the result are not evaluated. For example:
GoalKicker.com – Python® Notes for Professionals
81>>> def print_me():
print('I am here!')
>>> 0 and print_me()
0
In the above example, print_me is never executed because Python can determine the entire expression is False
when it encounters the 0 (False). Keep this in mind if print_me needs to execute to serve your program logic.
Testing for multiple conditions
A common mistake when checking for multiple conditions is to apply the logic incorrectly.
This example is trying to check if two variables are each greater than 2. The statement is evaluated as - if (a) and
(b > 2). This produces an unexpected result because bool(a) evaluates as True when a is not zero.
>>> a = 1
>>> b = 6
>>> if a and b > 2:
...
print('yes')
... else:
...
print('no')
yes
Each variable needs to be compared separately.
>>> if a > 2 and b > 2:
...
print('yes')
... else:
...
print('no')
no
Another, similar, mistake is made when checking if a variable is one of multiple values. The statement in this
example is evaluated as - if (a == 3) or (4) or (6). This produces an unexpected result because bool(4) and
bool(6) each evaluate to True
>>> a = 1
>>> if a == 3 or 4 or 6:
...
print('yes')
... else:
...
print('no')
yes
Again each comparison must be made separately
>>> if a == 3 or a == 4 or a == 6:
...
print('yes')
... else:
...
print('no')
no
Using the in operator is the canonical way to write this.
GoalKicker.com – Python® Notes for Professionals
82>>> if a in (3, 4, 6):
...
print('yes')
... else:
...
print('no')
no
Section 14.5: Using the cmp function to get the comparison
result of two objects
Python 2 includes a cmp function which allows you to determine if one object is less than, equal to, or greater than
another object. This function can be used to pick a choice out of a list based on one of those three options.
Suppose you need to print 'greater than' if x > y, 'less than' if x < y and 'equal' if x == y.
['equal', 'greater than', 'less than', ][cmp(x,y)]
# x,y = 1,1 output: 'equal'
# x,y = 1,2 output: 'less than'
# x,y = 2,1 output: 'greater than'
cmp(x,y) returns the following values
Comparison Result
x<y
-1
x == y0
x>y1
This function is removed on Python 3. You can use the cmp_to_key(func) helper function located in functools in
Python 3 to convert old comparison functions to key functions.
Section 14.6: Else statement
if condition:
body
else:
body
The else statement will execute it's body only if preceding conditional statements all evaluate to False.
if True:
print "It is true!"
else:
print "This won't get printed.."
# Output: It is true!
if False:
print "This won't get printed.."
else:
print "It is false!"
# Output: It is false!
GoalKicker.com – Python® Notes for Professionals
83Section 14.7: Testing if an object is None and assigning it
You'll often want to assign something to an object if it is None, indicating it has not been assigned. We'll use aDate.
The simplest way to do this is to use the is None test.
if aDate is None:
aDate=datetime.date.today()
(Note that it is more Pythonic to say is None instead of == None.)
But this can be optimized slightly by exploiting the notion that not None will evaluate to True in a boolean
expression. The following code is equivalent:
if not aDate:
aDate=datetime.date.today()
But there is a more Pythonic way. The following code is also equivalent:
aDate=aDate or datetime.date.today()
This does a Short Circuit evaluation. If aDate is initialized and is not None, then it gets assigned to itself with no net
eﬀect. If it is None, then the datetime.date.today() gets assigned to aDate.
Section 14.8: If statement
if condition:
body
The if statements checks the condition. If it evaluates to True, it executes the body of the if statement. If it
evaluates to False, it skips the body.
if True:
print "It is true!"
>> It is true!
if False:
print "This won't get printed.."
The condition can be any valid expression:
if 2 + 2 == 4:
print "I know math!"
>> I know math!
GoalKicker.com – Python® Notes for Professionals
84VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 15: Comparisons
Parameter
Details
x
First item to be compared
y
Second item to be compared
Section 15.1: Chain Comparisons
You can compare multiple items with multiple comparison operators with chain comparison. For example
x > y > z
is just a short form of:
x > y and y > z
This will evaluate to True only if both comparisons are True.
The general form is
a OP b OP c OP d ...
Where OP represents one of the multiple comparison operations you can use, and the letters represent arbitrary
valid expressions.
Note that 0 != 1 != 0 evaluates to True, even though 0 != 0 is False. Unlike the common mathematical
notation in which x != y != z means that x, y and z have diﬀerent values. Chaining == operations has
the natural meaning in most cases, since equality is generally transitive.
Style
There is no theoretical limit on how many items and comparison operations you use as long you have proper
syntax:
1 > -1 < 2 > 0.5 < 100 != 24
The above returns True if each comparison returns True. However, using convoluted chaining is not a good style. A
good chaining will be "directional", not more complicated than
1 > x > -4 > y != 8
Side eﬀects
As soon as one comparison returns False, the expression evaluates immediately to False, skipping all remaining
comparisons.
Note that the expression exp in a > exp > b will be evaluated only once, whereas in the case of
a > exp and exp > b
exp will be computed twice if a > exp is true.
GoalKicker.com – Python® Notes for Professionals
86Section 15.2: Comparison by `is` vs `==`
A common pitfall is confusing the equality comparison operators is and ==.
a == b compares the value of a and b.
a is b will compare the identities of a and b.
To illustrate:
a = 'Python is fun!'
b = 'Python is fun!'
a == b # returns True
a is b # returns False
a = [1, 2, 3, 4, 5]
b = a
# b references a
a == b
# True
a is b
# True
b = a[:]
# b now references a copy of a
a == b
# True
a is b
# False [!!]
Basically, is can be thought of as shorthand for id(a) == id(b).
Beyond this, there are quirks of the run-time environment that further complicate things. Short strings and small
integers will return True when compared with is, due to the Python machine attempting to use less memory for
identical objects.
a = 'short'
b = 'short'
c = 5
d = 5
a is b # True
c is d # True
But longer strings and larger integers will be stored separately.
a = 'not so short'
b = 'not so short'
c = 1000
d = 1000
a is b # False
c is d # False
You should use is to test for None:
if myvar is not None:
# not None
pass
if myvar is None:
# None
pass
A use of is is to test for a “sentinel” (i.e. a unique object).
sentinel = object()
def myfunc(var=sentinel):
GoalKicker.com – Python® Notes for Professionals
87if var is sentinel:
# value wasn’t provided
pass
else:
# value was provided
pass
Section 15.3: Greater than or less than
x > y
x < y
These operators compare two types of values, they're the less than and greater than operators. For numbers this
simply compares the numerical values to see which is larger:
12 > 4
# True
12 < 4
# False
1 < 4
# True
For strings they will compare lexicographically, which is similar to alphabetical order but not quite the same.
"alpha" < "beta"
# True
"gamma" > "beta"
# True
"gamma" < "OMEGA"
# False
In these comparisons, lowercase letters are considered 'greater than' uppercase, which is why "gamma" < "OMEGA"
is false. If they were all uppercase it would return the expected alphabetical ordering result:
"GAMMA" < "OMEGA"
# True
Each type deﬁnes it's calculation with the < and > operators diﬀerently, so you should investigate what the
operators mean with a given type before using it.
Section 15.4: Not equal to
x != y
This returns True if x and y are not equal and otherwise returns False.
12 != 1
# True
12 != '12'
# True
'12' != '12'
# False
GoalKicker.com – Python® Notes for Professionals
88Section 15.5: Equal To
x == y
This expression evaluates if x and y are the same value and returns the result as a boolean value. Generally both
type and value need to match, so the int 12 is not the same as the string '12'.
12 == 12
# True
12 == 1
# False
'12' == '12'
# True
'spam' == 'spam'
# True
'spam' == 'spam '
# False
'12' == 12
# False
Note that each type has to deﬁne a function that will be used to evaluate if two values are the same. For builtin
types these functions behave as you'd expect, and just evaluate things based on being the same value. However
custom types could deﬁne equality testing as whatever they'd like, including always returning True or always
returning False.
Section 15.6: Comparing Objects
In order to compare the equality of custom classes, you can override == and != by deﬁning __eq__ and __ne__
methods. You can also override __lt__ (<), __le__ (<=), __gt__ (>), and __ge__ (>). Note that you only need to
override two comparison methods, and Python can handle the rest (== is the same as not < and not >, etc.)
class Foo(object):
def __init__(self, item):
self.my_item = item
def __eq__(self, other):
return self.my_item == other.my_item
a = Foo(5)
b = Foo(5)
a == b
# True
a != b
# False
a is b
# False
Note that this simple comparison assumes that other (the object being compared to) is the same object type.
Comparing to another type will throw an error:
class Bar(object):
def __init__(self, item):
self.other_item = item
def __eq__(self, other):
return self.other_item == other.other_item
def __ne__(self, other):
return self.other_item != other.other_item
c = Bar(5)
a == c
# throws AttributeError: 'Foo' object has no attribute 'other_item'
GoalKicker.com – Python® Notes for Professionals
89Checking isinstance() or similar will help prevent this (if desired).
GoalKicker.com – Python® Notes for Professionals
90Chapter 16: Loops
Parameter
Details
boolean expression expression that can be evaluated in a boolean context, e.g. x < 10
variablevariable name for the current element from the iterable
iterableanything that implements iterations
As one of the most basic functions in programming, loops are an important piece to nearly every programming
language. Loops enable developers to set certain portions of their code to repeat through a number of loops which
are referred to as iterations. This topic covers using multiple types of loops and applications of loops in Python.
Section 16.1: Break and Continue in Loops
break statement
When a break statement executes inside a loop, control ﬂow "breaks" out of the loop immediately:
i = 0
while i < 7:
print(i)
if i == 4:
print("Breaking from loop")
break
i += 1
The loop conditional will not be evaluated after the break statement is executed. Note that break statements are
only allowed inside loops, syntactically. A break statement inside a function cannot be used to terminate loops that
called that function.
Executing the following prints every digit until number 4 when the break statement is met and the loop stops:
0
1
2
3
4
Breaking from loop
break statements can also be used inside for loops, the other looping construct provided by Python:
for i in (0, 1, 2, 3, 4):
print(i)
if i == 2:
break
Executing this loop now prints:
0
1
2
Note that 3 and 4 are not printed since the loop has ended.
GoalKicker.com – Python® Notes for Professionals
91If a loop has an else clause, it does not execute when the loop is terminated through a break statement.
continue statement
A continue statement will skip to the next iteration of the loop bypassing the rest of the current block but
continuing the loop. As with break, continue can only appear inside loops:
for i in (0, 1, 2, 3, 4, 5):
if i == 2 or i == 4:
continue
print(i)
0
1
3
5
Note that 2 and 4 aren't printed, this is because continue goes to the next iteration instead of continuing on to
print(i) when i == 2 or i == 4.
Nested Loops
break and continue only operate on a single level of loop. The following example will only break out of the inner
for loop, not the outer while loop:
while True:
for i in range(1,5):
if i == 2:
break
# Will only break out of the inner loop!
Python doesn't have the ability to break out of multiple levels of loop at once -- if this behavior is desired,
refactoring one or more loops into a function and replacing break with return may be the way to go.
Use return from within a function as a break
The return statement exits from a function, without executing the code that comes after it.
If you have a loop inside a function, using return from inside that loop is equivalent to having a break as the rest of
the code of the loop is not executed (note that any code after the loop is not executed either):
def break_loop():
for i in range(1, 5):
if (i == 2):
return(i)
print(i)
return(5)
If you have nested loops, the return statement will break all loops:
def break_all():
for j in range(1, 5):
for i in range(1,4):
if i*j == 6:
return(i)
print(i*j)
will output:
GoalKicker.com – Python® Notes for Professionals
921 # 1*1
2 # 1*2
3 # 1*3
4 # 1*4
2 # 2*1
4 # 2*2
# return because 2*3 = 6, the remaining iterations of both loops are not executed
Section 16.2: For loops
for loops iterate over a collection of items, such as list or dict, and run a block of code with each element from
the collection.
for i in [0, 1, 2, 3, 4]:
print(i)
The above for loop iterates over a list of numbers.
Each iteration sets the value of i to the next element of the list. So ﬁrst it will be 0, then 1, then 2, etc. The output
will be as follow:
0
1
2
3
4
range is a function that returns a series of numbers under an iterable form, thus it can be used in for loops:
for i in range(5):
print(i)
gives the exact same result as the ﬁrst for loop. Note that 5 is not printed as the range here is the ﬁrst ﬁve
numbers counting from 0.
Iterable objects and iterators
for loop can iterate on any iterable object which is an object which deﬁnes a __getitem__ or a __iter__ function.
The __iter__ function returns an iterator, which is an object with a next function that is used to access the next
element of the iterable.
Section 16.3: Iterating over lists
To iterate through a list you can use for:
for x in ['one', 'two', 'three', 'four']:
print(x)
This will print out the elements of the list:
one
two
three
four
GoalKicker.com – Python® Notes for Professionals
93The range function generates numbers which are also often used in a for loop.
for x in range(1, 6):
print(x)
The result will be a special range sequence type in python >=3 and a list in python <=2. Both can be looped through
using the for loop.
1
2
3
4
5
If you want to loop though both the elements of a list and have an index for the elements as well, you can use
Python's enumerate function:
for index, item in enumerate(['one', 'two', 'three', 'four']):
print(index, '::', item)
enumerate will generate tuples, which are unpacked into index (an integer) and item (the actual value from the list).
The above loop will print
(0, '::', 'one')
(1, '::', 'two')
(2, '::', 'three')
(3, '::', 'four')
Iterate over a list with value manipulation using map and lambda, i.e. apply lambda function on each element in the
list:
x = map(lambda e :
print(x)
e.upper(), ['one', 'two', 'three', 'four'])
Output:
['ONE', 'TWO', 'THREE', 'FOUR'] # Python 2.x
NB: in Python 3.x map returns an iterator instead of a list so you in case you need a list you have to cast the result
print(list(x))
Section 16.4: Loops with an "else" clause
The for and while compound statements (loops) can optionally have an else clause (in practice, this usage is fairly
rare).
The else clause only executes after a for loop terminates by iterating to completion, or after a while loop
terminates by its conditional expression becoming false.
for i in range(3):
print(i)
else:
print('done')
i = 0
GoalKicker.com – Python® Notes for Professionals
94while i < 3:
print(i)
i += 1
else:
print('done')
output:
0
1
2
done
The else clause does not execute if the loop terminates some other way (through a break statement or by raising
an exception):
for i in range(2):
print(i)
if i == 1:
break
else:
print('done')
output:
0
1
Most other programming languages lack this optional else clause of loops. The use of the keyword else in
particular is often considered confusing.
The original concept for such a clause dates back to Donald Knuth and the meaning of the else keyword becomes
clear if we rewrite a loop in terms of if statements and goto statements from earlier days before structured
programming or from a lower-level assembly language.
For example:
while loop_condition():
...
if break_condition():
break
...
is equivalent to:
# pseudocode
<<start>>:
if loop_condition():
...
if break_condition():
goto <<end>>
...
goto <<start>>
GoalKicker.com – Python® Notes for Professionals
95<<end>>:
These remain equivalent if we attach an else clause to each of them.
For example:
while loop_condition():
...
if break_condition():
break
...
else:
print('done')
is equivalent to:
# pseudocode
<<start>>:
if loop_condition():
...
if break_condition():
goto <<end>>
...
goto <<start>>
else:
print('done')
<<end>>:
A for loop with an else clause can be understood the same way. Conceptually, there is a loop condition that
remains True as long as the iterable object or sequence still has some remaining elements.
Why would one use this strange construct?
The main use case for the for...else construct is a concise implementation of search as for instance:
a = [1, 2, 3, 4]
for i in a:
if type(i) is not int:
print(i)
break
else:
print("no exception")
To make the else in this construct less confusing one can think of it as "if not break" or "if not found".
Some discussions on this can be found in [Python-ideas] Summary of for...else threads, Why does python use 'else'
after for and while loops? , and Else Clauses on Loop Statements
Section 16.5: The Pass Statement
pass is a null statement for when a statement is required by Python syntax (such as within the body of a for or
while loop), but no action is required or desired by the programmer. This can be useful as a placeholder for code
that is yet to be written.
for x in range(10):
GoalKicker.com – Python® Notes for Professionals
96pass #we don't want to do anything, or are not ready to do anything here, so we'll pass
In this example, nothing will happen. The for loop will complete without error, but no commands or code will be
actioned. pass allows us to run our code successfully without having all commands and action fully implemented.
Similarly, pass can be used in while loops, as well as in selections and function deﬁnitions etc.
while x == y:
pass
Section 16.6: Iterating over dictionaries
Considering the following dictionary:
d = {"a": 1, "b": 2, "c": 3}
To iterate through its keys, you can use:
for key in d:
print(key)
Output:
"a"
"b"
"c"
This is equivalent to:
for key in d.keys():
print(key)
or in Python 2:
for key in d.iterkeys():
print(key)
To iterate through its values, use:
for value in d.values():
print(value)
Output:
1
2
3
To iterate through its keys and values, use:
for key, value in d.items():
print(key, "::", value)
Output:
GoalKicker.com – Python® Notes for Professionals
97a :: 1
b :: 2
c :: 3
Note that in Python 2, .keys(), .values() and .items() return a list object. If you simply need to iterate through
the result, you can use the equivalent .iterkeys(), .itervalues() and .iteritems().
The diﬀerence between .keys() and .iterkeys(), .values() and .itervalues(), .items() and .iteritems() is
that the iter* methods are generators. Thus, the elements within the dictionary are yielded one by one as they are
evaluated. When a list object is returned, all of the elements are packed into a list and then returned for further
evaluation.
Note also that in Python 3, Order of items printed in the above manner does not follow any order.
Section 16.7: The "half loop" do-while
Unlike other languages, Python doesn't have a do-until or a do-while construct (this will allow code to be executed
once before the condition is tested). However, you can combine a while True with a break to achieve the same
purpose.
a = 10
while True:
a = a-1
print(a)
if a<7:
break
print('Done.')
This will print:
9
8
7
6
Done.
Section 16.8: Looping and Unpacking
If you want to loop over a list of tuples for example:
collection = [('a', 'b', 'c'), ('x', 'y', 'z'), ('1', '2', '3')]
instead of doing something like this:
for item in collection:
i1 = item[0]
i2 = item[1]
i3 = item[2]
# logic
or something like this:
for item in collection:
GoalKicker.com – Python® Notes for Professionals
98i1, i2, i3 = item
# logic
You can simply do this:
for i1, i2, i3 in collection:
# logic
This will also work for most types of iterables, not just tuples.
Section 16.9: Iterating dierent portion of a list with dierent
step size
Suppose you have a long list of elements and you are only interested in every other element of the list. Perhaps you
only want to examine the ﬁrst or last elements, or a speciﬁc range of entries in your list. Python has strong indexing
built-in capabilities. Here are some examples of how to achieve these scenarios.
Here's a simple list that will be used throughout the examples:
lst = ['alpha', 'bravo', 'charlie', 'delta', 'echo']
Iteration over the whole list
To iterate over each element in the list, a for loop like below can be used:
for s in lst:
print s[:1] # print the first letter
The for loop assigns s for each element of lst. This will print:
a
b
c
d
e
Often you need both the element and the index of that element. The enumerate keyword performs that task.
for idx, s in enumerate(lst):
print("%s has an index of %d" % (s, idx))
The index idx will start with zero and increment for each iteration, while the s will contain the element being
processed. The previous snippet will output:
alpha has an index of 0
bravo has an index of 1
charlie has an index of 2
delta has an index of 3
echo has an index of 4
Iterate over sub-list
If we want to iterate over a range (remembering that Python uses zero-based indexing), use the range keyword.
GoalKicker.com – Python® Notes for Professionals
99for i in range(2,4):
print("lst at %d contains %s" % (i, lst[i]))
This would output:
lst at 2 contains charlie
lst at 3 contains delta
The list may also be sliced. The following slice notation goes from element at index 1 to the end with a step of 2.
The two for loops give the same result.
for s in lst[1::2]:
print(s)
for i in range(1, len(lst), 2):
print(lst[i])
The above snippet outputs:
bravo
delta
Indexing and slicing is a topic of its own.
Section 16.10: While Loop
A while loop will cause the loop statements to be executed until the loop condition is falsey. The following code will
execute the loop statements a total of 4 times.
i = 0
while i < 4:
#loop statements
i = i + 1
While the above loop can easily be translated into a more elegant for loop, while loops are useful for checking if
some condition has been met. The following loop will continue to execute until myObject is ready.
myObject = anObject()
while myObject.isNotReady():
myObject.tryToGetReady()
while loops can also run without a condition by using numbers (complex or real) or True:
import cmath
complex_num = cmath.sqrt(-1)
while complex_num:
# You can also replace complex_num with any number, True or a value of any
type
print(complex_num)
# Prints 1j forever
If the condition is always true the while loop will run forever (inﬁnite loop) if it is not terminated by a break or return
statement or an exception.
while True:
print "Infinite loop"
GoalKicker.com – Python® Notes for Professionals
100# Infinite loop
# Infinite loop
# Infinite loop
# ...
GoalKicker.com – Python® Notes for Professionals
101Chapter 17: Arrays
Parameter
bDetails
Represents signed integer of size 1 byte
BRepresents unsigned integer of size 1 byte
cRepresents character of size 1 byte
uRepresents unicode character of size 2 bytes
hRepresents signed integer of size 2 bytes
HRepresents unsigned integer of size 2 bytes
iRepresents signed integer of size 2 bytes
IRepresents unsigned integer of size 2 bytes
wRepresents unicode character of size 4 bytes
lRepresents signed integer of size 4 bytes
LRepresents unsigned integer of size 4 bytes
fRepresents ﬂoating point of size 4 bytes
dRepresents ﬂoating point of size 8 bytes
"Arrays" in Python are not the arrays in conventional programming languages like C and Java, but closer to lists. A
list can be a collection of either homogeneous or heterogeneous elements, and may contain ints, strings or other
lists.
Section 17.1: Access individual elements through indexes
Individual elements can be accessed through indexes. Python arrays are zero-indexed. Here is an example:
my_array = array('i', [1,2,3,4,5])
print(my_array[1])
# 2
print(my_array[2])
# 3
print(my_array[0])
# 1
Section 17.2: Basic Introduction to Arrays
An array is a data structure that stores values of same data type. In Python, this is the main diﬀerence between
arrays and lists.
While python lists can contain values corresponding to diﬀerent data types, arrays in python can only contain
values corresponding to same data type. In this tutorial, we will understand the Python arrays with few examples.
If you are new to Python, get started with the Python Introduction article.
To use arrays in python language, you need to import the standard array module. This is because array is not a
fundamental data type like strings, integer etc. Here is how you can import array module in python :
from array import *
Once you have imported the array module, you can declare an array. Here is how you do it:
arrayIdentifierName = array(typecode, [Initializers])
GoalKicker.com – Python® Notes for Professionals
102In the declaration above, arrayIdentifierName is the name of array, typecode lets python know the type of array
and Initializers are the values with which array is initialized.
Typecodes are the codes that are used to deﬁne the type of array values or the type of array. The table in the
parameters section shows the possible values you can use when declaring an array and it's type.
Here is a real world example of python array declaration :
my_array = array('i',[1,2,3,4])
In the example above, typecode used is i. This typecode represents signed integer whose size is 2 bytes.
Here is a simple example of an array containing 5 integers
from array import *
my_array = array('i', [1,2,3,4,5])
for i in my_array:
print(i)
# 1
# 2
# 3
# 4
# 5
Section 17.3: Append any value to the array using append()
method
my_array = array('i', [1,2,3,4,5])
my_array.append(6)
# array('i', [1, 2, 3, 4, 5, 6])
Note that the value 6 was appended to the existing array values.
Section 17.4: Insert value in an array using insert() method
We can use the insert() method to insert a value at any index of the array. Here is an example :
my_array = array('i', [1,2,3,4,5])
my_array.insert(0,0)
#array('i', [0, 1, 2, 3, 4, 5])
In the above example, the value 0 was inserted at index 0. Note that the ﬁrst argument is the index while second
argument is the value.
Section 17.5: Extend python array using extend() method
A python array can be extended with more than one value using extend() method. Here is an example :
my_array = array('i', [1,2,3,4,5])
my_extnd_array = array('i', [7,8,9,10])
my_array.extend(my_extnd_array)
# array('i', [1, 2, 3, 4, 5, 7, 8, 9, 10])
We see that the array my_array was extended with values from my_extnd_array.
GoalKicker.com – Python® Notes for Professionals
103Section 17.6: Add items from list into array using fromlist()
method
Here is an example:
my_array = array('i', [1,2,3,4,5])
c=[11,12,13]
my_array.fromlist(c)
# array('i', [1, 2, 3, 4, 5, 11, 12, 13])
So we see that the values 11,12 and 13 were added from list c to my_array.
Section 17.7: Remove any array element using remove()
method
Here is an example :
my_array = array('i', [1,2,3,4,5])
my_array.remove(4)
# array('i', [1, 2, 3, 5])
We see that the element 4 was removed from the array.
Section 17.8: Remove last array element using pop() method
pop removes the last element from the array. Here is an example :
my_array = array('i', [1,2,3,4,5])
my_array.pop()
# array('i', [1, 2, 3, 4])
So we see that the last element (5) was popped out of array.
Section 17.9: Fetch any element through its index using index()
method
index() returns ﬁrst index of the matching value. Remember that arrays are zero-indexed.
my_array = array('i', [1,2,3,4,5])
print(my_array.index(5))
# 5
my_array = array('i', [1,2,3,3,5])
print(my_array.index(3))
# 3
Note in that second example that only one index was returned, even though the value exists twice in the array
Section 17.10: Reverse a python array using reverse() method
The reverse() method does what the name says it will do - reverses the array. Here is an example :
my_array = array('i', [1,2,3,4,5])
my_array.reverse()
# array('i', [5, 4, 3, 2, 1])
GoalKicker.com – Python® Notes for Professionals
104Section 17.11: Get array buer information through
buer_info() method
This method provides you the array buﬀer start address in memory and number of elements in array. Here is an
example:
my_array = array('i', [1,2,3,4,5])
my_array.buffer_info()
(33881712, 5)
Section 17.12: Check for number of occurrences of an element
using count() method
count() will return the number of times and element appears in an array. In the following example we see that the
value 3 occurs twice.
my_array = array('i', [1,2,3,3,5])
my_array.count(3)
# 2
Section 17.13: Convert array to string using tostring() method
tostring() converts the array to a string.
my_char_array = array('c', ['g','e','e','k'])
# array('c', 'geek')
print(my_char_array.tostring())
# geek
Section 17.14: Convert array to a python list with same
elements using tolist() method
When you need a Python list object, you can utilize the tolist() method to convert your array to a list.
my_array = array('i', [1,2,3,4,5])
c = my_array.tolist()
# [1, 2, 3, 4, 5]
Section 17.15: Append a string to char array using fromstring()
method
You are able to append a string to a character array using fromstring()
my_char_array = array('c', ['g','e','e','k'])
my_char_array.fromstring("stuff")
print(my_char_array)
#array('c', 'geekstuff')
GoalKicker.com – Python® Notes for Professionals
105Chapter 18: Multidimensional arrays
Section 18.1: Lists in lists
A good way to visualize a 2d array is as a list of lists. Something like this:
lst=[[1,2,3],[4,5,6],[7,8,9]]
here the outer list lst has three things in it. each of those things is another list: The ﬁrst one is: [1,2,3], the second
one is: [4,5,6] and the third one is: [7,8,9]. You can access these lists the same way you would access another
other element of a list, like this:
print (lst[0])
#output: [1, 2, 3]
print (lst[1])
#output: [4, 5, 6]
print (lst[2])
#output: [7, 8, 9]
You can then access the diﬀerent elements in each of those lists the same way:
print (lst[0][0])
#output: 1
print (lst[0][1])
#output: 2
Here the ﬁrst number inside the [] brackets means get the list in that position. In the above example we used the
number 0 to mean get the list in the 0th position which is [1,2,3]. The second set of [] brackets means get the
item in that position from the inner list. In this case we used both 0 and 1 the 0th position in the list we got is the
number 1 and in the 1st position it is 2
You can also set values inside these lists the same way:
lst[0]=[10,11,12]
Now the list is [[10,11,12],[4,5,6],[7,8,9]]. In this example we changed the whole ﬁrst list to be a completely
new list.
lst[1][2]=15
Now the list is [[10,11,12],[4,5,15],[7,8,9]]. In this example we changed a single element inside of one of the
inner lists. First we went into the list at position 1 and changed the element within it at position 2, which was 6 now
it's 15.
Section 18.2: Lists in lists in lists in..
This behaviour can be extended. Here is a 3-dimensional array:
[[[111,112,113],[121,122,123],[131,132,133]],[[211,212,213],[221,222,223],[231,232,233]],[[311,312,
313],[321,322,323],[331,332,333]]]
GoalKicker.com – Python® Notes for Professionals
106As is probably obvious, this gets a bit hard to read. Use backslashes to break up the diﬀerent dimensions:
[[[111,112,113],[121,122,123],[131,132,133]],\
[[211,212,213],[221,222,223],[231,232,233]],\
[[311,312,313],[321,322,323],[331,332,333]]]
By nesting the lists like this, you can extend to arbitrarily high dimensions.
Accessing is similar to 2D arrays:
print(myarray)
print(myarray[1])
print(myarray[2][1])
print(myarray[1][0][2])
etc.
And editing is also similar:
myarray[1]=new_n-1_d_list
myarray[2][1]=new_n-2_d_list
myarray[1][0][2]=new_n-3_d_list #or a single number if you're dealing with 3D arrays
etc.
GoalKicker.com – Python® Notes for Professionals
107Chapter 19: Dictionary
Parameter
Details
key
The desired key to lookup
value
The value to set or return
Section 19.1: Introduction to Dictionary
A dictionary is an example of a key value store also known as Mapping in Python. It allows you to store and retrieve
elements by referencing a key. As dictionaries are referenced by key, they have very fast lookups. As they are
primarily used for referencing items by key, they are not sorted.
creating a dict
Dictionaries can be initiated in many ways:
literal syntax
d = {}
d = {'key': 'value'}
# empty dict
# dict with initial values
Python 3.x Version ≥ 3.5
# Also unpacking one or multiple dictionaries with the literal syntax is possible
# makes a shallow copy of otherdict
d = {**otherdict}
# also updates the shallow copy with the contents of the yetanotherdict.
d = {**otherdict, **yetanotherdict}
dict comprehension
d = {k:v for k,v in [('key', 'value',)]}
see also: Comprehensions
built-in class: dict()
d = dict()
# empty dict
d = dict(key='value')
# explicit keyword arguments
d = dict([('key', 'value')]) # passing in a list of key/value pairs
# make a shallow copy of another dict (only possible if keys are only strings!)
d = dict(**otherdict)
modifying a dict
To add items to a dictionary, simply create a new key with a value:
d['newkey'] = 42
It also possible to add list and dictionary as value:
d['new_list'] = [1, 2, 3]
d['new_dict'] = {'nested_dict': 1}
To delete an item, delete the key from the dictionary:
del d['newkey']
GoalKicker.com – Python® Notes for Professionals
108Section 19.2: Avoiding KeyError Exceptions
One common pitfall when using dictionaries is to access a non-existent key. This typically results in a KeyError
exception
mydict = {}
mydict['not there']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'not there'
One way to avoid key errors is to use the dict.get method, which allows you to specify a default value to return in
the case of an absent key.
value = mydict.get(key, default_value)
Which returns mydict[key] if it exists, but otherwise returns default_value. Note that this doesn't add key to
mydict. So if you want to retain that key value pair, you should use mydict.setdefault(key, default_value),
which does store the key value pair.
mydict = {}
print(mydict)
# {}
print(mydict.get("foo", "bar"))
# bar
print(mydict)
# {}
print(mydict.setdefault("foo", "bar"))
# bar
print(mydict)
# {'foo': 'bar'}
An alternative way to deal with the problem is catching the exception
try:
value = mydict[key]
except KeyError:
value = default_value
You could also check if the key is in the dictionary.
if key in mydict:
value = mydict[key]
else:
value = default_value
Do note, however, that in multi-threaded environments it is possible for the key to be removed from the dictionary
after you check, creating a race condition where the exception can still be thrown.
Another option is to use a subclass of dict, collections.defaultdict, that has a default_factory to create new entries in
the dict when given a new_key.
Section 19.3: Iterating Over a Dictionary
If you use a dictionary as an iterator (e.g. in a for statement), it traverses the keys of the dictionary. For example:
GoalKicker.com – Python® Notes for Professionals
109d = {'a': 1, 'b': 2, 'c':3}
for key in d:
print(key, d[key])
# c 3
# b 2
# a 1
The same is true when used in a comprehension
print([key for key in d])
# ['c', 'b', 'a']
Python 3.x Version ≥ 3.0
The items() method can be used to loop over both the key and value simultaneously:
for key, value in d.items():
print(key, value)
# c 3
# b 2
# a 1
While the values() method can be used to iterate over only the values, as would be expected:
for key, value in d.values():
print(key, value)
# 3
# 2
# 1
Python 2.x Version ≥ 2.2
Here, the methods keys(), values() and items() return lists, and there are the three extra methods iterkeys()
itervalues() and iteritems() to return iterators.
Section 19.4: Dictionary with default values
Available in the standard library as defaultdict
from collections import defaultdict
d = defaultdict(int)
d['key']
d['key'] = 5
d['key']
# 0
# 5
d = defaultdict(lambda: 'empty')
d['key']
# 'empty'
d['key'] = 'full'
d['key']
# 'full'
[*] Alternatively, if you must use the built-in dict class, using dict.setdefault() will allow you to create a default
whenever you access a key that did not exist before:
>>> d = {}
{}
>>> d.setdefault('Another_key', []).append("This worked!")
>>> d
GoalKicker.com – Python® Notes for Professionals
110{'Another_key': ['This worked!']}
Keep in mind that if you have many values to add, dict.setdefault() will create a new instance of the initial value
(in this example a []) every time it's called - which may create unnecessary workloads.
[*] Python Cookbook, 3rd edition, by David Beazley and Brian K. Jones (O’Reilly). Copyright 2013 David Beazley and Brian
Jones, 978-1-449-34037-7.
Section 19.5: Merging dictionaries
Consider the following dictionaries:
>>> fish = {'name': "Nemo", 'hands': "fins", 'special': "gills"}
>>> dog = {'name': "Clifford", 'hands': "paws", 'color': "red"}
Python 3.5+
>>> fishdog = {**fish, **dog}
>>> fishdog
{'hands': 'paws', 'color': 'red', 'name': 'Clifford', 'special': 'gills'}
As this example demonstrates, duplicate keys map to their lattermost value (for example "Cliﬀord" overrides
"Nemo").
Python 3.3+
>>> from collections import ChainMap
>>> dict(ChainMap(fish, dog))
{'hands': 'fins', 'color': 'red', 'special': 'gills', 'name': 'Nemo'}
With this technique the foremost value takes precedence for a given key rather than the last ("Cliﬀord" is thrown
out in favor of "Nemo").
Python 2.x, 3.x
>>> from itertools import chain
>>> dict(chain(fish.items(), dog.items()))
{'hands': 'paws', 'color': 'red', 'name': 'Clifford', 'special': 'gills'}
This uses the lattermost value, as with the **-based technique for merging ("Cliﬀord" overrides "Nemo").
>>> fish.update(dog)
>>> fish
{'color': 'red', 'hands': 'paws', 'name': 'Clifford', 'special': 'gills'}
dict.update uses the latter dict to overwrite the previous one.
Section 19.6: Accessing keys and values
When working with dictionaries, it's often necessary to access all the keys and values in the dictionary, either in a
for loop, a list comprehension, or just as a plain list.
Given a dictionary like:
mydict = {
'a': '1',
GoalKicker.com – Python® Notes for Professionals
111'b': '2'
}
You can get a list of keys using the keys() method:
print(mydict.keys())
# Python2: ['a', 'b']
# Python3: dict_keys(['b', 'a'])
If instead you want a list of values, use the values() method:
print(mydict.values())
# Python2: ['1', '2']
# Python3: dict_values(['2', '1'])
If you want to work with both the key and its corresponding value, you can use the items() method:
print(mydict.items())
# Python2: [('a', '1'), ('b', '2')]
# Python3: dict_items([('b', '2'), ('a', '1')])
NOTE: Because a dict is unsorted, keys(), values(), and items() have no sort order. Use sort(), sorted(), or an
OrderedDict if you care about the order that these methods return.
Python 2/3 Diﬀerence: In Python 3, these methods return special iterable objects, not lists, and are the equivalent
of the Python 2 iterkeys(), itervalues(), and iteritems() methods. These objects can be used like lists for the
most part, though there are some diﬀerences. See PEP 3106 for more details.
Section 19.7: Accessing values of a dictionary
dictionary = {"Hello": 1234, "World": 5678}
print(dictionary["Hello"])
The above code will print 1234.
The string "Hello" in this example is called a key. It is used to lookup a value in the dict by placing the key in
square brackets.
The number 1234 is seen after the respective colon in the dict deﬁnition. This is called the value that "Hello" maps
to in this dict.
Looking up a value like this with a key that does not exist will raise a KeyError exception, halting execution if
uncaught. If we want to access a value without risking a KeyError, we can use the dictionary.get method. By
default if the key does not exist, the method will return None. We can pass it a second value to return instead of
None in the event of a failed lookup.
w = dictionary.get("whatever")
x = dictionary.get("whatever", "nuh-uh")
In this example w will get the value None and x will get the value "nuh-uh".
Section 19.8: Creating a dictionary
Rules for creating a dictionary:
GoalKicker.com – Python® Notes for Professionals
112Every key must be unique (otherwise it will be overridden)
Every key must be hashable (can use the hash function to hash it; otherwise TypeError will be thrown)
There is no particular order for the keys.
# Creating and populating it with values
stock = {'eggs': 5, 'milk': 2}
# Or creating an empty dictionary
dictionary = {}
# And populating it after
dictionary['eggs'] = 5
dictionary['milk'] = 2
# Values can also be lists
mydict = {'a': [1, 2, 3], 'b': ['one', 'two', 'three']}
# Use list.append() method to add new elements to the values list
mydict['a'].append(4)
# => {'a': [1, 2, 3, 4], 'b': ['one', 'two', 'three']}
mydict['b'].append('four') # => {'a': [1, 2, 3, 4], 'b': ['one', 'two', 'three', 'four']}
# We can also create a dictionary using a list of two-items tuples
iterable = [('eggs', 5), ('milk', 2)]
dictionary = dict(iterables)
# Or using keyword argument:
dictionary = dict(eggs=5, milk=2)
# Another way will be to use the dict.fromkeys:
dictionary = dict.fromkeys((milk, eggs)) # => {'milk': None, 'eggs': None}
dictionary = dict.fromkeys((milk, eggs), (2, 5)) # => {'milk': 2, 'eggs': 5}
Section 19.9: Creating an ordered dictionary
You can create an ordered dictionary which will follow a determined order when iterating over the keys in the
dictionary.
Use OrderedDict from the collections module. This will always return the dictionary elements in the original
insertion order when iterated over.
from collections import OrderedDict
d = OrderedDict()
d['first'] = 1
d['second'] = 2
d['third'] = 3
d['last'] = 4
# Outputs "first 1", "second 2", "third 3", "last 4"
for key in d:
print(key, d[key])
Section 19.10: Unpacking dictionaries using the ** operator
You can use the ** keyword argument unpacking operator to deliver the key-value pairs in a dictionary into a
function's arguments. A simpliﬁed example from the oﬃcial documentation:
>>>
GoalKicker.com – Python® Notes for Professionals
113>>> def parrot(voltage, state, action):
...
print("This parrot wouldn't", action, end=' ')
...
print("if you put", voltage, "volts through it.", end=' ')
...
print("E's", state, "!")
...
>>> d = {"voltage": "four million", "state": "bleedin' demised", "action": "VOOM"}
>>> parrot(**d)
This parrot wouldn't VOOM if you put four million volts through it. E's bleedin' demised !
As of Python 3.5 you can also use this syntax to merge an arbitrary number of dict objects.
>>> fish = {'name': "Nemo", 'hands': "fins", 'special': "gills"}
>>> dog = {'name': "Clifford", 'hands': "paws", 'color': "red"}
>>> fishdog = {**fish, **dog}
>>> fishdog
{'hands': 'paws', 'color': 'red', 'name': 'Clifford', 'special': 'gills'}
As this example demonstrates, duplicate keys map to their lattermost value (for example "Cliﬀord" overrides
"Nemo").
Section 19.11: The trailing comma
Like lists and tuples, you can include a trailing comma in your dictionary.
role = {"By day": "A typical programmer",
"By night": "Still a typical programmer", }
PEP 8 dictates that you should leave a space between the trailing comma and the closing brace.
Section 19.12: The dict() constructor
The dict() constructor can be used to create dictionaries from keyword arguments, or from a single iterable of
key-value pairs, or from a single dictionary and keyword arguments.
dict(a=1, b=2, c=3)
dict([('d', 4), ('e', 5), ('f', 6)])
dict([('a', 1)], b=2, c=3)
dict({'a' : 1, 'b' : 2}, c=3)
# {'a': 1, 'b': 2, 'c': 3}
# {'d': 4, 'e': 5, 'f': 6}
# {'a': 1, 'b': 2, 'c': 3}
# {'a': 1, 'b': 2, 'c': 3}
Section 19.13: Dictionaries Example
Dictionaries map keys to values.
car = {}
car["wheels"] = 4
car["color"] = "Red"
car["model"] = "Corvette"
Dictionary values can be accessed by their keys.
print "Little " + car["color"] + " " + car["model"] + "!"
# This would print out "Little Red Corvette!"
Dictionaries can also be created in a JSON style:
GoalKicker.com – Python® Notes for Professionals
114car = {"wheels": 4, "color": "Red", "model": "Corvette"}
Dictionary values can be iterated over:
for key in car:
print key + ": " + car[key]
# wheels: 4
# color: Red
# model: Corvette
Section 19.14: All combinations of dictionary values
options = {
"x": ["a", "b"],
"y": [10, 20, 30]
}
Given a dictionary such as the one shown above, where there is a list representing a set of values to explore for the
corresponding key. Suppose you want to explore "x"="a" with "y"=10, then "x"="a" with"y"=10, and so on until
you have explored all possible combinations.
You can create a list that returns all such combinations of values using the following code.
import itertools
options = {
"x": ["a", "b"],
"y": [10, 20, 30]}
keys = options.keys()
values = (options[key] for key in keys)
combinations = [dict(zip(keys, combination)) for combination in itertools.product(*values)]
print combinations
This gives us the following list stored in the variable combinations:
[{'x': 'a', 'y': 10},
{'x': 'b', 'y': 10},
{'x': 'a', 'y': 20},
{'x': 'b', 'y': 20},
{'x': 'a', 'y': 30},
{'x': 'b', 'y': 30}]
GoalKicker.com – Python® Notes for Professionals
115VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 20: List
The Python List is a general data structure widely used in Python programs. They are found in other languages,
often referred to as dynamic arrays. They are both mutable and a sequence data type that allows them to be indexed
and sliced. The list can contain diﬀerent types of objects, including other list objects.
Section 20.1: List methods and supported operators
Starting with a given list a:
a = [1, 2, 3, 4, 5]
1. append(value) – appends a new element to the end of the list.
# Append values 6, 7, and 7 to the list
a.append(6)
a.append(7)
a.append(7)
# a: [1, 2, 3, 4, 5, 6, 7, 7]
# Append another list
b = [8, 9]
a.append(b)
# a: [1, 2, 3, 4, 5, 6, 7, 7, [8, 9]]
# Append an element of a different type, as list elements do not need to have the same type
my_string = "hello world"
a.append(my_string)
# a: [1, 2, 3, 4, 5, 6, 7, 7, [8, 9], "hello world"]
Note that the append() method only appends one new element to the end of the list. If you append a list to
another list, the list that you append becomes a single element at the end of the ﬁrst list.
# Appending a list to another list
a = [1, 2, 3, 4, 5, 6, 7, 7]
b = [8, 9]
a.append(b)
# a: [1, 2, 3, 4, 5, 6, 7, 7, [8, 9]]
a[8]
# Returns: [8,9]
2. extend(enumerable) – extends the list by appending elements from another enumerable.
a = [1, 2, 3, 4, 5, 6, 7, 7]
b = [8, 9, 10]
# Extend list by appending all elements from b
a.extend(b)
# a: [1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10]
# Extend list with elements from a non-list enumerable:
a.extend(range(3))
# a: [1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10, 0, 1, 2]
Lists can also be concatenated with the + operator. Note that this does not modify any of the original lists:
GoalKicker.com – Python® Notes for Professionals
117a = [1, 2, 3, 4, 5, 6] + [7, 7] + b
# a: [1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10]
3. index(value, [startIndex]) – gets the index of the ﬁrst occurrence of the input value. If the input value is
not in the list a ValueError exception is raised. If a second argument is provided, the search is started at that
speciﬁed index.
a.index(7)
# Returns: 6
a.index(49) # ValueError, because 49 is not in a.
a.index(7, 7)
# Returns: 7
a.index(7, 8) # ValueError, because there is no 7 starting at index 8
4. insert(index, value) – inserts value just before the speciﬁed index. Thus after the insertion the new
element occupies position index.
a.insert(0, 0) # insert 0 at position 0
a.insert(2, 5) # insert 5 at position 2
# a: [0, 1, 5, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10]
5. pop([index]) – removes and returns the item at index. With no argument it removes and returns the last
element of the list.
a.pop(2)
# Returns: 5
# a: [0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10]
a.pop(8)
# Returns: 7
# a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# With no argument:
a.pop()
# Returns: 10
# a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
6. remove(value) – removes the ﬁrst occurrence of the speciﬁed value. If the provided value cannot be found, a
ValueError is raised.
a.remove(0)
a.remove(9)
# a: [1, 2, 3, 4, 5, 6, 7, 8]
a.remove(10)
# ValueError, because 10 is not in a
7. reverse() – reverses the list in-place and returns None.
a.reverse()
# a: [8, 7, 6, 5, 4, 3, 2, 1]
There are also other ways of reversing a list.
GoalKicker.com – Python® Notes for Professionals
1188. count(value) – counts the number of occurrences of some value in the list.
a.count(7)
# Returns: 2
9. sort() – sorts the list in numerical and lexicographical order and returns None.
a.sort()
# a = [1, 2, 3, 4, 5, 6, 7, 8]
# Sorts the list in numerical order
Lists can also be reversed when sorted using the reverse=True ﬂag in the sort() method.
a.sort(reverse=True)
# a = [8, 7, 6, 5, 4, 3, 2, 1]
If you want to sort by attributes of items, you can use the key keyword argument:
import datetime
class Person(object):
def __init__(self, name, birthday, height):
self.name = name
self.birthday = birthday
self.height = height
def __repr__(self):
return self.name
l = [Person("John Cena", datetime.date(1992, 9, 12), 175),
Person("Chuck Norris", datetime.date(1990, 8, 28), 180),
Person("Jon Skeet", datetime.date(1991, 7, 6), 185)]
l.sort(key=lambda item: item.name)
# l: [Chuck Norris, John Cena, Jon Skeet]
l.sort(key=lambda item: item.birthday)
# l: [Chuck Norris, Jon Skeet, John Cena]
l.sort(key=lambda item: item.height)
# l: [John Cena, Chuck Norris, Jon Skeet]
In case of list of dicts the concept is the same:
import datetime
l = [{'name':'John Cena', 'birthday': datetime.date(1992, 9, 12),'height': 175},
{'name': 'Chuck Norris', 'birthday': datetime.date(1990, 8, 28),'height': 180},
{'name': 'Jon Skeet', 'birthday': datetime.date(1991, 7, 6), 'height': 185}]
l.sort(key=lambda item: item['name'])
# l: [Chuck Norris, John Cena, Jon Skeet]
l.sort(key=lambda item: item['birthday'])
# l: [Chuck Norris, Jon Skeet, John Cena]
l.sort(key=lambda item: item['height'])
# l: [John Cena, Chuck Norris, Jon Skeet]
GoalKicker.com – Python® Notes for Professionals
119Sort by sub dict:
import datetime
l = [{'name':'John Cena', 'birthday': datetime.date(1992, 9, 12),'size': {'height': 175,
'weight': 100}},
{'name': 'Chuck Norris', 'birthday': datetime.date(1990, 8, 28),'size' : {'height': 180,
'weight': 90}},
{'name': 'Jon Skeet', 'birthday': datetime.date(1991, 7, 6), 'size': {'height': 185,
'weight': 110}}]
l.sort(key=lambda item: item['size']['height'])
# l: [John Cena, Chuck Norris, Jon Skeet]
Better way to sort using attrgetter and itemgetter
Lists can also be sorted using attrgetter and itemgetter functions from the operator module. These can help
improve readability and reusability. Here are some examples,
from operator import itemgetter,attrgetter
people = [{'name':'chandan','age':20,'salary':2000},
{'name':'chetan','age':18,'salary':5000},
{'name':'guru','age':30,'salary':3000}]
by_age = itemgetter('age')
by_salary = itemgetter('salary')
people.sort(key=by_age) #in-place sorting by age
people.sort(key=by_salary) #in-place sorting by salary
itemgetter can also be given an index. This is helpful if you want to sort based on indices of a tuple.
list_of_tuples = [(1,2), (3,4), (5,0)]
list_of_tuples.sort(key=itemgetter(1))
print(list_of_tuples) #[(5, 0), (1, 2), (3, 4)]
Use the attrgetter if you want to sort by attributes of an object,
persons = [Person("John Cena", datetime.date(1992, 9, 12), 175),
Person("Chuck Norris", datetime.date(1990, 8, 28), 180),
Person("Jon Skeet", datetime.date(1991, 7, 6), 185)] #reusing Person class from above
example
person.sort(key=attrgetter('name')) #sort by name
by_birthday = attrgetter('birthday')
person.sort(key=by_birthday) #sort by birthday
10. clear() – removes all items from the list
a.clear()
# a = []
11. Replication – multiplying an existing list by an integer will produce a larger list consisting of that many copies
of the original. This can be useful for example for list initialization:
b = ["blah"] * 3
# b = ["blah", "blah", "blah"]
GoalKicker.com – Python® Notes for Professionals
120b = [1, 3, 5] * 5
# [1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5]
Take care doing this if your list contains references to objects (eg a list of lists), see Common Pitfalls - List
multiplication and common references.
12. Element deletion – it is possible to delete multiple elements in the list using the del keyword and slice
notation:
a = list(range(10))
del a[::2]
# a = [1, 3, 5, 7, 9]
del a[-1]
# a = [1, 3, 5, 7]
del a[:]
# a = []
13. Copying
The default assignment "=" assigns a reference of the original list to the new name. That is, the original name
and new name are both pointing to the same list object. Changes made through any of them will be reﬂected
in another. This is often not what you intended.
b = a
a.append(6)
# b: [1, 2, 3, 4, 5, 6]
If you want to create a copy of the list you have below options.
You can slice it:
new_list = old_list[:]
You can use the built in list() function:
new_list = list(old_list)
You can use generic copy.copy():
import copy
new_list = copy.copy(old_list) #inserts references to the objects found in the original.
This is a little slower than list() because it has to ﬁnd out the datatype of old_list ﬁrst.
If the list contains objects and you want to copy them as well, use generic copy.deepcopy():
import copy
new_list = copy.deepcopy(old_list) #inserts copies of the objects found in the original.
Obviously the slowest and most memory-needing method, but sometimes unavoidable.
Python 3.x Version ≥ 3.0
GoalKicker.com – Python® Notes for Professionals
121copy() – Returns a shallow copy of the list
aa = a.copy()
# aa = [1, 2, 3, 4, 5]
Section 20.2: Accessing list values
Python lists are zero-indexed, and act like arrays in other languages.
lst = [1, 2, 3, 4]
lst[0] # 1
lst[1] # 2
Attempting to access an index outside the bounds of the list will raise an IndexError.
lst[4]
# IndexError: list index out of range
Negative indices are interpreted as counting from the end of the list.
lst[-1]
lst[-2]
lst[-5]
# 4
# 3
# IndexError: list index out of range
This is functionally equivalent to
lst[len(lst)-1]
# 4
Lists allow to use slice notation as lst[start:end:step]. The output of the slice notation is a new list containing
elements from index start to end-1. If options are omitted start defaults to beginning of list, end to end of list and
step to 1:
lst[1:]
# [2, 3, 4]
lst[:3]
# [1, 2, 3]
lst[::2]
# [1, 3]
lst[::-1]
# [4, 3, 2, 1]
lst[-1:0:-1] # [4, 3, 2]
lst[5:8]
# [] since starting index is greater than length of lst, returns empty list
lst[1:10]
# [2, 3, 4] same as omitting ending index
With this in mind, you can print a reversed version of the list by calling
lst[::-1]
# [4, 3, 2, 1]
When using step lengths of negative amounts, the starting index has to be greater than the ending index otherwise
the result will be an empty list.
lst[3:1:-1] # [4, 3]
Using negative step indices are equivalent to the following code:
reversed(lst)[0:2] # 0 = 1 -1
# 2 = 3 -1
The indices used are 1 less than those used in negative indexing and are reversed.
GoalKicker.com – Python® Notes for Professionals
122Advanced slicing
When lists are sliced the __getitem__() method of the list object is called, with a slice object. Python has a builtin
slice method to generate slice objects. We can use this to store a slice and reuse it later like so,
data = 'chandan purohit
22 2000'
name_slice = slice(0,19)
age_slice = slice(19,21)
salary_slice = slice(22,None)
#assuming data fields of fixed length
#now we can have more readable slices
print(data[name_slice]) #chandan purohit
print(data[age_slice]) #'22'
print(data[salary_slice]) #'2000'
This can be of great use by providing slicing functionality to our objects by overriding __getitem__ in our class.
Section 20.3: Checking if list is empty
The emptiness of a list is associated to the boolean False, so you don't have to check len(lst) == 0, but just lst
or not lst
lst = []
if not lst:
print("list is empty")
# Output: list is empty
Section 20.4: Iterating over a list
Python supports using a for loop directly on a list:
my_list = ['foo', 'bar', 'baz']
for item in my_list:
print(item)
# Output: foo
# Output: bar
# Output: baz
You can also get the position of each item at the same time:
for (index, item) in enumerate(my_list):
print('The item in position {} is: {}'.format(index, item))
# Output: The item in position 0 is: foo
# Output: The item in position 1 is: bar
# Output: The item in position 2 is: baz
The other way of iterating a list based on the index value:
for i in range(0,len(my_list)):
print(my_list[i])
#output:
>>>
foo
bar
GoalKicker.com – Python® Notes for Professionals
123baz
Note that changing items in a list while iterating on it may have unexpected results:
for item in my_list:
if item == 'foo':
del my_list[0]
print(item)
# Output: foo
# Output: baz
In this last example, we deleted the ﬁrst item at the ﬁrst iteration, but that caused bar to be skipped.
Section 20.5: Checking whether an item is in a list
Python makes it very simple to check whether an item is in a list. Simply use the in operator.
lst = ['test', 'twest', 'tweast', 'treast']
'test' in lst
# Out: True
'toast' in lst
# Out: False
Note: the in operator on sets is asymptotically faster than on lists. If you need to use it many times on
potentially large lists, you may want to convert your list to a set, and test the presence of elements on
the set.
slst = set(lst)
'test' in slst
# Out: True
Section 20.6: Any and All
You can use all() to determine if all the values in an iterable evaluate to True
nums = [1, 1, 0, 1]
all(nums)
# False
chars = ['a', 'b', 'c', 'd']
all(chars)
# True
Likewise, any() determines if one or more values in an iterable evaluate to True
nums = [1, 1, 0, 1]
any(nums)
# True
vals = [None, None, None, False]
any(vals)
# False
While this example uses a list, it is important to note these built-ins work with any iterable, including generators.
GoalKicker.com – Python® Notes for Professionals
124vals = [1, 2, 3, 4]
any(val > 12 for val in vals)
# False
any((val * 2) > 6 for val in vals)
# True
Section 20.7: Reversing list elements
You can use the reversed function which returns an iterator to the reversed list:
In [3]: rev = reversed(numbers)
In [4]: rev
Out[4]: [9, 8, 7, 6, 5, 4, 3, 2, 1]
Note that the list "numbers" remains unchanged by this operation, and remains in the same order it was originally.
To reverse in place, you can also use the reverse method.
You can also reverse a list (actually obtaining a copy, the original list is unaﬀected) by using the slicing syntax,
setting the third argument (the step) as -1:
In [1]: numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
In [2]: numbers[::-1]
Out[2]: [9, 8, 7, 6, 5, 4, 3, 2, 1]
Section 20.8: Concatenate and Merge lists
1. The simplest way to concatenate list1 and list2:
merged = list1 + list2
2. zip returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument
sequences or iterables:
alist = ['a1', 'a2', 'a3']
blist = ['b1', 'b2', 'b3']
for a, b in zip(alist, blist):
print(a, b)
# Output:
# a1 b1
# a2 b2
# a3 b3
If the lists have diﬀerent lengths then the result will include only as many elements as the shortest one:
alist = ['a1', 'a2', 'a3']
blist = ['b1', 'b2', 'b3', 'b4']
for a, b in zip(alist, blist):
print(a, b)
# Output:
# a1 b1
GoalKicker.com – Python® Notes for Professionals
125# a2 b2
# a3 b3
alist = []
len(list(zip(alist, blist)))
# Output:
# 0
For padding lists of unequal length to the longest one with Nones use itertools.zip_longest
(itertools.izip_longest in Python 2)
alist = ['a1', 'a2', 'a3']
blist = ['b1']
clist = ['c1', 'c2', 'c3', 'c4']
for a,b,c in itertools.zip_longest(alist, blist, clist):
print(a, b, c)
# Output:
# a1 b1 c1
# a2 None c2
# a3 None c3
# None None c4
3. Insert to a speciﬁc index values:
alist = [123, 'xyz', 'zara', 'abc']
alist.insert(3, [2009])
print("Final List :", alist)
Output:
Final List : [123, 'xyz', 'zara', 2009, 'abc']
Section 20.9: Length of a list
Use len() to get the one-dimensional length of a list.
len(['one', 'two'])
# returns 2
len(['one', [2, 3], 'four'])
# returns 3, not 4
len() also works on strings, dictionaries, and other data structures similar to lists.
Note that len() is a built-in function, not a method of a list object.
Also note that the cost of len() is O(1), meaning it will take the same amount of time to get the length of a list
regardless of its length.
Section 20.10: Remove duplicate values in list
Removing duplicate values in a list can be done by converting the list to a set (that is an unordered collection of
distinct objects). If a list data structure is needed, then the set can be converted back to a list using the function
list():
GoalKicker.com – Python® Notes for Professionals
126names = ["aixk", "duke", "edik", "tofp", "duke"]
list(set(names))
# Out: ['duke', 'tofp', 'aixk', 'edik']
Note that by converting a list to a set the original ordering is lost.
To preserve the order of the list one can use an OrderedDict
import collections
>>> collections.OrderedDict.fromkeys(names).keys()
# Out: ['aixk', 'duke', 'edik', 'tofp']
Section 20.11: Comparison of lists
It's possible to compare lists and other sequences lexicographically using comparison operators. Both operands
must be of the same type.
[1, 10, 100] < [2, 10, 100]
# True, because 1 < 2
[1, 10, 100] < [1, 10, 100]
# False, because the lists are equal
[1, 10, 100] <= [1, 10, 100]
# True, because the lists are equal
[1, 10, 100] < [1, 10, 101]
# True, because 100 < 101
[1, 10, 100] < [0, 10, 100]
# False, because 0 < 1
If one of the lists is contained at the start of the other, the shortest list wins.
[1, 10] < [1, 10, 100]
# True
Section 20.12: Accessing values in nested list
Starting with a three-dimensional list:
alist = [[[1,2],[3,4]], [[5,6,7],[8,9,10], [12, 13, 14]]]
Accessing items in the list:
print(alist[0][0][1])
#2
#Accesses second element in the first list in the first list
print(alist[1][1][2])
#10
#Accesses the third element in the second list in the second list
Performing support operations:
alist[0][0].append(11)
print(alist[0][0][2])
#11
#Appends 11 to the end of the first list in the first list
GoalKicker.com – Python® Notes for Professionals
127Using nested for loops to print the list:
for row in alist: #One way to loop through nested lists
for col in row:
print(col)
#[1, 2, 11]
#[3, 4]
#[5, 6, 7]
#[8, 9, 10]
#[12, 13, 14]
Note that this operation can be used in a list comprehension or even as a generator to produce eﬃciencies, e.g.:
[col for row in alist for col in row]
#[[1, 2, 11], [3, 4], [5, 6, 7], [8, 9, 10], [12, 13, 14]]
Not all items in the outer lists have to be lists themselves:
alist[1].insert(2, 15)
#Inserts 15 into the third position in the second list
Another way to use nested for loops. The other way is better but I've needed to use this on occasion:
for row in range(len(alist)): #A less Pythonic way to loop through lists
for col in range(len(alist[row])):
print(alist[row][col])
#[1, 2, 11]
#[3, 4]
#[5, 6, 7]
#[8, 9, 10]
#15
#[12, 13, 14]
Using slices in nested list:
print(alist[1][1:])
#[[8, 9, 10], 15, [12, 13, 14]]
#Slices still work
The ﬁnal list:
print(alist)
#[[[1, 2, 11], [3, 4]], [[5, 6, 7], [8, 9, 10], 15, [12, 13, 14]]]
Section 20.13: Initializing a List to a Fixed Number of Elements
For immutable elements (e.g. None, string literals etc.):
my_list = [None] * 10
my_list = ['test'] * 10
For mutable elements, the same construct will result in all elements of the list referring to the same object, for
example, for a set:
>>> my_list=[{1}] * 10
GoalKicker.com – Python® Notes for Professionals
128>>> print(my_list)
[{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}]
>>> my_list[0].add(2)
>>> print(my_list)
[{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}]
Instead, to initialize the list with a ﬁxed number of diﬀerent mutable objects, use:
my_list=[{1} for _ in range(10)]
GoalKicker.com – Python® Notes for Professionals
129Chapter 21: List comprehensions
List comprehensions in Python are concise, syntactic constructs. They can be utilized to generate lists from other
lists by applying functions to each element in the list. The following section explains and demonstrates the use of
these expressions.
Section 21.1: List Comprehensions
A list comprehension creates a new list by applying an expression to each element of an iterable. The most basic
form is:
[ <expression> for <element> in <iterable> ]
There's also an optional 'if' condition:
[ <expression> for <element> in <iterable> if <condition> ]
Each <element> in the <iterable> is plugged in to the <expression> if the (optional) <condition> evaluates to true
. All results are returned at once in the new list. Generator expressions are evaluated lazily, but list comprehensions
evaluate the entire iterator immediately - consuming memory proportional to the iterator's length.
To create a list of squared integers:
squares = [x * x for x in (1, 2, 3, 4)]
# squares: [1, 4, 9, 16]
The for expression sets x to each value in turn from (1, 2, 3, 4). The result of the expression x * x is appended
to an internal list. The internal list is assigned to the variable squares when completed.
Besides a speed increase (as explained here), a list comprehension is roughly equivalent to the following for-loop:
squares = []
for x in (1, 2, 3, 4):
squares.append(x * x)
# squares: [1, 4, 9, 16]
The expression applied to each element can be as complex as needed:
# Get a list of uppercase characters from a string
[s.upper() for s in "Hello World"]
# ['H', 'E', 'L', 'L', 'O', ' ', 'W', 'O', 'R', 'L', 'D']
# Strip off any commas from the end of strings in a list
[w.strip(',') for w in ['these,', 'words,,', 'mostly', 'have,commas,']]
# ['these', 'words', 'mostly', 'have,commas']
# Organize letters in words more reasonably - in an alphabetical order
sentence = "Beautiful is better than ugly"
["".join(sorted(word, key = lambda x: x.lower())) for word in sentence.split()]
# ['aBefiltuu', 'is', 'beertt', 'ahnt', 'gluy']
else
else can be used in List comprehension constructs, but be careful regarding the syntax. The if/else clauses should
GoalKicker.com – Python® Notes for Professionals
130be used before for loop, not after:
# create a list of characters in apple, replacing non vowels with '*'
# Ex - 'apple' --> ['a', '*', '*', '*' ,'e']
[x for x in 'apple' if x in 'aeiou' else '*']
#SyntaxError: invalid syntax
# When using if/else together use them before the loop
[x if x in 'aeiou' else '*' for x in 'apple']
#['a', '*', '*', '*', 'e']
Note this uses a diﬀerent language construct, a conditional expression, which itself is not part of the
comprehension syntax. Whereas the if after the for…in is a part of list comprehensions and used to ﬁlter
elements from the source iterable.
Double Iteration
Order of double iteration [... for x in ... for y in ...] is either natural or counter-intuitive. The rule of
thumb is to follow an equivalent for loop:
def foo(i):
return i, i + 0.5
for i in range(3):
for x in foo(i):
yield str(x)
This becomes:
[str(x)
for i in range(3)
for x in foo(i)
]
This can be compressed into one line as [str(x) for i in range(3) for x in foo(i)]
In-place Mutation and Other Side Eﬀects
Before using list comprehension, understand the diﬀerence between functions called for their side eﬀects
(mutating, or in-place functions) which usually return None, and functions that return an interesting value.
Many functions (especially pure functions) simply take an object and return some object. An in-place function
modiﬁes the existing object, which is called a side eﬀect. Other examples include input and output operations such
as printing.
list.sort() sorts a list in-place (meaning that it modiﬁes the original list) and returns the value None. Therefore, it
won't work as expected in a list comprehension:
[x.sort() for x in [[2, 1], [4, 3], [0, 1]]]
# [None, None, None]
Instead, sorted() returns a sorted list rather than sorting in-place:
GoalKicker.com – Python® Notes for Professionals
131[sorted(x) for x in [[2, 1], [4, 3], [0, 1]]]
# [[1, 2], [3, 4], [0, 1]]
Using comprehensions for side-eﬀects is possible, such as I/O or in-place functions. Yet a for loop is usually more
readable. While this works in Python 3:
[print(x) for x in (1, 2, 3)]
Instead use:
for x in (1, 2, 3):
print(x)
In some situations, side eﬀect functions are suitable for list comprehension. random.randrange() has the side
eﬀect of changing the state of the random number generator, but it also returns an interesting value. Additionally,
next() can be called on an iterator.
The following random value generator is not pure, yet makes sense as the random generator is reset every time the
expression is evaluated:
from random import randrange
[randrange(1, 7) for _ in range(10)]
# [2, 3, 2, 1, 1, 5, 2, 4, 3, 5]
Whitespace in list comprehensions
More complicated list comprehensions can reach an undesired length, or become less readable. Although less
common in examples, it is possible to break a list comprehension into multiple lines like so:
[
x for x
in 'foo'
if x not in 'bar'
]
Section 21.2: Conditional List Comprehensions
Given a list comprehension you can append one or more if conditions to ﬁlter values.
[<expression> for <element> in <iterable> if <condition>]
For each <element> in <iterable>; if <condition> evaluates to True, add <expression> (usually a function of
<element>) to the returned list.
For example, this can be used to extract only even numbers from a sequence of integers:
[x for x in range(10) if x % 2 == 0]
# Out: [0, 2, 4, 6, 8]
Live demo
The above code is equivalent to:
even_numbers = []
GoalKicker.com – Python® Notes for Professionals
132for x in range(10):
if x % 2 == 0:
even_numbers.append(x)
print(even_numbers)
# Out: [0, 2, 4, 6, 8]
Also, a conditional list comprehension of the form [e for x in y if c] (where e and c are expressions in terms of
x) is equivalent to list(filter(lambda x: c, map(lambda x: e, y))).
Despite providing the same result, pay attention to the fact that the former example is almost 2x faster than the
latter one. For those who are curious, this is a nice explanation of the reason why.
Note that this is quite diﬀerent from the ... if ... else ... conditional expression (sometimes known as a
ternary expression) that you can use for the <expression> part of the list comprehension. Consider the following
example:
[x if x % 2 == 0 else None for x in range(10)]
# Out: [0, None, 2, None, 4, None, 6, None, 8, None]
Live demo
Here the conditional expression isn't a ﬁlter, but rather an operator determining the value to be used for the list
items:
<value-if-condition-is-true> if <condition> else <value-if-condition-is-false>
This becomes more obvious if you combine it with other operators:
[2 * (x if x % 2 == 0 else -1) + 1 for x in range(10)]
# Out: [1, -1, 5, -1, 9, -1, 13, -1, 17, -1]
Live demo
If you are using Python 2.7, xrange may be better than range for several reasons as described in the xrange
documentation.
[2 * (x if x % 2 == 0 else -1) + 1 for x in xrange(10)]
# Out: [1, -1, 5, -1, 9, -1, 13, -1, 17, -1]
The above code is equivalent to:
numbers = []
for x in range(10):
if x % 2 == 0:
temp = x
else:
temp = -1
numbers.append(2 * temp + 1)
print(numbers)
# Out: [1, -1, 5, -1, 9, -1, 13, -1, 17, -1]
One can combine ternary expressions and if conditions. The ternary operator works on the ﬁltered result:
[x if x > 2 else '*' for x in range(10) if x % 2 == 0]
# Out: ['*', '*', 4, 6, 8]
GoalKicker.com – Python® Notes for Professionals
133The same couldn't have been achieved just by ternary operator only:
[x if (x > 2 and x % 2 == 0) else '*' for x in range(10)]
# Out:['*', '*', '*', '*', 4, '*', 6, '*', 8, '*']
See also: Filters, which often provide a suﬃcient alternative to conditional list comprehensions.
Section 21.3: Avoid repetitive and expensive operations using
conditional clause
Consider the below list comprehension:
>>> def f(x):
...
import time
...
time.sleep(.1)
...
return x**2
# Simulate expensive function
>>> [f(x) for x in range(1000) if f(x) > 10]
[16, 25, 36, ...]
This results in two calls to f(x) for 1,000 values of x: one call for generating the value and the other for checking the
if condition. If f(x) is a particularly expensive operation, this can have signiﬁcant performance implications.
Worse, if calling f() has side eﬀects, it can have surprising results.
Instead, you should evaluate the expensive operation only once for each value of x by generating an intermediate
iterable (generator expression) as follows:
>>> [v for v in (f(x) for x in range(1000)) if v > 10]
[16, 25, 36, ...]
Or, using the builtin map equivalent:
>>> [v for v in map(f, range(1000)) if v > 10]
[16, 25, 36, ...]
Another way that could result in a more readable code is to put the partial result (v in the previous example) in an
iterable (such as a list or a tuple) and then iterate over it. Since v will be the only element in the iterable, the result is
that we now have a reference to the output of our slow function computed only once:
>>> [v for x in range(1000) for v in [f(x)] if v > 10]
[16, 25, 36, ...]
However, in practice, the logic of code can be more complicated and it's important to keep it readable. In general, a
separate generator function is recommended over a complex one-liner:
>>> def process_prime_numbers(iterable):
...
for x in iterable:
...
if is_prime(x):
...
yield f(x)
...
>>> [x for x in process_prime_numbers(range(1000)) if x > 10]
[11, 13, 17, 19, ...]
Another way to prevent computing f(x) multiple times is to use the @functools.lru_cache()(Python 3.2+)
decorator on f(x). This way since the output of f for the input x has already been computed once, the second
GoalKicker.com – Python® Notes for Professionals
134function invocation of the original list comprehension will be as fast as a dictionary lookup. This approach uses
memoization to improve eﬃciency, which is comparable to using generator expressions.
Say you have to ﬂatten a list
l = [[1, 2, 3], [4, 5, 6], [7], [8, 9]]
Some of the methods could be:
reduce(lambda x, y: x+y, l)
sum(l, [])
list(itertools.chain(*l))
However list comprehension would provide the best time complexity.
[item for sublist in l for item in sublist]
The shortcuts based on + (including the implied use in sum) are, of necessity, O(L^2) when there are L sublists -- as
the intermediate result list keeps getting longer, at each step a new intermediate result list object gets allocated,
and all the items in the previous intermediate result must be copied over (as well as a few new ones added at the
end). So (for simplicity and without actual loss of generality) say you have L sublists of I items each: the ﬁrst I items
are copied back and forth L-1 times, the second I items L-2 times, and so on; total number of copies is I times the
sum of x for x from 1 to L excluded, i.e., I * (L**2)/2.
The list comprehension just generates one list, once, and copies each item over (from its original place of residence
to the result list) also exactly once.
Section 21.4: Dictionary Comprehensions
A dictionary comprehension is similar to a list comprehension except that it produces a dictionary object instead of
a list.
A basic example:
Python 2.x Version ≥ 2.7
{x: x * x for x in (1, 2, 3, 4)}
# Out: {1: 1, 2: 4, 3: 9, 4: 16}
which is just another way of writing:
dict((x, x * x) for x in (1, 2, 3, 4))
# Out: {1: 1, 2: 4, 3: 9, 4: 16}
As with a list comprehension, we can use a conditional statement inside the dict comprehension to produce only
the dict elements meeting some criterion.
Python 2.x Version ≥ 2.7
{name: len(name) for name in ('Stack', 'Overflow', 'Exchange') if len(name) > 6}
# Out: {'Exchange': 8, 'Overflow': 8}
Or, rewritten using a generator expression.
GoalKicker.com – Python® Notes for Professionals
135dict((name, len(name)) for name in ('Stack', 'Overflow', 'Exchange') if len(name) > 6)
# Out: {'Exchange': 8, 'Overflow': 8}
Starting with a dictionary and using dictionary comprehension as a key-value pair ﬁlter
Python 2.x Version ≥ 2.7
initial_dict = {'x': 1, 'y': 2}
{key: value for key, value in initial_dict.items() if key == 'x'}
# Out: {'x': 1}
Switching key and value of dictionary (invert dictionary)
If you have a dict containing simple hashable values (duplicate values may have unexpected results):
my_dict = {1: 'a', 2: 'b', 3: 'c'}
and you wanted to swap the keys and values you can take several approaches depending on your coding style:
swapped = {v: k for k, v in my_dict.items()}
swapped = dict((v, k) for k, v in my_dict.iteritems())
swapped = dict(zip(my_dict.values(), my_dict))
swapped = dict(zip(my_dict.values(), my_dict.keys()))
swapped = dict(map(reversed, my_dict.items()))
print(swapped)
# Out: {a: 1, b: 2, c: 3}
Python 2.x Version ≥ 2.3
If your dictionary is large, consider importing itertools and utilize izip or imap.
Merging Dictionaries
Combine dictionaries and optionally override old values with a nested dictionary comprehension.
dict1 = {'w': 1, 'x': 1}
dict2 = {'x': 2, 'y': 2, 'z': 2}
{k: v for d in [dict1, dict2] for k, v in d.items()}
# Out: {'w': 1, 'x': 2, 'y': 2, 'z': 2}
However, dictionary unpacking (PEP 448) may be a preferred.
Python 3.x Version ≥ 3.5
{**dict1, **dict2}
# Out: {'w': 1, 'x': 2, 'y': 2, 'z': 2}
Note: dictionary comprehensions were added in Python 3.0 and backported to 2.7+, unlike list comprehensions,
which were added in 2.0. Versions < 2.7 can use generator expressions and the dict() builtin to simulate the
behavior of dictionary comprehensions.
Section 21.5: List Comprehensions with Nested Loops
List Comprehensions can use nested for loops. You can code any number of nested for loops within a list
comprehension, and each for loop may have an optional associated if test. When doing so, the order of the for
GoalKicker.com – Python® Notes for Professionals
136constructs is the same order as when writing a series of nested for statements. The general structure of list
comprehensions looks like this:
[ expression for target1 in iterable1 [if condition1]
for target2 in iterable2 [if condition2]...
for targetN in iterableN [if conditionN] ]
For example, the following code ﬂattening a list of lists using multiple for statements:
data = [[1, 2], [3, 4], [5, 6]]
output = []
for each_list in data:
for element in each_list:
output.append(element)
print(output)
# Out: [1, 2, 3, 4, 5, 6]
can be equivalently written as a list comprehension with multiple for constructs:
data = [[1, 2], [3, 4], [5, 6]]
output = [element for each_list in data for element in each_list]
print(output)
# Out: [1, 2, 3, 4, 5, 6]
Live Demo
In both the expanded form and the list comprehension, the outer loop (ﬁrst for statement) comes ﬁrst.
In addition to being more compact, the nested comprehension is also signiﬁcantly faster.
In [1]: data = [[1,2],[3,4],[5,6]]
In [2]: def f():
...:
output=[]
...:
for each_list in data:
...:
for element in each_list:
...:
output.append(element)
...:
return output
In [3]: timeit f()
1000000 loops, best of 3: 1.37 µs per loop
In [4]: timeit [inner for outer in data for inner in outer]
1000000 loops, best of 3: 632 ns per loop
The overhead for the function call above is about 140ns.
Inline ifs are nested similarly, and may occur in any position after the ﬁrst for:
data = [[1], [2, 3], [4, 5]]
output = [element for each_list in data
if len(each_list) == 2
for element in each_list
if element != 5]
print(output)
# Out: [2, 3, 4]
Live Demo
For the sake of readability, however, you should consider using traditional for-loops. This is especially true when
nesting is more than 2 levels deep, and/or the logic of the comprehension is too complex. multiple nested loop list
GoalKicker.com – Python® Notes for Professionals
137comprehension could be error prone or it gives unexpected result.
Section 21.6: Generator Expressions
Generator expressions are very similar to list comprehensions. The main diﬀerence is that it does not create a full
set of results at once; it creates a generator object which can then be iterated over.
For instance, see the diﬀerence in the following code:
# list comprehension
[x**2 for x in range(10)]
# Output: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Python 2.x Version ≥ 2.4
# generator comprehension
(x**2 for x in xrange(10))
# Output: <generator object <genexpr> at 0x11b4b7c80>
These are two very diﬀerent objects:
the list comprehension returns a list object whereas the generator comprehension returns a generator.
generator objects cannot be indexed and makes use of the next function to get items in order.
Note: We use xrange since it too creates a generator object. If we would use range, a list would be created. Also,
xrange exists only in later version of python 2. In python 3, range just returns a generator. For more information,
see the Diﬀerences between range and xrange functions example.
Python 2.x Version ≥ 2.4
g = (x**2 for x in xrange(10))
print(g[0])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'generator' object has no attribute '__getitem__'
g.next()
g.next()
g.next()
...
g.next()# 0
# 1
# 4
g.next()# Throws StopIteration Exception
# 81
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
Python 3.x Version ≥ 3.0
NOTE: The function g.next() should be substituted by next(g) and xrange with range since
Iterator.next() and xrange() do not exist in Python 3.
Although both of these can be iterated in a similar way:
GoalKicker.com – Python® Notes for Professionals
138for i in [x**2 for x in range(10)]:
print(i)
"""
Out:
0
1
4
...
81
"""
Python 2.x Version ≥ 2.4
for i in (x**2 for x in xrange(10)):
print(i)
"""
Out:
0
1
4
.
.
.
81
"""
Use cases
Generator expressions are lazily evaluated, which means that they generate and return each value only when the
generator is iterated. This is often useful when iterating through large datasets, avoiding the need to create a
duplicate of the dataset in memory:
for square in (x**2 for x in range(1000000)):
#do something
Another common use case is to avoid iterating over an entire iterable if doing so is not necessary. In this example,
an item is retrieved from a remote API with each iteration of get_objects(). Thousands of objects may exist, must
be retrieved one-by-one, and we only need to know if an object matching a pattern exists. By using a generator
expression, when we encounter an object matching the pattern.
def get_objects():
"""Gets objects from an API one by one"""
while True:
yield get_next_item()
def object_matches_pattern(obj):
# perform potentially complex calculation
return matches_pattern
def right_item_exists():
items = (object_matched_pattern(each) for each in get_objects())
for item in items:
if item.is_the_right_one:
return True
return False
GoalKicker.com – Python® Notes for Professionals
139Section 21.7: Set Comprehensions
Set comprehension is similar to list and dictionary comprehension, but it produces a set, which is an unordered
collection of unique elements.
Python 2.x Version ≥ 2.7
# A set containing every value in range(5):
{x for x in range(5)}
# Out: {0, 1, 2, 3, 4}
# A set of even numbers between 1 and 10:
{x for x in range(1, 11) if x % 2 == 0}
# Out: {2, 4, 6, 8, 10}
# Unique alphabetic characters in a string of text:
text = "When in the Course of human events it becomes necessary for one people..."
{ch.lower() for ch in text if ch.isalpha()}
# Out: set(['a', 'c', 'b', 'e', 'f', 'i', 'h', 'm', 'l', 'o',
#
'n', 'p', 's', 'r', 'u', 't', 'w', 'v', 'y'])
Live Demo
Keep in mind that sets are unordered. This means that the order of the results in the set may diﬀer from the one
presented in the above examples.
Note: Set comprehension is available since python 2.7+, unlike list comprehensions, which were added in 2.0. In
Python 2.2 to Python 2.6, the set() function can be used with a generator expression to produce the same result:
Python 2.x Version ≥ 2.2
set(x for x in range(5))
# Out: {0, 1, 2, 3, 4}
Section 21.8: Refactoring ﬁlter and map to list
comprehensions
The filter or map functions should often be replaced by list comprehensions. Guido Van Rossum describes this
well in an open letter in 2005:
filter(P, S) is almost always written clearer as [x for x in S if P(x)], and this has the huge
advantage that the most common usages involve predicates that are comparisons, e.g. x==42, and
deﬁning a lambda for that just requires much more eﬀort for the reader (plus the lambda is slower than
the list comprehension). Even more so for map(F, S) which becomes [F(x) for x in S]. Of course, in
many cases you'd be able to use generator expressions instead.
The following lines of code are considered "not pythonic" and will raise errors in many python linters.
filter(lambda x: x % 2 == 0, range(10)) # even numbers < 10
map(lambda x: 2*x, range(10)) # multiply each number by two
reduce(lambda x,y: x+y, range(10)) # sum of all elements in list
Taking what we have learned from the previous quote, we can break down these filter and map expressions into
their equivalent list comprehensions; also removing the lambda functions from each - making the code more
readable in the process.
GoalKicker.com – Python® Notes for Professionals
140# Filter:
# P(x) = x % 2 == 0
# S = range(10)
[x for x in range(10) if x % 2 == 0]
# Map
# F(x) = 2*x
# S = range(10)
[2*x for x in range(10)]
Readability becomes even more apparent when dealing with chaining functions. Where due to readability, the
results of one map or ﬁlter function should be passed as a result to the next; with simple cases, these can be
replaced with a single list comprehension. Further, we can easily tell from the list comprehension what the outcome
of our process is, where there is more cognitive load when reasoning about the chained Map & Filter process.
# Map & Filter
filtered = filter(lambda x: x % 2 == 0, range(10))
results = map(lambda x: 2*x, filtered)
# List comprehension
results = [2*x for x in range(10) if x % 2 == 0]
Refactoring - Quick Reference
Map
map(F, S) == [F(x) for x in S]
Filter
filter(P, S) == [x for x in S if P(x)]
where F and P are functions which respectively transform input values and return a bool
Section 21.9: Comprehensions involving tuples
The for clause of a list comprehension can specify more than one variable:
[x + y for x, y in [(1, 2), (3, 4), (5, 6)]]
# Out: [3, 7, 11]
[x + y for x, y in zip([1, 3, 5], [2, 4, 6])]
# Out: [3, 7, 11]
This is just like regular for loops:
for x, y in [(1,2), (3,4), (5,6)]:
print(x+y)
# 3
# 7
# 11
Note however, if the expression that begins the comprehension is a tuple then it must be parenthesized:
[x, y for x, y in [(1, 2), (3, 4), (5, 6)]]
GoalKicker.com – Python® Notes for Professionals
141# SyntaxError: invalid syntax
[(x, y) for x, y in [(1, 2), (3, 4), (5, 6)]]
# Out: [(1, 2), (3, 4), (5, 6)]
Section 21.10: Counting Occurrences Using Comprehension
When we want to count the number of items in an iterable, that meet some condition, we can use comprehension
to produce an idiomatic syntax:
# Count the numbers in `range(1000)` that are even and contain the digit `9`:
print (sum(
1 for x in range(1000)
if x % 2 == 0 and
'9' in str(x)
))
# Out: 95
The basic concept can be summarized as:
1. Iterate over the elements in range(1000).
2. Concatenate all the needed if conditions.
3. Use 1 as expression to return a 1 for each item that meets the conditions.
4. Sum up all the 1s to determine number of items that meet the conditions.
Note: Here we are not collecting the 1s in a list (note the absence of square brackets), but we are passing the ones
directly to the sum function that is summing them up. This is called a generator expression, which is similar to a
Comprehension.
Section 21.11: Changing Types in a List
Quantitative data is often read in as strings that must be converted to numeric types before processing. The types
of all list items can be converted with either a List Comprehension or the map() function.
# Convert a list of strings to integers.
items = ["1","2","3","4"]
[int(item) for item in items]
# Out: [1, 2, 3, 4]
# Convert a list of strings to float.
items = ["1","2","3","4"]
map(float, items)
# Out:[1.0, 2.0, 3.0, 4.0]
Section 21.12: Nested List Comprehensions
Nested list comprehensions, unlike list comprehensions with nested loops, are List comprehensions within a list
comprehension. The initial expression can be any arbitrary expression, including another list comprehension.
#List Comprehension with nested loop
[x + y for x in [1, 2, 3] for y in [3, 4, 5]]
#Out: [4, 5, 6, 5, 6, 7, 6, 7, 8]
#Nested List Comprehension
[[x + y for x in [1, 2, 3]] for y in [3, 4, 5]]
#Out: [[4, 5, 6], [5, 6, 7], [6, 7, 8]]
GoalKicker.com – Python® Notes for Professionals
142The Nested example is equivalent to
l = []
for y in [3, 4, 5]:
temp = []
for x in [1, 2, 3]:
temp.append(x + y)
l.append(temp)
One example where a nested comprehension can be used it to transpose a matrix.
matrix = [[1,2,3],
[4,5,6],
[7,8,9]]
[[row[i] for row in matrix] for i in range(len(matrix))]
# [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
Like nested for loops, there is no limit to how deep comprehensions can be nested.
[[[i + j + k for k in 'cd'] for j in 'ab'] for i in '12']
# Out: [[['1ac', '1ad'], ['1bc', '1bd']], [['2ac', '2ad'], ['2bc', '2bd']]]
Section 21.13: Iterate two or more list simultaneously within
list comprehension
For iterating more than two lists simultaneously within list comprehension, one may use zip() as:
>>> list_1 = [1, 2, 3 , 4]
>>> list_2 = ['a', 'b', 'c', 'd']
>>> list_3 = ['6', '7', '8', '9']
# Two lists
>>> [(i, j) for i, j in zip(list_1, list_2)]
[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd')]
# Three lists
>>> [(i, j, k) for i, j, k in zip(list_1, list_2, list_3)]
[(1, 'a', '6'), (2, 'b', '7'), (3, 'c', '8'), (4, 'd', '9')]
# so on ...
GoalKicker.com – Python® Notes for Professionals
143Chapter 22: List slicing (selecting parts of
lists)
Section 22.1: Using the third "step" argument
lst = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
lst[::2]
# Output: ['a', 'c', 'e', 'g']
lst[::3]
# Output: ['a', 'd', 'g']
Section 22.2: Selecting a sublist from a list
lst = ['a', 'b', 'c', 'd', 'e']
lst[2:4]
# Output: ['c', 'd']
lst[2:]
# Output: ['c', 'd', 'e']
lst[:4]
# Output: ['a', 'b', 'c', 'd']
Section 22.3: Reversing a list with slicing
a = [1, 2, 3, 4, 5]
# steps through the list backwards (step=-1)
b = a[::-1]
# built-in list method to reverse 'a'
a.reverse()
if a = b:
print(True)
print(b)
# Output:
# True
# [5, 4, 3, 2, 1]
Section 22.4: Shifting a list using slicing
def shift_list(array, s):
"""Shifts the elements of a list to the left or right.
Args:
array - the list to shift
s - the amount to shift the list ('+': right-shift, '-': left-shift)
Returns:
shifted_array - the shifted list
GoalKicker.com – Python® Notes for Professionals
144"""
# calculate actual shift amount (e.g., 11 --> 1 if length of the array is 5)
s %= len(array)
# reverse the shift direction to be more intuitive
s *= -1
# shift array with list slicing
shifted_array = array[s:] + array[:s]
return shifted_array
my_array = [1, 2, 3, 4, 5]
# negative numbers
shift_list(my_array, -7)
>>> [3, 4, 5, 1, 2]
# no shift on numbers equal to the size of the array
shift_list(my_array, 5)
>>> [1, 2, 3, 4, 5]
# works on positive numbers
shift_list(my_array, 3)
>>> [3, 4, 5, 1, 2]
GoalKicker.com – Python® Notes for Professionals
145Chapter 23: groupby()
Parameter
Details
iterable
Any python iterable
key
Function(criteria) on which to group the iterable
In Python, the itertools.groupby() method allows developers to group values of an iterable class based on a
speciﬁed property into another iterable set of values.
Section 23.1: Example 4
In this example we see what happens when we use diﬀerent types of iterable.
things = [("animal", "bear"), ("animal", "duck"), ("plant", "cactus"), ("vehicle", "harley"), \
("vehicle", "speed boat"), ("vehicle", "school bus")]
dic = {}
f = lambda x: x[0]
for key, group in groupby(sorted(things, key=f), f):
dic[key] = list(group)
dic
Results in
{'animal': [('animal', 'bear'), ('animal', 'duck')],
'plant': [('plant', 'cactus')],
'vehicle': [('vehicle', 'harley'),
('vehicle', 'speed boat'),
('vehicle', 'school bus')]}
This example below is essentially the same as the one above it. The only diﬀerence is that I have changed all the
tuples to lists.
things = [["animal", "bear"], ["animal", "duck"], ["vehicle", "harley"], ["plant", "cactus"], \
["vehicle", "speed boat"], ["vehicle", "school bus"]]
dic = {}
f = lambda x: x[0]
for key, group in groupby(sorted(things, key=f), f):
dic[key] = list(group)
dic
Results
{'animal': [['animal', 'bear'], ['animal', 'duck']],
'plant': [['plant', 'cactus']],
'vehicle': [['vehicle', 'harley'],
['vehicle', 'speed boat'],
['vehicle', 'school bus']]}
Section 23.2: Example 2
This example illustrates how the default key is chosen if we do not specify any
c = groupby(['goat', 'dog', 'cow', 1, 1, 2, 3, 11, 10, ('persons', 'man', 'woman')])
dic = {}
for k, v in c:
GoalKicker.com – Python® Notes for Professionals
146dic[k] = list(v)
dic
Results in
{1: [1, 1],
2: [2],
3: [3],
('persons', 'man', 'woman'): [('persons', 'man', 'woman')],
'cow': ['cow'],
'dog': ['dog'],
10: [10],
11: [11],
'goat': ['goat']}
Notice here that the tuple as a whole counts as one key in this list
Section 23.3: Example 3
Notice in this example that mulato and camel don't show up in our result. Only the last element with the speciﬁed
key shows up. The last result for c actually wipes out two previous results. But watch the new version where I have
the data sorted ﬁrst on same key.
list_things = ['goat', 'dog', 'donkey', 'mulato', 'cow', 'cat', ('persons', 'man', 'woman'), \
'wombat', 'mongoose', 'malloo', 'camel']
c = groupby(list_things, key=lambda x: x[0])
dic = {}
for k, v in c:
dic[k] = list(v)
dic
Results in
{'c': ['camel'],
'd': ['dog', 'donkey'],
'g': ['goat'],
'm': ['mongoose', 'malloo'],
'persons': [('persons', 'man', 'woman')],
'w': ['wombat']}
Sorted Version
list_things = ['goat', 'dog', 'donkey', 'mulato', 'cow', 'cat', ('persons', 'man', 'woman'), \
'wombat', 'mongoose', 'malloo', 'camel']
sorted_list = sorted(list_things, key = lambda x: x[0])
print(sorted_list)
print()
c = groupby(sorted_list, key=lambda x: x[0])
dic = {}
for k, v in c:
dic[k] = list(v)
dic
Results in
['cow', 'cat', 'camel', 'dog', 'donkey', 'goat', 'mulato', 'mongoose', 'malloo', ('persons', 'man',
'woman'), 'wombat']
GoalKicker.com – Python® Notes for Professionals
147{'c': ['cow', 'cat', 'camel'],
'd': ['dog', 'donkey'],
'g': ['goat'],
'm': ['mulato', 'mongoose', 'malloo'],
'persons': [('persons', 'man', 'woman')],
'w': ['wombat']}
GoalKicker.com – Python® Notes for Professionals
148Chapter 24: Linked lists
A linked list is a collection of nodes, each made up of a reference and a value. Nodes are strung together into a
sequence using their references. Linked lists can be used to implement more complex data structures like lists,
stacks, queues, and associative arrays.
Section 24.1: Single linked list example
This example implements a linked list with many of the same methods as that of the built-in list object.
class Node:
def __init__(self, val):
self.data = val
self.next = None
def getData(self):
return self.data
def getNext(self):
return self.next
def setData(self, val):
self.data = val
def setNext(self, val):
self.next = val
class LinkedList:
def __init__(self):
self.head = None
def isEmpty(self):
"""Check if the list is empty"""
return self.head is None
def add(self, item):
"""Add the item to the list"""
new_node = Node(item)
new_node.setNext(self.head)
self.head = new_node
def size(self):
"""Return the length/size of the list"""
count = 0
current = self.head
while current is not None:
count += 1
current = current.getNext()
return count
def search(self, item):
"""Search for item in list. If found, return True. If not found, return False"""
current = self.head
found = False
while current is not None and not found:
if current.getData() is item:
found = True
else:
current = current.getNext()
GoalKicker.com – Python® Notes for Professionals
149return found
def remove(self, item):
"""Remove item from list. If item is not found in list, raise ValueError"""
current = self.head
previous = None
found = False
while current is not None and not found:
if current.getData() is item:
found = True
else:
previous = current
current = current.getNext()
if found:
if previous is None:
self.head = current.getNext()
else:
previous.setNext(current.getNext())
else:
raise ValueError
print 'Value not found.'
def insert(self, position, item):
"""
Insert item at position specified. If position specified is
out of bounds, raise IndexError
"""
if position > self.size() - 1:
raise IndexError
print "Index out of bounds."
current = self.head
previous = None
pos = 0
if position is 0:
self.add(item)
else:
new_node = Node(item)
while pos < position:
pos += 1
previous = current
current = current.getNext()
previous.setNext(new_node)
new_node.setNext(current)
def index(self, item):
"""
Return the index where item is found.
If item is not found, return None.
"""
current = self.head
pos = 0
found = False
while current is not None and not found:
if current.getData() is item:
found = True
else:
current = current.getNext()
pos += 1
if found:
pass
else:
pos = None
GoalKicker.com – Python® Notes for Professionals
150return pos
def pop(self, position = None):
"""
If no argument is provided, return and remove the item at the head.
If position is provided, return and remove the item at that position.
If index is out of bounds, raise IndexError
"""
if position > self.size():
print 'Index out of bounds'
raise IndexError
current = self.head
if position is None:
ret = current.getData()
self.head = current.getNext()
else:
pos = 0
previous = None
while pos < position:
previous = current
current = current.getNext()
pos += 1
ret = current.getData()
previous.setNext(current.getNext())
print ret
return ret
def append(self, item):
"""Append item to the end of the list"""
current = self.head
previous = None
pos = 0
length = self.size()
while pos < length:
previous = current
current = current.getNext()
pos += 1
new_node = Node(item)
if previous is None:
new_node.setNext(current)
self.head = new_node
else:
previous.setNext(new_node)
def printList(self):
"""Print the list"""
current = self.head
while current is not None:
print current.getData()
current = current.getNext()
Usage functions much like that of the built-in list.
ll = LinkedList()
ll.add('l')
ll.add('H')
ll.insert(1,'e')
ll.append('l')
ll.append('o')
ll.printList()
GoalKicker.com – Python® Notes for Professionals
151H
e
l
l
o
GoalKicker.com – Python® Notes for Professionals
152VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 25: Linked List Node
Section 25.1: Write a simple Linked List Node in python
A linked list is either:
the empty list, represented by None, or
a node that contains a cargo object and a reference to a linked list.
#! /usr/bin/env python
class Node:
def __init__(self, cargo=None, next=None):
self.car = cargo
self.cdr = next
def __str__(self):
return str(self.car)
def display(lst):
if lst:
w("%s " % lst)
display(lst.cdr)
else:
w("nil\n")
GoalKicker.com – Python® Notes for Professionals
154Chapter 26: Filter
Parameter
function
iterable
Details
callable that determines the condition or None then use the identity function for ﬁltering (positional-
only)
iterable that will be ﬁltered (positional-only)
Section 26.1: Basic use of ﬁlter
To filter discards elements of a sequence based on some criteria:
names = ['Fred', 'Wilma', 'Barney']
def long_name(name):
return len(name) > 5
Python 2.x Version ≥ 2.0
filter(long_name, names)
# Out: ['Barney']
[name for name in names if len(name) > 5] # equivalent list comprehension
# Out: ['Barney']
from itertools import ifilter
ifilter(long_name, names)
# as generator (similar to python 3.x filter builtin)
# Out: <itertools.ifilter at 0x4197e10>
list(ifilter(long_name, names)) # equivalent to filter with lists
# Out: ['Barney']
(name for name in names if len(name) > 5) # equivalent generator expression
# Out: <generator object <genexpr> at 0x0000000003FD5D38>
Python 2.x Version ≥ 2.6
# Besides the options for older python 2.x versions there is a future_builtin function:
from future_builtins import filter
filter(long_name, names)
# identical to itertools.ifilter
# Out: <itertools.ifilter at 0x3eb0ba8>
Python 3.x Version ≥ 3.0
filter(long_name, names)
# returns a generator
# Out: <filter at 0x1fc6e443470>
list(filter(long_name, names)) # cast to list
# Out: ['Barney']
(name for name in names if len(name) > 5) # equivalent generator expression
# Out: <generator object <genexpr> at 0x000001C6F49BF4C0>
Section 26.2: Filter without function
If the function parameter is None, then the identity function will be used:
list(filter(None, [1, 0, 2, [], '', 'a']))
# Out: [1, 2, 'a']
# discards 0, [] and ''
Python 2.x Version ≥ 2.0.1
[i for i in [1, 0, 2, [], '', 'a'] if i] # equivalent list comprehension
Python 3.x Version ≥ 3.0.0
GoalKicker.com – Python® Notes for Professionals
155(i for i in [1, 0, 2, [], '', 'a'] if i) # equivalent generator expression
Section 26.3: Filter as short-circuit check
filter (python 3.x) and ifilter (python 2.x) return a generator so they can be very handy when creating a short-
circuit test like or or and:
Python 2.x Version ≥ 2.0.1
# not recommended in real use but keeps the example short:
from itertools import ifilter as filter
Python 2.x Version ≥ 2.6.1
from future_builtins import filter
To ﬁnd the ﬁrst element that is smaller than 100:
car_shop = [('Toyota', 1000), ('rectangular tire', 80), ('Porsche', 5000)]
def find_something_smaller_than(name_value_tuple):
print('Check {0}, {1}$'.format(*name_value_tuple)
return name_value_tuple[1] < 100
next(filter(find_something_smaller_than, car_shop))
# Print: Check Toyota, 1000$
#
Check rectangular tire, 80$
# Out: ('rectangular tire', 80)
The next-function gives the next (in this case ﬁrst) element of and is therefore the reason why it's short-circuit.
Section 26.4: Complementary function: ﬁlterfalse, iﬁlterfalse
There is a complementary function for filter in the itertools-module:
Python 2.x Version ≥ 2.0.1
# not recommended in real use but keeps the example valid for python 2.x and python 3.x
from itertools import ifilterfalse as filterfalse
Python 3.x Version ≥ 3.0.0
from itertools import filterfalse
which works exactly like the generator filter but keeps only the elements that are False:
# Usage without function (None):
list(filterfalse(None, [1, 0, 2, [], '', 'a']))
# Out: [0, [], '']
# discards 1, 2, 'a'
# Usage with function
names = ['Fred', 'Wilma', 'Barney']
def long_name(name):
return len(name) > 5
list(filterfalse(long_name, names))
# Out: ['Fred', 'Wilma']
# Short-circuit usage with next:
car_shop = [('Toyota', 1000), ('rectangular tire', 80), ('Porsche', 5000)]
def find_something_smaller_than(name_value_tuple):
GoalKicker.com – Python® Notes for Professionals
156print('Check {0}, {1}$'.format(*name_value_tuple)
return name_value_tuple[1] < 100
next(filterfalse(find_something_smaller_than, car_shop))
# Print: Check Toyota, 1000$
# Out: ('Toyota', 1000)
# Using an equivalent generator:
car_shop = [('Toyota', 1000), ('rectangular tire', 80), ('Porsche', 5000)]
generator = (car for car in car_shop if not car[1] < 100)
next(generator)
GoalKicker.com – Python® Notes for Professionals
157Chapter 27: Heapq
Section 27.1: Largest and smallest items in a collection
To ﬁnd the largest items in a collection, heapq module has a function called nlargest, we pass it two arguments, the
ﬁrst one is the number of items that we want to retrieve, the second one is the collection name:
import heapq
numbers = [1, 4, 2, 100, 20, 50, 32, 200, 150, 8]
print(heapq.nlargest(4, numbers)) # [200, 150, 100, 50]
Similarly, to ﬁnd the smallest items in a collection, we use nsmallest function:
print(heapq.nsmallest(4, numbers))
# [1, 2, 4, 8]
Both nlargest and nsmallest functions take an optional argument (key parameter) for complicated data
structures. The following example shows the use of age property to retrieve the oldest and the youngest people
from people dictionary:
people = [
{'firstname': 'John', 'lastname': 'Doe', 'age': 30},
{'firstname': 'Jane', 'lastname': 'Doe', 'age': 25},
{'firstname': 'Janie', 'lastname': 'Doe', 'age': 10},
{'firstname': 'Jane', 'lastname': 'Roe', 'age': 22},
{'firstname': 'Johnny', 'lastname': 'Doe', 'age': 12},
{'firstname': 'John', 'lastname': 'Roe', 'age': 45}
]
oldest = heapq.nlargest(2, people, key=lambda s: s['age'])
print(oldest)
# Output: [{'firstname': 'John', 'age': 45, 'lastname': 'Roe'}, {'firstname': 'John', 'age': 30,
'lastname': 'Doe'}]
youngest = heapq.nsmallest(2, people, key=lambda s: s['age'])
print(youngest)
# Output: [{'firstname': 'Janie', 'age': 10, 'lastname': 'Doe'}, {'firstname': 'Johnny', 'age': 12,
'lastname': 'Doe'}]
Section 27.2: Smallest item in a collection
The most interesting property of a heap is that its smallest element is always the ﬁrst element: heap[0]
import heapq
numbers = [10, 4, 2, 100, 20, 50, 32, 200, 150, 8]
heapq.heapify(numbers)
print(numbers)
# Output: [2, 4, 10, 100, 8, 50, 32, 200, 150, 20]
heapq.heappop(numbers) # 2
print(numbers)
# Output: [4, 8, 10, 100, 20, 50, 32, 200, 150]
GoalKicker.com – Python® Notes for Professionals
158heapq.heappop(numbers) # 4
print(numbers)
# Output: [8, 20, 10, 100, 150, 50, 32, 200]
GoalKicker.com – Python® Notes for Professionals
159Chapter 28: Tuple
A tuple is an immutable list of values. Tuples are one of Python's simplest and most common collection types, and
can be created with the comma operator (value = 1, 2, 3).
Section 28.1: Tuple
Syntactically, a tuple is a comma-separated list of values:
t = 'a', 'b', 'c', 'd', 'e'
Although not necessary, it is common to enclose tuples in parentheses:
t = ('a', 'b', 'c', 'd', 'e')
Create an empty tuple with parentheses:
t0 = ()
type(t0)
# <type 'tuple'>
To create a tuple with a single element, you have to include a ﬁnal comma:
t1 = 'a',
type(t1)
# <type 'tuple'>
Note that a single value in parentheses is not a tuple:
t2 = ('a')
type(t2)
# <type 'str'>
To create a singleton tuple it is necessary to have a trailing comma.
t2 = ('a',)
type(t2)
# <type 'tuple'>
Note that for singleton tuples it's recommended (see PEP8 on trailing commas) to use parentheses. Also, no white
space after the trailing comma (see PEP8 on whitespaces)
t2 = ('a',)
t2 = 'a',
t2 = ('a', )
# PEP8-compliant
# this notation is not recommended by PEP8
# this notation is not recommended by PEP8
Another way to create a tuple is the built-in function tuple.
t = tuple('lupins')
print(t)
t = tuple(range(3))
print(t)
# ('l', 'u', 'p', 'i', 'n', 's')
# (0, 1, 2)
These examples are based on material from the book Think Python by Allen B. Downey.
GoalKicker.com – Python® Notes for Professionals
160Section 28.2: Tuples are immutable
One of the main diﬀerences between lists and tuples in Python is that tuples are immutable, that is, one cannot
add or modify items once the tuple is initialized. For example:
>>> t = (1, 4, 9)
>>> t[0] = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
Similarly, tuples don't have .append and .extend methods as list does. Using += is possible, but it changes the
binding of the variable, and not the tuple itself:
>>> t = (1, 2)
>>> q = t
>>> t += (3, 4)
>>> t
(1, 2, 3, 4)
>>> q
(1, 2)
Be careful when placing mutable objects, such as lists, inside tuples. This may lead to very confusing outcomes
when changing them. For example:
>>> t = (1, 2, 3, [1, 2, 3])
(1, 2, 3, [1, 2, 3])
>>> t[3] += [4, 5]
Will both raise an error and change the contents of the list within the tuple:
TypeError: 'tuple' object does not support item assignment
>>> t
(1, 2, 3, [1, 2, 3, 4, 5])
You can use the += operator to "append" to a tuple - this works by creating a new tuple with the new element you
"appended" and assign it to its current variable; the old tuple is not changed, but replaced!
This avoids converting to and from a list, but this is slow and is a bad practice, especially if you're going to append
multiple times.
Section 28.3: Packing and Unpacking Tuples
Tuples in Python are values separated by commas. Enclosing parentheses for inputting tuples are optional, so the
two assignments
a = 1, 2, 3
# a is the tuple (1, 2, 3)
and
a = (1, 2, 3) # a is the tuple (1, 2, 3)
are equivalent. The assignment a = 1, 2, 3 is also called packing because it packs values together in a tuple.
Note that a one-value tuple is also a tuple. To tell Python that a variable is a tuple and not a single value you can use
GoalKicker.com – Python® Notes for Professionals
161a trailing comma
a = 1 # a is the value 1
a = 1, # a is the tuple (1,)
A comma is needed also if you use parentheses
a = (1,) # a is the tuple (1,)
a = (1) # a is the value 1 and not a tuple
To unpack values from a tuple and do multiple assignments use
# unpacking AKA multiple assignment
x, y, z = (1, 2, 3)
# x == 1
# y == 2
# z == 3
The symbol _ can be used as a disposable variable name if one only needs some elements of a tuple, acting as a
placeholder:
a = 1, 2, 3, 4
_, x, y, _ = a
# x == 2
# y == 3
Single element tuples:
x, = 1,
x = 1,
# x is the value 1
# x is the tuple (1,)
In Python 3 a target variable with a * preﬁx can be used as a catch-all variable (see Unpacking Iterables ):
Python 3.x Version ≥ 3.0
first, *more, last = (1, 2, 3, 4, 5)
# first == 1
# more == [2, 3, 4]
# last == 5
Section 28.4: Built-in Tuple Functions
Tuples support the following build-in functions
Comparison
If elements are of the same type, python performs the comparison and returns the result. If elements are diﬀerent
types, it checks whether they are numbers.
If numbers, perform comparison.
If either element is a number, then the other element is returned.
Otherwise, types are sorted alphabetically .
If we reached the end of one of the lists, the longer list is "larger." If both list are same it returns 0.
tuple1 = ('a', 'b', 'c', 'd', 'e')
tuple2 = ('1','2','3')
GoalKicker.com – Python® Notes for Professionals
162tuple3 = ('a', 'b', 'c', 'd', 'e')
cmp(tuple1, tuple2)
Out: 1
cmp(tuple2, tuple1)
Out: -1
cmp(tuple1, tuple3)
Out: 0
Tuple Length
The function len returns the total length of the tuple
len(tuple1)
Out: 5
Max of a tuple
The function max returns item from the tuple with the max value
max(tuple1)
Out: 'e'
max(tuple2)
Out: '3'
Min of a tuple
The function min returns the item from the tuple with the min value
min(tuple1)
Out: 'a'
min(tuple2)
Out: '1'
Convert a list into tuple
The built-in function tuple converts a list into a tuple.
list = [1,2,3,4,5]
tuple(list)
Out: (1, 2, 3, 4, 5)
Tuple concatenation
Use + to concatenate two tuples
tuple1 + tuple2
Out: ('a', 'b', 'c', 'd', 'e', '1', '2', '3')
Section 28.5: Tuple Are Element-wise Hashable and Equatable
hash( (1, 2) ) # ok
hash( ([], {"hello"})
# not ok, since lists and sets are not hashabe
Thus a tuple can be put inside a set or as a key in a dict only if each of its elements can.
{ (1, 2) } #
ok
GoalKicker.com – Python® Notes for Professionals
163{ ([], {"hello"}) ) # not ok
Section 28.6: Indexing Tuples
x = (1, 2, 3)
x[0] # 1
x[1] # 2
x[2] # 3
x[3] # IndexError: tuple index out of range
Indexing with negative numbers will start from the last element as -1:
x[-1] # 3
x[-2] # 2
x[-3] # 1
x[-4] # IndexError: tuple index out of range
Indexing a range of elements
print(x[:-1])
print(x[-1:])
print(x[1:3])
# (1, 2)
# (3,)
# (2, 3)
Section 28.7: Reversing Elements
Reverse elements within a tuple
colors = "red", "green", "blue"
rev = colors[::-1]
# rev: ("blue", "green", "red")
colors = rev
# colors: ("blue", "green", "red")
Or using reversed (reversed gives an iterable which is converted to a tuple):
rev = tuple(reversed(colors))
# rev: ("blue", "green", "red")
colors = rev
# colors: ("blue", "green", "red")
GoalKicker.com – Python® Notes for Professionals
164Chapter 29: Basic Input and Output
Section 29.1: Using the print function
Python 3.x Version ≥ 3.0
In Python 3, print functionality is in the form of a function:
print("This string will be displayed in the output")
# This string will be displayed in the output
print("You can print \n escape characters too.")
# You can print escape characters too.
Python 2.x Version ≥ 2.3
In Python 2, print was originally a statement, as shown below.
print "This string will be displayed in the output"
# This string will be displayed in the output
print "You can print \n escape characters too."
# You can print escape characters too.
Note: using from __future__ import print_function in Python 2 will allow users to use the print() function the
same as Python 3 code. This is only available in Python 2.6 and above.
Section 29.2: Input from a File
Input can also be read from ﬁles. Files can be opened using the built-in function open. Using a with <command> as
<name> syntax (called a 'Context Manager') makes using open and getting a handle for the ﬁle super easy:
with open('somefile.txt', 'r') as fileobj:
# write code here using fileobj
This ensures that when code execution leaves the block the ﬁle is automatically closed.
Files can be opened in diﬀerent modes. In the above example the ﬁle is opened as read-only. To open an existing
ﬁle for reading only use r. If you want to read that ﬁle as bytes use rb. To append data to an existing ﬁle use a. Use
w to create a ﬁle or overwrite any existing ﬁles of the same name. You can use r+ to open a ﬁle for both reading and
writing. The ﬁrst argument of open() is the ﬁlename, the second is the mode. If mode is left blank, it will default to
r.
# let's create an example file:
with open('shoppinglist.txt', 'w') as fileobj:
fileobj.write('tomato\npasta\ngarlic')
with open('shoppinglist.txt', 'r') as fileobj:
# this method makes a list where each line
# of the file is an element in the list
lines = fileobj.readlines()
print(lines)
# ['tomato\n', 'pasta\n', 'garlic']
with open('shoppinglist.txt', 'r') as fileobj:
GoalKicker.com – Python® Notes for Professionals
165# here we read the whole content into one string:
content = fileobj.read()
# get a list of lines, just like int the previous example:
lines = content.split('\n')
print(lines)
# ['tomato', 'pasta', 'garlic']
If the size of the ﬁle is tiny, it is safe to read the whole ﬁle contents into memory. If the ﬁle is very large it is often
better to read line-by-line or by chunks, and process the input in the same loop. To do that:
with open('shoppinglist.txt', 'r') as fileobj:
# this method reads line by line:
lines = []
for line in fileobj:
lines.append(line.strip())
When reading ﬁles, be aware of the operating system-speciﬁc line-break characters. Although for line in
fileobj automatically strips them oﬀ, it is always safe to call strip() on the lines read, as it is shown above.
Opened ﬁles (fileobj in the above examples) always point to a speciﬁc location in the ﬁle. When they are ﬁrst
opened the ﬁle handle points to the very beginning of the ﬁle, which is the position 0. The ﬁle handle can display its
current position with tell:
fileobj = open('shoppinglist.txt', 'r')
pos = fileobj.tell()
print('We are at %u.' % pos) # We are at 0.
Upon reading all the content, the ﬁle handler's position will be pointed at the end of the ﬁle:
content = fileobj.read()
end = fileobj.tell()
print('This file was %u characters long.' % end)
# This file was 22 characters long.
fileobj.close()
The ﬁle handler position can be set to whatever is needed:
fileobj = open('shoppinglist.txt', 'r')
fileobj.seek(7)
pos = fileobj.tell()
print('We are at character #%u.' % pos)
You can also read any length from the ﬁle content during a given call. To do this pass an argument for read().
When read() is called with no argument it will read until the end of the ﬁle. If you pass an argument it will read that
number of bytes or characters, depending on the mode (rb and r respectively):
# reads the next 4 characters
# starting at the current position
next4 = fileobj.read(4)
# what we got?
print(next4) # 'cucu'
# where we are now?
pos = fileobj.tell()
print('We are at %u.' % pos) # We are at 11, as we was at 7, and read 4 chars.
fileobj.close()
GoalKicker.com – Python® Notes for Professionals
166To demonstrate the diﬀerence between characters and bytes:
with open('shoppinglist.txt', 'r') as fileobj:
print(type(fileobj.read())) # <class 'str'>
with open('shoppinglist.txt', 'rb') as fileobj:
print(type(fileobj.read())) # <class 'bytes'>
Section 29.3: Read from stdin
Python programs can read from unix pipelines. Here is a simple example how to read from stdin:
import sys
for line in sys.stdin:
print(line)
Be aware that sys.stdin is a stream. It means that the for-loop will only terminate when the stream has ended.
You can now pipe the output of another program into your python program as follows:
$ cat myfile | python myprogram.py
In this example cat myfile can be any unix command that outputs to stdout.
Alternatively, using the ﬁleinput module can come in handy:
import fileinput
for line in fileinput.input():
process(line)
Section 29.4: Using input() and raw_input()
Python 2.x Version ≥ 2.3
raw_input will wait for the user to enter text and then return the result as a string.
foo = raw_input("Put a message here that asks the user for input")
In the above example foo will store whatever input the user provides.
Python 3.x Version ≥ 3.0
input will wait for the user to enter text and then return the result as a string.
foo = input("Put a message here that asks the user for input")
In the above example foo will store whatever input the user provides.
Section 29.5: Function to prompt user for a number
def input_number(msg, err_msg=None):
while True:
try:
GoalKicker.com – Python® Notes for Professionals
167return float(raw_input(msg))
except ValueError:
if err_msg is not None:
print(err_msg)
def input_number(msg, err_msg=None):
while True:
try:
return float(input(msg))
except ValueError:
if err_msg is not None:
print(err_msg)
And to use it:
user_number = input_number("input a number: ", "that's not a number!")
Or, if you do not want an "error message":
user_number = input_number("input a number: ")
Section 29.6: Printing a string without a newline at the end
Python 2.x Version ≥ 2.3
In Python 2.x, to continue a line with print, end the print statement with a comma. It will automatically add a
space.
print "Hello,",
print "World!"
# Hello, World!
Python 3.x Version ≥ 3.0
In Python 3.x, the print function has an optional end parameter that is what it prints at the end of the given string.
By default it's a newline character, so equivalent to this:
print("Hello, ", end="\n")
print("World!")
# Hello,
# World!
But you could pass in other strings
print("Hello, ", end="")
print("World!")
# Hello, World!
print("Hello, ", end="<br>")
print("World!")
# Hello, <br>World!
print("Hello, ", end="BREAK")
print("World!")
# Hello, BREAKWorld!
If you want more control over the output, you can use sys.stdout.write:
GoalKicker.com – Python® Notes for Professionals
168import sys
sys.stdout.write("Hello, ")
sys.stdout.write("World!")
# Hello, World!
GoalKicker.com – Python® Notes for Professionals
169VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 30: Files & Folders I/O
Parameter
Details
ﬁlename
the path to your ﬁle or, if the ﬁle is in the working directory, the ﬁlename of your ﬁle
access_mode a string value that determines how the ﬁle is opened
buﬀering
an integer value used for optional line buﬀering
When it comes to storing, reading, or communicating data, working with the ﬁles of an operating system is both
necessary and easy with Python. Unlike other languages where ﬁle input and output requires complex reading and
writing objects, Python simpliﬁes the process only needing commands to open, read/write and close the ﬁle. This
topic explains how Python can interface with ﬁles on the operating system.
Section 30.1: File modes
There are diﬀerent modes you can open a ﬁle with, speciﬁed by the mode parameter. These include:
'r' - reading mode. The default. It allows you only to read the ﬁle, not to modify it. When using this mode the
ﬁle must exist.
'w' - writing mode. It will create a new ﬁle if it does not exist, otherwise will erase the ﬁle and allow you to
write to it.
'a' - append mode. It will write data to the end of the ﬁle. It does not erase the ﬁle, and the ﬁle must exist for
this mode.
'rb' - reading mode in binary. This is similar to r except that the reading is forced in binary mode. This is
also a default choice.
'r+' - reading mode plus writing mode at the same time. This allows you to read and write into ﬁles at the
same time without having to use r and w.
'rb+' - reading and writing mode in binary. The same as r+ except the data is in binary
'wb' - writing mode in binary. The same as w except the data is in binary.
'w+' - writing and reading mode. The exact same as r+ but if the ﬁle does not exist, a new one is made.
Otherwise, the ﬁle is overwritten.
'wb+' - writing and reading mode in binary mode. The same as w+ but the data is in binary.
'ab' - appending in binary mode. Similar to a except that the data is in binary.
'a+' - appending and reading mode. Similar to w+ as it will create a new ﬁle if the ﬁle does not exist.
Otherwise, the ﬁle pointer is at the end of the ﬁle if it exists.
'ab+' - appending and reading mode in binary. The same as a+ except that the data is in binary.
with open(filename, 'r') as f:
f.read()
with open(filename, 'w') as f:
f.write(filedata)
with open(filename, 'a') as f:
f.write('\\n' + newdata)
r
Read
✔
r+
w w+ a a+
✔
✘
✔
✘ ✔
GoalKicker.com – Python® Notes for Professionals
171Write✘✔✔✔✔✔
Creates ﬁle✘✘✔✔✔✔
Erases ﬁle✘✘✔✔✘✘
Initial position Start Start Start Start End End
Python 3 added a new mode for exclusive creation so that you will not accidentally truncate or overwrite and
existing ﬁle.
'x' - open for exclusive creation, will raise FileExistsError if the ﬁle already exists
'xb' - open for exclusive creation writing mode in binary. The same as x except the data is in binary.
'x+' - reading and writing mode. Similar to w+ as it will create a new ﬁle if the ﬁle does not exist. Otherwise,
will raise FileExistsError.
'xb+' - writing and reading mode. The exact same as x+ but the data is binary
x
Read✘x+
✔
Write✔✔
Creates ﬁle✔✔
Erases ﬁle✘✘
Initial position Start Start
Allow one to write your ﬁle open code in a more pythonic manner:
Python 3.x Version ≥ 3.3
try:
with open("fname", "r") as fout:
# Work with your open file
except FileExistsError:
# Your error handling goes here
In Python 2 you would have done something like
Python 2.x Version ≥ 2.0
import os.path
if os.path.isfile(fname):
with open("fname", "w") as fout:
# Work with your open file
else:
# Your error handling goes here
Section 30.2: Reading a ﬁle line-by-line
The simplest way to iterate over a ﬁle line-by-line:
with open('myfile.txt', 'r') as fp:
for line in fp:
print(line)
readline() allows for more granular control over line-by-line iteration. The example below is equivalent to the one
above:
with open('myfile.txt', 'r') as fp:
while True:
cur_line = fp.readline()
GoalKicker.com – Python® Notes for Professionals
172# If the result is an empty string
if cur_line == '':
# We have reached the end of the file
break
print(cur_line)
Using the for loop iterator and readline() together is considered bad practice.
More commonly, the readlines() method is used to store an iterable collection of the ﬁle's lines:
with open("myfile.txt", "r") as fp:
lines = fp.readlines()
for i in range(len(lines)):
print("Line " + str(i) + ": " + line)
This would print the following:
Line 0: hello
Line 1: world
Section 30.3: Iterate ﬁles (recursively)
To iterate all ﬁles, including in sub directories, use os.walk:
import os
for root, folders, files in os.walk(root_dir):
for filename in files:
print root, filename
root_dir can be "." to start from current directory, or any other path to start from.
Python 3.x Version ≥ 3.5
If you also wish to get information about the ﬁle, you may use the more eﬃcient method os.scandir like so:
for entry in os.scandir(path):
if not entry.name.startswith('.') and entry.is_file():
print(entry.name)
Section 30.4: Getting the full contents of a ﬁle
The preferred method of ﬁle i/o is to use the with keyword. This will ensure the ﬁle handle is closed once the
reading or writing has been completed.
with open('myfile.txt') as in_file:
content = in_file.read()
print(content)
or, to handle closing the ﬁle manually, you can forgo with and simply call close yourself:
in_file = open('myfile.txt', 'r')
content = in_file.read()
print(content)
GoalKicker.com – Python® Notes for Professionals
173in_file.close()
Keep in mind that without using a with statement, you might accidentally keep the ﬁle open in case an unexpected
exception arises like so:
in_file = open('myfile.txt', 'r')
raise Exception("oops")
in_file.close() # This will never be called
Section 30.5: Writing to a ﬁle
with open('myfile.txt', 'w') as f:
f.write("Line 1")
f.write("Line 2")
f.write("Line 3")
f.write("Line 4")
If you open myfile.txt, you will see that its contents are:
Line 1Line 2Line 3Line 4
Python doesn't automatically add line breaks, you need to do that manually:
with open('myfile.txt', 'w') as f:
f.write("Line 1\n")
f.write("Line 2\n")
f.write("Line 3\n")
f.write("Line 4\n")
Line 1
Line 2
Line 3
Line 4
Do not use os.linesep as a line terminator when writing ﬁles opened in text mode (the default); use \n instead.
If you want to specify an encoding, you simply add the encoding parameter to the open function:
with open('my_file.txt', 'w', encoding='utf-8') as f:
f.write('utf-8 text')
It is also possible to use the print statement to write to a ﬁle. The mechanics are diﬀerent in Python 2 vs Python 3,
but the concept is the same in that you can take the output that would have gone to the screen and send it to a ﬁle
instead.
Python 3.x Version ≥ 3.0
with open('fred.txt', 'w') as outfile:
s = "I'm Not Dead Yet!"
print(s) # writes to stdout
print(s, file = outfile) # writes to outfile
#Note: it is possible to specify the file parameter AND write to the screen
#by making sure file ends up with a None value either directly or via a variable
GoalKicker.com – Python® Notes for Professionals
174myfile = None
print(s, file = myfile) # writes to stdout
print(s, file = None)
# writes to stdout
In Python 2 you would have done something like
Python 2.x Version ≥ 2.0
outfile = open('fred.txt', 'w')
s = "I'm Not Dead Yet!"
print s
# writes to stdout
print >> outfile, s
# writes to outfile
Unlike using the write function, the print function does automatically add line breaks.
Section 30.6: Check whether a ﬁle or path exists
Employ the EAFP coding style and try to open it.
import errno
try:
with open(path) as f:
# File exists
except IOError as e:
# Raise the exception if it is not ENOENT (No such file or directory)
if e.errno != errno.ENOENT:
raise
# No such file or directory
This will also avoid race-conditions if another process deleted the ﬁle between the check and when it is used. This
race condition could happen in the following cases:
Using the os module:
import os
os.path.isfile('/path/to/some/file.txt')
Python 3.x Version ≥ 3.4
Using pathlib:
import pathlib
path = pathlib.Path('/path/to/some/file.txt')
if path.is_file():
...
To check whether a given path exists or not, you can follow the above EAFP procedure, or explicitly check the path:
import os
path = "/home/myFiles/directory1"
if os.path.exists(path):
## Do stuff
GoalKicker.com – Python® Notes for Professionals
175Section 30.7: Random File Access Using mmap
Using the mmap module allows the user to randomly access locations in a ﬁle by mapping the ﬁle into memory. This
is an alternative to using normal ﬁle operations.
import mmap
with open('filename.ext', 'r') as fd:
# 0: map the whole file
mm = mmap.mmap(fd.fileno(), 0)
# print characters at indices 5 through 10
print mm[5:10]
# print the line starting from mm's current position
print mm.readline()
# write a character to the 5th index
mm[5] = 'a'
# return mm's position to the beginning of the file
mm.seek(0)
# close the mmap object
mm.close()
Section 30.8: Replacing text in a ﬁle
import fileinput
replacements = {'Search1': 'Replace1',
'Search2': 'Replace2'}
for line in fileinput.input('filename.txt', inplace=True):
for search_for in replacements:
replace_with = replacements[search_for]
line = line.replace(search_for, replace_with)
print(line, end='')
Section 30.9: Checking if a ﬁle is empty
>>> import os
>>> os.stat(path_to_file).st_size == 0
or
>>> import os
>>> os.path.getsize(path_to_file) > 0
However, both will throw an exception if the ﬁle does not exist. To avoid having to catch such an error, do this:
import os
def is_empty_file(fpath):
return os.path.isfile(fpath) and os.path.getsize(fpath) > 0
which will return a bool value.
GoalKicker.com – Python® Notes for Professionals
176Section 30.10: Read a ﬁle between a range of lines
So let's suppose you want to iterate only between some speciﬁc lines of a ﬁle
You can make use of itertools for that
import itertools
with open('myfile.txt', 'r') as f:
for line in itertools.islice(f, 12, 30):
# do something here
This will read through the lines 13 to 20 as in python indexing starts from 0. So line number 1 is indexed as 0
As can also read some extra lines by making use of the next() keyword here.
And when you are using the ﬁle object as an iterable, please don't use the readline() statement here as the two
techniques of traversing a ﬁle are not to be mixed together
Section 30.11: Copy a directory tree
import shutil
source='//192.168.1.2/Daily Reports'
destination='D:\\Reports\\Today'
shutil.copytree(source, destination)
The destination directory must not exist already.
Section 30.12: Copying contents of one ﬁle to a dierent ﬁle
with open(input_file, 'r') as in_file, open(output_file, 'w') as out_file:
for line in in_file:
out_file.write(line)
Using the shutil module:
import shutil
shutil.copyfile(src, dst)
GoalKicker.com – Python® Notes for Professionals
177Chapter 31: os.path
This module implements some useful functions on pathnames. The path parameters can be passed as either
strings, or bytes. Applications are encouraged to represent ﬁle names as (Unicode) character strings.
Section 31.1: Join Paths
To join two or more path components together, ﬁrstly import os module of python and then use following:
import os
os.path.join('a', 'b', 'c')
The advantage of using os.path is that it allows code to remain compatible over all operating systems, as this uses
the separator appropriate for the platform it's running on.
For example, the result of this command on Windows will be:
>>> os.path.join('a', 'b', 'c')
'a\b\c'
In an Unix OS:
>>> os.path.join('a', 'b', 'c')
'a/b/c'
Section 31.2: Path Component Manipulation
To split one component oﬀ of the path:
>>> p = os.path.join(os.getcwd(), 'foo.txt')
>>> p
'/Users/csaftoiu/tmp/foo.txt'
>>> os.path.dirname(p)
'/Users/csaftoiu/tmp'
>>> os.path.basename(p)
'foo.txt'
>>> os.path.split(os.getcwd())
('/Users/csaftoiu/tmp', 'foo.txt')
>>> os.path.splitext(os.path.basename(p))
('foo', '.txt')
Section 31.3: Get the parent directory
os.path.abspath(os.path.join(PATH_TO_GET_THE_PARENT, os.pardir))
Section 31.4: If the given path exists
to check if the given path exists
path = '/home/john/temp'
os.path.exists(path)
#this returns false if path doesn't exist or if the path is a broken symbolic link
GoalKicker.com – Python® Notes for Professionals
178Section 31.5: check if the given path is a directory, ﬁle,
symbolic link, mount point etc
to check if the given path is a directory
dirname = '/home/john/python'
os.path.isdir(dirname)
to check if the given path is a ﬁle
filename = dirname + 'main.py'
os.path.isfile(filename)
to check if the given path is symbolic link
symlink = dirname + 'some_sym_link'
os.path.islink(symlink)
to check if the given path is a mount point
mount_path = '/home'
os.path.ismount(mount_path)
Section 31.6: Absolute Path from Relative Path
Use os.path.abspath:
>>> os.getcwd()
'/Users/csaftoiu/tmp'
>>> os.path.abspath('foo')
'/Users/csaftoiu/tmp/foo'
>>> os.path.abspath('../foo')
'/Users/csaftoiu/foo'
>>> os.path.abspath('/foo')
'/foo'
GoalKicker.com – Python® Notes for Professionals
179Chapter 32: Iterables and Iterators
Section 32.1: Iterator vs Iterable vs Generator
An iterable is an object that can return an iterator. Any object with state that has an __iter__ method and returns
an iterator is an iterable. It may also be an object without state that implements a __getitem__ method. - The
method can take indices (starting from zero) and raise an IndexError when the indices are no longer valid.
Python's str class is an example of a __getitem__ iterable.
An Iterator is an object that produces the next value in a sequence when you call next(*object*) on some object.
Moreover, any object with a __next__ method is an iterator. An iterator raises StopIteration after exhausting the
iterator and cannot be re-used at this point.
Iterable classes:
Iterable classes deﬁne an __iter__ and a __next__ method. Example of an iterable class:
class MyIterable:
def __iter__(self):
return self
def __next__(self):
#code
#Classic iterable object in older versions of python, __getitem__ is still supported...
class MySequence:
def __getitem__(self, index):
if (condition):
raise IndexError
return (item)
#Can produce a plain `iterator` instance by using iter(MySequence())
Trying to instantiate the abstract class from the collections module to better see this.
Example:
Python 2.x Version ≥ 2.3
import collections
>>> collections.Iterator()
>>> TypeError: Cant instantiate abstract class Iterator with abstract methods next
Python 3.x Version ≥ 3.0
>>> TypeError: Cant instantiate abstract class Iterator with abstract methods __next__
Handle Python 3 compatibility for iterable classes in Python 2 by doing the following:
Python 2.x Version ≥ 2.3
class MyIterable(object): #or collections.Iterator, which I'd recommend....
....
GoalKicker.com – Python® Notes for Professionals
180def __iter__(self):
return self
def next(self): #code
__next__ = next
Both of these are now iterators and can be looped through:
ex1 = MyIterableClass()
ex2 = MySequence()
for (item) in (ex1): #code
for (item) in (ex2): #code
Generators are simple ways to create iterators. A generator is an iterator and an iterator is an iterable.
Section 32.2: Extract values one by one
Start with iter() built-in to get iterator over iterable and use next() to get elements one by one until
StopIteration is raised signifying the end:
s = {1, 2}
i = iter(s)
a = next(i)
b = next(i)
c = next(i)
# or list or generator or even iterator
# get iterator
# a = 1
# b = 2
# raises StopIteration
Section 32.3: Iterating over entire iterable
s = {1, 2, 3}
# get every element in s
for a in s:
print a # prints 1, then 2, then 3
# copy into list
l1 = list(s) # l1 = [1, 2, 3]
# use list comprehension
l2 = [a * 2 for a in s if a > 2]
# l2 = [6]
Section 32.4: Verify only one element in iterable
Use unpacking to extract the ﬁrst element and ensure it's the only one:
a, = iterable
def foo():
yield 1
a, = foo()
# a = 1
nums = [1, 2, 3]
a, = nums # ValueError: too many values to unpack
GoalKicker.com – Python® Notes for Professionals
181Section 32.5: What can be iterable
Iterable can be anything for which items are received one by one, forward only. Built-in Python collections are
iterable:
[1, 2, 3]
(1, 2, 3)
{1, 2, 3}
{1: 2, 3: 4}
# list, iterate over items
# tuple
# set
# dict, iterate over keys
Generators return iterables:
def foo(): # foo isn't iterable yet...
yield 1
res = foo()
# ...but res already is
Section 32.6: Iterator isn't reentrant!
def gen():
yield 1
iterable = gen()
for a in iterable:
print a
# What was the first item of iterable? No way to get it now.
# Only to get a new iterator
gen()
GoalKicker.com – Python® Notes for Professionals
182Chapter 33: Functions
Parameter
Details
arg1, ..., argN Regular arguments
*args
Unnamed positional arguments
kw1, ..., kwN Keyword-only arguments
**kwargs
The rest of keyword arguments
Functions in Python provide organized, reusable and modular code to perform a set of speciﬁc actions. Functions
simplify the coding process, prevent redundant logic, and make the code easier to follow. This topic describes the
declaration and utilization of functions in Python.
Python has many built-in functions like print(), input(), len(). Besides built-ins you can also create your own
functions to do more speciﬁc jobs—these are called user-deﬁned functions.
Section 33.1: Deﬁning and calling simple functions
Using the def statement is the most common way to deﬁne a function in python. This statement is a so called single
clause compound statement with the following syntax:
def function_name(parameters):
statement(s)
function_name is known as the identiﬁer of the function. Since a function deﬁnition is an executable statement its
execution binds the function name to the function object which can be called later on using the identiﬁer.
parameters is an optional list of identiﬁers that get bound to the values supplied as arguments when the function is
called. A function may have an arbitrary number of arguments which are separated by commas.
statement(s) – also known as the function body – are a nonempty sequence of statements executed each time the
function is called. This means a function body cannot be empty, just like any indented block.
Here’s an example of a simple function deﬁnition which purpose is to print Hello each time it’s called:
def greet():
print("Hello")
Now let’s call the deﬁned greet() function:
greet()
# Out: Hello
That’s another example of a function deﬁnition which takes one single argument and displays the passed in value
each time the function is called:
def greet_two(greeting):
print(greeting)
After that the greet_two() function must be called with an argument:
greet_two("Howdy")
# Out: Howdy
GoalKicker.com – Python® Notes for Professionals
183Also you can give a default value to that function argument:
def greet_two(greeting="Howdy"):
print(greeting)
Now you can call the function without giving a value:
greet_two()
# Out: Howdy
You'll notice that unlike many other languages, you do not need to explicitly declare a return type of the function.
Python functions can return values of any type via the return keyword. One function can return any number of
diﬀerent types!
def many_types(x):
if x < 0:
return "Hello!"
else:
return 0
print(many_types(1))
print(many_types(-1))
# Output:
0
Hello!
As long as this is handled correctly by the caller, this is perfectly valid Python code.
A function that reaches the end of execution without a return statement will always return None:
def do_nothing():
pass
print(do_nothing())
# Out: None
As mentioned previously a function deﬁnition must have a function body, a nonempty sequence of statements.
Therefore the pass statement is used as function body, which is a null operation – when it is executed, nothing
happens. It does what it means, it skips. It is useful as a placeholder when a statement is required syntactically, but
no code needs to be executed.
Section 33.2: Deﬁning a function with an arbitrary number of
arguments
Arbitrary number of positional arguments:
Deﬁning a function capable of taking an arbitrary number of arguments can be done by preﬁxing one of the
arguments with a *
def func(*args):
# args will be a tuple containing all values that are passed in
for i in args:
print(i)
func(1, 2, 3)
# Calling it with 3 arguments
GoalKicker.com – Python® Notes for Professionals
184# Out: 1
#
2
#
3
list_of_arg_values = [1, 2, 3]
func(*list_of_arg_values) # Calling it with list of values, * expands the list
# Out: 1
#
2
#
3
func() # Calling it without arguments
# No Output
You can't provide a default for args, for example func(*args=[1, 2, 3]) will raise a syntax error (won't even
compile).
You can't provide these by name when calling the function, for example func(*args=[1, 2, 3]) will raise a
TypeError.
But if you already have your arguments in an array (or any other Iterable), you can invoke your function like this:
func(*my_stuff).
These arguments (*args) can be accessed by index, for example args[0] will return the ﬁrst argument
Arbitrary number of keyword arguments
You can take an arbitrary number of arguments with a name by deﬁning an argument in the deﬁnition with two *
in front of it:
def func(**kwargs):
# kwargs will be a dictionary containing the names as keys and the values as values
for name, value in kwargs.items():
print(name, value)
func(value1=1, value2=2, value3=3)
# Out: value1 1
#
value2 2
#
value3 3# Calling it with 3 arguments
func()
# No Out put# Calling it without arguments
my_dict = {'foo': 1, 'bar': 2}
func(**my_dict)
# Out: foo 1
#
bar 2
# Calling it with a dictionary
You can't provide these without names, for example func(1, 2, 3) will raise a TypeError.
kwargs is a plain native python dictionary. For example, args['value1'] will give the value for argument value1. Be
sure to check beforehand that there is such an argument or a KeyError will be raised.
Warning
You can mix these with other optional and required arguments but the order inside the deﬁnition matters.
The positional/keyword arguments come ﬁrst. (Required arguments).
Then comes the arbitrary *arg arguments. (Optional).
GoalKicker.com – Python® Notes for Professionals
185Then keyword-only arguments come next. (Required).
Finally the arbitrary keyword **kwargs come. (Optional).
#
|-positional-|-optional-|---keyword-only--|-optional-|
def func(arg1, arg2=10 , *args, kwarg1, kwarg2=2, **kwargs):
pass
arg1 must be given, otherwise a TypeError is raised. It can be given as positional (func(10)) or keyword
argument (func(arg1=10)).
kwarg1 must also be given, but it can only be provided as keyword-argument: func(kwarg1=10).
arg2 and kwarg2 are optional. If the value is to be changed the same rules as for arg1 (either positional or
keyword) and kwarg1 (only keyword) apply.
*args catches additional positional parameters. But note, that arg1 and arg2 must be provided as positional
arguments to pass arguments to *args: func(1, 1, 1, 1).
**kwargs catches all additional keyword parameters. In this case any parameter that is not arg1, arg2,
kwarg1 or kwarg2. For example: func(kwarg3=10).
In Python 3, you can use * alone to indicate that all subsequent arguments must be speciﬁed as keywords.
For instance the math.isclose function in Python 3.5 and higher is deﬁned using def math.isclose (a, b,
*, rel_tol=1e-09, abs_tol=0.0), which means the ﬁrst two arguments can be supplied positionally but the
optional third and fourth parameters can only be supplied as keyword arguments.
Python 2.x doesn't support keyword-only parameters. This behavior can be emulated with kwargs:
def func(arg1, arg2=10, **kwargs):
try:
kwarg1 = kwargs.pop("kwarg1")
except KeyError:
raise TypeError("missing required keyword-only argument: 'kwarg1'")
kwarg2 = kwargs.pop("kwarg2", 2)
# function body ...
Note on Naming
The convention of naming optional positional arguments args and optional keyword arguments kwargs is just a
convention you can use any names you like but it is useful to follow the convention so that others know what you
are doing, or even yourself later so please do.
Note on Uniqueness
Any function can be deﬁned with none or one *args and none or one **kwargs but not with more than one of
each. Also *args must be the last positional argument and **kwargs must be the last parameter. Attempting to use
more than one of either will result in a Syntax Error exception.
Note on Nesting Functions with Optional Arguments
It is possible to nest such functions and the usual convention is to remove the items that the code has already
handled but if you are passing down the parameters you need to pass optional positional args with a * preﬁx and
optional keyword args with a ** preﬁx, otherwise args with be passed as a list or tuple and kwargs as a single
dictionary. e.g.:
def fn(**kwargs):
print(kwargs)
f1(**kwargs)
GoalKicker.com – Python® Notes for Professionals
186def f1(**kwargs):
print(len(kwargs))
fn(a=1, b=2)
# Out:
# {'a': 1, 'b': 2}
# 2
Section 33.3: Lambda (Inline/Anonymous) Functions
The lambda keyword creates an inline function that contains a single expression. The value of this expression is
what the function returns when invoked.
Consider the function:
def greeting():
return "Hello"
which, when called as:
print(greeting())
prints:
Hello
This can be written as a lambda function as follows:
greet_me = lambda: "Hello"
See note at the bottom of this section regarding the assignment of lambdas to variables. Generally, don't
do it.
This creates an inline function with the name greet_me that returns Hello. Note that you don't write return when
creating a function with lambda. The value after : is automatically returned.
Once assigned to a variable, it can be used just like a regular function:
print(greet_me())
prints:
Hello
lambdas can take arguments, too:
strip_and_upper_case = lambda s: s.strip().upper()
strip_and_upper_case("
Hello
")
returns the string:
HELLO
GoalKicker.com – Python® Notes for Professionals
187They can also take arbitrary number of arguments / keyword arguments, like normal functions.
greeting = lambda x, *args, **kwargs: print(x, args, kwargs)
greeting('hello', 'world', world='world')
prints:
hello ('world',) {'world': 'world'}
lambdas are commonly used for short functions that are convenient to deﬁne at the point where they are called
(typically with sorted, filter and map).
For example, this line sorts a list of strings ignoring their case and ignoring whitespace at the beginning and at the
end:
sorted( [" foo ", "
# Out:
# ['
bAR', 'BaZ
bAR", "BaZ
"], key=lambda s: s.strip().upper())
', ' foo ']
Sort list just ignoring whitespaces:
sorted( [" foo ", "
bAR", "BaZ
# Out:
# ['BaZ
', '
bAR', ' foo ']
"], key=lambda s: s.strip())
Examples with map:
sorted( map( lambda s: s.strip().upper(), [" foo ", "
# Out:
# ['BAR', 'BAZ', 'FOO']
sorted( map( lambda s: s.strip(), [" foo ", "
# Out:
# ['BaZ', 'bAR', 'foo']
bAR", "BaZ
bAR", "BaZ
"]))
"]))
Examples with numerical lists:
my_list = [3, -4, -2, 5, 1, 7]
sorted( my_list, key=lambda x: abs(x))
# Out:
# [1, -2, 3, -4, 5, 7]
list( filter( lambda x: x>0, my_list))
# Out:
# [3, 5, 1, 7]
list( map( lambda x: abs(x), my_list))
# Out:
[3, 4, 2, 5, 1, 7]
One can call other functions (with/without arguments) from inside a lambda function.
def foo(msg):
print(msg)
greet = lambda x = "hello world": foo(x)
greet()
GoalKicker.com – Python® Notes for Professionals
188prints:
hello world
This is useful because lambda may contain only one expression and by using a subsidiary function one can run
multiple statements.
NOTE
Bear in mind that PEP-8 (the oﬃcial Python style guide) does not recommend assigning lambdas to variables (as we
did in the ﬁrst two examples):
Always use a def statement instead of an assignment statement that binds a lambda expression directly
to an identiﬁer.
Yes:
def f(x): return 2*x
No:
f = lambda x: 2*x
The ﬁrst form means that the name of the resulting function object is speciﬁcally f instead of the generic
<lambda>. This is more useful for tracebacks and string representations in general. The use of the
assignment statement eliminates the sole beneﬁt a lambda expression can oﬀer over an explicit def
statement (i.e. that it can be embedded inside a larger expression).
Section 33.4: Deﬁning a function with optional arguments
Optional arguments can be deﬁned by assigning (using =) a default value to the argument-name:
def make(action='nothing'):
return action
Calling this function is possible in 3 diﬀerent ways:
make("fun")
# Out: fun
make(action="sleep")
# Out: sleep
# The argument is optional so the function will use the default value if the argument is
# not passed in.
make()
# Out: nothing
Warning
Mutable types (list, dict, set, etc.) should be treated with care when given as default attribute. Any
mutation of the default argument will change it permanently. See Deﬁning a function with optional
mutable arguments.
GoalKicker.com – Python® Notes for Professionals
189Section 33.5: Deﬁning a function with optional mutable
arguments
There is a problem when using optional arguments with a mutable default type (described in Deﬁning a function
with optional arguments), which can potentially lead to unexpected behaviour.
Explanation
This problem arises because a function's default arguments are initialised once, at the point when the function is
deﬁned, and not (like many other languages) when the function is called. The default values are stored inside the
function object's __defaults__ member variable.
def f(a, b=42, c=[]):
pass
print(f.__defaults__)
# Out: (42, [])
For immutable types (see Argument passing and mutability) this is not a problem because there is no way to
mutate the variable; it can only ever be reassigned, leaving the original value unchanged. Hence, subsequent are
guaranteed to have the same default value. However, for a mutable type, the original value can mutate, by making
calls to its various member functions. Therefore, successive calls to the function are not guaranteed to have the
initial default value.
def append(elem, to=[]):
to.append(elem)
# This call to append() mutates the default variable "to"
return to
append(1)
# Out: [1]
append(2) # Appends it to the internally stored list
# Out: [1, 2]
append(3, [])
# Out: [3]
# Using a new created list gives the expected result
# Calling it again without argument will append to the internally stored list again
append(4)
# Out: [1, 2, 4]
Note: Some IDEs like PyCharm will issue a warning when a mutable type is speciﬁed as a default
attribute.
Solution
If you want to ensure that the default argument is always the one you specify in the function deﬁnition, then the
solution is to always use an immutable type as your default argument.
A common idiom to achieve this when a mutable type is needed as the default, is to use None (immutable) as the
default argument and then assign the actual default value to the argument variable if it is equal to None.
def append(elem, to=None):
if to is None:
to = []
GoalKicker.com – Python® Notes for Professionals
190to.append(elem)
return to
Section 33.6: Argument passing and mutability
First, some terminology:
argument (actual parameter): the actual variable being passed to a function;
parameter (formal parameter): the receiving variable that is used in a function.
In Python, arguments are passed by assignment (as opposed to other languages, where arguments can be
passed by value/reference/pointer).
Mutating a parameter will mutate the argument (if the argument's type is mutable).
def foo(x):
x[0] = 9
print(x)
y = [4, 5, 6]
foo(y)
# Out: [9, 5, 6]
print(y)
# Out: [9, 5, 6]
# here x is the parameter
# This mutates the list labelled by both x and y
# call foo with y as argument
# list labelled by x has been mutated
# list labelled by y has been mutated too
Reassigning the parameter won’t reassign the argument.
def foo(x):
x[0] = 9
x = [1, 2, 3]
x[2] = 8# here x is the parameter, when we call foo(y) we assign y to x
# This mutates the list labelled by both x and y
# x is now labeling a different list (y is unaffected)
# This mutates x's list, not y's list
y = [4, 5, 6]
foo(y)
y
# Out: [9, 5, 6]# y is the argument, x is the parameter
# Pretend that we wrote "x = y", then go to line 1
In Python, we don’t really assign values to variables, instead we bind (i.e. assign, attach) variables
(considered as names) to objects.
Immutable: Integers, strings, tuples, and so on. All operations make copies.
Mutable: Lists, dictionaries, sets, and so on. Operations may or may not mutate.
x = [3, 1, 9]
y = x
x.append(5)
# Mutates the list labelled by x and y, both x and y are bound to [3, 1, 9]
x.sort()
# Mutates the list labelled by x and y (in-place sorting)
x = x + [4]
# Does not mutate the list (makes a copy for x only, not y)
z = x
# z is x ([1, 3, 9, 4])
x += [6]
# Mutates the list labelled by both x and z (uses the extend function).
x = sorted(x) # Does not mutate the list (makes a copy for x only).
x
# Out: [1, 3, 4, 5, 6, 9]
y
# Out: [1, 3, 5, 9]
z
GoalKicker.com – Python® Notes for Professionals
191# Out: [1, 3, 5, 9, 4, 6]
Section 33.7: Returning values from functions
Functions can return a value that you can use directly:
def give_me_five():
return 5
print(give_me_five())
# Out: 5
# Print the returned value
or save the value for later use:
num = give_me_five()
print(num)
# Out: 5
# Print the saved returned value
or use the value for any operations:
print(give_me_five() + 10)
# Out: 15
If return is encountered in the function the function will be exited immediately and subsequent operations will not
be evaluated:
def give_me_another_five():
return 5
print('This statement will not be printed. Ever.')
print(give_me_another_five())
# Out: 5
You can also return multiple values (in the form of a tuple):
def give_me_two_fives():
return 5, 5 # Returns two 5
first, second = give_me_two_fives()
print(first)
# Out: 5
print(second)
# Out: 5
A function with no return statement implicitly returns None. Similarly a function with a return statement, but no
return value or variable returns None.
Section 33.8: Closure
Closures in Python are created by function calls. Here, the call to makeInc creates a binding for x that is referenced
inside the function inc. Each call to makeInc creates a new instance of this function, but each instance has a link to a
diﬀerent binding of x.
def makeInc(x):
def inc(y):
# x is "attached" in the definition of inc
GoalKicker.com – Python® Notes for Professionals
192return y + x
return inc
incOne = makeInc(1)
incFive = makeInc(5)
incOne(5) # returns 6
incFive(5) # returns 10
Notice that while in a regular closure the enclosed function fully inherits all variables from its enclosing
environment, in this construct the enclosed function has only read access to the inherited variables but cannot
make assignments to them
def makeInc(x):
def inc(y):
# incrementing x is not allowed
x += y
return x
return inc
incOne = makeInc(1)
incOne(5) # UnboundLocalError: local variable 'x' referenced before assignment
Python 3 oﬀers the nonlocal statement (Nonlocal Variables ) for realizing a full closure with nested functions.
Python 3.x Version ≥ 3.0
def makeInc(x):
def inc(y):
nonlocal x
# now assigning a value to x is allowed
x += y
return x
return inc
incOne = makeInc(1)
incOne(5) # returns 6
Section 33.9: Forcing the use of named parameters
All parameters speciﬁed after the ﬁrst asterisk in the function signature are keyword-only.
def f(*a, b):
pass
f(1, 2, 3)
# TypeError: f() missing 1 required keyword-only argument: 'b'
In Python 3 it's possible to put a single asterisk in the function signature to ensure that the remaining arguments
may only be passed using keyword arguments.
def f(a, b, *, c):
pass
f(1, 2, 3)
# TypeError: f() takes 2 positional arguments but 3 were given
GoalKicker.com – Python® Notes for Professionals
193f(1, 2, c=3)
# No error
Section 33.10: Nested functions
Functions in python are ﬁrst-class objects. They can be deﬁned in any scope
def fibonacci(n):
def step(a,b):
return b, a+b
a, b = 0, 1
for i in range(n):
a, b = step(a, b)
return a
Functions capture their enclosing scope can be passed around like any other sort of object
def make_adder(n):
def adder(x):
return n + x
return adder
add5 = make_adder(5)
add6 = make_adder(6)
add5(10)
#Out: 15
add6(10)
#Out: 16
def repeatedly_apply(func, n, x):
for i in range(n):
x = func(x)
return x
repeatedly_apply(add5, 5, 1)
#Out: 26
Section 33.11: Recursion limit
There is a limit to the depth of possible recursion, which depends on the Python implementation. When the limit is
reached, a RuntimeError exception is raised:
def cursing(depth):
try:
cursing(depth + 1) # actually, re-cursing
except RuntimeError as RE:
print('I recursed {} times!'.format(depth))
cursing(0)
# Out: I recursed 1083 times!
It is possible to change the recursion depth limit by using sys.setrecursionlimit(limit) and check this limit by
sys.getrecursionlimit().
sys.setrecursionlimit(2000)
cursing(0)
# Out: I recursed 1997 times!
GoalKicker.com – Python® Notes for Professionals
194From Python 3.5, the exception is a RecursionError, which is derived from RuntimeError.
Section 33.12: Recursive Lambda using assigned variable
One method for creating recursive lambda functions involves assigning the function to a variable and then
referencing that variable within the function itself. A common example of this is the recursive calculation of the
factorial of a number - such as shown in the following code:
lambda_factorial = lambda i:1 if i==0 else i*lambda_factorial(i-1)
print(lambda_factorial(4)) # 4 * 3 * 2 * 1 = 12 * 2 = 24
Description of code
The lambda function, through its variable assignment, is passed a value (4) which it evaluates and returns 1 if it is 0
or else it returns the current value (i) * another calculation by the lambda function of the value - 1 (i-1). This
continues until the passed value is decremented to 0 (return 1). A process which can be visualized as:
Section 33.13: Recursive functions
A recursive function is a function that calls itself in its deﬁnition. For example the mathematical function, factorial,
deﬁned by factorial(n) = n*(n-1)*(n-2)*...*3*2*1. can be programmed as
GoalKicker.com – Python® Notes for Professionals
195def factorial(n):
#n here should be an integer
if n == 0:
return 1
else:
return n*factorial(n-1)
the outputs here are:
factorial(0)
#out 1
factorial(1)
#out 1
factorial(2)
#out 2
factorial(3)
#out 6
as expected. Notice that this function is recursive because the second return factorial(n-1), where the function
calls itself in its deﬁnition.
Some recursive functions can be implemented using lambda, the factorial function using lambda would be
something like this:
factorial = lambda n: 1 if n == 0 else n*factorial(n-1)
The function outputs the same as above.
Section 33.14: Deﬁning a function with arguments
Arguments are deﬁned in parentheses after the function name:
def divide(dividend, divisor): # The names of the function and its arguments
# The arguments are available by name in the body of the function
print(dividend / divisor)
The function name and its list of arguments are called the signature of the function. Each named argument is
eﬀectively a local variable of the function.
When calling the function, give values for the arguments by listing them in order
divide(10, 2)
# output: 5
or specify them in any order using the names from the function deﬁnition:
divide(divisor=2, dividend=10)
# output: 5
Section 33.15: Iterable and dictionary unpacking
Functions allow you to specify these types of parameters: positional, named, variable positional, Keyword args
(kwargs). Here is a clear and concise use of each type.
def unpacking(a, b, c=45, d=60, *args, **kwargs):
GoalKicker.com – Python® Notes for Professionals
196print(a, b, c, d, args, kwargs)
>>> unpacking(1, 2)
1 2 45 60 () {}
>>> unpacking(1, 2, 3, 4)
1 2 3 4 () {}
>>> unpacking(1, 2, c=3, d=4)
1 2 3 4 () {}
>>> unpacking(1, 2, d=4, c=3)
1 2 3 4 () {}
>>> pair = (3,)
>>> unpacking(1, 2, *pair, d=4)
1 2 3 4 () {}
>>> unpacking(1, 2, d=4, *pair)
1 2 3 4 () {}
>>> unpacking(1, 2, *pair, c=3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'c'
>>> unpacking(1, 2, c=3, *pair)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'c'
>>> args_list = [3]
>>> unpacking(1, 2, *args_list, d=4)
1 2 3 4 () {}
>>> unpacking(1, 2, d=4, *args_list)
1 2 3 4 () {}
>>> unpacking(1, 2, c=3, *args_list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'c'
>>> unpacking(1, 2, *args_list, c=3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'c'
>>> pair = (3, 4)
>>> unpacking(1, 2, *pair)
1 2 3 4 () {}
>>> unpacking(1, 2, 3, 4, *pair)
1 2 3 4 (3, 4) {}
>>> unpacking(1, 2, d=4, *pair)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'd'
>>> unpacking(1, 2, *pair, d=4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'd'
>>> args_list = [3, 4]
>>> unpacking(1, 2, *args_list)
1 2 3 4 () {}
>>> unpacking(1, 2, 3, 4, *args_list)
1 2 3 4 (3, 4) {}
GoalKicker.com – Python® Notes for Professionals
197>>> unpacking(1, 2, d=4, *args_list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'd'
>>> unpacking(1, 2, *args_list, d=4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'd'
>>> arg_dict = {'c':3, 'd':4}
>>> unpacking(1, 2, **arg_dict)
1 2 3 4 () {}
>>> arg_dict = {'d':4, 'c':3}
>>> unpacking(1, 2, **arg_dict)
1 2 3 4 () {}
>>> arg_dict = {'c':3, 'd':4, 'not_a_parameter': 75}
>>> unpacking(1, 2, **arg_dict)
1 2 3 4 () {'not_a_parameter': 75}
>>> unpacking(1, 2, *pair, **arg_dict)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'd'
>>> unpacking(1, 2, 3, 4, **arg_dict)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'd'
# Positional arguments take priority over any other form of argument passing
>>> unpacking(1, 2, **arg_dict, c=3)
1 2 3 4 () {'not_a_parameter': 75}
>>> unpacking(1, 2, 3, **arg_dict, c=3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpacking() got multiple values for argument 'c'
Section 33.16: Deﬁning a function with multiple arguments
One can give a function as many arguments as one wants, the only ﬁxed rules are that each argument name must
be unique and that optional arguments must be after the not-optional ones:
def func(value1, value2, optionalvalue=10):
return '{0} {1} {2}'.format(value1, value2, optionalvalue1)
When calling the function you can either give each keyword without the name but then the order matters:
print(func(1, 'a', 100))
# Out: 1 a 100
print(func('abc', 14))
# abc 14 10
Or combine giving the arguments with name and without. Then the ones with name must follow those without but
the order of the ones with name doesn't matter:
print(func('This', optionalvalue='StackOverflow Documentation', value2='is'))
# Out: This is StackOverflow Documentation
GoalKicker.com – Python® Notes for Professionals
198Chapter 34: Deﬁning functions with list
arguments
Section 34.1: Function and Call
Lists as arguments are just another variable:
def func(myList):
for item in myList:
print(item)
and can be passed in the function call itself:
func([1,2,3,5,7])
1
2
3
5
7
Or as a variable:
aList = ['a','b','c','d']
func(aList)
a
b
c
d
GoalKicker.com – Python® Notes for Professionals
199VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 35: Functional Programming in
Python
Functional programming decomposes a problem into a set of functions. Ideally, functions only take inputs and
produce outputs, and don’t have any internal state that aﬀects the output produced for a given input.below are
functional techniques common to many languages: such as lambda, map, reduce.
Section 35.1: Lambda Function
An anonymous, inlined function deﬁned with lambda. The parameters of the lambda are deﬁned to the left of the
colon. The function body is deﬁned to the right of the colon. The result of running the function body is (implicitly)
returned.
s=lambda x:x*x
s(2)
=>4
Section 35.2: Map Function
Map takes a function and a collection of items. It makes a new, empty collection, runs the function on each item in
the original collection and inserts each return value into the new collection. It returns the new collection.
This is a simple map that takes a list of names and returns a list of the lengths of those names:
name_lengths = map(len, ["Mary", "Isla", "Sam"])
print(name_lengths)
=>[4, 4, 3]
Section 35.3: Reduce Function
Reduce takes a function and a collection of items. It returns a value that is created by combining the items.
This is a simple reduce. It returns the sum of all the items in the collection.
total = reduce(lambda a, x: a + x, [0, 1, 2, 3, 4])
print(total)
=>10
Section 35.4: Filter Function
Filter takes a function and a collection. It returns a collection of every item for which the function returned True.
arr=[1,2,3,4,5,6]
[i for i in filter(lambda x:x>4,arr)]
# outputs[5,6]
GoalKicker.com – Python® Notes for Professionals
201Chapter 36: Partial functions
Param
details
x
the number to be raised
ythe exponent
raisethe function to be specialized
As you probably know if you came from OOP school, specializing an abstract class and use it is a practice you
should keep in mind when writing your code.
What if you could deﬁne an abstract function and specialize it in order to create diﬀerent versions of it? Thinks it as
a sort of function Inheritance where you bind speciﬁc params to make them reliable for a speciﬁc scenario.
Section 36.1: Raise the power
Let's suppose we want raise x to a number y.
You'd write this as:
def raise_power(x, y):
return x**y
What if your y value can assume a ﬁnite set of values?
Let's suppose y can be one of [3,4,5] and let's say you don't want oﬀer end user the possibility to use such function
since it is very computationally intensive. In fact you would check if provided y assumes a valid value and rewrite
your function as:
def raise(x, y):
if y in (3,4,5):
return x**y
raise NumberNotInRangeException("You should provide a valid exponent")
Messy? Let's use the abstract form and specialize it to all three cases: let's implement them partially.
from functors import partial
raise_to_three = partial(raise, y=3)
raise_to_four = partial(raise, y=4)
raise_to_five = partial(raise, y=5)
What happens here? We ﬁxed the y params and we deﬁned three diﬀerent functions.
No need to use the abstract function deﬁned above (you could make it private) but you could use partial applied
functions to deal with raising a number to a ﬁxed value.
GoalKicker.com – Python® Notes for Professionals
202Chapter 37: Decorators
Parameter
Details
f
The function to be decorated (wrapped)
Decorator functions are software design patterns. They dynamically alter the functionality of a function, method, or
class without having to directly use subclasses or change the source code of the decorated function. When used
correctly, decorators can become powerful tools in the development process. This topic covers implementation and
applications of decorator functions in Python.
Section 37.1: Decorator function
Decorators augment the behavior of other functions or methods. Any function that takes a function as a parameter
and returns an augmented function can be used as a decorator.
# This simplest decorator does nothing to the function being decorated. Such
# minimal decorators can occasionally be used as a kind of code markers.
def super_secret_function(f):
return f
@super_secret_function
def my_function():
print("This is my secret function.")
The @-notation is syntactic sugar that is equivalent to the following:
my_function = super_secret_function(my_function)
It is important to bear this in mind in order to understand how the decorators work. This "unsugared" syntax makes
it clear why the decorator function takes a function as an argument, and why it should return another function. It
also demonstrates what would happen if you don't return a function:
def disabled(f):
"""
This function returns nothing, and hence removes the decorated function
from the local scope.
"""
pass
@disabled
def my_function():
print("This function can no longer be called...")
my_function()
# TypeError: 'NoneType' object is not callable
Thus, we usually deﬁne a new function inside the decorator and return it. This new function would ﬁrst do
something that it needs to do, then call the original function, and ﬁnally process the return value. Consider this
simple decorator function that prints the arguments that the original function receives, then calls it.
#This is the decorator
def print_args(func):
def inner_func(*args, **kwargs):
print(args)
print(kwargs)
GoalKicker.com – Python® Notes for Professionals
203return func(*args, **kwargs) #Call the original function with its arguments.
return inner_func
@print_args
def multiply(num_a, num_b):
return num_a * num_b
print(multiply(3, 5))
#Output:
# (3,5) - This is actually the 'args' that the function receives.
# {} - This is the 'kwargs', empty because we didn't specify keyword arguments.
# 15 - The result of the function.
Section 37.2: Decorator class
As mentioned in the introduction, a decorator is a function that can be applied to another function to augment its
behavior. The syntactic sugar is equivalent to the following: my_func = decorator(my_func). But what if the
decorator was instead a class? The syntax would still work, except that now my_func gets replaced with an instance
of the decorator class. If this class implements the __call__() magic method, then it would still be possible to use
my_func as if it was a function:
class Decorator(object):
"""Simple decorator class."""
def __init__(self, func):
self.func = func
def __call__(self, *args, **kwargs):
print('Before the function call.')
res = self.func(*args, **kwargs)
print('After the function call.')
return res
@Decorator
def testfunc():
print('Inside the function.')
testfunc()
# Before the function call.
# Inside the function.
# After the function call.
Note that a function decorated with a class decorator will no longer be considered a "function" from type-checking
perspective:
import types
isinstance(testfunc, types.FunctionType)
# False
type(testfunc)
# <class '__main__.Decorator'>
Decorating Methods
For decorating methods you need to deﬁne an additional __get__-method:
from types import MethodType
class Decorator(object):
def __init__(self, func):
GoalKicker.com – Python® Notes for Professionals
204self.func = func
def __call__(self, *args, **kwargs):
print('Inside the decorator.')
return self.func(*args, **kwargs)
def __get__(self, instance, cls):
# Return a Method if it is called on an instance
return self if instance is None else MethodType(self, instance)
class Test(object):
@Decorator
def __init__(self):
pass
a = Test()
Inside the decorator.
Warning!
Class Decorators only produce one instance for a speciﬁc function so decorating a method with a class decorator
will share the same decorator between all instances of that class:
from types import MethodType
class CountCallsDecorator(object):
def __init__(self, func):
self.func = func
self.ncalls = 0
# Number of calls of this method
def __call__(self, *args, **kwargs):
self.ncalls += 1
# Increment the calls counter
return self.func(*args, **kwargs)
def __get__(self, instance, cls):
return self if instance is None else MethodType(self, instance)
class Test(object):
def __init__(self):
pass
@CountCallsDecorator
def do_something(self):
return 'something was done'
a = Test()
a.do_something()
a.do_something.ncalls
b = Test()
b.do_something()
b.do_something.ncalls
# 1
# 2
Section 37.3: Decorator with arguments (decorator factory)
A decorator takes just one argument: the function to be decorated. There is no way to pass other arguments.
But additional arguments are often desired. The trick is then to make a function which takes arbitrary arguments
GoalKicker.com – Python® Notes for Professionals
205and returns a decorator.
Decorator functions
def decoratorfactory(message):
def decorator(func):
def wrapped_func(*args, **kwargs):
print('The decorator wants to tell you: {}'.format(message))
return func(*args, **kwargs)
return wrapped_func
return decorator
@decoratorfactory('Hello World')
def test():
pass
test()
The decorator wants to tell you: Hello World
Important Note:
With such decorator factories you must call the decorator with a pair of parentheses:
@decoratorfactory # Without parentheses
def test():
pass
test()
TypeError: decorator() missing 1 required positional argument: 'func'
Decorator classes
def decoratorfactory(*decorator_args, **decorator_kwargs):
class Decorator(object):
def __init__(self, func):
self.func = func
def __call__(self, *args, **kwargs):
print('Inside the decorator with arguments {}'.format(decorator_args))
return self.func(*args, **kwargs)
return Decorator
@decoratorfactory(10)
def test():
pass
test()
Inside the decorator with arguments (10,)
GoalKicker.com – Python® Notes for Professionals
206Section 37.4: Making a decorator look like the decorated
function
Decorators normally strip function metadata as they aren't the same. This can cause problems when using meta-
programming to dynamically access function metadata. Metadata also includes function's docstrings and its name.
functools.wraps makes the decorated function look like the original function by copying several attributes to the
wrapper function.
from functools import wraps
The two methods of wrapping a decorator are achieving the same thing in hiding that the original function has
been decorated. There is no reason to prefer the function version to the class version unless you're already using
one over the other.
As a function
def decorator(func):
# Copies the docstring, name, annotations and module to the decorator
@wraps(func)
def wrapped_func(*args, **kwargs):
return func(*args, **kwargs)
return wrapped_func
@decorator
def test():
pass
test.__name__
'test'
As a class
class Decorator(object):
def __init__(self, func):
# Copies name, module, annotations and docstring to the instance.
self._wrapped = wraps(func)(self)
def __call__(self, *args, **kwargs):
return self._wrapped(*args, **kwargs)
@Decorator
def test():
"""Docstring of test."""
pass
test.__doc__
'Docstring of test.'
Section 37.5: Using a decorator to time a function
import time
def timer(func):
def inner(*args, **kwargs):
GoalKicker.com – Python® Notes for Professionals
207t1 = time.time()
f = func(*args, **kwargs)
t2 = time.time()
print 'Runtime took {0} seconds'.format(t2-t1)
return f
return inner
@timer
def example_function():
#do stuff
example_function()
Section 37.6: Create singleton class with a decorator
A singleton is a pattern that restricts the instantiation of a class to one instance/object. Using a decorator, we can
deﬁne a class as a singleton by forcing the class to either return an existing instance of the class or create a new
instance (if it doesn't exist).
def singleton(cls):
instance = [None]
def wrapper(*args, **kwargs):
if instance[0] is None:
instance[0] = cls(*args, **kwargs)
return instance[0]
return wrapper
This decorator can be added to any class declaration and will make sure that at most one instance of the class is
created. Any subsequent calls will return the already existing class instance.
@singleton
class SomeSingletonClass:
x = 2
def __init__(self):
print("Created!")
instance = SomeSingletonClass()
instance = SomeSingletonClass()
print(instance.x)# prints: Created!
# doesn't print anything
# 2
instance.x = 3
print(SomeSingletonClass().x)# 3
So it doesn't matter whether you refer to the class instance via your local variable or whether you create another
"instance", you always get the same object.
GoalKicker.com – Python® Notes for Professionals
208Chapter 38: Classes
Python oﬀers itself not only as a popular scripting language, but also supports the object-oriented programming
paradigm. Classes describe data and provide methods to manipulate that data, all encompassed under a single
object. Furthermore, classes allow for abstraction by separating concrete implementation details from abstract
representations of data.
Code utilizing classes is generally easier to read, understand, and maintain.
Section 38.1: Introduction to classes
A class, functions as a template that deﬁnes the basic characteristics of a particular object. Here's an example:
class Person(object):
"""A simple class."""
species = "Homo Sapiens"
# docstring
# class attribute
def __init__(self, name):
"""This is the initializer. It's a special
method (see below).
"""
self.name = name# special method
def __str__(self):
"""This method is run when Python tries
to cast the object to a string. Return
this string when using print(), etc.
"""
return self.name# special method
# instance attribute
def rename(self, renamed):
# regular method
"""Reassign and print the name attribute."""
self.name = renamed
print("Now my name is {}".format(self.name))
There are a few things to note when looking at the above example.
1. The class is made up of attributes (data) and methods (functions).
2. Attributes and methods are simply deﬁned as normal variables and functions.
3. As noted in the corresponding docstring, the __init__() method is called the initializer. It's equivalent to the
constructor in other object oriented languages, and is the method that is ﬁrst run when you create a new
object, or new instance of the class.
4. Attributes that apply to the whole class are deﬁned ﬁrst, and are called class attributes.
5. Attributes that apply to a speciﬁc instance of a class (an object) are called instance attributes. They are
generally deﬁned inside __init__(); this is not necessary, but it is recommended (since attributes deﬁned
outside of __init__() run the risk of being accessed before they are deﬁned).
6. Every method, included in the class deﬁnition passes the object in question as its ﬁrst parameter. The word
self is used for this parameter (usage of self is actually by convention, as the word self has no inherent
meaning in Python, but this is one of Python's most respected conventions, and you should always follow it).
7. Those used to object-oriented programming in other languages may be surprised by a few things. One is that
Python has no real concept of private elements, so everything, by default, imitates the behavior of the
C++/Java public keyword. For more information, see the "Private Class Members" example on this page.
8. Some of the class's methods have the following form: __functionname__(self, other_stuff). All such
methods are called "magic methods" and are an important part of classes in Python. For instance, operator
overloading in Python is implemented with magic methods. For more information, see the relevant
GoalKicker.com – Python® Notes for Professionals
209documentation.
Now let's make a few instances of our Person class!
>>> # Instances
>>> kelly = Person("Kelly")
>>> joseph = Person("Joseph")
>>> john_doe = Person("John Doe")
We currently have three Person objects, kelly, joseph, and john_doe.
We can access the attributes of the class from each instance using the dot operator . Note again the diﬀerence
between class and instance attributes:
>>> # Attributes
>>> kelly.species
'Homo Sapiens'
>>> john_doe.species
'Homo Sapiens'
>>> joseph.species
'Homo Sapiens'
>>> kelly.name
'Kelly'
>>> joseph.name
'Joseph'
We can execute the methods of the class using the same dot operator .:
>>> # Methods
>>> john_doe.__str__()
'John Doe'
>>> print(john_doe)
'John Doe'
>>> john_doe.rename("John")
'Now my name is John'
Section 38.2: Bound, unbound, and static methods
The idea of bound and unbound methods was removed in Python 3. In Python 3 when you declare a method within
a class, you are using a def keyword, thus creating a function object. This is a regular function, and the surrounding
class works as its namespace. In the following example we declare method f within class A, and it becomes a
function A.f:
Python 3.x Version ≥ 3.0
class A(object):
def f(self, x):
return 2 * x
A.f
# <function A.f at ...>
(in Python 3.x)
In Python 2 the behavior was diﬀerent: function objects within the class were implicitly replaced with objects of type
instancemethod, which were called unbound methods because they were not bound to any particular class instance.
It was possible to access the underlying function using .__func__ property.
Python 2.x Version ≥ 2.3
A.f
GoalKicker.com – Python® Notes for Professionals
210# <unbound method A.f>
(in Python 2.x)
A.f.__class__
# <type 'instancemethod'>
A.f.__func__
# <function f at ...>
The latter behaviors are conﬁrmed by inspection - methods are recognized as functions in Python 3, while the
distinction is upheld in Python 2.
Python 3.x Version ≥ 3.0
import inspect
inspect.isfunction(A.f)
# True
inspect.ismethod(A.f)
# False
Python 2.x Version ≥ 2.3
import inspect
inspect.isfunction(A.f)
# False
inspect.ismethod(A.f)
# True
In both versions of Python function/method A.f can be called directly, provided that you pass an instance of class A
as the ﬁrst argument.
A.f(1, 7)
# Python 2: TypeError: unbound method f() must be called with
#
A instance as first argument (got int instance instead)
# Python 3: 14
a = A()
A.f(a, 20)
# Python 2 & 3: 40
Now suppose a is an instance of class A, what is a.f then? Well, intuitively this should be the same method f of class
A, only it should somehow "know" that it was applied to the object a – in Python this is called method bound to a.
The nitty-gritty details are as follows: writing a.f invokes the magic __getattribute__ method of a, which ﬁrst
checks whether a has an attribute named f (it doesn't), then checks the class A whether it contains a method with
such a name (it does), and creates a new object m of type method which has the reference to the original A.f in
m.__func__, and a reference to the object a in m.__self__. When this object is called as a function, it simply does
the following: m(...) => m.__func__(m.__self__, ...). Thus this object is called a bound method because when
invoked it knows to supply the object it was bound to as the ﬁrst argument. (These things work same way in Python
2 and 3).
a = A()
a.f
# <bound method A.f of <__main__.A object at ...>>
a.f(2)
# 4
# Note: the bound method object a.f is recreated *every time* you call it:
a.f is a.f # False
# As a performance optimization you can store the bound method in the object's
# __dict__, in which case the method object will remain fixed:
a.f = a.f
GoalKicker.com – Python® Notes for Professionals
211a.f is a.f
# True
Finally, Python has class methods and static methods – special kinds of methods. Class methods work the same
way as regular methods, except that when invoked on an object they bind to the class of the object instead of to the
object. Thus m.__self__ = type(a). When you call such bound method, it passes the class of a as the ﬁrst
argument. Static methods are even simpler: they don't bind anything at all, and simply return the underlying
function without any transformations.
class D(object):
multiplier = 2
@classmethod
def f(cls, x):
return cls.multiplier * x
@staticmethod
def g(name):
print("Hello, %s" % name)
D.f
# <bound method type.f of <class '__main__.D'>>
D.f(12)
# 24
D.g
# <function D.g at ...>
D.g("world")
# Hello, world
Note that class methods are bound to the class even when accessed on the instance:
d = D()
d.multiplier = 1337
(D.multiplier, d.multiplier)
# (2, 1337)
d.f
# <bound method D.f of <class '__main__.D'>>
d.f(10)
# 20
It is worth noting that at the lowest level, functions, methods, staticmethods, etc. are actually descriptors that
invoke __get__, __set__ and optionally __del__ special methods. For more details on classmethods and
staticmethods:
What is the diﬀerence between @staticmethod and @classmethod in Python?
Meaning of @classmethod and @staticmethod for beginner?
Section 38.3: Basic inheritance
Inheritance in Python is based on similar ideas used in other object oriented languages like Java, C++ etc. A new
class can be derived from an existing class as follows.
class BaseClass(object):
pass
class DerivedClass(BaseClass):
pass
GoalKicker.com – Python® Notes for Professionals
212The BaseClass is the already existing (parent) class, and the DerivedClass is the new (child) class that inherits (or
subclasses) attributes from BaseClass. Note: As of Python 2.2, all classes implicitly inherit from the object class,
which is the base class for all built-in types.
We deﬁne a parent Rectangle class in the example below, which implicitly inherits from object:
class Rectangle():
def __init__(self, w, h):
self.w = w
self.h = h
def area(self):
return self.w * self.h
def perimeter(self):
return 2 * (self.w + self.h)
The Rectangle class can be used as a base class for deﬁning a Square class, as a square is a special case of
rectangle.
class Square(Rectangle):
def __init__(self, s):
# call parent constructor, w and h are both s
super(Square, self).__init__(s, s)
self.s = s
The Square class will automatically inherit all attributes of the Rectangle class as well as the object class. super() is
used to call the __init__() method of Rectangle class, essentially calling any overridden method of the base class.
Note: in Python 3, super() does not require arguments.
Derived class objects can access and modify the attributes of its base classes:
r.area()
# Output: 12
r.perimeter()
# Output: 14
s.area()
# Output: 4
s.perimeter()
# Output: 8
Built-in functions that work with inheritance
issubclass(DerivedClass, BaseClass): returns True if DerivedClass is a subclass of the BaseClass
isinstance(s, Class): returns True if s is an instance of Class or any of the derived classes of Class
# subclass check
issubclass(Square, Rectangle)
# Output: True
# instantiate
r = Rectangle(3, 4)
s = Square(2)
isinstance(r, Rectangle)
# Output: True
isinstance(r, Square)
GoalKicker.com – Python® Notes for Professionals
213# Output: False
# A rectangle is not a square
isinstance(s, Rectangle)
# Output: True
# A square is a rectangle
isinstance(s, Square)
# Output: True
Section 38.4: Monkey Patching
In this case, "monkey patching" means adding a new variable or method to a class after it's been deﬁned. For
instance, say we deﬁned class A as
class A(object):
def __init__(self, num):
self.num = num
def __add__(self, other):
return A(self.num + other.num)
But now we want to add another function later in the code. Suppose this function is as follows.
def get_num(self):
return self.num
But how do we add this as a method in A? That's simple we just essentially place that function into A with an
assignment statement.
A.get_num = get_num
Why does this work? Because functions are objects just like any other object, and methods are functions that
belong to the class.
The function get_num shall be available to all existing (already created) as well to the new instances of A
These additions are available on all instances of that class (or its subclasses) automatically. For example:
foo = A(42)
A.get_num = get_num
bar = A(6);
foo.get_num() # 42
bar.get_num() # 6
Note that, unlike some other languages, this technique does not work for certain built-in types, and it is not
considered good style.
Section 38.5: New-style vs. old-style classes
Python 2.x Version ≥ 2.2.0
New-style classes were introduced in Python 2.2 to unify classes and types. They inherit from the top-level object
GoalKicker.com – Python® Notes for Professionals
214type. A new-style class is a user-deﬁned type, and is very similar to built-in types.
# new-style class
class New(object):
pass
# new-style instance
new = New()
new.__class__
# <class '__main__.New'>
type(new)
# <class '__main__.New'>
issubclass(New, object)
# True
Old-style classes do not inherit from object. Old-style instances are always implemented with a built-in instance
type.
# old-style class
class Old:
pass
# old-style instance
old = Old()
old.__class__
# <class __main__.Old at ...>
type(old)
# <type 'instance'>
issubclass(Old, object)
# False
Python 3.x Version ≥ 3.0.0
In Python 3, old-style classes were removed.
New-style classes in Python 3 implicitly inherit from object, so there is no need to specify MyClass(object)
anymore.
class MyClass:
pass
my_inst = MyClass()
type(my_inst)
# <class '__main__.MyClass'>
my_inst.__class__
# <class '__main__.MyClass'>
issubclass(MyClass, object)
# True
Section 38.6: Class methods: alternate initializers
Class methods present alternate ways to build instances of classes. To illustrate, let's look at an example.
Let's suppose we have a relatively simple Person class:
class Person(object):
GoalKicker.com – Python® Notes for Professionals
215def __init__(self, first_name, last_name, age):
self.first_name = first_name
self.last_name = last_name
self.age = age
self.full_name = first_name + " " + last_name
def greet(self):
print("Hello, my name is " + self.full_name + ".")
It might be handy to have a way to build instances of this class specifying a full name instead of ﬁrst and last name
separately. One way to do this would be to have last_name be an optional parameter, and assuming that if it isn't
given, we passed the full name in:
class Person(object):
def __init__(self, first_name, age, last_name=None):
if last_name is None:
self.first_name, self.last_name = first_name.split(" ", 2)
else:
self.first_name = first_name
self.last_name = last_name
self.full_name = self.first_name + " " + self.last_name
self.age = age
def greet(self):
print("Hello, my name is " + self.full_name + ".")
However, there are two main problems with this bit of code:
1. The parameters first_name and last_name are now misleading, since you can enter a full name for
first_name. Also, if there are more cases and/or more parameters that have this kind of ﬂexibility, the
if/elif/else branching can get annoying fast.
2. Not quite as important, but still worth pointing out: what if last_name is None, but first_name doesn't split
into two or more things via spaces? We have yet another layer of input validation and/or exception
handling...
Enter class methods. Rather than having a single initializer, we will create a separate initializer, called
from_full_name, and decorate it with the (built-in) classmethod decorator.
class Person(object):
def __init__(self, first_name, last_name, age):
self.first_name = first_name
self.last_name = last_name
self.age = age
self.full_name = first_name + " " + last_name
@classmethod
def from_full_name(cls, name, age):
if " " not in name:
raise ValueError
first_name, last_name = name.split(" ", 2)
return cls(first_name, last_name, age)
def greet(self):
print("Hello, my name is " + self.full_name + ".")
GoalKicker.com – Python® Notes for Professionals
216Notice cls instead of self as the ﬁrst argument to from_full_name. Class methods are applied to the overall class,
not an instance of a given class (which is what self usually denotes). So, if cls is our Person class, then the returned
value from the from_full_name class method is Person(first_name, last_name, age), which uses Person's
__init__ to create an instance of the Person class. In particular, if we were to make a subclass Employee of Person,
then from_full_name would work in the Employee class as well.
To show that this works as expected, let's create instances of Person in more than one way without the branching
in __init__:
In [2]: bob = Person("Bob", "Bobberson", 42)
In [3]: alice = Person.from_full_name("Alice Henderson", 31)
In [4]: bob.greet()
Hello, my name is Bob Bobberson.
In [5]: alice.greet()
Hello, my name is Alice Henderson.
Other references:
Python @classmethod and @staticmethod for beginner?
https://docs.python.org/2/library/functions.html#classmethod
https://docs.python.org/3.5/library/functions.html#classmethod
Section 38.7: Multiple Inheritance
Python uses the C3 linearization algorithm to determine the order in which to resolve class attributes, including
methods. This is known as the Method Resolution Order (MRO).
Here's a simple example:
class Foo(object):
foo = 'attr foo of Foo'
class Bar(object):
foo = 'attr foo of Bar' # we won't see this.
bar = 'attr bar of Bar'
class FooBar(Foo, Bar):
foobar = 'attr foobar of FooBar'
Now if we instantiate FooBar, if we look up the foo attribute, we see that Foo's attribute is found ﬁrst
fb = FooBar()
and
>>> fb.foo
'attr foo of Foo'
Here's the MRO of FooBar:
GoalKicker.com – Python® Notes for Professionals
217>>> FooBar.mro()
[<class '__main__.FooBar'>, <class '__main__.Foo'>, <class '__main__.Bar'>, <type 'object'>]
It can be simply stated that Python's MRO algorithm is
1. Depth ﬁrst (e.g. FooBar then Foo) unless
2. a shared parent (object) is blocked by a child (Bar) and
3. no circular relationships allowed.
That is, for example, Bar cannot inherit from FooBar while FooBar inherits from Bar.
For a comprehensive example in Python, see the wikipedia entry.
Another powerful feature in inheritance is super. super can fetch parent classes features.
class Foo(object):
def foo_method(self):
print "foo Method"
class Bar(object):
def bar_method(self):
print "bar Method"
class FooBar(Foo, Bar):
def foo_method(self):
super(FooBar, self).foo_method()
Multiple inheritance with init method of class, when every class has own init method then we try for multiple
inheritance then only init method get called of class which is inherit ﬁrst.
for below example only Foo class init method getting called Bar class init not getting called
class Foo(object):
def __init__(self):
print "foo init"
class Bar(object):
def __init__(self):
print "bar init"
class FooBar(Foo, Bar):
def __init__(self):
print "foobar init"
super(FooBar, self).__init__()
a = FooBar()
Output:
foobar init
foo init
But it doesn't mean that Bar class is not inherit. Instance of ﬁnal FooBar class is also instance of Bar class and Foo
class.
print isinstance(a,FooBar)
print isinstance(a,Foo)
GoalKicker.com – Python® Notes for Professionals
218print isinstance(a,Bar)
Output:
True
True
True
Section 38.8: Properties
Python classes support properties, which look like regular object variables, but with the possibility of attaching
custom behavior and documentation.
class MyClass(object):
def __init__(self):
self._my_string = ""
@property
def string(self):
"""A profoundly important string."""
return self._my_string
@string.setter
def string(self, new_value):
assert isinstance(new_value, str), \
"Give me a string, not a %r!" % type(new_value)
self._my_string = new_value
@string.deleter
def x(self):
self._my_string = None
The object's of class MyClass will appear to have a property .string, however it's behavior is now tightly controlled:
mc = MyClass()
mc.string = "String!"
print(mc.string)
del mc.string
As well as the useful syntax as above, the property syntax allows for validation, or other augmentations to be added
to those attributes. This could be especially useful with public APIs - where a level of help should be given to the
user.
Another common use of properties is to enable the class to present 'virtual attributes' - attributes which aren't
actually stored but are computed only when requested.
class Character(object):
def __init__(name, max_hp):
self._name = name
self._hp = max_hp
self._max_hp = max_hp
# Make hp read only by not providing a set method
@property
def hp(self):
return self._hp
GoalKicker.com – Python® Notes for Professionals
219# Make name read only by not providing a set method
@property
def name(self):
return self.name
def take_damage(self, damage):
self.hp -= damage
self.hp = 0 if self.hp <0 else self.hp
@property
def is_alive(self):
return self.hp != 0
@property
def is_wounded(self):
return self.hp < self.max_hp if self.hp > 0 else False
@property
def is_dead(self):
return not self.is_alive
bilbo = Character('Bilbo Baggins', 100)
bilbo.hp
# out : 100
bilbo.hp = 200
# out : AttributeError: can't set attribute
# hp attribute is read only.
bilbo.is_alive
# out : True
bilbo.is_wounded
# out : False
bilbo.is_dead
# out : False
bilbo.take_damage( 50 )
bilbo.hp
# out : 50
bilbo.is_alive
# out : True
bilbo.is_wounded
# out : True
bilbo.is_dead
# out : False
bilbo.take_damage( 50 )
bilbo.hp
# out : 0
bilbo.is_alive
# out : False
bilbo.is_wounded
# out : False
bilbo.is_dead
# out : True
Section 38.9: Default values for instance variables
If the variable contains a value of an immutable type (e.g. a string) then it is okay to assign a default value like this
GoalKicker.com – Python® Notes for Professionals
220class Rectangle(object):
def __init__(self, width, height, color='blue'):
self.width = width
self.height = height
self.color = color
def area(self):
return self.width
* self.height
# Create some instances of the class
default_rectangle = Rectangle(2, 3)
print(default_rectangle.color) # blue
red_rectangle = Rectangle(2, 3, 'red')
print(red_rectangle.color) # red
One needs to be careful when initializing mutable objects such as lists in the constructor. Consider the following
example:
class Rectangle2D(object):
def __init__(self, width, height, pos=[0,0], color='blue'):
self.width = width
self.height = height
self.pos = pos
self.color = color
r1 = Rectangle2D(5,3)
r2 = Rectangle2D(7,8)
r1.pos[0] = 4
r1.pos # [4, 0]
r2.pos # [4, 0] r2's pos has changed as well
This behavior is caused by the fact that in Python default parameters are bound at function execution and not at
function declaration. To get a default instance variable that's not shared among instances, one should use a
construct like this:
class Rectangle2D(object):
def __init__(self, width, height, pos=None, color='blue'):
self.width = width
self.height = height
self.pos = pos or [0, 0] # default value is [0, 0]
self.color = color
r1 = Rectangle2D(5,3)
r2 = Rectangle2D(7,8)
r1.pos[0] = 4
r1.pos # [4, 0]
r2.pos # [0, 0] r2's pos hasn't changed
See also Mutable Default Arguments and “Least Astonishment” and the Mutable Default Argument.
Section 38.10: Class and instance variables
Instance variables are unique for each instance, while class variables are shared by all instances.
class C:
x = 2
# class variable
GoalKicker.com – Python® Notes for Professionals
221def __init__(self, y):
self.y = y # instance variable
C.x
# 2
C.y
# AttributeError: type object 'C' has no attribute 'y'
c1 = C(3)
c1.x
# 2
c1.y
# 3
c2 = C(4)
c2.x
# 2
c2.y
# 4
Class variables can be accessed on instances of this class, but assigning to the class attribute will create an instance
variable which shadows the class variable
c2.x = 4
c2.x
# 4
C.x
# 2
Note that mutating class variables from instances can lead to some unexpected consequences.
class D:
x = []
def __init__(self, item):
self.x.append(item) # note that this is not an assignment!
d1 = D(1)
d2 = D(2)
d1.x
# [1, 2]
d2.x
# [1, 2]
D.x
# [1, 2]
Section 38.11: Class composition
Class composition allows explicit relations between objects. In this example, people live in cities that belong to
countries. Composition allows people to access the number of all people living in their country:
class Country(object):
def __init__(self):
self.cities=[]
def addCity(self,city):
self.cities.append(city)
GoalKicker.com – Python® Notes for Professionals
222class City(object):
def __init__(self, numPeople):
self.people = []
self.numPeople = numPeople
def addPerson(self, person):
self.people.append(person)
def join_country(self,country):
self.country = country
country.addCity(self)
for i in range(self.numPeople):
person(i).join_city(self)
class Person(object):
def __init__(self, ID):
self.ID=ID
def join_city(self, city):
self.city = city
city.addPerson(self)
def people_in_my_country(self):
x= sum([len(c.people) for c in self.city.country.cities])
return x
US=Country()
NYC=City(10).join_country(US)
SF=City(5).join_country(US)
print(US.cities[0].people[0].people_in_my_country())
# 15
Section 38.12: Listing All Class Members
The dir() function can be used to get a list of the members of a class:
dir(Class)
For example:
>>> dir(list)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__',
'__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__',
'__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count',
'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
It is common to look only for "non-magic" members. This can be done using a simple comprehension that lists
members with names not starting with __:
>>> [m for m in dir(list) if not m.startswith('__')]
['append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse',
'sort']
GoalKicker.com – Python® Notes for Professionals
223Caveats:
Classes can deﬁne a __dir__() method. If that method exists calling dir() will call __dir__(), otherwise Python
will try to create a list of members of the class. This means that the dir function can have unexpected results. Two
quotes of importance from the oﬃcial python documentation:
If the object does not provide dir(), the function tries its best to gather information from the object’s dict
attribute, if deﬁned, and from its type object. The resulting list is not necessarily complete, and may be
inaccurate when the object has a custom getattr().
Note: Because dir() is supplied primarily as a convenience for use at an interactive prompt, it tries to
supply an interesting set of names more than it tries to supply a rigorously or consistently deﬁned set of
names, and its detailed behavior may change across releases. For example, metaclass attributes are not
in the result list when the argument is a class.
Section 38.13: Singleton class
A singleton is a pattern that restricts the instantiation of a class to one instance/object. For more info on python
singleton design patterns, see here.
class Singleton:
def __new__(cls):
try:
it = cls.__it__
except AttributeError:
it = cls.__it__ = object.__new__(cls)
return it
def __repr__(self):
return '<{}>'.format(self.__class__.__name__.upper())
def __eq__(self, other):
return other is self
Another method is to decorate your class. Following the example from this answer create a Singleton class:
class Singleton:
"""
A non-thread-safe helper class to ease implementing singletons.
This should be used as a decorator -- not a metaclass -- to the
class that should be a singleton.
The decorated class can define one `__init__` function that
takes only the `self` argument. Other than that, there are
no restrictions that apply to the decorated class.
To get the singleton instance, use the `Instance` method. Trying
to use `__call__` will result in a `TypeError` being raised.
Limitations: The decorated class cannot be inherited from.
"""
def __init__(self, decorated):
GoalKicker.com – Python® Notes for Professionals
224self._decorated = decorated
def Instance(self):
"""
Returns the singleton instance. Upon its first call, it creates a
new instance of the decorated class and calls its `__init__` method.
On all subsequent calls, the already created instance is returned.
"""
try:
return self._instance
except AttributeError:
self._instance = self._decorated()
return self._instance
def __call__(self):
raise TypeError('Singletons must be accessed through `Instance()`.')
def __instancecheck__(self, inst):
return isinstance(inst, self._decorated)
To use you can use the Instance method
@Singleton
class Single:
def __init__(self):
self.name=None
self.val=0
def getName(self):
print(self.name)
x=Single.Instance()
y=Single.Instance()
x.name='I\'m single'
x.getName() # outputs I'm single
y.getName() # outputs I'm single
Section 38.14: Descriptors and Dotted Lookups
Descriptors are objects that are (usually) attributes of classes and that have any of __get__, __set__, or
__delete__ special methods.
Data Descriptors have any of __set__, or __delete__
These can control the dotted lookup on an instance, and are used to implement functions, staticmethod,
classmethod, and property. A dotted lookup (e.g. instance foo of class Foo looking up attribute bar - i.e. foo.bar)
uses the following algorithm:
1. bar is looked up in the class, Foo. If it is there and it is a Data Descriptor, then the data descriptor is used.
That's how property is able to control access to data in an instance, and instances cannot override this. If a
Data Descriptor is not there, then
2. bar is looked up in the instance __dict__. This is why we can override or block methods being called from an
instance with a dotted lookup. If bar exists in the instance, it is used. If not, we then
3. look in the class Foo for bar. If it is a Descriptor, then the descriptor protocol is used. This is how functions
(in this context, unbound methods), classmethod, and staticmethod are implemented. Else it simply returns
the object there, or there is an AttributeError
GoalKicker.com – Python® Notes for Professionals
225Chapter 39: Metaclasses
Metaclasses allow you to deeply modify the behaviour of Python classes (in terms of how they're deﬁned,
instantiated, accessed, and more) by replacing the type metaclass that new classes use by default.
Section 39.1: Basic Metaclasses
When type is called with three arguments it behaves as the (meta)class it is, and creates a new instance, ie. it
produces a new class/type.
Dummy = type('OtherDummy', (), dict(x=1))
Dummy.__class__
# <type 'type'>
Dummy().__class__.__class__ # <type 'type'>
It is possible to subclass type to create an custom metaclass.
class mytype(type):
def __init__(cls, name, bases, dict):
# call the base initializer
type.__init__(cls, name, bases, dict)
# perform custom initialization...
cls.__custom_attribute__ = 2
Now, we have a new custom mytype metaclass which can be used to create classes in the same manner as type.
MyDummy = mytype('MyDummy', (), dict(x=2))
MyDummy.__class__
# <class '__main__.mytype'>
MyDummy().__class__.__class__ # <class '__main__.mytype'>
MyDummy.__custom_attribute__
# 2
When we create a new class using the class keyword the metaclass is by default chosen based on upon the
baseclasses.
>>> class Foo(object):
...
pass
>>> type(Foo)
type
In the above example the only baseclass is object so our metaclass will be the type of object, which is type. It is
possible override the default, however it depends on whether we use Python 2 or Python 3:
Python 2.x Version ≤ 2.7
A special class-level attribute __metaclass__ can be used to specify the metaclass.
class MyDummy(object):
__metaclass__ = mytype
type(MyDummy) # <class '__main__.mytype'>
Python 3.x Version ≥ 3.0
A special metaclass keyword argument specify the metaclass.
class MyDummy(metaclass=mytype):
GoalKicker.com – Python® Notes for Professionals
226pass
type(MyDummy)
# <class '__main__.mytype'>
Any keyword arguments (except metaclass) in the class declaration will be passed to the metaclass. Thus class
MyDummy(metaclass=mytype, x=2) will pass x=2 as a keyword argument to the mytype constructor.
Read this in-depth description of python meta-classes for more details.
Section 39.2: Singletons using metaclasses
A singleton is a pattern that restricts the instantiation of a class to one instance/object. For more info on python
singleton design patterns, see here.
class SingletonType(type):
def __call__(cls, *args, **kwargs):
try:
return cls.__instance
except AttributeError:
cls.__instance = super(SingletonType, cls).__call__(*args, **kwargs)
return cls.__instance
Python 2.x Version ≤ 2.7
class MySingleton(object):
__metaclass__ = SingletonType
Python 3.x Version ≥ 3.0
class MySingleton(metaclass=SingletonType):
pass
MySingleton() is MySingleton()
# True, only one instantiation occurs
Section 39.3: Using a metaclass
Metaclass syntax
Python 2.x Version ≤ 2.7
class MyClass(object):
__metaclass__ = SomeMetaclass
Python 3.x Version ≥ 3.0
class MyClass(metaclass=SomeMetaclass):
pass
Python 2 and 3 compatibility with six
import six
class MyClass(six.with_metaclass(SomeMetaclass)):
pass
Section 39.4: Introduction to Metaclasses
What is a metaclass?
In Python, everything is an object: integers, strings, lists, even functions and classes themselves are objects. And
every object is an instance of a class.
To check the class of an object x, one can call type(x), so:
GoalKicker.com – Python® Notes for Professionals
227>>> type(5)
<type 'int'>
>>> type(str)
<type 'type'>
>>> type([1, 2, 3])
<type 'list'>
>>> class C(object):
...
pass
...
>>> type(C)
<type 'type'>
Most classes in python are instances of type. type itself is also a class. Such classes whose instances are also
classes are called metaclasses.
The Simplest Metaclass
OK, so there is already one metaclass in Python: type. Can we create another one?
class SimplestMetaclass(type):
pass
class MyClass(object):
__metaclass__ = SimplestMetaclass
That does not add any functionality, but it is a new metaclass, see that MyClass is now an instance of
SimplestMetaclass:
>>> type(MyClass)
<class '__main__.SimplestMetaclass'>
A Metaclass which does Something
A metaclass which does something usually overrides type's __new__, to modify some properties of the class to be
created, before calling the original __new__ which creates the class:
class AnotherMetaclass(type):
def __new__(cls, name, parents, dct):
# cls is this class
# name is the name of the class to be created
# parents is the list of the class's parent classes
# dct is the list of class's attributes (methods, static variables)
# here all of the attributes can be modified before creating the class, e.g.
dct['x'] = 8
# now the class will have a static variable x = 8
# return value is the new class. super will take care of that
return super(AnotherMetaclass, cls).__new__(cls, name, parents, dct)
Section 39.5: Custom functionality with metaclasses
Functionality in metaclasses can be changed so that whenever a class is built, a string is printed to standard
output, or an exception is thrown. This metaclass will print the name of the class being built.
class VerboseMetaclass(type):
GoalKicker.com – Python® Notes for Professionals
228def __new__(cls, class_name, class_parents, class_dict):
print("Creating class ", class_name)
new_class = super().__new__(cls, class_name, class_parents, class_dict)
return new_class
You can use the metaclass like so:
class Spam(metaclass=VerboseMetaclass):
def eggs(self):
print("[insert example string here]")
s = Spam()
s.eggs()
The standard output will be:
Creating class Spam
[insert example string here]
Section 39.6: The default metaclass
You may have heard that everything in Python is an object. It is true, and all objects have a class:
>>> type(1)
int
The literal 1 is an instance of int. Let's declare a class:
>>> class Foo(object):
...
pass
...
Now let's instantiate it:
>>> bar = Foo()
What is the class of bar?
>>> type(bar)
Foo
Nice, bar is an instance of Foo. But what is the class of Foo itself?
>>> type(Foo)
type
Ok, Foo itself is an instance of type. How about type itself?
>>> type(type)
type
So what is a metaclass? For now let's pretend it is just a fancy name for the class of a class. Takeaways:
Everything is an object in Python, so everything has a class
The class of a class is called a metaclass
The default metaclass is type, and by far it is the most common metaclass
GoalKicker.com – Python® Notes for Professionals
229But why should you know about metaclasses? Well, Python itself is quite "hackable", and the concept of metaclass
is important if you are doing advanced stuﬀ like meta-programming or if you want to control how your classes are
initialized.
GoalKicker.com – Python® Notes for Professionals
230VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 40: String Formatting
When storing and transforming data for humans to see, string formatting can become very important. Python
oﬀers a wide variety of string formatting methods which are outlined in this topic.
Section 40.1: Basics of String Formatting
foo = 1
bar = 'bar'
baz = 3.14
You can use str.format to format output. Bracket pairs are replaced with arguments in the order in which the
arguments are passed:
print('{}, {} and {}'.format(foo, bar, baz))
# Out: "1, bar and 3.14"
Indexes can also be speciﬁed inside the brackets. The numbers correspond to indexes of the arguments passed to
the str.format function (0-based).
print('{0}, {1}, {2}, and {1}'.format(foo, bar, baz))
# Out: "1, bar, 3.14, and bar"
print('{0}, {1}, {2}, and {3}'.format(foo, bar, baz))
# Out: index out of range error
Named arguments can be also used:
print("X value is: {x_val}. Y value is: {y_val}.".format(x_val=2, y_val=3))
# Out: "X value is: 2. Y value is: 3."
Object attributes can be referenced when passed into str.format:
class AssignValue(object):
def __init__(self, value):
self.value = value
my_value = AssignValue(6)
print('My value is: {0.value}'.format(my_value))
# Out: "My value is: 6"
# "0" is optional
Dictionary keys can be used as well:
my_dict = {'key': 6, 'other_key': 7}
print("My other key is: {0[other_key]}".format(my_dict))
# Out: "My other key is: 7"
# "0" is optional
Same applies to list and tuple indices:
my_list = ['zero', 'one', 'two']
print("2nd element is: {0[2]}".format(my_list))
# Out: "2nd element is: two"
# "0" is optional
Note: In addition to str.format, Python also provides the modulo operator %--also known as the string
formatting or interpolation operator (see PEP 3101)--for formatting strings. str.format is a successor of %
GoalKicker.com – Python® Notes for Professionals
232and it oﬀers greater ﬂexibility, for instance by making it easier to carry out multiple substitutions.
In addition to argument indexes, you can also include a format speciﬁcation inside the curly brackets. This is an
expression that follows special rules and must be preceded by a colon (:). See the docs for a full description of
format speciﬁcation. An example of format speciﬁcation is the alignment directive :~^20 (^ stands for center
alignment, total width 20, ﬁll with ~ character):
'{:~^20}'.format('centered')
# Out: '~~~~~~centered~~~~~~'
format allows behaviour not possible with %, for example repetition of arguments:
t = (12, 45, 22222, 103, 6)
print '{0} {2} {1} {2} {3} {2} {4} {2}'.format(*t)
# Out: 12 22222 45 22222 103 22222 6 22222
As format is a function, it can be used as an argument in other functions:
number_list = [12,45,78]
print map('the number is {}'.format, number_list)
# Out: ['the number is 12', 'the number is 45', 'the number is 78']
from datetime import datetime,timedelta
once_upon_a_time = datetime(2010, 7, 1, 12, 0, 0)
delta = timedelta(days=13, hours=8, minutes=20)
gen = (once_upon_a_time + x * delta for x in xrange(5))
print '\n'.join(map('{:%Y-%m-%d %H:%M:%S}'.format, gen))
#Out: 2010-07-01 12:00:00
#
2010-07-14 20:20:00
#
2010-07-28 04:40:00
#
2010-08-10 13:00:00
#
2010-08-23 21:20:00
Section 40.2: Alignment and padding
Python 2.x Version ≥ 2.6
The format() method can be used to change the alignment of the string. You have to do it with a format expression
of the form :[fill_char][align_operator][width] where align_operator is one of:
< forces the ﬁeld to be left-aligned within width.
> forces the ﬁeld to be right-aligned within width.
^ forces the ﬁeld to be centered within width.
= forces the padding to be placed after the sign (numeric types only).
fill_char (if omitted default is whitespace) is the character used for the padding.
'{:~<9s}, World'.format('Hello')
# 'Hello~~~~, World'
'{:~>9s}, World'.format('Hello')
# '~~~~Hello, World'
GoalKicker.com – Python® Notes for Professionals
233'{:~^9s}'.format('Hello')
# '~~Hello~~'
'{:0=6d}'.format(-123)
# '-00123'
Note: you could achieve the same results using the string functions ljust(), rjust(), center(), zfill(), however
these functions are deprecated since version 2.5.
Section 40.3: Format literals (f-string)
Literal format strings were introduced in PEP 498 (Python3.6 and upwards), allowing you to prepend f to the
beginning of a string literal to eﬀectively apply .format to it with all variables in the current scope.
>>> foo = 'bar'
>>> f'Foo is {foo}'
'Foo is bar'
This works with more advanced format strings too, including alignment and dot notation.
>>> f'{foo:^7s}'
' bar '
Note: The f'' does not denote a particular type like b'' for bytes or u'' for unicode in python2. The formatting is
immediately applied, resulting in a normal string.
The format strings can also be nested:
>>> price = 478.23
>>> f"{f'${price:0.2f}':*>20s}"
'*************$478.23'
The expressions in an f-string are evaluated in left-to-right order. This is detectable only if the expressions have side
eﬀects:
>>> def fn(l, incr):
...
result = l[0]
...
l[0] += incr
...
return result
...
>>> lst = [0]
>>> f'{fn(lst,2)} {fn(lst,3)}'
'0 2'
>>> f'{fn(lst,2)} {fn(lst,3)}'
'5 7'
>>> lst
[10]
Section 40.4: Float formatting
>>> '{0:.0f}'.format(42.12345)
'42'
>>> '{0:.1f}'.format(42.12345)
'42.1'
>>> '{0:.3f}'.format(42.12345)
GoalKicker.com – Python® Notes for Professionals
234'42.123'
>>> '{0:.5f}'.format(42.12345)
'42.12345'
>>> '{0:.7f}'.format(42.12345)
'42.1234500'
Same hold for other way of referencing:
>>> '{:.3f}'.format(42.12345)
'42.123'
>>> '{answer:.3f}'.format(answer=42.12345)
'42.123'
Floating point numbers can also be formatted in scientiﬁc notation or as percentages:
>>> '{0:.3e}'.format(42.12345)
'4.212e+01'
>>> '{0:.0%}'.format(42.12345)
'4212%'
You can also combine the {0} and {name} notations. This is especially useful when you want to round all variables
to a pre-speciﬁed number of decimals with 1 declaration:
>>> s = 'Hello'
>>> a, b, c = 1.12345, 2.34567, 34.5678
>>> digits = 2
>>> '{0}! {1:.{n}f}, {2:.{n}f}, {3:.{n}f}'.format(s, a, b, c, n=digits)
'Hello! 1.12, 2.35, 34.57'
Section 40.5: Named placeholders
Format strings may contain named placeholders that are interpolated using keyword arguments to format.
Using a dictionary (Python 2.x)
>>> data = {'first': 'Hodor', 'last': 'Hodor!'}
>>> '{first} {last}'.format(**data)
'Hodor Hodor!'
Using a dictionary (Python 3.2+)
>>> '{first} {last}'.format_map(data)
'Hodor Hodor!'
str.format_map allows to use dictionaries without having to unpack them ﬁrst. Also the class of data (which might
be a custom type) is used instead of a newly ﬁlled dict.
Without a dictionary:
>>> '{first} {last}'.format(first='Hodor', last='Hodor!')
'Hodor Hodor!'
GoalKicker.com – Python® Notes for Professionals
235Section 40.6: String formatting with datetime
Any class can conﬁgure its own string formatting syntax through the __format__ method. A type in the standard
Python library that makes handy use of this is the datetime type, where one can use strftime-like formatting
codes directly within str.format:
>>> from datetime import datetime
>>> 'North America: {dt:%m/%d/%Y}. ISO: {dt:%Y-%m-%d}.'.format(dt=datetime.now())
'North America: 07/21/2016. ISO: 2016-07-21.'
A full list of list of datetime formatters can be found in the oﬃcial documentation.
Section 40.7: Formatting Numerical Values
The .format() method can interpret a number in diﬀerent formats, such as:
>>> '{:c}'.format(65)
'A'# Unicode character
>>> '{:d}'.format(0x0a)
'10'# base 10
>>> '{:n}'.format(0x0a)
'10'# base 10 using current locale for separators
Format integers to diﬀerent bases (hex, oct, binary)
>>> '{0:x}'.format(10) # base 16, lowercase - Hexadecimal
'a'
>>> '{0:X}'.format(10) # base 16, uppercase - Hexadecimal
'A'
>>> '{:o}'.format(10) # base 8 - Octal
'12'
>>> '{:b}'.format(10) # base 2 - Binary
'1010'
>>> '{0:#b}, {0:#o}, {0:#x}'.format(42) # With prefix
'0b101010, 0o52, 0x2a'
>>> '8 bit: {0:08b}; Three bytes: {0:06x}'.format(42) # Add zero padding
'8 bit: 00101010; Three bytes: 00002a'
Use formatting to convert an RGB ﬂoat tuple to a color hex string:
>>> r, g, b = (1.0, 0.4, 0.0)
>>> '#{:02X}{:02X}{:02X}'.format(int(255 * r), int(255 * g), int(255 * b))
'#FF6600'
Only integers can be converted:
>>> '{:x}'.format(42.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'x' for object of type 'float'
GoalKicker.com – Python® Notes for Professionals
236Section 40.8: Nested formatting
Some formats can take additional parameters, such as the width of the formatted string, or the alignment:
>>> '{:.>10}'.format('foo')
'.......foo'
Those can also be provided as parameters to format by nesting more {} inside the {}:
>>> '{:.>{}}'.format('foo', 10)
'.......foo'
'{:{}{}{}}'.format('foo', '*', '^', 15)
'******foo******'
In the latter example, the format string '{:{}{}{}}' is modiﬁed to '{:*^15}' (i.e. "center and pad with * to total
length of 15") before applying it to the actual string 'foo' to be formatted that way.
This can be useful in cases when parameters are not known beforehand, for instances when aligning tabular data:
>>> data = ["a", "bbbbbbb", "ccc"]
>>> m = max(map(len, data))
>>> for d in data:
...
print('{:>{}}'.format(d, m))
a
bbbbbbb
ccc
Section 40.9: Format using Getitem and Getattr
Any data structure that supports __getitem__ can have their nested structure formatted:
person = {'first': 'Arthur', 'last': 'Dent'}
'{p[first]} {p[last]}'.format(p=person)
# 'Arthur Dent'
Object attributes can be accessed using getattr():
class Person(object):
first = 'Zaphod'
last = 'Beeblebrox'
'{p.first} {p.last}'.format(p=Person())
# 'Zaphod Beeblebrox'
Section 40.10: Padding and truncating strings, combined
Say you want to print variables in a 3 character column.
Note: doubling { and } escapes them.
s = """
pad
{{:3}}
:{a:3}:
truncate
GoalKicker.com – Python® Notes for Professionals
237{{:.3}}:{e:.3}:
combined
{{:>3.3}}
{{:3.3}}
{{:3.3}}
{{:3.3}}
""":{a:>3.3}:
:{a:3.3}:
:{c:3.3}:
:{e:3.3}:
print (s.format(a="1"*1, c="3"*3, e="5"*5))
Output:
pad
{:3}:1
truncate
{:.3}:555:
combined
{:>3.3}
{:3.3}
{:3.3}
{:3.3}: 1:
:1 :
:333:
:555:
:
Section 40.11: Custom formatting for a class
Note:
Everything below applies to the str.format method, as well as the format function. In the text below, the
two are interchangeable.
For every value which is passed to the format function, Python looks for a __format__ method for that argument.
Your own custom class can therefore have their own __format__ method to determine how the format function will
display and format your class and it's attributes.
This is diﬀerent than the __str__ method, as in the __format__ method you can take into account the formatting
language, including alignment, ﬁeld width etc, and even (if you wish) implement your own format speciﬁers, and
your own formatting language extensions.1
object.__format__(self, format_spec)
For example:
# Example in Python 2 - but can be easily applied to Python 3
class Example(object):
def __init__(self,a,b,c):
self.a, self.b, self.c = a,b,c
def __format__(self, format_spec):
""" Implement special semantics for the 's' format specifier """
# Reject anything that isn't an s
if format_spec[-1] != 's':
raise ValueError('{} format specifier not understood for this object',
format_spec[:-1])
GoalKicker.com – Python® Notes for Professionals
238# Output in this example will be (<a>,<b>,<c>)
raw = "(" + ",".join([str(self.a), str(self.b), str(self.c)]) + ")"
# Honor the format language by using the inbuilt string format
# Since we know the original format_spec ends in an 's'
# we can take advantage of the str.format method with a
# string argument we constructed above
return "{r:{f}}".format( r=raw, f=format_spec )
inst = Example(1,2,3)
print "{0:>20s}".format( inst )
# out :
(1,2,3)
# Note how the right align and field width of 20 has been honored.
Note:
If your custom class does not have a custom __format__ method and an instance of the class is passed to
the format function, Python2 will always use the return value of the __str__ method or __repr__
method to determine what to print (and if neither exist then the default repr will be used), and you will
need to use the s format speciﬁer to format this. With Python3, to pass your custom class to the format
function, you will need deﬁne __format__ method on your custom class.
GoalKicker.com – Python® Notes for Professionals
239Chapter 41: String Methods
Section 41.1: Changing the capitalization of a string
Python's string type provides many functions that act on the capitalization of a string. These include:
str.casefold
str.upper
str.lower
str.capitalize
str.title
str.swapcase
With unicode strings (the default in Python 3), these operations are not 1:1 mappings or reversible. Most of these
operations are intended for display purposes, rather than normalization.
Python 3.x Version ≥ 3.3
str.casefold()
str.casefold creates a lowercase string that is suitable for case insensitive comparisons. This is more aggressive
than str.lower and may modify strings that are already in lowercase or cause strings to grow in length, and is not
intended for display purposes.
"XßΣ".casefold()
# 'xssσ'
"XßΣ".lower()
# 'xßς'
The transformations that take place under casefolding are deﬁned by the Unicode Consortium in the
CaseFolding.txt ﬁle on their website.
str.upper()
str.upper takes every character in a string and converts it to its uppercase equivalent, for example:
"This is a 'string'.".upper()
# "THIS IS A 'STRING'."
str.lower()
str.lower does the opposite; it takes every character in a string and converts it to its lowercase equivalent:
"This IS a 'string'.".lower()
# "this is a 'string'."
str.capitalize()
str.capitalize returns a capitalized version of the string, that is, it makes the ﬁrst character have upper case and
the rest lower:
"this Is A 'String'.".capitalize() # Capitalizes the first character and lowercases all others
GoalKicker.com – Python® Notes for Professionals
240# "This is a 'string'."
str.title()
str.title returns the title cased version of the string, that is, every letter in the beginning of a word is made upper
case and all others are made lower case:
"this Is a 'String'".title()
# "This Is A 'String'"
str.swapcase()
str.swapcase returns a new string object in which all lower case characters are swapped to upper case and all
upper case characters to lower:
"this iS A STRiNG".swapcase() #Swaps case of each character
# "THIS Is a strIng"
Usage as str class methods
It is worth noting that these methods may be called either on string objects (as shown above) or as a class method
of the str class (with an explicit call to str.upper, etc.)
str.upper("This is a 'string'")
# "THIS IS A 'STRING'"
This is most useful when applying one of these methods to many strings at once in say, a map function.
map(str.upper,["These","are","some","'strings'"])
# ['THESE', 'ARE', 'SOME', "'STRINGS'"]
Section 41.2: str.translate: Translating characters in a string
Python supports a translate method on the str type which allows you to specify the translation table (used for
replacements) as well as any characters which should be deleted in the process.
str.translate(table[, deletechars])
Parameter
Description
table
It is a lookup table that deﬁnes the mapping from one character to another.
deletechars A list of characters which are to be removed from the string.
The maketrans method (str.maketrans in Python 3 and string.maketrans in Python 2) allows you to generate a
translation table.
>>> translation_table = str.maketrans("aeiou", "12345")
>>> my_string = "This is a string!"
>>> translated = my_string.translate(translation_table)
'Th3s 3s 1 str3ng!'
The translate method returns a string which is a translated copy of the original string.
You can set the table argument to None if you only need to delete characters.
>>> 'this syntax is very useful'.translate(None, 'aeiou')
GoalKicker.com – Python® Notes for Professionals
241'ths syntx s vry sfl'
Section 41.3: str.format and f-strings: Format values into a
string
Python provides string interpolation and formatting functionality through the str.format function, introduced in
version 2.6 and f-strings introduced in version 3.6.
Given the following variables:
i = 10
f = 1.5
s = "foo"
l = ['a', 1, 2]
d = {'a': 1, 2: 'foo'}
The following statements are all equivalent
"10 1.5 foo ['a', 1, 2] {'a': 1, 2: 'foo'}"
>>> "{} {} {} {} {}".format(i, f, s, l, d)
>>> str.format("{} {} {} {} {}", i, f, s, l, d)
>>> "{0} {1} {2} {3} {4}".format(i, f, s, l, d)
>>> "{0:d} {1:0.1f} {2} {3!r} {4!r}".format(i, f, s, l, d)
>>> "{i:d} {f:0.1f} {s} {l!r} {d!r}".format(i=i, f=f, s=s, l=l, d=d)
>>> f"{i} {f} {s} {l} {d}"
>>> f"{i:d} {f:0.1f} {s} {l!r} {d!r}"
For reference, Python also supports C-style qualiﬁers for string formatting. The examples below are equivalent to
those above, but the str.format versions are preferred due to beneﬁts in ﬂexibility, consistency of notation, and
extensibility:
"%d %0.1f %s %r %r" % (i, f, s, l, d)
"%(i)d %(f)0.1f %(s)s %(l)r %(d)r" % dict(i=i, f=f, s=s, l=l, d=d)
The braces uses for interpolation in str.format can also be numbered to reduce duplication when formatting
strings. For example, the following are equivalent:
"I am from Australia. I love cupcakes from Australia!"
>>> "I am from {}. I love cupcakes from {}!".format("Australia", "Australia")
>>> "I am from {0}. I love cupcakes from {0}!".format("Australia")
While the oﬃcial python documentation is, as usual, thorough enough, pyformat.info has a great set of examples
with detailed explanations.
Additionally, the { and } characters can be escaped by using double brackets:
"{'a': 5, 'b': 6}"
GoalKicker.com – Python® Notes for Professionals
242>>> "{{'{}': {}, '{}': {}}}".format("a", 5, "b", 6)
>>> f"{{'{'a'}': {5}, '{'b'}': {6}}"
See String Formatting for additional information. str.format() was proposed in PEP 3101 and f-strings in PEP 498.
Section 41.4: String module's useful constants
Python's string module provides constants for string related operations. To use them, import the string module:
>>> import string
string.ascii_letters:
Concatenation of ascii_lowercase and ascii_uppercase:
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
string.ascii_lowercase:
Contains all lower case ASCII characters:
>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
string.ascii_uppercase:
Contains all upper case ASCII characters:
>>> string.ascii_uppercase
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
string.digits:
Contains all decimal digit characters:
>>> string.digits
'0123456789'
string.hexdigits:
Contains all hex digit characters:
>>> string.hexdigits
'0123456789abcdefABCDEF'
string.octaldigits:
Contains all octal digit characters:
>>> string.octaldigits
'01234567'
GoalKicker.com – Python® Notes for Professionals
243string.punctuation:
Contains all characters which are considered punctuation in the C locale:
>>> string.punctuation
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
string.whitespace:
Contains all ASCII characters considered whitespace:
>>> string.whitespace
' \t\n\r\x0b\x0c'
In script mode, print(string.whitespace) will print the actual characters, use str to get the string returned
above.
string.printable:
Contains all characters which are considered printable; a combination of string.digits, string.ascii_letters,
string.punctuation, and string.whitespace.
>>> string.printable
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~
\t\n\r\x0b\x0c'
Section 41.5: Stripping unwanted leading/trailing characters
from a string
Three methods are provided that oﬀer the ability to strip leading and trailing characters from a string: str.strip,
str.rstrip and str.lstrip. All three methods have the same signature and all three return a new string object
with unwanted characters removed.
str.strip([chars])
str.strip acts on a given string and removes (strips) any leading or trailing characters contained in the argument
chars; if chars is not supplied or is None, all white space characters are removed by default. For example:
>>> "
a line with leading and trailing space
'a line with leading and trailing space'
".strip()
If chars is supplied, all characters contained in it are removed from the string, which is returned. For example:
>>> ">>> a Python prompt".strip('> ')
'a Python prompt'
# strips '>' character and space character
str.rstrip([chars]) and str.lstrip([chars])
These methods have similar semantics and arguments with str.strip(), their diﬀerence lies in the direction from
which they start. str.rstrip() starts from the end of the string while str.lstrip() splits from the start of the
string.
GoalKicker.com – Python® Notes for Professionals
244For example, using str.rstrip:
>>> "
spacious string
'
spacious string'
".rstrip()
While, using str.lstrip:
>>> "
spacious string
'spacious string
'
".rstrip()
Section 41.6: Reversing a string
A string can reversed using the built-in reversed() function, which takes a string and returns an iterator in reverse
order.
>>> reversed('hello')
<reversed object at 0x0000000000000000>
>>> [char for char in reversed('hello')]
['o', 'l', 'l', 'e', 'h']
reversed() can be wrapped in a call to ''.join() to make a string from the iterator.
>>> ''.join(reversed('hello'))
'olleh'
While using reversed() might be more readable to uninitiated Python users, using extended slicing with a step of
-1 is faster and more concise. Here , try to implement it as function:
>>> def reversed_string(main_string):
...
return main_string[::-1]
...
>>> reversed_string('hello')
'olleh'
Section 41.7: Split a string based on a delimiter into a list of
strings
str.split(sep=None, maxsplit=-1)
str.split takes a string and returns a list of substrings of the original string. The behavior diﬀers depending on
whether the sep argument is provided or omitted.
If sep isn't provided, or is None, then the splitting takes place wherever there is whitespace. However, leading and
trailing whitespace is ignored, and multiple consecutive whitespace characters are treated the same as a single
whitespace character:
>>> "This is a sentence.".split()
['This', 'is', 'a', 'sentence.']
>>> " This is
a sentence. ".split()
['This', 'is', 'a', 'sentence.']
>>> "
[]
".split()
GoalKicker.com – Python® Notes for Professionals
245The sep parameter can be used to deﬁne a delimiter string. The original string is split where the delimiter string
occurs, and the delimiter itself is discarded. Multiple consecutive delimiters are not treated the same as a single
occurrence, but rather cause empty strings to be created.
>>> "This is a sentence.".split(' ')
['This', 'is', 'a', 'sentence.']
>>> "Earth,Stars,Sun,Moon".split(',')
['Earth', 'Stars', 'Sun', 'Moon']
>>> " This is
a sentence. ".split(' ')
['', 'This', 'is', '', '', '', 'a', 'sentence.', '', '']
>>> "This is a sentence.".split('e')
['This is a s', 'nt', 'nc', '.']
>>> "This is a sentence.".split('en')
['This is a s', 't', 'ce.']
The default is to split on every occurrence of the delimiter, however the maxsplit parameter limits the number of
splittings that occur. The default value of -1 means no limit:
>>> "This is a sentence.".split('e', maxsplit=0)
['This is a sentence.']
>>> "This is a sentence.".split('e', maxsplit=1)
['This is a s', 'ntence.']
>>> "This is a sentence.".split('e', maxsplit=2)
['This is a s', 'nt', 'nce.']
>>> "This is a sentence.".split('e', maxsplit=-1)
['This is a s', 'nt', 'nc', '.']
str.rsplit(sep=None, maxsplit=-1)
str.rsplit ("right split") diﬀers from str.split ("left split") when maxsplit is speciﬁed. The splitting starts at the
end of the string rather than at the beginning:
>>> "This is a sentence.".rsplit('e', maxsplit=1)
['This is a sentenc', '.']
>>> "This is a sentence.".rsplit('e', maxsplit=2)
['This is a sent', 'nc', '.']
Note: Python speciﬁes the maximum number of splits performed, while most other programming languages
specify the maximum number of substrings created. This may create confusion when porting or comparing code.
Section 41.8: Replace all occurrences of one substring with
another substring
Python's str type also has a method for replacing occurrences of one sub-string with another sub-string in a given
string. For more demanding cases, one can use re.sub.
str.replace(old, new[, count]):
GoalKicker.com – Python® Notes for Professionals
246str.replace takes two arguments old and new containing the old sub-string which is to be replaced by the new sub-
string. The optional argument count speciﬁes the number of replacements to be made:
For example, in order to replace 'foo' with 'spam' in the following string, we can call str.replace with old =
'foo' and new = 'spam':
>>> "Make sure to foo your sentence.".replace('foo', 'spam')
"Make sure to spam your sentence."
If the given string contains multiple examples that match the old argument, all occurrences are replaced with the
value supplied in new:
>>> "It can foo multiple examples of foo if you want.".replace('foo', 'spam')
"It can spam multiple examples of spam if you want."
unless, of course, we supply a value for count. In this case count occurrences are going to get replaced:
>>> """It can foo multiple examples of foo if you want, \
... or you can limit the foo with the third argument.""".replace('foo', 'spam', 1)
'It can spam multiple examples of foo if you want, or you can limit the foo with the third
argument.'
Section 41.9: Testing what a string is composed of
Python's str type also features a number of methods that can be used to evaluate the contents of a string. These
are str.isalpha, str.isdigit, str.isalnum, str.isspace. Capitalization can be tested with str.isupper,
str.islower and str.istitle.
str.isalpha
str.isalpha takes no arguments and returns True if the all characters in a given string are alphabetic, for example:
>>> "Hello World".isalpha()
False
>>> "Hello2World".isalpha()
False
>>> "HelloWorld!".isalpha()
False
>>> "HelloWorld".isalpha()
True
# contains a space
# contains a number
# contains punctuation
As an edge case, the empty string evaluates to False when used with "".isalpha().
str.isupper, str.islower, str.istitle
These methods test the capitalization in a given string.
str.isupper is a method that returns True if all characters in a given string are uppercase and False otherwise.
>>> "HeLLO WORLD".isupper()
False
>>> "HELLO WORLD".isupper()
True
>>> "".isupper()
GoalKicker.com – Python® Notes for Professionals
247False
Conversely, str.islower is a method that returns True if all characters in a given string are lowercase and False
otherwise.
>>> "Hello world".islower()
False
>>> "hello world".islower()
True
>>> "".islower()
False
str.istitle returns True if the given string is title cased; that is, every word begins with an uppercase character
followed by lowercase characters.
>>> "hello world".istitle()
False
>>> "Hello world".istitle()
False
>>> "Hello World".istitle()
True
>>> "".istitle()
False
str.isdecimal, str.isdigit, str.isnumeric
str.isdecimal returns whether the string is a sequence of decimal digits, suitable for representing a decimal
number.
str.isdigit includes digits not in a form suitable for representing a decimal number, such as superscript digits.
str.isnumeric includes any number values, even if not digits, such as values outside the range 0-9.
12345
?2??5
?²³?????
??
Five
isdecimalisdigitisnumeric
True
True
False
False
FalseTrue
True
True
False
FalseTrue
True
True
True
False
Bytestrings (bytes in Python 3, str in Python 2), only support isdigit, which only checks for basic ASCII digits.
As with str.isalpha, the empty string evaluates to False.
str.isalnum
This is a combination of str.isalpha and str.isnumeric, speciﬁcally it evaluates to True if all characters in the
given string are alphanumeric, that is, they consist of alphabetic or numeric characters:
>>> "Hello2World".isalnum()
True
>>> "HelloWorld".isalnum()
True
>>> "2016".isalnum()
True
GoalKicker.com – Python® Notes for Professionals
248>>> "Hello World".isalnum()
False
# contains whitespace
str.isspace
Evaluates to True if the string contains only whitespace characters.
>>> "\t\r\n".isspace()
True
>>> " ".isspace()
True
Sometimes a string looks “empty” but we don't know whether it's because it contains just whitespace or no
character at all
>>> "".isspace()
False
To cover this case we need an additional test
>>> my_str = ''
>>> my_str.isspace()
False
>>> my_str.isspace() or not my_str
True
But the shortest way to test if a string is empty or just contains whitespace characters is to use strip(with no
arguments it removes all leading and trailing whitespace characters)
>>> not my_str.strip()
True
Section 41.10: String Contains
Python makes it extremely intuitive to check if a string contains a given substring. Just use the in operator:
>>> "foo" in "foo.baz.bar"
True
Note: testing an empty string will always result in True:
>>> "" in "test"
True
Section 41.11: Join a list of strings into one string
A string can be used as a separator to join a list of strings together into a single string using the join() method. For
example you can create a string where each element in a list is separated by a space.
>>> " ".join(["once","upon","a","time"])
"once upon a time"
The following example separates the string elements with three hyphens.
>>> "---".join(["once", "upon", "a", "time"])
GoalKicker.com – Python® Notes for Professionals
249"once---upon---a---time"
Section 41.12: Counting number of times a substring appears
in a string
One method is available for counting the number of occurrences of a sub-string in another string, str.count.
str.count(sub[, start[, end]])
str.count returns an int indicating the number of non-overlapping occurrences of the sub-string sub in another
string. The optional arguments start and end indicate the beginning and the end in which the search will take
place. By default start = 0 and end = len(str) meaning the whole string will be searched:
>>> s = "She sells seashells by the seashore."
>>> s.count("sh")
2
>>> s.count("se")
3
>>> s.count("sea")
2
>>> s.count("seashells")
1
By specifying a diﬀerent value for start, end we can get a more localized search and count, for example, if start is
equal to 13 the call to:
>>> s.count("sea", start)
1
is equivalent to:
>>> t = s[start:]
>>> t.count("sea")
1
Section 41.13: Case insensitive string comparisons
Comparing string in a case insensitive way seems like something that's trivial, but it's not. This section only
considers unicode strings (the default in Python 3). Note that Python 2 may have subtle weaknesses relative to
Python 3 - the later's unicode handling is much more complete.
The ﬁrst thing to note it that case-removing conversions in unicode aren't trivial. There is text for which
text.lower() != text.upper().lower(), such as "ß":
>>> "ß".lower()
'ß'
>>> "ß".upper().lower()
'ss'
But let's say you wanted to caselessly compare "BUSSE" and "Buße". You probably also want to compare "BUSSE"
and "BU E" equal - that's the newer capital form. The recommended way is to use casefold:
Python 3.x Version ≥ 3.3
GoalKicker.com – Python® Notes for Professionals
250>>> help(str.casefold)
"""
Help on method_descriptor:
casefold(...)
S.casefold() -> str
Return a version of S suitable for caseless comparisons.
"""
Do not just use lower. If casefold is not available, doing .upper().lower() helps (but only somewhat).
Then you should consider accents. If your font renderer is good, you probably think "ê" == "ê" - but it doesn't:
>>> "ê" == "ê"
False
This is because they are actually
>>> import unicodedata
>>> [unicodedata.name(char) for char in "ê"]
['LATIN SMALL LETTER E WITH CIRCUMFLEX']
>>> [unicodedata.name(char) for char in "ê"]
['LATIN SMALL LETTER E', 'COMBINING CIRCUMFLEX ACCENT']
The simplest way to deal with this is unicodedata.normalize. You probably want to use NFKD normalization, but
feel free to check the documentation. Then one does
>>> unicodedata.normalize("NFKD", "ê") == unicodedata.normalize("NFKD", "ê")
True
To ﬁnish up, here this is expressed in functions:
import unicodedata
def normalize_caseless(text):
return unicodedata.normalize("NFKD", text.casefold())
def caseless_equal(left, right):
return normalize_caseless(left) == normalize_caseless(right)
Section 41.14: Justify strings
Python provides functions for justifying strings, enabling text padding to make aligning various strings much easier.
Below is an example of str.ljust and str.rjust:
interstates_lengths = {
5: (1381, 2222),
19: (63, 102),
40: (2555, 4112),
93: (189,305),
}
for road, length in interstates_lengths.items():
miles,kms = length
GoalKicker.com – Python® Notes for Professionals
251print('{} -> {} mi. ({} km.)'.format(str(road).rjust(4), str(miles).ljust(4),
str(kms).ljust(4)))
40 -> 2555 mi. (4112 km.)
19 -> 63
mi. (102 km.)
5 -> 1381 mi. (2222 km.)
93 -> 189 mi. (305 km.)
ljust and rjust are very similar. Both have a width parameter and an optional fillchar parameter. Any string
created by these functions is at least as long as the width parameter that was passed into the function. If the string
is longer than width alread, it is not truncated. The fillchar argument, which defaults to the space character ' '
must be a single character, not a multicharacter string.
The ljust function pads the end of the string it is called on with the fillchar until it is width characters long. The
rjust function pads the beginning of the string in a similar fashion. Therefore, the l and r in the names of these
functions refer to the side that the original string, not the fillchar, is positioned in the output string.
Section 41.15: Test the starting and ending characters of a
string
In order to test the beginning and ending of a given string in Python, one can use the methods str.startswith()
and str.endswith().
str.startswith(prefix[, start[, end]])
As its name implies, str.startswith is used to test whether a given string starts with the given characters in
prefix.
>>> s = "This is a test string"
>>> s.startswith("T")
True
>>> s.startswith("Thi")
True
>>> s.startswith("thi")
False
The optional arguments start and end specify the start and end points from which the testing will start and ﬁnish.
In the following example, by specifying a start value of 2 our string will be searched from position 2 and afterwards:
>>> s.startswith("is", 2)
True
This yields True since s[2] == 'i' and s[3] == 's'.
You can also use a tuple to check if it starts with any of a set of strings
>>> s.startswith(('This', 'That'))
True
>>> s.startswith(('ab', 'bc'))
False
str.endswith(prefix[, start[, end]])
str.endswith is exactly similar to str.startswith with the only diﬀerence being that it searches for ending
characters and not starting characters. For example, to test if a string ends in a full stop, one could write:
GoalKicker.com – Python® Notes for Professionals
252>>> s = "this ends in a full stop."
>>> s.endswith('.')
True
>>> s.endswith('!')
False
as with startswith more than one characters can used as the ending sequence:
>>> s.endswith('stop.')
True
>>> s.endswith('Stop.')
False
You can also use a tuple to check if it ends with any of a set of strings
>>> s.endswith(('.', 'something'))
True
>>> s.endswith(('ab', 'bc'))
False
Section 41.16: Conversion between str or bytes data and
unicode characters
The contents of ﬁles and network messages may represent encoded characters. They often need to be converted to
unicode for proper display.
In Python 2, you may need to convert str data to Unicode characters. The default ('', "", etc.) is an ASCII string, with
any values outside of ASCII range displayed as escaped values. Unicode strings are u'' (or u"", etc.).
Python 2.x Version ≥ 2.3
# You get "© abc" encoded in UTF-8 from a file, network, or other data source
s = '\xc2\xa9 abc'
s[0]
type(s)
# s is a byte array, not a string of characters
# Doesn't know the original was UTF-8
# Default form of string literals in Python 2
# '\xc2' - meaningless byte (without context such as an encoding)
# str - even though it's not a useful one w/o having a known encoding
u = s.decode('utf-8')
# u'\xa9 abc'
# Now we have a Unicode string, which can be read as UTF-8 and printed
properly
# In Python 2, Unicode string literals need a leading u
# str.decode converts a string which may contain escaped bytes to a Unicode
string
u[0]
type(u)
u.encode('utf-8')
# u'\xa9' - Unicode Character 'COPYRIGHT SIGN' (U+00A9) '©'
# unicode
# '\xc2\xa9 abc'
# unicode.encode produces a string with escaped bytes for non-ASCII characters
In Python 3 you may need to convert arrays of bytes (referred to as a 'byte literal') to strings of Unicode characters.
The default is now a Unicode string, and bytestring literals must now be entered as b'', b"", etc. A byte literal will
return True to isinstance(some_val, byte), assuming some_val to be a string that might be encoded as bytes.
Python 3.x Version ≥ 3.0
# You get from file or network "© abc" encoded in UTF-8
GoalKicker.com – Python® Notes for Professionals
253s = b'\xc2\xa9 abc' # s is a byte array, not characters
# In Python 3, the default string literal is Unicode; byte array literals need a
leading b
s[0]
# b'\xc2' - meaningless byte (without context such as an encoding)
type(s)
# bytes - now that byte arrays are explicit, Python can show that.
u = s.decode('utf-8')
Unicode)
u[0]
type(u)
u.encode('utf-8')
# '© abc' on a Unicode terminal
# bytes.decode converts a byte array to a string (which will, in Python 3, be
# '\u00a9' - Unicode Character 'COPYRIGHT SIGN' (U+00A9) '©'
# str
# The default string literal in Python 3 is UTF-8 Unicode
# b'\xc2\xa9 abc'
# str.encode produces a byte array, showing ASCII-range bytes as unescaped
characters.
GoalKicker.com – Python® Notes for Professionals
254Chapter 42: Using loops within functions
In Python function will be returned as soon as execution hits "return" statement.
Section 42.1: Return statement inside loop in a function
In this example, function will return as soon as value var has 1
def func(params):
for value in params:
print ('Got value {}'.format(value))
if value == 1:
# Returns from function as soon as value is 1
print (">>>> Got 1")
return
print ("Still looping")
return "Couldn't find 1"
func([5, 3, 1, 2, 8, 9])
output
Got value 5
Still looping
Got value 3
Still looping
Got value 1
>>>> Got 1
GoalKicker.com – Python® Notes for Professionals
255Chapter 43: Importing modules
Section 43.1: Importing a module
Use the import statement:
>>> import random
>>> print(random.randint(1, 10))
4
import module will import a module and then allow you to reference its objects -- values, functions and classes, for
example -- using the module.name syntax. In the above example, the random module is imported, which contains the
randint function. So by importing random you can call randint with random.randint.
You can import a module and assign it to a diﬀerent name:
>>> import random as rn
>>> print(rn.randint(1, 10))
4
If your python ﬁle main.py is in the same folder as custom.py. You can import it like this:
import custom
It is also possible to import a function from a module:
>>> from math import sin
>>> sin(1)
0.8414709848078965
To import speciﬁc functions deeper down into a module, the dot operator may be used only on the left side of the
import keyword:
from urllib.request import urlopen
In python, we have two ways to call function from top level. One is import and another is from. We should use
import when we have a possibility of name collision. Suppose we have hello.py ﬁle and world.py ﬁles having same
function named function. Then import statement will work good.
from hello import function
from world import function
function() #world's function will be invoked. Not hello's
In general import will provide you a namespace.
import hello
import world
hello.function() # exclusively hello's function will be invoked
world.function() # exclusively world's function will be invoked
But if you are sure enough, in your whole project there is no way having same function name you should use from
statement
GoalKicker.com – Python® Notes for Professionals
256Multiple imports can be made on the same line:
>>> # Multiple modules
>>> import time, sockets, random
>>> # Multiple functions
>>> from math import sin, cos, tan
>>> # Multiple constants
>>> from math import pi, e
>>> print(pi)
3.141592653589793
>>> print(cos(45))
0.5253219888177297
>>> print(time.time())
1482807222.7240417
The keywords and syntax shown above can also be used in combinations:
>>> from urllib.request import urlopen as geturl, pathname2url as path2url, getproxies
>>> from math import factorial as fact, gamma, atan as arctan
>>> import random.randint, time, sys
>>> print(time.time())
1482807222.7240417
>>> print(arctan(60))
1.554131203080956
>>> filepath = "/dogs/jumping poodle (december).png"
>>> print(path2url(filepath))
/dogs/jumping%20poodle%20%28december%29.png
Section 43.2: The __all__ special variable
Modules can have a special variable named __all__ to restrict what variables are imported when using from
mymodule import *.
Given the following module:
# mymodule.py
__all__ = ['imported_by_star']
imported_by_star = 42
not_imported_by_star = 21
Only imported_by_star is imported when using from mymodule import *:
>>> from mymodule import *
>>> imported_by_star
42
>>> not_imported_by_star
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'not_imported_by_star' is not defined
However, not_imported_by_star can be imported explicitly:
>>> from mymodule import not_imported_by_star
>>> not_imported_by_star
GoalKicker.com – Python® Notes for Professionals
25721
Section 43.3: Import modules from an arbitrary ﬁlesystem
location
If you want to import a module that doesn't already exist as a built-in module in the Python Standard Library nor as
a side-package, you can do this by adding the path to the directory where your module is found to sys.path. This
may be useful where multiple python environments exist on a host.
import sys
sys.path.append("/path/to/directory/containing/your/module")
import mymodule
It is important that you append the path to the directory in which mymodule is found, not the path to the module
itself.
Section 43.4: Importing all names from a module
from module_name import *
for example:
from math import *
sqrt(2)
# instead of math.sqrt(2)
ceil(2.7) # instead of math.ceil(2.7)
This will import all names deﬁned in the math module into the global namespace, other than names that begin with
an underscore (which indicates that the writer feels that it is for internal use only).
Warning: If a function with the same name was already deﬁned or imported, it will be overwritten. Almost always
importing only speciﬁc names from math import sqrt, ceil is the recommended way:
def sqrt(num):
print("I don't know what's the square root of {}.".format(num))
sqrt(4)
# Output: I don't know what's the square root of 4.
from math import *
sqrt(4)
# Output: 2.0
Starred imports are only allowed at the module level. Attempts to perform them in class or function deﬁnitions
result in a SyntaxError.
def f():
from math import *
and
class A:
from math import *
both fail with:
GoalKicker.com – Python® Notes for Professionals
258SyntaxError: import * only allowed at module level
Section 43.5: Programmatic importing
Python 2.x Version ≥ 2.7
To import a module through a function call, use the importlib module (included in Python starting in version 2.7):
import importlib
random = importlib.import_module("random")
The importlib.import_module() function will also import the submodule of a package directly:
collections_abc = importlib.import_module("collections.abc")
For older versions of Python, use the imp module.
Python 2.x Version ≤ 2.7
Use the functions imp.find_module and imp.load_module to perform a programmatic import.
Taken from standard library documentation
import imp, sys
def import_module(name):
fp, pathname, description = imp.find_module(name)
try:
return imp.load_module(name, fp, pathname, description)
finally:
if fp:
fp.close()
Do NOT use __import__() to programmatically import modules! There are subtle details involving sys.modules,
the fromlist argument, etc. that are easy to overlook which importlib.import_module() handles for you.
Section 43.6: PEP8 rules for Imports
Some recommended PEP8 style guidelines for imports:
1. Imports should be on separate lines:
from math import sqrt, ceil
from math import sqrt
from math import ceil
# Not recommended
# Recommended
2. Order imports as follows at the top of the module:
Standard library imports
Related third party imports
Local application/library speciﬁc imports
3. Wildcard imports should be avoided as it leads to confusion in names in the current namespace. If you do
from module import *, it can be unclear if a speciﬁc name in your code comes from module or not. This is
GoalKicker.com – Python® Notes for Professionals
259doubly true if you have multiple from module import *-type statements.
4. Avoid using relative imports; use explicit imports instead.
Section 43.7: Importing speciﬁc names from a module
Instead of importing the complete module you can import only speciﬁed names:
from random import randint # Syntax "from MODULENAME import NAME1[, NAME2[, ...]]"
print(randint(1, 10))
# Out: 5
from random is needed, because the python interpreter has to know from which resource it should import a
function or class and import randint speciﬁes the function or class itself.
Another example below (similar to the one above):
from math import pi
print(pi)
# Out: 3.14159265359
The following example will raise an error, because we haven't imported a module:
random.randrange(1, 10)
# works only if "import random" has been run before
Outputs:
NameError: name 'random' is not defined
The python interpreter does not understand what you mean with random. It needs to be declared by adding import
random to the example:
import random
random.randrange(1, 10)
Section 43.8: Importing submodules
from module.submodule import function
This imports function from module.submodule.
Section 43.9: Re-importing a module
When using the interactive interpreter, you might want to reload a module. This can be useful if you're editing a
module and want to import the newest version, or if you've monkey-patched an element of an existing module and
want to revert your changes.
Note that you can't just import the module again to revert:
import math
math.pi = 3
print(math.pi)
import math
print(math.pi)
# 3
# 3
GoalKicker.com – Python® Notes for Professionals
260This is because the interpreter registers every module you import. And when you try to reimport a module, the
interpreter sees it in the register and does nothing. So the hard way to reimport is to use import after removing the
corresponding item from the register:
print(math.pi)
# 3
import sys
if 'math' in sys.modules: # Is the ``math`` module in the register?
del sys.modules['math'] # If so, remove it.
import math
print(math.pi)
# 3.141592653589793
But there is more a straightforward and simple way.
Python 2
Use the reload function:
Python 2.x Version ≥ 2.3
import math
math.pi = 3
print(math.pi)
reload(math)
print(math.pi)
# 3
# 3.141592653589793
Python 3
The reload function has moved to importlib:
Python 3.x Version ≥ 3.0
import math
math.pi = 3
print(math.pi)
# 3
from importlib import reload
reload(math)
print(math.pi)
# 3.141592653589793
Section 43.10: __import__() function
The __import__() function can be used to import modules where the name is only known at runtime
if user_input == "os":
os = __import__("os")
# equivalent to import os
This function can also be used to specify the ﬁle path to a module
mod = __import__(r"C:/path/to/file/anywhere/on/computer/module.py")
GoalKicker.com – Python® Notes for Professionals
261Chapter 44: Dierence between Module
and Package
Section 44.1: Modules
A module is a single Python ﬁle that can be imported. Using a module looks like this:
module.py
def hi():
print("Hello world!")
my_script.py
import module
module.hi()
in an interpreter
>>> from module import hi
>>> hi()
# Hello world!
Section 44.2: Packages
A package is made up of multiple Python ﬁles (or modules), and can even include libraries written in C or C++.
Instead of being a single ﬁle, it is an entire folder structure which might look like this:
Folder package
__init__.py
dog.py
hi.py
__init__.py
from package.dog import woof
from package.hi import hi
dog.py
def woof():
print("WOOF!!!")
hi.py
def hi():
print("Hello world!")
All Python packages must contain an __init__.py ﬁle. When you import a package in your script (import package),
the __init__.py script will be run, giving you access to the all of the functions in the package. In this case, it allows
you to use the package.hi and package.woof functions.
GoalKicker.com – Python® Notes for Professionals
262VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 45: Math Module
Section 45.1: Rounding: round, ﬂoor, ceil, trunc
In addition to the built-in round function, the math module provides the floor, ceil, and trunc functions.
x = 1.55
y = -1.55
# round to the nearest integer
round(x)
# 2
round(y)
# -2
# the second argument gives how many decimal places to round to (defaults to 0)
round(x, 1)
# 1.6
round(y, 1)
# -1.6
# math is a module so import it first, then use it.
import math
# get the largest integer less than x
math.floor(x) # 1
math.floor(y) # -2
# get the smallest integer greater than x
math.ceil(x)
# 2
math.ceil(y)
# -1
# drop fractional part of x
math.trunc(x) # 1, equivalent to math.floor for positive numbers
math.trunc(y) # -1, equivalent to math.ceil for negative numbers
Python 2.x Version ≤ 2.7
floor, ceil, trunc, and round always return a float.
round(1.3)
# 1.0
round always breaks ties away from zero.
round(0.5)
round(1.5)
# 1.0
# 2.0
Python 3.x Version ≥ 3.0
floor, ceil, and trunc always return an Integral value, while round returns an Integral value if called with one
argument.
round(1.3)
round(1.33, 1)
# 1
# 1.3
round breaks ties towards the nearest even number. This corrects the bias towards larger numbers when
performing a large number of calculations.
round(0.5)
round(1.5)
# 0
# 2
Warning!
GoalKicker.com – Python® Notes for Professionals
264As with any ﬂoating-point representation, some fractions cannot be represented exactly. This can lead to some
unexpected rounding behavior.
round(2.675, 2)
# 2.67, not 2.68!
Warning about the ﬂoor, trunc, and integer division of negative numbers
Python (and C++ and Java) round away from zero for negative numbers. Consider:
>>> math.floor(-1.7)
-2.0
>>> -5 // 2
-3
Section 45.2: Trigonometry
Calculating the length of the hypotenuse
math.hypot(2, 4) # Just a shorthand for SquareRoot(2**2 + 4**2)
# Out: 4.47213595499958
Converting degrees to/from radians
All math functions expect radians so you need to convert degrees to radians:
math.radians(45)
# Out: 0.7853981633974483
# Convert 45 degrees to radians
All results of the inverse trigonometric functions return the result in radians, so you may need to convert it back to
degrees:
math.degrees(math.asin(1))
# Out: 90.0
# Convert the result of asin to degrees
Sine, cosine, tangent and inverse functions
# Sine and arc sine
math.sin(math.pi / 2)
# Out: 1.0
math.sin(math.radians(90))
# Out: 1.0
math.asin(1)
# Out: 1.5707963267948966
math.asin(1) / math.pi
# Out: 0.5
# Sine of 90 degrees
# "= pi / 2"
# Cosine and arc cosine:
math.cos(math.pi / 2)
# Out: 6.123233995736766e-17
# Almost zero but not exactly because "pi" is a float with limited precision!
math.acos(1)
# Out: 0.0
# Tangent and arc tangent:
math.tan(math.pi/2)
# Out: 1.633123935319537e+16
# Very large but not exactly "Inf" because "pi" is a float with limited precision
Python 3.x Version ≥ 3.5
math.atan(math.inf)
GoalKicker.com – Python® Notes for Professionals
265# Out: 1.5707963267948966 # This is just "pi / 2"
math.atan(float('inf'))
# Out: 1.5707963267948966 # This is just "pi / 2"
Apart from the math.atan there is also a two-argument math.atan2 function, which computes the correct quadrant
and avoids pitfalls of division by zero:
math.atan2(1, 2)
# Equivalent to "math.atan(1/2)"
# Out: 0.4636476090008061 # ≈ 26.57 degrees, 1st quadrant
math.atan2(-1, -2) # Not equal to "math.atan(-1/-2)" == "math.atan(1/2)"
# Out: -2.677945044588987 # ≈ -153.43 degrees (or 206.57 degrees), 3rd quadrant
math.atan2(1, 0)
# math.atan(1/0) would raise ZeroDivisionError
# Out: 1.5707963267948966 # This is just "pi / 2"
Hyperbolic sine, cosine and tangent
# Hyperbolic sine function
math.sinh(math.pi) # = 11.548739357257746
math.asinh(1)
# = 0.8813735870195429
# Hyperbolic cosine function
math.cosh(math.pi) # = 11.591953275521519
math.acosh(1)
# = 0.0
# Hyperbolic tangent function
math.tanh(math.pi) # = 0.99627207622075
math.atanh(0.5)
# = 0.5493061443340549
Section 45.3: Pow for faster exponentiation
Using the timeit module from the command line:
> python -m timeit 'for x in xrange(50000): b = x**3'
10 loops, best of 3: 51.2 msec per loop
> python -m timeit 'from math import pow' 'for x in xrange(50000): b = pow(x,3)'
100 loops, best of 3: 9.15 msec per loop
The built-in ** operator often comes in handy, but if performance is of the essence, use math.pow. Be sure to note,
however, that pow returns ﬂoats, even if the arguments are integers:
> from math import pow
> pow(5,5)
3125.0
Section 45.4: Inﬁnity and NaN ("not a number")
In all versions of Python, we can represent inﬁnity and NaN ("not a number") as follows:
pos_inf = float('inf')
neg_inf = float('-inf')
not_a_num = float('nan')
# positive infinity
# negative infinity
# NaN ("not a number")
In Python 3.5 and higher, we can also use the deﬁned constants math.inf and math.nan:
Python 3.x Version ≥ 3.5
GoalKicker.com – Python® Notes for Professionals
266pos_inf = math.inf
neg_inf = -math.inf
not_a_num = math.nan
The string representations display as inf and -inf and nan:
pos_inf, neg_inf, not_a_num
# Out: (inf, -inf, nan)
We can test for either positive or negative inﬁnity with the isinf method:
math.isinf(pos_inf)
# Out: True
math.isinf(neg_inf)
# Out: True
We can test speciﬁcally for positive inﬁnity or for negative inﬁnity by direct comparison:
pos_inf == float('inf')
# Out: True# or== math.inf in Python 3.5+
neg_inf == float('-inf')
# Out: True# or== -math.inf in Python 3.5+
neg_inf == pos_inf
# Out: False
Python 3.2 and higher also allows checking for ﬁniteness:
Python 3.x Version ≥ 3.2
math.isfinite(pos_inf)
# Out: False
math.isfinite(0.0)
# Out: True
Comparison operators work as expected for positive and negative inﬁnity:
import sys
sys.float_info.max
# Out: 1.7976931348623157e+308
(this is system-dependent)
pos_inf > sys.float_info.max
# Out: True
neg_inf < -sys.float_info.max
# Out: True
But if an arithmetic expression produces a value larger than the maximum that can be represented as a float, it
will become inﬁnity:
pos_inf == sys.float_info.max * 1.0000001
# Out: True
neg_inf == -sys.float_info.max * 1.0000001
GoalKicker.com – Python® Notes for Professionals
267# Out: True
However division by zero does not give a result of inﬁnity (or negative inﬁnity where appropriate), rather it raises a
ZeroDivisionError exception.
try:
x = 1.0 / 0.0
print(x)
except ZeroDivisionError:
print("Division by zero")
# Out: Division by zero
Arithmetic operations on inﬁnity just give inﬁnite results, or sometimes NaN:
-5.0 * pos_inf == neg_inf
# Out: True
-5.0 * neg_inf == pos_inf
# Out: True
pos_inf * neg_inf == neg_inf
# Out: True
0.0 * pos_inf
# Out: nan
0.0 * neg_inf
# Out: nan
pos_inf / pos_inf
# Out: nan
NaN is never equal to anything, not even itself. We can test for it is with the isnan method:
not_a_num == not_a_num
# Out: False
math.isnan(not_a_num)
Out: True
NaN always compares as "not equal", but never less than or greater than:
not_a_num != 5.0
# Out: True# or any random value
not_a_num > 5.0
# Out: Falseor
not_a_num < 5.0
or
not_a_num == 5.0
Arithmetic operations on NaN always give NaN. This includes multiplication by -1: there is no "negative NaN".
5.0 * not_a_num
# Out: nan
float('-nan')
# Out: nan
Python 3.x Version ≥ 3.5
-math.nan
GoalKicker.com – Python® Notes for Professionals
268# Out: nan
There is one subtle diﬀerence between the old float versions of NaN and inﬁnity and the Python 3.5+ math library
constants:
Python 3.x Version ≥ 3.5
math.inf is math.inf, math.nan is math.nan
# Out: (True, True)
float('inf') is float('inf'), float('nan') is float('nan')
# Out: (False, False)
Section 45.5: Logarithms
math.log(x) gives the natural (base e) logarithm of x.
math.log(math.e)
math.log(1)
math.log(100)
# 1.0
# 0.0
# 4.605170185988092
math.log can lose precision with numbers close to 1, due to the limitations of ﬂoating-point numbers. In order to
accurately calculate logs close to 1, use math.log1p, which evaluates the natural logarithm of 1 plus the argument:
math.log(1 + 1e-20)
math.log1p(1e-20)
# 0.0
# 1e-20
math.log10 can be used for logs base 10:
math.log10(10)
# 1.0
Python 2.x Version ≥ 2.3.0
When used with two arguments, math.log(x, base) gives the logarithm of x in the given base (i.e. log(x) /
log(base).
math.log(100, 10) # 2.0
math.log(27, 3)
# 3.0
math.log(1, 10)
# 0.0
Section 45.6: Constants
math modules includes two commonly used mathematical constants.
math.pi - The mathematical constant pi
math.e - The mathematical constant e (base of natural logarithm)
>>> from math import pi, e
>>> pi
3.141592653589793
>>> e
2.718281828459045
>>>
Python 3.5 and higher have constants for inﬁnity and NaN ("not a number"). The older syntax of passing a string to
float() still works.
GoalKicker.com – Python® Notes for Professionals
269Python 3.x Version ≥ 3.5
math.inf == float('inf')
# Out: True
-math.inf == float('-inf')
# Out: True
# NaN never compares equal to anything, even itself
math.nan == float('nan')
# Out: False
Section 45.7: Imaginary Numbers
Imaginary numbers in Python are represented by a "j" or "J" trailing the target number.
1j
1j * 1j
# Equivalent to the square root of -1.
# = (-1+0j)
Section 45.8: Copying signs
In Python 2.6 and higher, math.copysign(x, y) returns x with the sign of y. The returned value is always a float.
Python 2.x Version ≥ 2.6
math.copysign(-2, 3)
math.copysign(3, -3)
math.copysign(4, 14.2)
math.copysign(1, -0.0)
# 2.0
# -3.0
# 4.0
# -1.0, on a platform which supports signed zero
Section 45.9: Complex numbers and the cmath module
The cmath module is similar to the math module, but deﬁnes functions appropriately for the complex plane.
First of all, complex numbers are a numeric type that is part of the Python language itself rather than being
provided by a library class. Thus we don't need to import cmath for ordinary arithmetic expressions.
Note that we use j (or J) and not i.
z = 1 + 3j
We must use 1j since j would be the name of a variable rather than a numeric literal.
1j * 1j
Out: (-1+0j)
1j ** 1j
# Out: (0.20787957635076193+0j)
# "i to the i"
==
math.e ** -(math.pi/2)
We have the real part and the imag (imaginary) part, as well as the complex conjugate:
# real part and imaginary part are both float type
z.real, z.imag
# Out: (1.0, 3.0)
z.conjugate()
# Out: (1-3j)
# z.conjugate() == z.real - z.imag * 1j
GoalKicker.com – Python® Notes for Professionals
270The built-in functions abs and complex are also part of the language itself and don't require any import:
abs(1 + 1j)
# Out: 1.4142135623730951
# square root of 2
complex(1)
# Out: (1+0j)
complex(imag=1)
# Out: (1j)
complex(1, 1)
# Out: (1+1j)
The complex function can take a string, but it can't have spaces:
complex('1+1j')
# Out: (1+1j)
complex('1 + 1j')
# Exception: ValueError: complex() arg is a malformed string
But for most functions we do need the module, for instance sqrt:
import cmath
cmath.sqrt(-1)
# Out: 1j
Naturally the behavior of sqrt is diﬀerent for complex numbers and real numbers. In non-complex math the square
root of a negative number raises an exception:
import math
math.sqrt(-1)
# Exception: ValueError: math domain error
Functions are provided to convert to and from polar coordinates:
cmath.polar(1 + 1j)
# Out: (1.4142135623730951, 0.7853981633974483)# == (sqrt(1 + 1), atan2(1, 1))
abs(1 + 1j), cmath.phase(1 + 1j)
# Out: (1.4142135623730951, 0.7853981633974483)# same as previous calculation
cmath.rect(math.sqrt(2), math.atan(1))
# Out: (1.0000000000000002+1.0000000000000002j)
The mathematical ﬁeld of complex analysis is beyond the scope of this example, but many functions in the complex
plane have a "branch cut", usually along the real axis or the imaginary axis. Most modern platforms support "signed
zero" as speciﬁed in IEEE 754, which provides continuity of those functions on both sides of the branch cut. The
following example is from the Python documentation:
cmath.phase(complex(-1.0, 0.0))
# Out: 3.141592653589793
cmath.phase(complex(-1.0, -0.0))
GoalKicker.com – Python® Notes for Professionals
271# Out: -3.141592653589793
The cmath module also provides many functions with direct counterparts from the math module.
In addition to sqrt, there are complex versions of exp, log, log10, the trigonometric functions and their inverses
(sin, cos, tan, asin, acos, atan), and the hyperbolic functions and their inverses (sinh, cosh, tanh, asinh, acosh,
atanh). Note however there is no complex counterpart of math.atan2, the two-argument form of arctangent.
cmath.log(1+1j)
# Out: (0.34657359027997264+0.7853981633974483j)
cmath.exp(1j * cmath.pi)
# Out: (-1+1.2246467991473532e-16j)
# e to the i pi == -1, within rounding error
The constants pi and e are provided. Note these are float and not complex.
type(cmath.pi)
# Out: <class 'float'>
The cmath module also provides complex versions of isinf, and (for Python 3.2+) isfinite. See "Inﬁnity and NaN".
A complex number is considered inﬁnite if either its real part or its imaginary part is inﬁnite.
cmath.isinf(complex(float('inf'), 0.0))
# Out: True
Likewise, the cmath module provides a complex version of isnan. See "Inﬁnity and NaN". A complex number is
considered "not a number" if either its real part or its imaginary part is "not a number".
cmath.isnan(0.0, float('nan'))
# Out: True
Note there is no cmath counterpart of the math.inf and math.nan constants (from Python 3.5 and higher)
Python 3.x Version ≥ 3.5
cmath.isinf(complex(0.0, math.inf))
# Out: True
cmath.isnan(complex(math.nan, 0.0))
# Out: True
cmath.inf
# Exception: AttributeError: module 'cmath' has no attribute 'inf'
In Python 3.5 and higher, there is an isclose method in both cmath and math modules.
Python 3.x Version ≥ 3.5
z = cmath.rect(*cmath.polar(1+1j))
z
# Out: (1.0000000000000002+1.0000000000000002j)
cmath.isclose(z, 1+1j)
# True
GoalKicker.com – Python® Notes for Professionals
272Chapter 46: Complex math
Section 46.1: Advanced complex arithmetic
The module cmath includes additional functions to use complex numbers.
import cmath
This module can calculate the phase of a complex number, in radians:
z = 2+3j # A complex number
cmath.phase(z) # 0.982793723247329
It allows the conversion between the cartesian (rectangular) and polar representations of complex numbers:
cmath.polar(z) # (3.605551275463989, 0.982793723247329)
cmath.rect(2, cmath.pi/2) # (0+2j)
The module contains the complex version of
Exponential and logarithmic functions (as usual, log is the natural logarithm and log10 the decimal
logarithm):
cmath.exp(z) # (-7.315110094901103+1.0427436562359045j)
cmath.log(z) # (1.2824746787307684+0.982793723247329j)
cmath.log10(-100) # (2+1.3643763538418412j)
Square roots:
cmath.sqrt(z) # (1.6741492280355401+0.8959774761298381j)
Trigonometric functions and their inverses:
cmath.sin(z) # (9.15449914691143-4.168906959966565j)
cmath.cos(z) # (-4.189625690968807-9.109227893755337j)
cmath.tan(z) # (-0.003764025641504249+1.00323862735361j)
cmath.asin(z) # (0.5706527843210994+1.9833870299165355j)
cmath.acos(z) # (1.0001435424737972-1.9833870299165355j)
cmath.atan(z) # (1.4099210495965755+0.22907268296853878j)
cmath.sin(z)**2 + cmath.cos(z)**2 # (1+0j)
Hyperbolic functions and their inverses:
cmath.sinh(z) # (-3.59056458998578+0.5309210862485197j)
cmath.cosh(z) # (-3.7245455049153224+0.5118225699873846j)
cmath.tanh(z) # (0.965385879022133-0.009884375038322495j)
cmath.asinh(z) # (0.5706527843210994+1.9833870299165355j)
cmath.acosh(z) # (1.9833870299165355+1.0001435424737972j)
cmath.atanh(z) # (0.14694666622552977+1.3389725222944935j)
cmath.cosh(z)**2 - cmath.sin(z)**2 # (1+0j)
cmath.cosh((0+1j)*z) - cmath.cos(z) # 0j
GoalKicker.com – Python® Notes for Professionals
273Section 46.2: Basic complex arithmetic
Python has built-in support for complex arithmetic. The imaginary unit is denoted by j:
z = 2+3j # A complex number
w = 1-7j # Another complex number
Complex numbers can be summed, subtracted, multiplied, divided and exponentiated:
z + w # (3-4j)
z - w # (1+10j)
z * w # (23-11j)
z / w # (-0.38+0.34j)
z**3 # (-46+9j)
Python can also extract the real and imaginary parts of complex numbers, and calculate their absolute value and
conjugate:
z.real # 2.0
z.imag # 3.0
abs(z) # 3.605551275463989
z.conjugate() # (2-3j)
GoalKicker.com – Python® Notes for Professionals
274Chapter 47: Collections module
The built-in collections package provides several specialized, ﬂexible collection types that are both high-
performance and provide alternatives to the general collection types of dict, list, tuple and set. The module also
deﬁnes abstract base classes describing diﬀerent types of collection functionality (such as MutableSet and
ItemsView).
Section 47.1: collections.Counter
Counter is a dict sub class that allows you to easily count objects. It has utility methods for working with the
frequencies of the objects that you are counting.
import collections
counts = collections.Counter([1,2,3])
the above code creates an object, counts, which has the frequencies of all the elements passed to the constructor.
This example has the value Counter({1: 1, 2: 1, 3: 1})
Constructor examples
Letter Counter
>>> collections.Counter('Happy Birthday')
Counter({'a': 2, 'p': 2, 'y': 2, 'i': 1, 'r': 1, 'B': 1, ' ': 1, 'H': 1, 'd': 1, 'h': 1, 't': 1})
Word Counter
>>> collections.Counter('I am Sam Sam I am That Sam-I-am That Sam-I-am! I do not like that Sam-I-
am'.split())
Counter({'I': 3, 'Sam': 2, 'Sam-I-am': 2, 'That': 2, 'am': 2, 'do': 1, 'Sam-I-am!': 1, 'that': 1,
'not': 1, 'like': 1})
Recipes
>>> c = collections.Counter({'a': 4, 'b': 2, 'c': -2, 'd': 0})
Get count of individual element
>>> c['a']
4
Set count of individual element
>>> c['c'] = -3
>>> c
Counter({'a': 4, 'b': 2, 'd': 0, 'c': -3})
Get total number of elements in counter (4 + 2 + 0 - 3)
>>> sum(c.itervalues())
3
# negative numbers are counted!
Get elements (only those with positive counter are kept)
GoalKicker.com – Python® Notes for Professionals
275>>> list(c.elements())
['a', 'a', 'a', 'a', 'b', 'b']
Remove keys with 0 or negative value
>>> c - collections.Counter()
Counter({'a': 4, 'b': 2})
Remove everything
>>> c.clear()
>>> c
Counter()
Add remove individual elements
>>> c.update({'a': 3, 'b':3})
>>> c.update({'a': 2, 'c':2}) # adds to existing, sets if they don't exist
>>> c
Counter({'a': 5, 'b': 3, 'c': 2})
>>> c.subtract({'a': 3, 'b': 3, 'c': 3}) # subtracts (negative values are allowed)
>>> c
Counter({'a': 2, 'b': 0, 'c': -1})
Section 47.2: collections.OrderedDict
The order of keys in Python dictionaries is arbitrary: they are not governed by the order in which you add them.
For example:
>>> d = {'foo': 5, 'bar': 6}
>>> print(d)
{'foo': 5, 'bar': 6}
>>> d['baz'] = 7
>>> print(a)
{'baz': 7, 'foo': 5, 'bar': 6}
>>> d['foobar'] = 8
>>> print(a)
{'baz': 7, 'foo': 5, 'bar': 6, 'foobar': 8}
```
(The arbitrary ordering implied above means that you may get diﬀerent results with the above code to that shown
here.)
The order in which the keys appear is the order which they would be iterated over, e.g. using a for loop.
The collections.OrderedDict class provides dictionary objects that retain the order of keys. OrderedDicts can be
created as shown below with a series of ordered items (here, a list of tuple key-value pairs):
>>> from collections import OrderedDict
>>> d = OrderedDict([('foo', 5), ('bar', 6)])
>>> print(d)
OrderedDict([('foo', 5), ('bar', 6)])
>>> d['baz'] = 7
>>> print(d)
OrderedDict([('foo', 5), ('bar', 6), ('baz', 7)])
>>> d['foobar'] = 8
GoalKicker.com – Python® Notes for Professionals
276>>> print(d)
OrderedDict([('foo', 5), ('bar', 6), ('baz', 7), ('foobar', 8)])
Or we can create an empty OrderedDict and then add items:
>>> o = OrderedDict()
>>> o['key1'] = "value1"
>>> o['key2'] = "value2"
>>> print(o)
OrderedDict([('key1', 'value1'), ('key2', 'value2')])
Iterating through an OrderedDict allows key access in the order they were added.
What happens if we assign a new value to an existing key?
>>> d['foo'] = 4
>>> print(d)
OrderedDict([('foo', 4), ('bar', 6), ('baz', 7), ('foobar', 8)])
The key retains its original place in the OrderedDict.
Section 47.3: collections.defaultdict
collections.defaultdict(default_factory) returns a subclass of dict that has a default value for missing keys. The
argument should be a function that returns the default value when called with no arguments. If there is nothing
passed, it defaults to None.
>>> state_capitals = collections.defaultdict(str)
>>> state_capitals
defaultdict(<class 'str'>, {})
returns a reference to a defaultdict that will create a string object with its default_factory method.
A typical usage of defaultdict is to use one of the builtin types such as str, int, list or dict as the
default_factory, since these return empty types when called with no arguments:
>>> str()
''
>>> int()
0
>>> list
[]
Calling the defaultdict with a key that does not exist does not produce an error as it would in a normal dictionary.
>>> state_capitals['Alaska']
''
>>> state_capitals
defaultdict(<class 'str'>, {'Alaska': ''})
Another example with int:
>>> fruit_counts = defaultdict(int)
>>> fruit_counts['apple'] += 2 # No errors should occur
>>> fruit_counts
default_dict(int, {'apple': 2})
>>> fruit_counts['banana'] # No errors should occur
GoalKicker.com – Python® Notes for Professionals
2770
>>> fruit_counts # A new key is created
default_dict(int, {'apple': 2, 'banana': 0})
Normal dictionary methods work with the default dictionary
>>> state_capitals['Alabama'] = 'Montgomery'
>>> state_capitals
defaultdict(<class 'str'>, {'Alabama': 'Montgomery', 'Alaska': ''})
Using list as the default_factory will create a list for each new key.
>>> s = [('NC', 'Raleigh'), ('VA', 'Richmond'), ('WA', 'Seattle'), ('NC', 'Asheville')]
>>> dd = collections.defaultdict(list)
>>> for k, v in s:
...
dd[k].append(v)
>>> dd
defaultdict(<class 'list'>,
{'VA': ['Richmond'],
'NC': ['Raleigh', 'Asheville'],
'WA': ['Seattle']})
Section 47.4: collections.namedtuple
Deﬁne a new type Person using namedtuple like this:
Person = namedtuple('Person', ['age', 'height', 'name'])
The second argument is the list of attributes that the tuple will have. You can list these attributes also as either
space or comma separated string:
Person = namedtuple('Person', 'age, height, name')
or
Person = namedtuple('Person', 'age height name')
Once deﬁned, a named tuple can be instantiated by calling the object with the necessary parameters, e.g.:
dave = Person(30, 178, 'Dave')
Named arguments can also be used:
jack = Person(age=30, height=178, name='Jack S.')
Now you can access the attributes of the namedtuple:
print(jack.age) # 30
print(jack.name) # 'Jack S.'
The ﬁrst argument to the namedtuple constructor (in our example 'Person') is the typename. It is typical to use the
same word for the constructor and the typename, but they can be diﬀerent:
Human = namedtuple('Person', 'age, height, name')
dave = Human(30, 178, 'Dave')
GoalKicker.com – Python® Notes for Professionals
278print(dave)
# yields: Person(age=30, height=178, name='Dave')
Section 47.5: collections.deque
Returns a new deque object initialized left-to-right (using append()) with data from iterable. If iterable is not
speciﬁed, the new deque is empty.
Deques are a generalization of stacks and queues (the name is pronounced “deck” and is short for “double-ended
queue”). Deques support thread-safe, memory eﬃcient appends and pops from either side of the deque with
approximately the same O(1) performance in either direction.
Though list objects support similar operations, they are optimized for fast ﬁxed-length operations and incur O(n)
memory movement costs for pop(0) and insert(0, v) operations which change both the size and position of the
underlying data representation.
New in version 2.4.
If maxlen is not speciﬁed or is None, deques may grow to an arbitrary length. Otherwise, the deque is bounded to the
speciﬁed maximum length. Once a bounded length deque is full, when new items are added, a corresponding
number of items are discarded from the opposite end. Bounded length deques provide functionality similar to the
tail ﬁlter in Unix. They are also useful for tracking transactions and other pools of data where only the most recent
activity is of interest.
Changed in version 2.6: Added maxlen parameter.
>>> from collections import deque
>>> d = deque('ghi')
>>> for elem in d:
...
print elem.upper()
G
H
I
# make a new deque with three items
# iterate over the deque's elements
>>> d.append('j')
>>> d.appendleft('f')
>>> d
deque(['f', 'g', 'h', 'i', 'j'])# add a new entry to the right side
# add a new entry to the left side
# show the representation of the deque
>>> d.pop()
'j'
>>> d.popleft()
'f'
>>> list(d)
['g', 'h', 'i']
>>> d[0]
'g'
>>> d[-1]
'i'# return and remove the rightmost item
# return and remove the leftmost item
# list the contents of the deque
# peek at leftmost item
# peek at rightmost item
>>> list(reversed(d))
# list the contents of a deque in reverse
['i', 'h', 'g']
>>> 'h' in d
# search the deque
True
>>> d.extend('jkl')
# add multiple elements at once
>>> d
deque(['g', 'h', 'i', 'j', 'k', 'l'])
>>> d.rotate(1)
# right rotation
>>> d
GoalKicker.com – Python® Notes for Professionals
279deque(['l', 'g', 'h', 'i', 'j', 'k'])
>>> d.rotate(-1)
# left rotation
>>> d
deque(['g', 'h', 'i', 'j', 'k', 'l'])
>>> deque(reversed(d))
# make a new deque in reverse order
deque(['l', 'k', 'j', 'i', 'h', 'g'])
>>> d.clear()
# empty the deque
>>> d.pop()
# cannot pop from an empty deque
Traceback (most recent call last):
File "<pyshell#6>", line 1, in -toplevel-
d.pop()
IndexError: pop from an empty deque
>>> d.extendleft('abc')
>>> d
deque(['c', 'b', 'a'])
# extendleft() reverses the input order
Source: https://docs.python.org/2/library/collections.html
Section 47.6: collections.ChainMap
ChainMap is new in version 3.3
Returns a new ChainMap object given a number of maps. This object groups multiple dicts or other mappings
together to create a single, updateable view.
ChainMaps are useful managing nested contexts and overlays. An example in the python world is found in the
implementation of the Context class in Django's template engine. It is useful for quickly linking a number of
mappings so that the result can be treated as a single unit. It is often much faster than creating a new dictionary
and running multiple update() calls.
Anytime one has a chain of lookup values there can be a case for ChainMap. An example includes having both user
speciﬁed values and a dictionary of default values. Another example is the POST and GET parameter maps found in
web use, e.g. Django or Flask. Through the use of ChainMap one returns a combined view of two distinct
dictionaries.
The maps parameter list is ordered from ﬁrst-searched to last-searched. Lookups search the underlying mappings
successively until a key is found. In contrast, writes, updates, and deletions only operate on the ﬁrst mapping.
import collections
# define two dictionaries with at least some keys overlapping.
dict1 = {'apple': 1, 'banana': 2}
dict2 = {'coconut': 1, 'date': 1, 'apple': 3}
# create two ChainMaps with different ordering of those dicts.
combined_dict = collections.ChainMap(dict1, dict2)
reverse_ordered_dict = collections.ChainMap(dict2, dict1)
Note the impact of order on which value is found ﬁrst in the subsequent lookup
for k, v in combined_dict.items():
print(k, v)
date 1
apple 1
banana 2
GoalKicker.com – Python® Notes for Professionals
280coconut 1
for k, v in reverse_ordered_dict.items():
print(k, v)
date 1
apple 3
banana 2
coconut 1
GoalKicker.com – Python® Notes for Professionals
281Chapter 48: Operator module
Section 48.1: Itemgetter
Grouping the key-value pairs of a dictionary by the value with itemgetter:
from itertools import groupby
from operator import itemgetter
adict = {'a': 1, 'b': 5, 'c': 1}
dict((i, dict(v)) for i, v in groupby(adict.items(), itemgetter(1)))
# Output: {1: {'a': 1, 'c': 1}, 5: {'b': 5}}
which is equivalent (but faster) to a lambda function like this:
dict((i, dict(v)) for i, v in groupby(adict.items(), lambda x: x[1]))
Or sorting a list of tuples by the second element ﬁrst the ﬁrst element as secondary:
alist_of_tuples = [(5,2), (1,3), (2,2)]
sorted(alist_of_tuples, key=itemgetter(1,0))
# Output: [(2, 2), (5, 2), (1, 3)]
Section 48.2: Operators as alternative to an inﬁx operator
For every inﬁx operator, e.g. + there is an operator-function (operator.add for +):
1 + 1
# Output: 2
from operator import add
add(1, 1)
# Output: 2
even though the main documentation states that for the arithmetic operators only numerical input is allowed it is
possible:
from operator import mul
mul('a', 10)
# Output: 'aaaaaaaaaa'
mul([3], 3)
# Output: [3, 3, 3]
See also: mapping from operation to operator function in the oﬃcial Python documentation.
Section 48.3: Methodcaller
Instead of this lambda-function that calls the method explicitly:
alist = ['wolf', 'sheep', 'duck']
list(filter(lambda x: x.startswith('d'), alist))
# Output: ['duck']
# Keep only elements that start with 'd'
one could use a operator-function that does the same:
from operator import methodcaller
GoalKicker.com – Python® Notes for Professionals
282list(filter(methodcaller('startswith', 'd'), alist)) # Does the same but is faster.
# Output: ['duck']
GoalKicker.com – Python® Notes for Professionals
283Chapter 49: JSON Module
Section 49.1: Storing data in a ﬁle
The following snippet encodes the data stored in d into JSON and stores it in a ﬁle (replace filename with the actual
name of the ﬁle).
import json
d = {
'foo': 'bar',
'alice': 1,
'wonderland': [1, 2, 3]
}
with open(filename, 'w') as f:
json.dump(d, f)
Section 49.2: Retrieving data from a ﬁle
The following snippet opens a JSON encoded ﬁle (replace filename with the actual name of the ﬁle) and returns the
object that is stored in the ﬁle.
import json
with open(filename, 'r') as f:
d = json.load(f)
Section 49.3: Formatting JSON output
Let's say we have the following data:
>>> data = {"cats": [{"name": "Tubbs", "color": "white"}, {"name": "Pepper", "color": "black"}]}
Just dumping this as JSON does not do anything special here:
>>> print(json.dumps(data))
{"cats": [{"name": "Tubbs", "color": "white"}, {"name": "Pepper", "color": "black"}]}
Setting indentation to get prettier output
If we want pretty printing, we can set an indent size:
>>> print(json.dumps(data, indent=2))
{
"cats": [
{
"name": "Tubbs",
"color": "white"
},
{
"name": "Pepper",
"color": "black"
}
]
}
GoalKicker.com – Python® Notes for Professionals
284Sorting keys alphabetically to get consistent output
By default the order of keys in the output is undeﬁned. We can get them in alphabetical order to make sure we
always get the same output:
>>> print(json.dumps(data, sort_keys=True))
{"cats": [{"color": "white", "name": "Tubbs"}, {"color": "black", "name": "Pepper"}]}
Getting rid of whitespace to get compact output
We might want to get rid of the unnecessary spaces, which is done by setting separator strings diﬀerent from the
default ', ' and ': ':
>>>print(json.dumps(data, separators=(',', ':')))
{"cats":[{"name":"Tubbs","color":"white"},{"name":"Pepper","color":"black"}]}
Section 49.4: `load` vs `loads`, `dump` vs `dumps`
The json module contains functions for both reading and writing to and from unicode strings, and reading and
writing to and from ﬁles. These are diﬀerentiated by a trailing s in the function name. In these examples we use a
StringIO object, but the same functions would apply for any ﬁle-like object.
Here we use the string-based functions:
import json
data = {u"foo": u"bar", u"baz": []}
json_string = json.dumps(data)
# u'{"foo": "bar", "baz": []}'
json.loads(json_string)
# {u"foo": u"bar", u"baz": []}
And here we use the ﬁle-based functions:
import json
from io import StringIO
json_file = StringIO()
data = {u"foo": u"bar", u"baz": []}
json.dump(data, json_file)
json_file.seek(0) # Seek back to the start of the file before reading
json_file_content = json_file.read()
# u'{"foo": "bar", "baz": []}'
json_file.seek(0) # Seek back to the start of the file before reading
json.load(json_file)
# {u"foo": u"bar", u"baz": []}
As you can see the main diﬀerence is that when dumping json data you must pass the ﬁle handle to the function, as
opposed to capturing the return value. Also worth noting is that you must seek to the start of the ﬁle before reading
or writing, in order to avoid data corruption. When opening a ﬁle the cursor is placed at position 0, so the below
would also work:
import json
json_file_path = './data.json'
data = {u"foo": u"bar", u"baz": []}
GoalKicker.com – Python® Notes for Professionals
285with open(json_file_path, 'w') as json_file:
json.dump(data, json_file)
with open(json_file_path) as json_file:
json_file_content = json_file.read()
# u'{"foo": "bar", "baz": []}'
with open(json_file_path) as json_file:
json.load(json_file)
# {u"foo": u"bar", u"baz": []}
Having both ways of dealing with json data allows you to idiomatically and eﬃciently work with formats which build
upon json, such as pyspark's json-per-line:
# loading from a file
data = [json.loads(line) for line in open(file_path).splitlines()]
# dumping to a file
with open(file_path, 'w') as json_file:
for item in data:
json.dump(item, json_file)
json_file.write('\n')
Section 49.5: Calling `json.tool` from the command line to
pretty-print JSON output
Given some JSON ﬁle "foo.json" like:
{"foo": {"bar": {"baz": 1}}}
we can call the module directly from the command line (passing the ﬁlename as an argument) to pretty-print it:
$ python -m json.tool foo.json
{
"foo": {
"bar": {
"baz": 1
}
}
}
The module will also take input from STDOUT, so (in Bash) we equally could do:
$ cat foo.json | python -m json.tool
Section 49.6: JSON encoding custom objects
If we just try the following:
import json
from datetime import datetime
data = {'datetime': datetime(2016, 9, 26, 4, 44, 0)}
print(json.dumps(data))
we get an error saying TypeError: datetime.datetime(2016, 9, 26, 4, 44) is not JSON serializable.
To be able to serialize the datetime object properly, we need to write custom code for how to convert it:
GoalKicker.com – Python® Notes for Professionals
286class DatetimeJSONEncoder(json.JSONEncoder):
def default(self, obj):
try:
return obj.isoformat()
except AttributeError:
# obj has no isoformat method; let the builtin JSON encoder handle it
return super(DatetimeJSONEncoder, self).default(obj)
and then use this encoder class instead of json.dumps:
encoder = DatetimeJSONEncoder()
print(encoder.encode(data))
# prints {"datetime": "2016-09-26T04:44:00"}
Section 49.7: Creating JSON from Python dict
import json
d = {
'foo': 'bar',
'alice': 1,
'wonderland': [1, 2, 3]
}
json.dumps(d)
The above snippet will return the following:
'{"wonderland": [1, 2, 3], "foo": "bar", "alice": 1}'
Section 49.8: Creating Python dict from JSON
import json
s = '{"wonderland": [1, 2, 3], "foo": "bar", "alice": 1}'
json.loads(s)
The above snippet will return the following:
{u'alice': 1, u'foo': u'bar', u'wonderland': [1, 2, 3]}
GoalKicker.com – Python® Notes for Professionals
287VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 50: Sqlite3 Module
Section 50.1: Sqlite3 - Not require separate server process
The sqlite3 module was written by Gerhard Häring. To use the module, you must ﬁrst create a Connection object
that represents the database. Here the data will be stored in the example.db ﬁle:
import sqlite3
conn = sqlite3.connect('example.db')
You can also supply the special name :memory: to create a database in RAM. Once you have a Connection, you can
create a Cursor object and call its execute() method to perform SQL commands:
c = conn.cursor()
# Create table
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')
# Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
# Save (commit) the changes
conn.commit()
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
Section 50.2: Getting the values from the database and Error
handling
Fetching the values from the SQLite3 database.
Print row values returned by select query
import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()
c.execute("SELECT * from table_name where id=cust_id")
for row in c:
print row # will be a list
To fetch single matching fetchone() method
print c.fetchone()
For multiple rows use fetchall() method
a=c.fetchall() #which is similar to list(cursor) method used previously
for row in a:
print row
Error handling can be done using sqlite3.Error built in function
GoalKicker.com – Python® Notes for Professionals
289try:
#SQL Code
except sqlite3.Error as e:
print "An error occurred:", e.args[0]
GoalKicker.com – Python® Notes for Professionals
290Chapter 51: The os Module
Parameter
Details
A path to a ﬁle. The path separator may be determined by os.path.sep.
Path
The desired permission, in octal (e.g. 0700)
Mode
This module provides a portable way of using operating system dependent functionality.
Section 51.1: makedirs - recursive directory creation
Given a local directory with the following contents:
└── dir1
├── subdir1
└── subdir2
We want to create the same subdir1, subdir2 under a new directory dir2, which does not exist yet.
import os
os.makedirs("./dir2/subdir1")
os.makedirs("./dir2/subdir2")
Running this results in
├── dir1
│├── subdir1
│└── subdir2
└── dir2
├── subdir1
└── subdir2
dir2 is only created the ﬁrst time it is needed, for subdir1's creation.
If we had used os.mkdir instead, we would have had an exception because dir2 would not have existed yet.
os.mkdir("./dir2/subdir1")
OSError: [Errno 2] No such file or directory: './dir2/subdir1'
os.makedirs won't like it if the target directory exists already. If we re-run it again:
OSError: [Errno 17] File exists: './dir2/subdir1'
However, this could easily be ﬁxed by catching the exception and checking that the directory has been created.
try:
os.makedirs("./dir2/subdir1")
except OSError:
if not os.path.isdir("./dir2/subdir1"):
raise
try:
os.makedirs("./dir2/subdir2")
except OSError:
GoalKicker.com – Python® Notes for Professionals
291if not os.path.isdir("./dir2/subdir2"):
raise
Section 51.2: Create a directory
os.mkdir('newdir')
If you need to specify permissions, you can use the optional mode argument:
os.mkdir('newdir', mode=0700)
Section 51.3: Get current directory
Use the os.getcwd() function:
print(os.getcwd())
Section 51.4: Determine the name of the operating system
The os module provides an interface to determine what type of operating system the code is currently running on.
os.name
This can return one of the following in Python 3:
posix
nt
ce
java
More detailed information can be retrieved from sys.platform
Section 51.5: Remove a directory
Remove the directory at path:
os.rmdir(path)
You should not use os.remove() to remove a directory. That function is for ﬁles and using it on directories will
result in an OSError
Section 51.6: Follow a symlink (POSIX)
Sometimes you need to determine the target of a symlink. os.readlink will do this:
print(os.readlink(path_to_symlink))
Section 51.7: Change permissions on a ﬁle
os.chmod(path, mode)
where mode is the desired permission, in octal.
GoalKicker.com – Python® Notes for Professionals
292Chapter 52: The locale Module
Section 52.1: Currency Formatting US Dollars Using the locale
Module
import locale
locale.setlocale(locale.LC_ALL, '')
Out[2]: 'English_United States.1252'
locale.currency(762559748.49)
Out[3]: '$762559748.49'
locale.currency(762559748.49, grouping=True)
Out[4]: '$762,559,748.49'
GoalKicker.com – Python® Notes for Professionals
293Chapter 53: Itertools Module
Section 53.1: Combinations method in Itertools Module
itertools.combinations will return a generator of the k-combination sequence of a list.
In other words: It will return a generator of tuples of all the possible k-wise combinations of the input list.
For Example:
If you have a list:
a = [1,2,3,4,5]
b = list(itertools.combinations(a, 2))
print b
Output:
[(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)]
The above output is a generator converted to a list of tuples of all the possible pair-wise combinations of the input
list a
You can also ﬁnd all the 3-combinations:
a = [1,2,3,4,5]
b = list(itertools.combinations(a, 3))
print b
Output:
[(1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 4),
(1, 3, 5), (1, 4, 5), (2, 3, 4), (2, 3, 5),
(2, 4, 5), (3, 4, 5)]
Section 53.2: itertools.dropwhile
itertools.dropwhile enables you to take items from a sequence after a condition ﬁrst becomes False.
def is_even(x):
return x % 2 == 0
lst = [0, 2, 4, 12, 18, 13, 14, 22, 23, 44]
result = list(itertools.dropwhile(is_even, lst))
print(result)
This outputs [13, 14, 22, 23, 44].
(This example is same as the example for takewhile but using dropwhile.)
Note that, the ﬁrst number that violates the predicate (i.e.: the function returning a Boolean value) is_even is, 13.
All the elements before that, are discarded.
GoalKicker.com – Python® Notes for Professionals
294The output produced by dropwhile is similar to the output generated from the code below.
def dropwhile(predicate, iterable):
iterable = iter(iterable)
for x in iterable:
if not predicate(x):
yield x
break
for x in iterable:
yield x
The concatenation of results produced by takewhile and dropwhile produces the original iterable.
result = list(itertools.takewhile(is_even, lst)) + list(itertools.dropwhile(is_even, lst))
Section 53.3: Zipping two iterators until they are both
exhausted
Similar to the built-in function zip(), itertools.zip_longest will continue iterating beyond the end of the shorter
of two iterables.
from itertools import zip_longest
a = [i for i in range(5)] # Length is 5
b = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] # Length is 7
for i in zip_longest(a, b):
x, y = i # Note that zip longest returns the values as a tuple
print(x, y)
An optional fillvalue argument can be passed (defaults to '') like so:
for i in zip_longest(a, b, fillvalue='Hogwash!'):
x, y = i # Note that zip longest returns the values as a tuple
print(x, y)
In Python 2.6 and 2.7, this function is called itertools.izip_longest.
Section 53.4: Take a slice of a generator
Itertools "islice" allows you to slice a generator:
results = fetch_paged_results() # returns a generator
limit = 20 # Only want the first 20 results
for data in itertools.islice(results, limit):
print(data)
Normally you cannot slice a generator:
def gen():
n = 0
while n < 20:
n += 1
yield n
for part in gen()[:3]:
print(part)
Will give
GoalKicker.com – Python® Notes for Professionals
295Traceback (most recent call last):
File "gen.py", line 6, in <module>
for part in gen()[:3]:
TypeError: 'generator' object is not subscriptable
However, this works:
import itertools
def gen():
n = 0
while n < 20:
n += 1
yield n
for part in itertools.islice(gen(), 3):
print(part)
Note that like a regular slice, you can also use start, stop and step arguments:
itertools.islice(iterable, 1, 30, 3)
Section 53.5: Grouping items from an iterable object using a
function
Start with an iterable which needs to be grouped
lst = [("a", 5, 6), ("b", 2, 4), ("a", 2, 5), ("c", 2, 6)]
Generate the grouped generator, grouping by the second element in each tuple:
def testGroupBy(lst):
groups = itertools.groupby(lst, key=lambda x: x[1])
for key, group in groups:
print(key, list(group))
testGroupBy(lst)
# 5 [('a', 5, 6)]
# 2 [('b', 2, 4), ('a', 2, 5), ('c', 2, 6)]
Only groups of consecutive elements are grouped. You may need to sort by the same key before calling groupby
For E.g, (Last element is changed)
lst = [("a", 5, 6), ("b", 2, 4), ("a", 2, 5), ("c", 5, 6)]
testGroupBy(lst)
# 5 [('a', 5, 6)]
# 2 [('b', 2, 4), ('a', 2, 5)]
# 5 [('c', 5, 6)]
The group returned by groupby is an iterator that will be invalid before next iteration. E.g the following will not work
if you want the groups to be sorted by key. Group 5 is empty below because when group 2 is fetched it invalidates 5
lst = [("a", 5, 6), ("b", 2, 4), ("a", 2, 5), ("c", 2, 6)]
groups = itertools.groupby(lst, key=lambda x: x[1])
for key, group in sorted(groups):
GoalKicker.com – Python® Notes for Professionals
296print(key, list(group))
# 2 [('c', 2, 6)]
# 5 []
To correctly do sorting, create a list from the iterator before sorting
groups = itertools.groupby(lst, key=lambda x: x[1])
for key, group in sorted((key, list(group)) for key, group in groups):
print(key, list(group))
# 2 [('b', 2, 4), ('a', 2, 5), ('c', 2, 6)]
# 5 [('a', 5, 6)]
Section 53.6: itertools.takewhile
itertools.takewhile enables you to take items from a sequence until a condition ﬁrst becomes False.
def is_even(x):
return x % 2 == 0
lst = [0, 2, 4, 12, 18, 13, 14, 22, 23, 44]
result = list(itertools.takewhile(is_even, lst))
print(result)
This outputs [0, 2, 4, 12, 18].
Note that, the ﬁrst number that violates the predicate (i.e.: the function returning a Boolean value) is_even is, 13.
Once takewhile encounters a value that produces False for the given predicate, it breaks out.
The output produced by takewhile is similar to the output generated from the code below.
def takewhile(predicate, iterable):
for x in iterable:
if predicate(x):
yield x
else:
break
Note: The concatenation of results produced by takewhile and dropwhile produces the original iterable.
result = list(itertools.takewhile(is_even, lst)) + list(itertools.dropwhile(is_even, lst))
Section 53.7: itertools.permutations
itertools.permutations returns a generator with successive r-length permutations of elements in the iterable.
a = [1,2,3]
list(itertools.permutations(a))
# [(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]
list(itertools.permutations(a, 2))
[(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]
GoalKicker.com – Python® Notes for Professionals
297if the list a has duplicate elements, the resulting permutations will have duplicate elements, you can use set to get
unique permutations:
a = [1,2,1]
list(itertools.permutations(a))
# [(1, 2, 1), (1, 1, 2), (2, 1, 1), (2, 1, 1), (1, 1, 2), (1, 2, 1)]
set(itertools.permutations(a))
# {(1, 1, 2), (1, 2, 1), (2, 1, 1)}
Section 53.8: itertools.repeat
Repeat something n times:
>>> import itertools
>>> for i in itertools.repeat('over-and-over', 3):
...
print(i)
over-and-over
over-and-over
over-and-over
Section 53.9: Get an accumulated sum of numbers in an
iterable
Python 3.x Version ≥ 3.2
accumulate yields a cumulative sum (or product) of numbers.
>>> import itertools as it
>>> import operator
>>> list(it.accumulate([1,2,3,4,5]))
[1, 3, 6, 10, 15]
>>> list(it.accumulate([1,2,3,4,5], func=operator.mul))
[1, 2, 6, 24, 120]
Section 53.10: Cycle through elements in an iterator
cycle is an inﬁnite iterator.
>>> import itertools as it
>>> it.cycle('ABCD')
A B C D A B C D A B C D ...
Therefore, take care to give boundaries when using this to avoid an inﬁnite loop. Example:
>>> # Iterate over each element in cycle for a fixed range
>>> cycle_iterator = it.cycle('abc123')
>>> [next(cycle_iterator) for i in range(0, 10)]
['a', 'b', 'c', '1', '2', '3', 'a', 'b', 'c', '1']
Section 53.11: itertools.product
This function lets you iterate over the Cartesian product of a list of iterables.
GoalKicker.com – Python® Notes for Professionals
298For example,
for x, y in itertools.product(xrange(10), xrange(10)):
print x, y
is equivalent to
for x in xrange(10):
for y in xrange(10):
print x, y
Like all python functions that accept a variable number of arguments, we can pass a list to itertools.product for
unpacking, with the * operator.
Thus,
its = [xrange(10)] * 2
for x,y in itertools.product(*its):
print x, y
produces the same results as both of the previous examples.
>>> from itertools import product
>>> a=[1,2,3,4]
>>> b=['a','b','c']
>>> product(a,b)
<itertools.product object at 0x0000000002712F78>
>>> for i in product(a,b):
...
print i
...
(1, 'a')
(1, 'b')
(1, 'c')
(2, 'a')
(2, 'b')
(2, 'c')
(3, 'a')
(3, 'b')
(3, 'c')
(4, 'a')
(4, 'b')
(4, 'c')
Section 53.12: itertools.count
Introduction:
This simple function generates inﬁnite series of numbers. For example...
for number in itertools.count():
if number > 20:
break
print(number)
Note that we must break or it prints forever!
Output:
GoalKicker.com – Python® Notes for Professionals
2990
1
2
3
4
5
6
7
8
9
10
Arguments:
count() takes two arguments, start and step:
for number in itertools.count(start=10, step=4):
print(number)
if number > 20:
break
Output:
10
14
18
22
Section 53.13: Chaining multiple iterators together
Use itertools.chain to create a single generator which will yield the values from several generators in sequence.
from itertools import chain
a = (x for x in ['1', '2', '3', '4'])
b = (x for x in ['x', 'y', 'z'])
' '.join(chain(a, b))
Results in:
'1 2 3 4 x y z'
As an alternate constructor, you can use the classmethod chain.from_iterable which takes as its single parameter
an iterable of iterables. To get the same result as above:
' '.join(chain.from_iterable([a,b])
While chain can take an arbitrary number of arguments, chain.from_iterable is the only way to chain an inﬁnite
number of iterables.
GoalKicker.com – Python® Notes for Professionals
300Chapter 54: Asyncio Module
Section 54.1: Coroutine and Delegation Syntax
Before Python 3.5+ was released, the asyncio module used generators to mimic asynchronous calls and thus had a
diﬀerent syntax than the current Python 3.5 release.
Python 3.x Version ≥ 3.5
Python 3.5 introduced the async and await keywords. Note the lack of parentheses around the await func() call.
import asyncio
async def main():
print(await func())
async def func():
# Do time intensive stuff...
return "Hello, world!"
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Python 3.x Version ≥ 3.3 Version < 3.5
Before Python 3.5, the @asyncio.coroutine decorator was used to deﬁne a coroutine. The yield from expression
was used for generator delegation. Note the parentheses around the yield from func().
import asyncio
@asyncio.coroutine
def main():
print((yield from func()))
@asyncio.coroutine
def func():
# Do time intensive stuff..
return "Hello, world!"
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Python 3.x Version ≥ 3.5
Here is an example that shows how two functions can be run asynchronously:
import asyncio
async def cor1():
print("cor1 start")
for i in range(10):
await asyncio.sleep(1.5)
print("cor1", i)
async def cor2():
print("cor2 start")
for i in range(15):
await asyncio.sleep(1)
GoalKicker.com – Python® Notes for Professionals
301print("cor2", i)
loop = asyncio.get_event_loop()
cors = asyncio.wait([cor1(), cor2()])
loop.run_until_complete(cors)
Section 54.2: Asynchronous Executors
Note: Uses the Python 3.5+ async/await syntax
asyncio supports the use of Executor objects found in concurrent.futures for scheduling tasks asynchronously.
Event loops have the function run_in_executor() which takes an Executor object, a Callable, and the Callable's
parameters.
Scheduling a task for an Executor
import asyncio
from concurrent.futures import ThreadPoolExecutor
def func(a, b):
# Do time intensive stuff...
return a + b
async def main(loop):
executor = ThreadPoolExecutor()
result = await loop.run_in_executor(executor, func, "Hello,", " world!")
print(result)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
Each event loop also has a "default" Executor slot that can be assigned to an Executor. To assign an Executor and
schedule tasks from the loop you use the set_default_executor() method.
import asyncio
from concurrent.futures import ThreadPoolExecutor
def func(a, b):
# Do time intensive stuff...
return a + b
async def main(loop):
# NOTE: Using `None` as the first parameter designates the `default` Executor.
result = await loop.run_in_executor(None, func, "Hello,", " world!")
print(result)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.set_default_executor(ThreadPoolExecutor())
loop.run_until_complete(main(loop))
There are two main types of Executor in concurrent.futures, the ThreadPoolExecutor and the
ProcessPoolExecutor. The ThreadPoolExecutor contains a pool of threads which can either be manually set to a
speciﬁc number of threads through the constructor or defaults to the number of cores on the machine times 5. The
ThreadPoolExecutor uses the pool of threads to execute tasks assigned to it and is generally better at CPU-bound
operations rather than I/O bound operations. Contrast that to the ProcessPoolExecutor which spawns a new
process for each task assigned to it. The ProcessPoolExecutor can only take tasks and parameters that are
GoalKicker.com – Python® Notes for Professionals
302picklable. The most common non-picklable tasks are the methods of objects. If you must schedule an object's
method as a task in an Executor you must use a ThreadPoolExecutor.
Section 54.3: Using UVLoop
uvloop is an implementation for the asyncio.AbstractEventLoop based on libuv (Used by nodejs). It is compliant
with 99% of asyncio features and is much faster than the traditional asyncio.EventLoop. uvloop is currently not
available on Windows, install it with pip install uvloop.
import asyncio
import uvloop
if __name__ == "__main__":
asyncio.set_event_loop(uvloop.new_event_loop())
# Do your stuff here ...
One can also change the event loop factory by setting the EventLoopPolicy to the one in uvloop.
import asyncio
import uvloop
if __name__ == "__main__":
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
loop = asyncio.new_event_loop()
Section 54.4: Synchronization Primitive: Event
Concept
Use an Event to synchronize the scheduling of multiple coroutines.
Put simply, an event is like the gun shot at a running race: it lets the runners oﬀ the starting blocks.
Example
import asyncio
# event trigger function
def trigger(event):
print('EVENT SET')
event.set() # wake up coroutines waiting
# event consumers
async def consumer_a(event):
consumer_name = 'Consumer A'
print('{} waiting'.format(consumer_name))
await event.wait()
print('{} triggered'.format(consumer_name))
async def consumer_b(event):
consumer_name = 'Consumer B'
print('{} waiting'.format(consumer_name))
await event.wait()
print('{} triggered'.format(consumer_name))
# event
event = asyncio.Event()
# wrap coroutines in one future
GoalKicker.com – Python® Notes for Professionals
303main_future = asyncio.wait([consumer_a(event),
consumer_b(event)])
# event loop
event_loop = asyncio.get_event_loop()
event_loop.call_later(0.1, functools.partial(trigger, event))
# trigger event in 0.1 sec
# complete main_future
done, pending = event_loop.run_until_complete(main_future)
Output:
Consumer B waiting
Consumer A waiting
EVENT SET
Consumer B triggered
Consumer A triggered
Section 54.5: A Simple Websocket
Here we make a simple echo websocket using asyncio. We deﬁne coroutines for connecting to a server and
sending/receiving messages. The communications of the websocket are run in a main coroutine, which is run by an
event loop. This example is modiﬁed from a prior post.
import asyncio
import aiohttp
session = aiohttp.ClientSession()
class EchoWebsocket:
# handles the context manager
async def connect(self):
self.websocket = await session.ws_connect("wss://echo.websocket.org")
async def send(self, message):
self.websocket.send_str(message)
async def receive(self):
result = (await self.websocket.receive())
return result.data
async def main():
echo = EchoWebsocket()
await echo.connect()
await echo.send("Hello World!")
print(await echo.receive())
# "Hello World!"
if __name__ == '__main__':
# The main loop
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Section 54.6: Common Misconception about asyncio
probably the most common misconception about asnycio is that it lets you run any task in parallel - sidestepping
the GIL (global interpreter lock) and therefore execute blocking jobs in parallel (on separate threads). it does not!
GoalKicker.com – Python® Notes for Professionals
304asyncio (and libraries that are built to collaborate with asyncio) build on coroutines: functions that (collaboratively)
yield the control ﬂow back to the calling function. note asyncio.sleep in the examples above. this is an example of
a non-blocking coroutine that waits 'in the background' and gives the control ﬂow back to the calling function (when
called with await). time.sleep is an example of a blocking function. the execution ﬂow of the program will just stop
there and only return after time.sleep has ﬁnished.
a real-live example is the requests library which consists (for the time being) on blocking functions only. there is no
concurrency if you call any of its functions within asyncio. aiohttp on the other hand was built with asyncio in
mind. its coroutines will run concurrently.
if you have long-running CPU-bound tasks you would like to run in parallel asyncio is not for you. for that
you need threads or multiprocessing.
if you have IO-bound jobs running, you may run them concurrently using asyncio.
GoalKicker.com – Python® Notes for Professionals
305VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 55: Random module
Section 55.1: Creating a random user password
In order to create a random user password we can use the symbols provided in the string module. Speciﬁcally
punctuation for punctuation symbols, ascii_letters for letters and digits for digits:
from string import punctuation, ascii_letters, digits
We can then combine all these symbols in a name named symbols:
symbols = ascii_letters + digits + punctuation
Remove either of these to create a pool of symbols with fewer elements.
After this, we can use random.SystemRandom to generate a password. For a 10 length password:
secure_random = random.SystemRandom()
password = "".join(secure_random.choice(symbols) for i in range(10))
print(password) # '^@g;J?]M6e'
Note that other routines made immediately available by the random module — such as random.choice,
random.randint, etc. — are unsuitable for cryptographic purposes.
Behind the curtains, these routines use the Mersenne Twister PRNG, which does not satisfy the requirements of a
CSPRNG. Thus, in particular, you should not use any of them to generate passwords you plan to use. Always use an
instance of SystemRandom as shown above.
Python 3.x Version ≥ 3.6
Starting from Python 3.6, the secrets module is available, which exposes cryptographically safe functionality.
Quoting the oﬃcial documentation, to generate "a ten-character alphanumeric password with at least one lowercase
character, at least one uppercase character, and at least three digits," you could:
import string
alphabet = string.ascii_letters + string.digits
while True:
password = ''.join(choice(alphabet) for i in range(10))
if (any(c.islower() for c in password)
and any(c.isupper() for c in password)
and sum(c.isdigit() for c in password) >= 3):
break
Section 55.2: Create cryptographically secure random
numbers
By default the Python random module use the Mersenne Twister PRNG to generate random numbers, which,
although suitable in domains like simulations, fails to meet security requirements in more demanding
environments.
In order to create a cryptographically secure pseudorandom number, one can use SystemRandom which, by using
os.urandom, is able to act as a Cryptographically secure pseudorandom number generator, CPRNG.
GoalKicker.com – Python® Notes for Professionals
307The easiest way to use it simply involves initializing the SystemRandom class. The methods provided are similar to
the ones exported by the random module.
from random import SystemRandom
secure_rand_gen = SystemRandom()
In order to create a random sequence of 10 ints in range [0, 20], one can simply call randrange():
print([secure_rand_gen.randrange(10) for i in range(10)])
# [9, 6, 9, 2, 2, 3, 8, 0, 9, 9]
To create a random integer in a given range, one can use randint:
print(secure_rand_gen.randint(0, 20))
# 5
and, accordingly for all other methods. The interface is exactly the same, the only change is the underlying number
generator.
You can also use os.urandom directly to obtain cryptographically secure random bytes.
Section 55.3: Random and sequences: shue, choice and
sample
import random
shuﬄe()
You can use random.shuffle() to mix up/randomize the items in a mutable and indexable sequence. For
example a list:
laughs = ["Hi", "Ho", "He"]
random.shuffle(laughs)# Shuffles in-place! Don't do: laughs = random.shuffle(laughs)
print(laughs)
# Out: ["He", "Hi", "Ho"]# Output may vary!
choice()
Takes a random element from an arbitrary sequence:
print(random.choice(laughs))
# Out: He
# Output may vary!
sample()
Like choice it takes random elements from an arbitrary sequence but you can specify how many:
#
|--sequence--|--number--|
print(random.sample(
laughs
,
1
)) # Take one element
# Out: ['Ho']
# Output may vary!
it will not take the same element twice:
print(random.sample(laughs, 3)) # Take 3 random element from the sequence.
# Out: ['Ho', 'He', 'Hi']
# Output may vary!
GoalKicker.com – Python® Notes for Professionals
308print(random.sample(laughs, 4))
# Take 4 random element from the 3-item sequence.
ValueError: Sample larger than population
Section 55.4: Creating random integers and ﬂoats: randint,
randrange, random, and uniform
import random
randint()
Returns a random integer between x and y (inclusive):
random.randint(x, y)
For example getting a random number between 1 and 8:
random.randint(1, 8) # Out: 8
randrange()
random.randrange has the same syntax as range and unlike random.randint, the last value is not inclusive:
random.randrange(100)
# Random integer between 0 and 99
random.randrange(20, 50)
# Random integer between 20 and 49
random.rangrange(10, 20, 3) # Random integer between 10 and 19 with step 3 (10, 13, 16 and 19)
GoalKicker.com – Python® Notes for Professionals
309random
Returns a random ﬂoating point number between 0 and 1:
random.random() # Out: 0.66486093215306317
uniform
Returns a random ﬂoating point number between x and y (inclusive):
random.uniform(1, 8) # Out: 3.726062641730108
Section 55.5: Reproducible random numbers: Seed and State
Setting a speciﬁc Seed will create a ﬁxed random-number series:
random.seed(5)
# Create a fixed state
print(random.randrange(0, 10)) # Get a random integer between 0 and 9
# Out: 9
print(random.randrange(0, 10))
# Out: 4
Resetting the seed will create the same "random" sequence again:
random.seed(5)
# Reset the random module to the same fixed state.
print(random.randrange(0, 10))
GoalKicker.com – Python® Notes for Professionals
310# Out: 9
print(random.randrange(0, 10))
# Out: 4
Since the seed is ﬁxed these results are always 9 and 4. If having speciﬁc numbers is not required only that the
values will be the same one can also just use getstate and setstate to recover to a previous state:
save_state = random.getstate()
print(random.randrange(0, 10))
# Out: 5
print(random.randrange(0, 10))
# Out: 8# Get the current state
random.setstate(save_state)
print(random.randrange(0, 10))
# Out: 5
print(random.randrange(0, 10))
# Out: 8# Reset to saved state
To pseudo-randomize the sequence again you seed with None:
random.seed(None)
Or call the seed method with no arguments:
random.seed()
Section 55.6: Random Binary Decision
import random
probability = 0.3
if random.random() < probability:
print("Decision with probability 0.3")
else:
print("Decision with probability 0.7")
GoalKicker.com – Python® Notes for Professionals
311Chapter 56: Functools Module
Section 56.1: partial
The partial function creates partial function application from another function. It is used to bind values to some of
the function's arguments (or keyword arguments) and produce a callable without the already deﬁned arguments.
>>> from functools import partial
>>> unhex = partial(int, base=16)
>>> unhex.__doc__ = 'Convert base16 string to int'
>>> unhex('ca11ab1e')
3390155550
partial(), as the name suggests, allows a partial evaluation of a function. Let's look at following example:
In [2]: from functools import partial
In [3]: def f(a, b, c, x):
...:
return 1000*a + 100*b + 10*c + x
...:
In [4]: g = partial(f, 1, 1, 1)
In [5]: print g(2)
1112
When g is created, f, which takes four arguments(a, b, c, x), is also partially evaluated for the ﬁrst three
arguments, a, b, c,. Evaluation of f is completed when g is called, g(2), which passes the fourth argument to f.
One way to think of partial is a shift register; pushing in one argument at the time into some function. partial
comes handy for cases where data is coming in as stream and we cannot pass more than one argument.
Section 56.2: cmp_to_key
Python changed its sorting methods to accept a key function. Those functions take a value and return a key which is
used to sort the arrays.
Old comparison functions used to take two values and return -1, 0 or +1 if the ﬁrst argument is small, equal or
greater than the second argument respectively. This is incompatible to the new key-function.
That's where functools.cmp_to_key comes in:
>>> import functools
>>> import locale
>>> sorted(["A", "S", "F", "D"], key=functools.cmp_to_key(locale.strcoll))
['A', 'D', 'F', 'S']
Example taken and adapted from the Python Standard Library Documentation.
Section 56.3: lru_cache
The @lru_cache decorator can be used wrap an expensive, computationally-intensive function with a Least Recently
Used cache. This allows function calls to be memoized, so that future calls with the same parameters can return
instantly instead of having to be recomputed.
GoalKicker.com – Python® Notes for Professionals
312@lru_cache(maxsize=None) # Boundless cache
def fibonacci(n):
if n < 2:
return n
return fibonacci(n-1) + fibonacci(n-2)
>>> fibonacci(15)
In the example above, the value of fibonacci(3) is only calculated once, whereas if fibonacci didn't have an LRU
cache, fibonacci(3) would have been computed upwards of 230 times. Hence, @lru_cache is especially great for
recursive functions or dynamic programming, where an expensive function could be called multiple times with the
same exact parameters.
@lru_cache has two arguments
maxsize: Number of calls to save. When the number of unique calls exceeds maxsize, the LRU cache will
remove the least recently used calls.
typed (added in 3.3): Flag for determining if equivalent arguments of diﬀerent types belong to diﬀerent cache
records (i.e. if 3.0 and 3 count as diﬀerent arguments)
We can see cache stats too:
>>> fib.cache_info()
CacheInfo(hits=13, misses=16, maxsize=None, currsize=16)
NOTE: Since @lru_cache uses dictionaries to cache results, all parameters for the function must be hashable for the
cache to work.
Oﬃcial Python docs for @lru_cache. @lru_cache was added in 3.2.
Section 56.4: total_ordering
When we want to create an orderable class, normally we need to deﬁne the methods __eq()__, __lt__(),
__le__(), __gt__() and __ge__().
The total_ordering decorator, applied to a class, permits the deﬁnition of __eq__() and only one between
__lt__(), __le__(), __gt__() and __ge__(), and still allow all the ordering operations on the class.
@total_ordering
class Employee:
...
def __eq__(self, other):
return ((self.surname, self.name) == (other.surname, other.name))
def __lt__(self, other):
return ((self.surname, self.name) < (other.surname, other.name))
The decorator uses a composition of the provided methods and algebraic operations to derive the other
comparison methods. For example if we deﬁned __lt__() and __eq()__ and we want to derive __gt__(), we can
simply check not __lt__() and not __eq()__.
Note: The total_ordering function is only available since Python 2.7.
GoalKicker.com – Python® Notes for Professionals
313Section 56.5: reduce
In Python 3.x, the reduce function already explained here has been removed from the built-ins and must now be
imported from functools.
from functools import reduce
def factorial(n):
return reduce(lambda a, b: (a*b), range(1, n+1))
GoalKicker.com – Python® Notes for Professionals
314Chapter 57: The dis module
Section 57.1: What is Python bytecode?
Python is a hybrid interpreter. When running a program, it ﬁrst assembles it into bytecode which can then be run in
the Python interpreter (also called a Python virtual machine). The dis module in the standard library can be used to
make the Python bytecode human-readable by disassembling classes, methods, functions, and code objects.
>>> def hello():
...
print "Hello, World"
...
>>> dis.dis(hello)
2
0 LOAD_CONST
3 PRINT_ITEM
4 PRINT_NEWLINE
5 LOAD_CONST
8 RETURN_VALUE
1 ('Hello, World')
0 (None)
The Python interpreter is stack-based and uses a ﬁrst-in last-out system.
Each operation code (opcode) in the Python assembly language (the bytecode) takes a ﬁxed number of items from
the stack and returns a ﬁxed number of items to the stack. If there aren't enough items on the stack for an opcode,
the Python interpreter will crash, possibly without an error message.
Section 57.2: Constants in the dis module
EXTENDED_ARG = 145 # All opcodes greater than this have 2 operands
HAVE_ARGUMENT = 90 # All opcodes greater than this have at least 1 operands
cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is', 'is ...
# A list of comparator id's. The indices are used as operands in some opcodes
# All opcodes in these lists have the respective types as there operands
hascompare = [107]
hasconst = [100]
hasfree = [135, 136, 137]
hasjabs = [111, 112, 113, 114, 115, 119]
hasjrel = [93, 110, 120, 121, 122, 143]
haslocal = [124, 125, 126]
hasname = [90, 91, 95, 96, 97, 98, 101, 106, 108, 109, 116]
# A map of opcodes to ids
opmap = {'BINARY_ADD': 23, 'BINARY_AND': 64, 'BINARY_DIVIDE': 21, 'BIN...
# A map of ids to opcodes
opname = ['STOP_CODE', 'POP_TOP', 'ROT_TWO', 'ROT_THREE', 'DUP_TOP', '...
Section 57.3: Disassembling modules
To disassemble a Python module, ﬁrst this has to be turned into a .pyc ﬁle (Python compiled). To do this, run
python -m compileall <file>.py
Then in an interpreter, run
import dis
import marshal
GoalKicker.com – Python® Notes for Professionals
315with open("<file>.pyc", "rb") as code_f:
code_f.read(8) # Magic number and modification time
code = marshal.load(code_f) # Returns a code object which can be disassembled
dis.dis(code) # Output the disassembly
This will compile a Python module and output the bytecode instructions with dis. The module is never imported so
it is safe to use with untrusted code.
GoalKicker.com – Python® Notes for Professionals
316Chapter 58: The base64 Module
Parameter
Description
base64.b64encode(s, altchars=None)
sA bytes-like object
altcharsA bytes-like object of length 2+ of characters to replace the
'+' and '=' characters when creating the Base64 alphabet.
Extra characters are ignored.
base64.b64decode(s, altchars=None,
validate=False)
sA bytes-like object
altcharsA bytes-like object of length 2+ of characters to replace the
'+' and '=' characters when creating the Base64 alphabet.
Extra characters are ignored.
validateIf validate is True, the characters not in the normal Base64
alphabet or the alternative alphabet are not discarded
before the padding check
base64.standard_b64encode(s)
s
A bytes-like object
base64.standard_b64decode(s)
s
A bytes-like object
base64.urlsafe_b64encode(s)
s
A bytes-like object
base64.urlsafe_b64decode(s)
s
A bytes-like object
b32encode(s)
s
A bytes-like object
b32decode(s)
s
A bytes-like object
base64.b16encode(s)
s
A bytes-like object
base64.b16decode(s)
s
A bytes-like object
base64.a85encode(b, foldspaces=False,
wrapcol=0, pad=False, adobe=False)
bA bytes-like object
foldspacesIf foldspaces is True, the character 'y' will be used instead
of 4 consecutive spaces.
wrapcolThe number characters before a newline (0 implies no
newlines)
padIf pad is True, the bytes are padded to a multiple of 4
before encoding
adobeIf adobe is True, the encoded sequenced with be framed
with '<~' and ''~>' as used with Adobe products
base64.a85decode(b, foldspaces=False,
adobe=False, ignorechars=b'\t\n\r\v')
bA bytes-like object
foldspacesIf foldspaces is True, the character 'y' will be used instead
of 4 consecutive spaces.
GoalKicker.com – Python® Notes for Professionals
317adobeIf adobe is True, the encoded sequenced with be framed
with '<~' and ''~>' as used with Adobe products
ignorecharsA bytes-like object of characters to ignore in the encoding
process
base64.b85encode(b, pad=False)
bA bytes-like object
padIf pad is True, the bytes are padded to a multiple of 4
before encoding
base64.b85decode(b)
b
A bytes-like object
Base 64 encoding represents a common scheme for encoding binary into ASCII string format using radix 64. The
base64 module is part of the standard library, which means it installs along with Python. Understanding of bytes
and strings is critical to this topic and can be reviewed here. This topic explains how to use the various features and
number bases of the base64 module.
Section 58.1: Encoding and Decoding Base64
To include the base64 module in your script, you must import it ﬁrst:
import base64
The base64 encode and decode functions both require a bytes-like object. To get our string into bytes, we must
encode it using Python's built in encode function. Most commonly, the UTF-8 encoding is used, however a full list of
these standard encodings (including languages with diﬀerent characters) can be found here in the oﬃcial Python
Documentation. Below is an example of encoding a string into bytes:
s = "Hello World!"
b = s.encode("UTF-8")
The output of the last line would be:
b'Hello World!'
The b preﬁx is used to denote the value is a bytes object.
To Base64 encode these bytes, we use the base64.b64encode() function:
import base64
s = "Hello World!"
b = s.encode("UTF-8")
e = base64.b64encode(b)
print(e)
That code would output the following:
b'SGVsbG8gV29ybGQh'
which is still in the bytes object. To get a string out of these bytes, we can use Python's decode() method with the
UTF-8 encoding:
import base64
s = "Hello World!"
b = s.encode("UTF-8")
e = base64.b64encode(b)
GoalKicker.com – Python® Notes for Professionals
318s1 = e.decode("UTF-8")
print(s1)
The output would then be:
SGVsbG8gV29ybGQh
If we wanted to encode the string and then decode we could use the base64.b64decode() method:
import base64
# Creating a string
s = "Hello World!"
# Encoding the string into bytes
b = s.encode("UTF-8")
# Base64 Encode the bytes
e = base64.b64encode(b)
# Decoding the Base64 bytes to string
s1 = e.decode("UTF-8")
# Printing Base64 encoded string
print("Base64 Encoded:", s1)
# Encoding the Base64 encoded string into bytes
b1 = s1.encode("UTF-8")
# Decoding the Base64 bytes
d = base64.b64decode(b1)
# Decoding the bytes to string
s2 = d.decode("UTF-8")
print(s2)
As you may have expected, the output would be the original string:
Base64 Encoded: SGVsbG8gV29ybGQh
Hello World!
Section 58.2: Encoding and Decoding Base32
The base64 module also includes encoding and decoding functions for Base32. These functions are very similar to
the Base64 functions:
import base64
# Creating a string
s = "Hello World!"
# Encoding the string into bytes
b = s.encode("UTF-8")
# Base32 Encode the bytes
e = base64.b32encode(b)
# Decoding the Base32 bytes to string
s1 = e.decode("UTF-8")
# Printing Base32 encoded string
print("Base32 Encoded:", s1)
# Encoding the Base32 encoded string into bytes
b1 = s1.encode("UTF-8")
# Decoding the Base32 bytes
d = base64.b32decode(b1)
# Decoding the bytes to string
s2 = d.decode("UTF-8")
print(s2)
This would produce the following output:
GoalKicker.com – Python® Notes for Professionals
319Base32 Encoded: JBSWY3DPEBLW64TMMQQQ====
Hello World!
Section 58.3: Encoding and Decoding Base16
The base64 module also includes encoding and decoding functions for Base16. Base 16 is most commonly referred
to as hexadecimal. These functions are very similar to the both the Base64 and Base32 functions:
import base64
# Creating a string
s = "Hello World!"
# Encoding the string into bytes
b = s.encode("UTF-8")
# Base16 Encode the bytes
e = base64.b16encode(b)
# Decoding the Base16 bytes to string
s1 = e.decode("UTF-8")
# Printing Base16 encoded string
print("Base16 Encoded:", s1)
# Encoding the Base16 encoded string into bytes
b1 = s1.encode("UTF-8")
# Decoding the Base16 bytes
d = base64.b16decode(b1)
# Decoding the bytes to string
s2 = d.decode("UTF-8")
print(s2)
This would produce the following output:
Base16 Encoded: 48656C6C6F20576F726C6421
Hello World!
Section 58.4: Encoding and Decoding ASCII85
Adobe created its own encoding called ASCII85 which is similar to Base85, but has its diﬀerences. This encoding is
used frequently in Adobe PDF ﬁles. These functions were released in Python version 3.4. Otherwise, the functions
base64.a85encode() and base64.a85encode() are similar to the previous:
import base64
# Creating a string
s = "Hello World!"
# Encoding the string into bytes
b = s.encode("UTF-8")
# ASCII85 Encode the bytes
e = base64.a85encode(b)
# Decoding the ASCII85 bytes to string
s1 = e.decode("UTF-8")
# Printing ASCII85 encoded string
print("ASCII85 Encoded:", s1)
# Encoding the ASCII85 encoded string into bytes
b1 = s1.encode("UTF-8")
# Decoding the ASCII85 bytes
d = base64.a85decode(b1)
# Decoding the bytes to string
s2 = d.decode("UTF-8")
GoalKicker.com – Python® Notes for Professionals
320print(s2)
This outputs the following:
ASCII85 Encoded: 87cURD]i,"Ebo80
Hello World!
Section 58.5: Encoding and Decoding Base85
Just like the Base64, Base32, and Base16 functions, the Base85 encoding and decoding functions are
base64.b85encode() and base64.b85decode():
import base64
# Creating a string
s = "Hello World!"
# Encoding the string into bytes
b = s.encode("UTF-8")
# Base85 Encode the bytes
e = base64.b85encode(b)
# Decoding the Base85 bytes to string
s1 = e.decode("UTF-8")
# Printing Base85 encoded string
print("Base85 Encoded:", s1)
# Encoding the Base85 encoded string into bytes
b1 = s1.encode("UTF-8")
# Decoding the Base85 bytes
d = base64.b85decode(b1)
# Decoding the bytes to string
s2 = d.decode("UTF-8")
print(s2)
which outputs the following:
Base85 Encoded: NM&qnZy;B1a%^NF
Hello World!
GoalKicker.com – Python® Notes for Professionals
321Chapter 59: Queue Module
The Queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded
programming when information must be exchanged safely between multiple threads. There are three types of
queues provides by queue module,Which are as following : 1. Queue 2. LifoQueue 3. PriorityQueue Exception which
could be come: 1. Full (queue overﬂow) 2. Empty (queue underﬂow)
Section 59.1: Simple example
from Queue import Queue
question_queue = Queue()
for x in range(1,10):
temp_dict = ('key', x)
question_queue.put(temp_dict)
while(not question_queue.empty()):
item = question_queue.get()
print(str(item))
Output:
('key', 1)
('key', 2)
('key', 3)
('key', 4)
('key', 5)
('key', 6)
('key', 7)
('key', 8)
('key', 9)
GoalKicker.com – Python® Notes for Professionals
322VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 60: Deque Module
Parameter
iterableDetails
Creates the deque with initial elements copied from another iterable.
maxlenLimits how large the deque can be, pushing out old elements as new are added.
Section 60.1: Basic deque using
The main methods that are useful with this class are popleft and appendleft
from collections import deque
d = deque([1, 2, 3])
p = d.popleft()
d.appendleft(5)
# p = 1, d = deque([2, 3])
# d = deque([5, 2, 3])
Section 60.2: Available methods in deque
Creating empty deque:
dl = deque()
# deque([]) creating empty deque
Creating deque with some elements:
dl = deque([1, 2, 3, 4])
# deque([1, 2, 3, 4])
Adding element to deque:
dl.append(5)
# deque([1, 2, 3, 4, 5])
Adding element left side of deque:
dl.appendleft(0)
# deque([0, 1, 2, 3, 4, 5])
Adding list of elements to deque:
dl.extend([6, 7])
# deque([0, 1, 2, 3, 4, 5, 6, 7])
Adding list of elements to from the left side:
dl.extendleft([-2, -1])
# deque([-1, -2, 0, 1, 2, 3, 4, 5, 6, 7])
Using .pop() element will naturally remove an item from the right side:
dl.pop()
# 7 => deque([-1, -2, 0, 1, 2, 3, 4, 5, 6])
Using .popleft() element to remove an item from the left side:
dl.popleft()
# -1 deque([-2, 0, 1, 2, 3, 4, 5, 6])
Remove element by its value:
GoalKicker.com – Python® Notes for Professionals
324dl.remove(1)
# deque([-2, 0, 2, 3, 4, 5, 6])
Reverse the order of the elements in deque:
dl.reverse()
# deque([6, 5, 4, 3, 2, 0, -2])
Section 60.3: limit deque size
Use the maxlen parameter while creating a deque to limit the size of the deque:
from collections import deque
d = deque(maxlen=3) # only holds 3 items
d.append(1) # deque([1])
d.append(2) # deque([1, 2])
d.append(3) # deque([1, 2, 3])
d.append(4) # deque([2, 3, 4]) (1 is removed because its maxlen is 3)
Section 60.4: Breadth First Search
The Deque is the only Python data structure with fast Queue operations. (Note queue.Queue isn't normally suitable,
since it's meant for communication between threads.) A basic use case of a Queue is the breadth ﬁrst search.
from collections import deque
def bfs(graph, root):
distances = {}
distances[root] = 0
q = deque([root])
while q:
# The oldest seen (but not yet visited) node will be the left most one.
current = q.popleft()
for neighbor in graph[current]:
if neighbor not in distances:
distances[neighbor] = distances[current] + 1
# When we see a new node, we add it to the right side of the queue.
q.append(neighbor)
return distances
Say we have a simple directed graph:
graph = {1:[2,3], 2:[4], 3:[4,5], 4:[3,5], 5:[]}
We can now ﬁnd the distances from some starting position:
>>> bfs(graph, 1)
{1: 0, 2: 1, 3: 1, 4: 2, 5: 2}
>>> bfs(graph, 3)
{3: 0, 4: 1, 5: 1}
GoalKicker.com – Python® Notes for Professionals
325Chapter 61: Webbrowser Module
Parameter
Details
webbrowser.open()
urlthe URL to open in the web browser
new0 opens the URL in the existing tab, 1 opens in a new window, 2 opens in new tab
autoraiseif set to True, the window will be moved on top of the other windows
webbrowser.open_new()
url
the URL to open in the web browser
webbrowser.open_new_tab()
url
the URL to open in the web browser
webbrowser.get()
using
the browser to use
webbrowser.register()
urlbrowser name
constructorpath to the executable browser (help)
instanceAn instance of a web browser returned from the webbrowser.get() method
According to Python's standard documentation, the webbrowser module provides a high-level interface to allow
displaying Web-based documents to users. This topic explains and demonstrates proper usage of the webbrowser
module.
Section 61.1: Opening a URL with Default Browser
To simply open a URL, use the webbrowser.open() method:
import webbrowser
webbrowser.open("http://stackoverflow.com")
If a browser window is currently open, the method will open a new tab at the speciﬁed URL. If no window is open,
the method will open the operating system's default browser and navigate to the URL in the parameter. The open
method supports the following parameters:
url - the URL to open in the web browser (string) [required]
new - 0 opens in existing tab, 1 opens new window, 2 opens new tab (integer) [default 0]
autoraise - if set to True, the window will be moved on top of other applications' windows (Boolean)
[default False]
Note, the new and autoraise arguments rarely work as the majority of modern browsers refuse these commands.
Webbrowser can also try to open URLs in new windows with the open_new method:
import webbrowser
webbrowser.open_new("http://stackoverflow.com")
This method is commonly ignored by modern browsers and the URL is usually opened in a new tab. Opening a new
tab can be tried by the module using the open_new_tab method:
import webbrowser
webbrowser.open_new_tab("http://stackoverflow.com")
GoalKicker.com – Python® Notes for Professionals
326Section 61.2: Opening a URL with Dierent Browsers
The webbrowser module also supports diﬀerent browsers using the register() and get() methods. The get
method is used to create a browser controller using a speciﬁc executable's path and the register method is used to
attach these executables to preset browser types for future use, commonly when multiple browser types are used.
import webbrowser
ff_path = webbrowser.get("C:/Program Files/Mozilla Firefox/firefox.exe")
ff = webbrowser.get(ff_path)
ff.open("http://stackoverflow.com/")
Registering a browser type:
import webbrowser
ff_path = webbrowser.get("C:/Program Files/Mozilla Firefox/firefox.exe")
ff = webbrowser.get(ff_path)
webbrowser.register('firefox', None, ff)
# Now to refer to use Firefox in the future you can use this
webbrowser.get('firefox').open("https://stackoverflow.com/")
GoalKicker.com – Python® Notes for Professionals
327Chapter 62: tkinter
Released in Tkinter is Python's most popular GUI (Graphical User Interface) library. This topic explains proper usage
of this library and its features.
Section 62.1: Geometry Managers
Tkinter has three mechanisms for geometry management: place, pack, and grid.
The place manager uses absolute pixel coordinates.
The pack manager places widgets into one of 4 sides. New widgets are placed next to existing widgets.
The grid manager places widgets into a grid similar to a dynamically resizing spreadsheet.
Place
The most common keyword arguments for widget.place are as follows:
x, the absolute x-coordinate of the widget
y, the absolute y-coordinate of the widget
height, the absolute height of the widget
width, the absolute width of the widget
A code example using place:
class PlaceExample(Frame):
def __init__(self,master):
Frame.__init__(self,master)
self.grid()
top_text=Label(master,text="This is on top at the origin")
#top_text.pack()
top_text.place(x=0,y=0,height=50,width=200)
bottom_right_text=Label(master,text="This is at position 200,400")
#top_text.pack()
bottom_right_text.place(x=200,y=400,height=50,width=200)
# Spawn Window
if __name__=="__main__":
root=Tk()
place_frame=PlaceExample(root)
place_frame.mainloop()
Pack
widget.pack can take the following keyword arguments:
expand, whether or not to ﬁll space left by parent
fill, whether to expand to ﬁll all space (NONE (default), X, Y, or BOTH)
side, the side to pack against (TOP (default), BOTTOM, LEFT, or RIGHT)
Grid
The most commonly used keyword arguments of widget.grid are as follows:
row, the row of the widget (default smallest unoccupied)
rowspan, the number of columns a widget spans (default 1)
column, the column of the widget (default 0)
GoalKicker.com – Python® Notes for Professionals
328columnspan, the number of columns a widget spans (default 1)
sticky, where to place widget if the grid cell is larger than it (combination of N,NE,E,SE,S,SW,W,NW)
The rows and columns are zero indexed. Rows increase going down, and columns increase going right.
A code example using grid:
from tkinter import *
class GridExample(Frame):
def __init__(self,master):
Frame.__init__(self,master)
self.grid()
top_text=Label(self,text="This text appears on top left")
top_text.grid() # Default position 0, 0
bottom_text=Label(self,text="This text appears on bottom left")
bottom_text.grid() # Default position 1, 0
right_text=Label(self,text="This text appears on the right and spans both rows",
wraplength=100)
# Position is 0,1
# Rowspan means actual position is [0-1],1
right_text.grid(row=0,column=1,rowspan=2)
# Spawn Window
if __name__=="__main__":
root=Tk()
grid_frame=GridExample(root)
grid_frame.mainloop()
Never mix pack and grid within the same frame! Doing so will lead to application deadlock!
Section 62.2: A minimal tkinter Application
tkinter is a GUI toolkit that provides a wrapper around the Tk/Tcl GUI library and is included with Python. The
following code creates a new window using tkinter and places some text in the window body.
Note: In Python 2, the capitalization may be slightly diﬀerent, see Remarks section below.
import tkinter as tk
# GUI window is a subclass of the basic tkinter Frame object
class HelloWorldFrame(tk.Frame):
def __init__(self, master):
# Call superclass constructor
tk.Frame.__init__(self, master)
# Place frame into main window
self.grid()
# Create text box with "Hello World" text
hello = tk.Label(self, text="Hello World! This label can hold strings!")
# Place text box into frame
hello.grid(row=0, column=0)
# Spawn window
if __name__ == "__main__":
# Create main window object
root = tk.Tk()
# Set title of window
root.title("Hello World!")
GoalKicker.com – Python® Notes for Professionals
329# Instantiate HelloWorldFrame object
hello_frame = HelloWorldFrame(root)
# Start GUI
hello_frame.mainloop()
GoalKicker.com – Python® Notes for Professionals
330Chapter 63: pyautogui module
pyautogui is a module used to control mouse and keyboard. This module is basically used to automate mouse click
and keyboard press tasks. For the mouse, the coordinates of the screen (0,0) start from the top-left corner. If you
are out of control, then quickly move the mouse cursor to top-left, it will take the control of mouse and keyboard
from the Python and give it back to you.
Section 63.1: Mouse Functions
These are some of useful mouse functions to control the mouse.
size()
#gave you the size of the screen
position()
#return current position of mouse
moveTo(200,0,duration=1.5)
#move the cursor to (200,0) position with 1.5 second delay
moveRel()
#move the cursor relative to your current position.
click(337,46)
#it will click on the position mention there
dragRel()
#it will drag the mouse relative to position
pyautogui.displayMousePosition()
#gave you the current mouse position but should be done on
terminal.
Section 63.2: Keyboard Functions
These are some of useful keyboard functions to automate the key pressing.
typewrite('')
#this will type the string on the screen where current window has focused.
typewrite(['a','b','left','left','X','Y'])
pyautogui.KEYBOARD_KEYS
#get the list of all the keyboard_keys.
pyautogui.hotkey('ctrl','o')
#for the combination of keys to enter.
Section 63.3: Screenshot And Image Recognition
These function will help you to take the screenshot and also match the image with the part of the screen.
.screenshot('c:\\path')
#get the screenshot.
.locateOnScreen('c:\\path')
#search that image on screen and get the coordinates for you.
locateCenterOnScreen('c:\\path')
#get the coordinate for the image on screen.
GoalKicker.com – Python® Notes for Professionals
331Chapter 64: Indexing and Slicing
Paramer
obj
Description
The object that you want to extract a "sub-object" from
startThe index of obj that you want the sub-object to start from (keep in mind that Python is zero-indexed,
meaning that the ﬁrst item of obj has an index of 0). If omitted, defaults to 0.
stopThe (non-inclusive) index of obj that you want the sub-object to end at. If omitted, defaults to len(obj).
stepAllows you to select only every step item. If omitted, defaults to 1.
Section 64.1: Basic Slicing
For any iterable (for eg. a string, list, etc), Python allows you to slice and return a substring or sublist of its data.
Format for slicing:
iterable_name[start:stop:step]
where,
start is the ﬁrst index of the slice. Defaults to 0 (the index of the ﬁrst element)
stop one past the last index of the slice. Defaults to len(iterable)
step is the step size (better explained by the examples below)
Examples:
a = "abcdef"
a
# "abcdef"
# Same as a[:] or a[::] since it uses the defaults for all three indices
a[-1]
# "f"
a[:]
# "abcdef"
a[::]
# "abcdef"
a[3:]
# "def" (from index 3, to end(defaults to size of iterable))
a[:4]
# "abcd" (from beginning(default 0) to position 4 (excluded))
a[2:4]
# "cd" (from position 2, to position 4 (excluded))
In addition, any of the above can be used with the step size deﬁned:
a[::2]
a[1:4:2]
# "ace" (every 2nd element)
# "bd" (from index 1, to index 4 (excluded), every 2nd element)
Indices can be negative, in which case they're computed from the end of the sequence
a[:-1]
a[:-2]
a[-1:]
# "abcde" (from index 0 (default), to the second last element (last element - 1))
# "abcd" (from index 0 (default), to the third last element (last element -2))
# "f" (from the last element to the end (default len())
Step sizes can also be negative, in which case slice will iterate through the list in reverse order:
a[3:1:-1]
# "dc" (from index 2 to None (default), in reverse order)
This construct is useful for reversing an iterable
a[::-1]
# "fedcba" (from last element (default len()-1), to first, in reverse order(-1))
GoalKicker.com – Python® Notes for Professionals
332Notice that for negative steps the default end_index is None (see http://stackoverﬂow.com/a/12521981 )
a[5:None:-1] # "fedcba" (this is equivalent to a[::-1])
a[5:0:-1]
# "fedcb" (from the last element (index 5) to second element (index 1)
Section 64.2: Reversing an object
You can use slices to very easily reverse a str, list, or tuple (or basically any collection object that implements
slicing with the step parameter). Here is an example of reversing a string, although this applies equally to the other
types listed above:
s = 'reverse me!'
s[::-1]
# '!em esrever'
Let's quickly look at the syntax. [::-1] means that the slice should be from the beginning until the end of the string
(because start and end are omitted) and a step of -1 means that it should move through the string in reverse.
Section 64.3: Slice assignment
Another neat feature using slices is slice assignment. Python allows you to assign new slices to replace old slices of
a list in a single operation.
This means that if you have a list, you can replace multiple members in a single assignment:
lst = [1, 2, 3]
lst[1:3] = [4, 5]
print(lst) # Out: [1, 4, 5]
The assignment shouldn't match in size as well, so if you wanted to replace an old slice with a new slice that is
diﬀerent in size, you could:
lst = [1, 2, 3, 4, 5]
lst[1:4] = [6]
print(lst) # Out: [1, 6, 5]
It's also possible to use the known slicing syntax to do things like replacing the entire list:
lst = [1, 2, 3]
lst[:] = [4, 5, 6]
print(lst) # Out: [4, 5, 6]
Or just the last two members:
lst = [1, 2, 3]
lst[-2:] = [4, 5, 6]
print(lst) # Out: [1, 4, 5, 6]
Section 64.4: Making a shallow copy of an array
A quick way to make a copy of an array (as opposed to assigning a variable with another reference to the original
array) is:
arr[:]
GoalKicker.com – Python® Notes for Professionals
333Let's examine the syntax. [:] means that start, end, and slice are all omitted. They default to 0, len(arr), and 1,
respectively, meaning that subarray that we are requesting will have all of the elements of arr from the beginning
until the very end.
In practice, this looks something like:
arr = ['a', 'b', 'c']
copy = arr[:]
arr.append('d')
print(arr)
# ['a', 'b', 'c', 'd']
print(copy)
# ['a', 'b', 'c']
As you can see, arr.append('d') added d to arr, but copy remained unchanged!
Note that this makes a shallow copy, and is identical to arr.copy().
Section 64.5: Indexing custom classes: __getitem__,
__setitem__ and __delitem__
class MultiIndexingList:
def __init__(self, value):
self.value = value
def __repr__(self):
return repr(self.value)
def __getitem__(self, item):
if isinstance(item, (int, slice)):
return self.__class__(self.value[item])
return [self.value[i] for i in item]
def __setitem__(self, item, value):
if isinstance(item, int):
self.value[item] = value
elif isinstance(item, slice):
raise ValueError('Cannot interpret slice with multiindexing')
else:
for i in item:
if isinstance(i, slice):
raise ValueError('Cannot interpret slice with multiindexing')
self.value[i] = value
def __delitem__(self, item):
if isinstance(item, int):
del self.value[item]
elif isinstance(item, slice):
del self.value[item]
else:
if any(isinstance(elem, slice) for elem in item):
raise ValueError('Cannot interpret slice with multiindexing')
item = sorted(item, reverse=True)
for elem in item:
del self.value[elem]
This allows slicing and indexing for element access:
a = MultiIndexingList([1,2,3,4,5,6,7,8])
a
# Out: [1, 2, 3, 4, 5, 6, 7, 8]
GoalKicker.com – Python® Notes for Professionals
334a[1,5,2,6,1]
# Out: [2, 6, 3, 7, 2]
a[4, 1, 5:, 2, ::2]
# Out: [5, 2, [6, 7, 8], 3, [1, 3, 5, 7]]
#
4|1-|----50:---|2-|-----::2-----
<-- indicated which element came from which index
While setting and deleting elements only allows for comma separated integer indexing (no slicing):
a[4] = 1000
a
# Out: [1, 2, 3, 4, 1000, 6, 7, 8]
a[2,6,1] = 100
a
# Out: [1, 100, 100, 4, 1000, 6, 100, 8]
del a[5]
a
# Out: [1, 100, 100, 4, 1000, 100, 8]
del a[4,2,5]
a
# Out: [1, 100, 4, 8]
Section 64.6: Basic Indexing
Python lists are 0-based i.e. the ﬁrst element in the list can be accessed by the index 0
arr = ['a', 'b', 'c', 'd']
print(arr[0])
>> 'a'
You can access the second element in the list by index 1, third element by index 2 and so on:
print(arr[1])
>> 'b'
print(arr[2])
>> 'c'
You can also use negative indices to access elements from the end of the list. eg. index -1 will give you the last
element of the list and index -2 will give you the second-to-last element of the list:
print(arr[-1])
>> 'd'
print(arr[-2])
>> 'c'
If you try to access an index which is not present in the list, an IndexError will be raised:
print arr[6]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
GoalKicker.com – Python® Notes for Professionals
335VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 65: Plotting with Matplotlib
Matplotlib (https://matplotlib.org/) is a library for 2D plotting based on NumPy. Here are some basic examples.
More examples can be found in the oﬃcial documentation (https://matplotlib.org/2.0.2/gallery.html and
https://matplotlib.org/2.0.2/examples/index.html)
Section 65.1: Plots with Common X-axis but dierent Y-axis :
Using twinx()
In this example, we will plot a sine curve and a hyperbolic sine curve in the same plot with a common x-axis having
diﬀerent y-axis. This is accomplished by the use of twinx() command.
# Plotting tutorials in Python
# Adding Multiple plots by twin x axis
# Good for plots having different y axis range
# Separate axes and figure objects
# replicate axes object and plot curves
# use axes to set attributes
# Note:
# Grid for second curve unsuccessful : let me know if you find it! :(
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2.0*np.pi, 101)
y = np.sin(x)
z = np.sinh(x)
# separate the figure object and axes object
# from the plotting object
fig, ax1 = plt.subplots()
# Duplicate the axes with a different y axis
# and the same x axis
ax2 = ax1.twinx() # ax2 and ax1 will have common x axis and different y axis
# plot the curves on axes 1, and 2, and get the curve handles
curve1, = ax1.plot(x, y, label="sin", color='r')
curve2, = ax2.plot(x, z, label="sinh", color='b')
# Make a curves list to access the parameters in the curves
curves = [curve1, curve2]
# add legend via axes 1 or axes 2 object.
# one command is usually sufficient
# ax1.legend() # will not display the legend of ax2
# ax2.legend() # will not display the legend of ax1
ax1.legend(curves, [curve.get_label() for curve in curves])
# ax2.legend(curves, [curve.get_label() for curve in curves]) # also valid
# Global figure properties
plt.title("Plot of sine and hyperbolic sine")
plt.show()
GoalKicker.com – Python® Notes for Professionals
337Section 65.2: Plots with common Y-axis and dierent X-axis
using twiny()
In this example, a plot with curves having common y-axis but diﬀerent x-axis is demonstrated using twiny()
method. Also, some additional features such as the title, legend, labels, grids, axis ticks and colours are added to
the plot.
# Plotting tutorials in Python
# Adding Multiple plots by twin y axis
# Good for plots having different x axis range
# Separate axes and figure objects
# replicate axes object and plot curves
# use axes to set attributes
import numpy as np
import matplotlib.pyplot as plt
y = np.linspace(0, 2.0*np.pi, 101)
x1 = np.sin(y)
x2 = np.sinh(y)
# values for making ticks in x and y axis
ynumbers = np.linspace(0, 7, 15)
xnumbers1 = np.linspace(-1, 1, 11)
xnumbers2 = np.linspace(0, 300, 7)
# separate the figure object and axes object
# from the plotting object
fig, ax1 = plt.subplots()
GoalKicker.com – Python® Notes for Professionals
338# Duplicate the axes with a different x axis
# and the same y axis
ax2 = ax1.twiny() # ax2 and ax1 will have common y axis and different x axis
# plot the curves on axes 1, and 2, and get the axes handles
curve1, = ax1.plot(x1, y, label="sin", color='r')
curve2, = ax2.plot(x2, y, label="sinh", color='b')
# Make a curves list to access the parameters in the curves
curves = [curve1, curve2]
# add legend via axes 1 or axes 2 object.
# one command is usually sufficient
# ax1.legend() # will not display the legend of ax2
# ax2.legend() # will not display the legend of ax1
# ax1.legend(curves, [curve.get_label() for curve in curves])
ax2.legend(curves, [curve.get_label() for curve in curves]) # also valid
# x axis labels via the axes
ax1.set_xlabel("Magnitude", color=curve1.get_color())
ax2.set_xlabel("Magnitude", color=curve2.get_color())
# y axis label via the axes
ax1.set_ylabel("Angle/Value", color=curve1.get_color())
# ax2.set_ylabel("Magnitude", color=curve2.get_color()) # does not work
# ax2 has no property control over y axis
# y ticks - make them coloured as well
ax1.tick_params(axis='y', colors=curve1.get_color())
# ax2.tick_params(axis='y', colors=curve2.get_color()) # does not work
# ax2 has no property control over y axis
# x axis ticks via the axes
ax1.tick_params(axis='x', colors=curve1.get_color())
ax2.tick_params(axis='x', colors=curve2.get_color())
# set x ticks
ax1.set_xticks(xnumbers1)
ax2.set_xticks(xnumbers2)
# set y ticks
ax1.set_yticks(ynumbers)
# ax2.set_yticks(ynumbers) # also works
# Grids via axes 1 # use this if axes 1 is used to
# define the properties of common x axis
# ax1.grid(color=curve1.get_color())
# To make grids using axes 2
ax1.grid(color=curve2.get_color())
ax2.grid(color=curve2.get_color())
ax1.xaxis.grid(False)
# Global figure properties
plt.title("Plot of sine and hyperbolic sine")
plt.show()
GoalKicker.com – Python® Notes for Professionals
339Section 65.3: A Simple Plot in Matplotlib
This example illustrates how to create a simple sine curve using Matplotlib
# Plotting tutorials in Python
# Launching a simple plot
import numpy as np
import matplotlib.pyplot as plt
# angle varying between 0 and 2*pi
x = np.linspace(0, 2.0*np.pi, 101)
y = np.sin(x)
# sine function
plt.plot(x, y)
plt.show()
GoalKicker.com – Python® Notes for Professionals
340Section 65.4: Adding more features to a simple plot : axis
labels, title, axis ticks, grid, and legend
In this example, we take a sine curve plot and add more features to it; namely the title, axis labels, title, axis ticks,
grid and legend.
# Plotting tutorials in Python
# Enhancing a plot
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2.0*np.pi, 101)
y = np.sin(x)
# values for making ticks in x and y axis
xnumbers = np.linspace(0, 7, 15)
ynumbers = np.linspace(-1, 1, 11)
plt.plot(x, y, color='r', label='sin') # r - red colour
plt.xlabel("Angle in Radians")
plt.ylabel("Magnitude")
plt.title("Plot of some trigonometric functions")
plt.xticks(xnumbers)
plt.yticks(ynumbers)
plt.legend()
plt.grid()
plt.axis([0, 6.5, -1.1, 1.1]) # [xstart, xend, ystart, yend]
plt.show()
GoalKicker.com – Python® Notes for Professionals
341Section 65.5: Making multiple plots in the same ﬁgure by
superimposition similar to MATLAB
In this example, a sine curve and a cosine curve are plotted in the same ﬁgure by superimposing the plots on top of
each other.
# Plotting tutorials in Python
# Adding Multiple plots by superimposition
# Good for plots sharing similar x, y limits
# Using single plot command and legend
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2.0*np.pi, 101)
y = np.sin(x)
z = np.cos(x)
# values for making ticks in x and y axis
xnumbers = np.linspace(0, 7, 15)
ynumbers = np.linspace(-1, 1, 11)
plt.plot(x, y, 'r', x, z, 'g') # r, g - red, green colour
plt.xlabel("Angle in Radians")
plt.ylabel("Magnitude")
plt.title("Plot of some trigonometric functions")
plt.xticks(xnumbers)
plt.yticks(ynumbers)
plt.legend(['sine', 'cosine'])
plt.grid()
GoalKicker.com – Python® Notes for Professionals
342plt.axis([0, 6.5, -1.1, 1.1]) # [xstart, xend, ystart, yend]
plt.show()
Section 65.6: Making multiple Plots in the same ﬁgure using
plot superimposition with separate plot commands
Similar to the previous example, here, a sine and a cosine curve are plotted on the same ﬁgure using separate plot
commands. This is more Pythonic and can be used to get separate handles for each plot.
# Plotting tutorials in Python
# Adding Multiple plots by superimposition
# Good for plots sharing similar x, y limits
# Using multiple plot commands
# Much better and preferred than previous
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2.0*np.pi, 101)
y = np.sin(x)
z = np.cos(x)
# values for making ticks in x and y axis
xnumbers = np.linspace(0, 7, 15)
ynumbers = np.linspace(-1, 1, 11)
plt.plot(x, y, color='r', label='sin') # r - red colour
plt.plot(x, z, color='g', label='cos') # g - green colour
plt.xlabel("Angle in Radians")
plt.ylabel("Magnitude")
GoalKicker.com – Python® Notes for Professionals
343plt.title("Plot of some trigonometric functions")
plt.xticks(xnumbers)
plt.yticks(ynumbers)
plt.legend()
plt.grid()
plt.axis([0, 6.5, -1.1, 1.1]) # [xstart, xend, ystart, yend]
plt.show()
GoalKicker.com – Python® Notes for Professionals
344Chapter 66: graph-tool
The python tools can be used to generate graph
Section 66.1: PyDotPlus
PyDotPlus is an improved version of the old pydot project that provides a Python Interface to Graphviz’s Dot
language.
Installation
For the latest stable version:
pip install pydotplus
For the development version:
pip install https://github.com/carlos-jenkins/pydotplus/archive/master.zip
Load graph as deﬁned by a DOT ﬁle
The ﬁle is assumed to be in DOT format. It will be loaded, parsed and a Dot class will be returned,
representing the graph. For example, a simple demo.dot:
digraph demo1{ a -> b -> c; c ->a; }
import pydotplus
graph_a = pydotplus.graph_from_dot_file('demo.dot')
graph_a.write_svg('test.svg') # generate graph in svg.
You will get a svg(Scalable Vector Graphics) like this:
Section 66.2: PyGraphviz
Get PyGraphviz from the Python Package Index at http://pypi.python.org/pypi/pygraphviz
or install it with:
pip install pygraphviz
GoalKicker.com – Python® Notes for Professionals
345and an attempt will be made to ﬁnd and install an appropriate version that matches your operating system and
Python version.
You can install the development version (at github.com) with:
pip install git://github.com/pygraphviz/pygraphviz.git#egg=pygraphviz
Get PyGraphviz from the Python Package Index at http://pypi.python.org/pypi/pygraphviz
or install it with:
easy_install pygraphviz
and an attempt will be made to ﬁnd and install an appropriate version that matches your operating system and
Python version.
Load graph as deﬁned by a DOT ﬁle
The ﬁle is assumed to be in DOT format. It will be loaded, parsed and a Dot class will be returned,
representing the graph. For example,a simple demo.dot:
digraph demo1{ a -> b -> c; c ->a; }
Load it and draw it.
import pygraphviz as pgv
G = pgv.AGraph("demo.dot")
G.draw('test', format='svg', prog='dot')
You will get a svg(Scalable Vector Graphics) like this:
GoalKicker.com – Python® Notes for Professionals
346Chapter 67: Generators
Generators are lazy iterators created by generator functions (using yield) or generator expressions (using
(an_expression for x in an_iterator)).
Section 67.1: Introduction
Generator expressions are similar to list, dictionary and set comprehensions, but are enclosed with parentheses.
The parentheses do not have to be present when they are used as the sole argument for a function call.
expression = (x**2 for x in range(10))
This example generates the 10 ﬁrst perfect squares, including 0 (in which x = 0).
Generator functions are similar to regular functions, except that they have one or more yield statements in their
body. Such functions cannot return any values (however empty returns are allowed if you want to stop the
generator early).
def function():
for x in range(10):
yield x**2
This generator function is equivalent to the previous generator expression, it outputs the same.
Note: all generator expressions have their own equivalent functions, but not vice versa.
A generator expression can be used without parentheses if both parentheses would be repeated otherwise:
sum(i for i in range(10) if i % 2 == 0)
any(x = 0 for x in foo)
type(a > b for a in foo if a % 2 == 1)
#Output: 20
#Output: True or False depending on foo
#Output: <class 'generator'>
Instead of:
sum((i for i in range(10) if i % 2 == 0))
any((x = 0 for x in foo))
type((a > b for a in foo if a % 2 == 1))
But not:
fooFunction(i for i in range(10) if i % 2 == 0,foo,bar)
return x = 0 for x in foo
barFunction(baz, a > b for a in foo if a % 2 == 1)
Calling a generator function produces a generator object, which can later be iterated over. Unlike other types of
iterators, generator objects may only be traversed once.
g1 = function()
print(g1) # Out: <generator object function at 0x1012e1888>
Notice that a generator's body is not immediately executed: when you call function() in the example above, it
immediately returns a generator object, without executing even the ﬁrst print statement. This allows generators to
consume less memory than functions that return a list, and it allows creating generators that produce inﬁnitely long
sequences.
GoalKicker.com – Python® Notes for Professionals
347For this reason, generators are often used in data science, and other contexts involving large amounts of data.
Another advantage is that other code can immediately use the values yielded by a generator, without waiting for
the complete sequence to be produced.
However, if you need to use the values produced by a generator more than once, and if generating them costs
more than storing, it may be better to store the yielded values as a list than to re-generate the sequence. See
'Resetting a generator' below for more details.
Typically a generator object is used in a loop, or in any function that requires an iterable:
for x in g1:
print("Received", x)
# Output:
# Received 0
# Received 1
# Received 4
# Received 9
# Received 16
# Received 25
# Received 36
# Received 49
# Received 64
# Received 81
arr1 = list(g1)
# arr1 = [], because the loop above already consumed all the values.
g2 = function()
arr2 = list(g2) # arr2 = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Since generator objects are iterators, one can iterate over them manually using the next() function. Doing so will
return the yielded values one by one on each subsequent invocation.
Under the hood, each time you call next() on a generator, Python executes statements in the body of the
generator function until it hits the next yield statement. At this point it returns the argument of the yield
command, and remembers the point where that happened. Calling next() once again will resume execution from
that point and continue until the next yield statement.
If Python reaches the end of the generator function without encountering any more yields, a StopIteration
exception is raised (this is normal, all iterators behave in the same way).
g3 = function()
a = next(g3) # a becomes 0
b = next(g3) # b becomes 1
c = next(g3) # c becomes 2
...
j = next(g3) # Raises StopIteration, j remains undefined
Note that in Python 2 generator objects had .next() methods that could be used to iterate through the yielded
values manually. In Python 3 this method was replaced with the .__next__() standard for all iterators.
Resetting a generator
Remember that you can only iterate through the objects generated by a generator once. If you have already iterated
through the objects in a script, any further attempt do so will yield None.
If you need to use the objects generated by a generator more than once, you can either deﬁne the generator
GoalKicker.com – Python® Notes for Professionals
348function again and use it a second time, or, alternatively, you can store the output of the generator function in a list
on ﬁrst use. Re-deﬁning the generator function will be a good option if you are dealing with large volumes of data,
and storing a list of all data items would take up a lot of disc space. Conversely, if it is costly to generate the items
initially, you may prefer to store the generated items in a list so that you can re-use them.
Section 67.2: Inﬁnite sequences
Generators can be used to represent inﬁnite sequences:
def integers_starting_from(n):
while True:
yield n
n += 1
natural_numbers = integers_starting_from(1)
Inﬁnite sequence of numbers as above can also be generated with the help of itertools.count. The above code
could be written as below
natural_numbers = itertools.count(1)
You can use generator comprehensions on inﬁnite generators to produce new generators:
multiples_of_two = (x * 2 for x in natural_numbers)
multiples_of_three = (x for x in natural_numbers if x % 3 == 0)
Be aware that an inﬁnite generator does not have an end, so passing it to any function that will attempt to consume
the generator entirely will have dire consequences:
list(multiples_of_two)
# will never terminate, or raise an OS-specific error
Instead, use list/set comprehensions with range (or xrange for python < 3.0):
first_five_multiples_of_three = [next(multiples_of_three) for _ in range(5)]
# [3, 6, 9, 12, 15]
or use itertools.islice() to slice the iterator to a subset:
from itertools import islice
multiples_of_four = (x * 4 for x in integers_starting_from(1))
first_five_multiples_of_four = list(islice(multiples_of_four, 5))
# [4, 8, 12, 16, 20]
Note that the original generator is updated too, just like all other generators coming from the same "root":
next(natural_numbers)
next(multiples_of_two)
next(multiples_of_four)
# yields 16
# yields 34
# yields 24
An inﬁnite sequence can also be iterated with a for-loop. Make sure to include a conditional break statement so
that the loop would terminate eventually:
for idx, number in enumerate(multiplies_of_two):
print(number)
if idx == 9:
GoalKicker.com – Python® Notes for Professionals
349break
# stop after taking the first 10 multiplies of two
Classic example - Fibonacci numbers
import itertools
def fibonacci():
a, b = 1, 1
while True:
yield a
a, b = b, a + b
first_ten_fibs = list(itertools.islice(fibonacci(), 10))
# [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
def nth_fib(n):
return next(itertools.islice(fibonacci(), n - 1, n))
ninety_nineth_fib = nth_fib(99)
# 354224848179261915075
Section 67.3: Sending objects to a generator
In addition to receiving values from a generator, it is possible to send an object to a generator using the send()
method.
def accumulator():
total = 0
value = None
while True:
# receive sent value
value = yield total
if value is None: break
# aggregate values
total += value
generator = accumulator()
# advance until the first "yield"
next(generator)
# 0
# from this point on, the generator aggregates values
generator.send(1)
# 1
generator.send(10)
# 11
generator.send(100) # 111
# ...
# Calling next(generator) is equivalent to calling generator.send(None)
next(generator)
# StopIteration
What happens here is the following:
When you ﬁrst call next(generator), the program advances to the ﬁrst yield statement, and returns the
value of total at that point, which is 0. The execution of the generator suspends at this point.
When you then call generator.send(x), the interpreter takes the argument x and makes it the return value
of the last yield statement, which gets assigned to value. The generator then proceeds as usual, until it
yields the next value.
When you ﬁnally call next(generator), the program treats this as if you're sending None to the generator.
There is nothing special about None, however, this example uses None as a special value to ask the generator
to stop.
GoalKicker.com – Python® Notes for Professionals
350Section 67.4: Yielding all values from another iterable
Python 3.x Version ≥ 3.3
Use yield from if you want to yield all values from another iterable:
def foob(x):
yield from range(x * 2)
yield from range(2)
list(foob(5))
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]
This works with generators as well.
def fibto(n):
a, b = 1, 1
while True:
if a >= n: break
yield a
a, b = b, a + b
def usefib():
yield from fibto(10)
yield from fibto(20)
list(usefib())
# [1, 1, 2, 3, 5, 8, 1, 1, 2, 3, 5, 8, 13]
Section 67.5: Iteration
A generator object supports the iterator protocol. That is, it provides a next() method (__next__() in Python 3.x),
which is used to step through its execution, and its __iter__ method returns itself. This means that a generator can
be used in any language construct which supports generic iterable objects.
# naive partial implementation of the Python 2.x xrange()
def xrange(n):
i = 0
while i < n:
yield i
i += 1
# looping
for i in xrange(10):
print(i) # prints the values 0, 1, ..., 9
# unpacking
a, b, c = xrange(3)# 0, 1, 2
# building a list
l = list(xrange(10))# [0, 1, ..., 9]
Section 67.6: The next() function
The next() built-in is a convenient wrapper which can be used to receive a value from any iterator (including a
generator iterator) and to provide a default value in case the iterator is exhausted.
def nums():
yield 1
GoalKicker.com – Python® Notes for Professionals
351yield 2
yield 3
generator = nums()
next(generator, None)
next(generator, None)
next(generator, None)
next(generator, None)
next(generator, None)
# ...
# 1
# 2
# 3
# None
# None
The syntax is next(iterator[, default]). If iterator ends and a default value was passed, it is returned. If no
default was provided, StopIteration is raised.
Section 67.7: Coroutines
Generators can be used to implement coroutines:
# create and advance generator to the first yield
def coroutine(func):
def start(*args,**kwargs):
cr = func(*args,**kwargs)
next(cr)
return cr
return start
# example coroutine
@coroutine
def adder(sum = 0):
while True:
x = yield sum
sum += x
# example use
s = adder()
s.send(1) # 1
s.send(2) # 3
Coroutines are commonly used to implement state machines, as they are primarily useful for creating single-
method procedures that require a state to function properly. They operate on an existing state and return the value
obtained on completion of the operation.
Section 67.8: Refactoring list-building code
Suppose you have complex code that creates and returns a list by starting with a blank list and repeatedly
appending to it:
def create():
result = []
# logic here...
result.append(value) # possibly in several places
# more logic...
return result # possibly in several places
values = create()
When it's not practical to replace the inner logic with a list comprehension, you can turn the entire function into a
generator in-place, and then collect the results:
GoalKicker.com – Python® Notes for Professionals
352def create_gen():
# logic...
yield value
# more logic
return # not needed if at the end of the function, of course
values = list(create_gen())
If the logic is recursive, use yield from to include all the values from the recursive call in a "ﬂattened" result:
def preorder_traversal(node):
yield node.value
for child in node.children:
yield from preorder_traversal(child)
Section 67.9: Yield with recursion: recursively listing all ﬁles in
a directory
First, import the libraries that work with ﬁles:
from os import listdir
from os.path import isfile, join, exists
A helper function to read only ﬁles from a directory:
def get_files(path):
for file in listdir(path):
full_path = join(path, file)
if isfile(full_path):
if exists(full_path):
yield full_path
Another helper function to get only the subdirectories:
def get_directories(path):
for directory in listdir(path):
full_path = join(path, directory)
if not isfile(full_path):
if exists(full_path):
yield full_path
Now use these functions to recursively get all ﬁles within a directory and all its subdirectories (using generators):
def get_files_recursive(directory):
for file in get_files(directory):
yield file
for subdirectory in get_directories(directory):
for file in get_files_recursive(subdirectory): # here the recursive call
yield file
This function can be simpliﬁed using yield from:
def get_files_recursive(directory):
yield from get_files(directory)
for subdirectory in get_directories(directory):
yield from get_files_recursive(subdirectory)
GoalKicker.com – Python® Notes for Professionals
353Section 67.10: Generator expressions
It's possible to create generator iterators using a comprehension-like syntax.
generator = (i * 2 for i in range(3))
next(generator)
next(generator)
next(generator)
next(generator)
# 0
# 2
# 4
# raises StopIteration
If a function doesn't necessarily need to be passed a list, you can save on characters (and improve readability) by
placing a generator expression inside a function call. The parenthesis from the function call implicitly make your
expression a generator expression.
sum(i ** 2 for i in range(4))
# 0^2 + 1^2 + 2^2 + 3^2 = 0 + 1 + 4 + 9 = 14
Additionally, you will save on memory because instead of loading the entire list you are iterating over ([0, 1, 2,
3] in the above example), the generator allows Python to use values as needed.
Section 67.11: Using a generator to ﬁnd Fibonacci Numbers
A practical use case of a generator is to iterate through values of an inﬁnite series. Here's an example of ﬁnding the
ﬁrst ten terms of the Fibonacci Sequence.
def fib(a=0, b=1):
"""Generator that yields Fibonacci numbers. `a` and `b` are the seed values"""
while True:
yield a
a, b = b, a + b
f = fib()
print(', '.join(str(next(f)) for _ in range(10)))
0, 1, 1, 2, 3, 5, 8, 13, 21, 34
Section 67.12: Searching
The next function is useful even without iterating. Passing a generator expression to next is a quick way to search
for the ﬁrst occurrence of an element matching some predicate. Procedural code like
def find_and_transform(sequence, predicate, func):
for element in sequence:
if predicate(element):
return func(element)
raise ValueError
item = find_and_transform(my_sequence, my_predicate, my_func)
can be replaced with:
item = next(my_func(x) for x in my_sequence if my_predicate(x))
# StopIteration will be raised if there are no matches; this exception can
# be caught and transformed, if desired.
GoalKicker.com – Python® Notes for Professionals
354For this purpose, it may be desirable to create an alias, such as first = next, or a wrapper function to convert the
exception:
def first(generator):
try:
return next(generator)
except StopIteration:
raise ValueError
Section 67.13: Iterating over generators in parallel
To iterate over several generators in parallel, use the zip builtin:
for x, y in zip(a,b):
print(x,y)
Results in:
1 x
2 y
3 z
In python 2 you should use itertools.izip instead. Here we can also see that the all the zip functions yield tuples.
Note that zip will stop iterating as soon as one of the iterables runs out of items. If you'd like to iterate for as long as
the longest iterable, use itertools.zip_longest().
GoalKicker.com – Python® Notes for Professionals
355Chapter 68: Reduce
Parameter
Details
function
function that is used for reducing the iterable (must take two arguments). (positional-only)
iterableiterable that's going to be reduced. (positional-only)
initializerstart-value of the reduction. (optional, positional-only)
Section 68.1: Overview
# No import needed
# No import required...
from functools import reduce # ... but it can be loaded from the functools module
from functools import reduce # mandatory
reduce reduces an iterable by applying a function repeatedly on the next element of an iterable and the
cumulative result so far.
def add(s1, s2):
return s1 + s2
asequence = [1, 2, 3]
reduce(add, asequence)
# Out: 6
# equivalent to: add(add(1,2),3)
In this example, we deﬁned our own add function. However, Python comes with a standard equivalent function in
the operator module:
import operator
reduce(operator.add, asequence)
# Out: 6
reduce can also be passed a starting value:
reduce(add, asequence, 10)
# Out: 16
Section 68.2: Using reduce
def multiply(s1, s2):
print('{arg1} * {arg2} = {res}'.format(arg1=s1,
arg2=s2,
res=s1*s2))
return s1 * s2
asequence = [1, 2, 3]
Given an initializer the function is started by applying it to the initializer and the ﬁrst iterable element:
cumprod = reduce(multiply, asequence, 5)
# Out: 5 * 1 = 5
GoalKicker.com – Python® Notes for Professionals
356#
5 * 2 = 10
#
10 * 3 = 30
print(cumprod)
# Out: 30
Without initializer parameter the reduce starts by applying the function to the ﬁrst two list elements:
cumprod = reduce(multiply, asequence)
# Out: 1 * 2 = 2
#
2 * 3 = 6
print(cumprod)
# Out: 6
Section 68.3: Cumulative product
import operator
reduce(operator.mul, [10, 5, -3])
# Out: -150
Section 68.4: Non short-circuit variant of any/all
reduce will not terminate the iteration before the iterable has been completely iterated over so it can be used to
create a non short-circuit any() or all() function:
import operator
# non short-circuit "all"
reduce(operator.and_, [False, True, True, True]) # = False
# non short-circuit "any"
reduce(operator.or_, [True, False, False, False]) # = True
GoalKicker.com – Python® Notes for Professionals
357Chapter 69: Map Function
Parameter
functionDetails
function for mapping (must take as many parameters as there are iterables) (positional-only)
iterablethe function is applied to each element of the iterable (positional-only)
*additional_iterables see iterable, but as many as you like (optional, positional-only)
Section 69.1: Basic use of map, itertools.imap and
future_builtins.map
The map function is the simplest one among Python built-ins used for functional programming. map() applies a
speciﬁed function to each element in an iterable:
names = ['Fred', 'Wilma', 'Barney']
Python 3.x Version ≥ 3.0
map(len, names) # map in Python 3.x is a class; its instances are iterable
# Out: <map object at 0x00000198B32E2CF8>
A Python 3-compatible map is included in the future_builtins module:
Python 2.x Version ≥ 2.6
from future_builtins import map # contains a Python 3.x compatible map()
map(len, names)
# see below
# Out: <itertools.imap instance at 0x3eb0a20>
Alternatively, in Python 2 one can use imap from itertools to get a generator
Python 2.x Version ≥ 2.3
map(len, names)
# Out: [4, 5, 6]
# map() returns a list
from itertools import imap
imap(len, names) # itertools.imap() returns a generator
# Out: <itertools.imap at 0x405ea20>
The result can be explicitly converted to a list to remove the diﬀerences between Python 2 and 3:
list(map(len, names))
# Out: [4, 5, 6]
map() can be replaced by an equivalent list comprehension or generator expression:
[len(item) for item in names] # equivalent to Python 2.x map()
# Out: [4, 5, 6]
(len(item) for item in names) # equivalent to Python 3.x map()
# Out: <generator object <genexpr> at 0x00000195888D5FC0>
Section 69.2: Mapping each value in an iterable
For example, you can take the absolute value of each element:
list(map(abs, (1, -1, 2, -2, 3, -3))) # the call to `list` is unnecessary in 2.x
GoalKicker.com – Python® Notes for Professionals
358# Out: [1, 1, 2, 2, 3, 3]
Anonymous function also support for mapping a list:
map(lambda x:x*2, [1, 2, 3, 4, 5])
# Out: [2, 4, 6, 8, 10]
or converting decimal values to percentages:
def to_percent(num):
return num * 100
list(map(to_percent, [0.95, 0.75, 1.01, 0.1]))
# Out: [95.0, 75.0, 101.0, 10.0]
or converting dollars to euros (given an exchange rate):
from functools import partial
from operator import mul
rate = 0.9 # fictitious exchange rate, 1 dollar = 0.9 euros
dollars = {'under_my_bed': 1000,
'jeans': 45,
'bank': 5000}
sum(map(partial(mul, rate), dollars.values()))
# Out: 5440.5
functools.partial is a convenient way to ﬁx parameters of functions so that they can be used with map instead of
using lambda or creating customized functions.
Section 69.3: Mapping values of dierent iterables
For example calculating the average of each i-th element of multiple iterables:
def average(*args):
return float(sum(args)) / len(args)
# cast to float - only mandatory for python 2.x
measurement1 = [100, 111, 99, 97]
measurement2 = [102, 117, 91, 102]
measurement3 = [104, 102, 95, 101]
list(map(average, measurement1, measurement2, measurement3))
# Out: [102.0, 110.0, 95.0, 100.0]
There are diﬀerent requirements if more than one iterable is passed to map depending on the version of python:
The function must take as many parameters as there are iterables:
def median_of_three(a, b, c):
return sorted((a, b, c))[1]
list(map(median_of_three, measurement1, measurement2))
TypeError: median_of_three() missing 1 required positional argument: 'c'
GoalKicker.com – Python® Notes for Professionals
359list(map(median_of_three, measurement1, measurement2, measurement3, measurement3))
TypeError: median_of_three() takes 3 positional arguments but 4 were given
Python 2.x Version ≥ 2.0.1
map: The mapping iterates as long as one iterable is still not fully consumed but assumes None from the fully
consumed iterables:
import operator
measurement1 = [100, 111, 99, 97]
measurement2 = [102, 117]
# Calculate difference between elements
list(map(operator.sub, measurement1, measurement2))
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
itertools.imap and future_builtins.map: The mapping stops as soon as one iterable stops:
import operator
from itertools import imap
measurement1 = [100, 111, 99, 97]
measurement2 = [102, 117]
# Calculate difference between elements
list(imap(operator.sub, measurement1, measurement2))
# Out: [-2, -6]
list(imap(operator.sub, measurement2, measurement1))
# Out: [2, 6]
Python 3.x Version ≥ 3.0.0
The mapping stops as soon as one iterable stops:
import operator
measurement1 = [100, 111, 99, 97]
measurement2 = [102, 117]
# Calculate difference between elements
list(map(operator.sub, measurement1, measurement2))
# Out: [-2, -6]
list(map(operator.sub, measurement2, measurement1))
# Out: [2, 6]
GoalKicker.com – Python® Notes for Professionals
360Section 69.4: Transposing with Map: Using "None" as function
argument (python 2.x only)
from itertools import imap
from future_builtins import map as fmap # Different name to highlight differences
image = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
list(map(None, *image))
# Out: [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
list(fmap(None, *image))
# Out: [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
list(imap(None, *image))
# Out: [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
image2 = [[1, 2, 3],
[4, 5],
[7, 8, 9]]
list(map(None, *image2))
# Out: [(1, 4, 7), (2, 5, 8), (3, None, 9)]
list(fmap(None, *image2))
# Out: [(1, 4, 7), (2, 5, 8)]
list(imap(None, *image2))
# Out: [(1, 4, 7), (2, 5, 8)]
# Fill missing values with None
# ignore columns with missing values
# dito
Python 3.x Version ≥ 3.0.0
list(map(None, *image))
TypeError: 'NoneType' object is not callable
But there is a workaround to have similar results:
def conv_to_list(*args):
return list(args)
list(map(conv_to_list, *image))
# Out: [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
Section 69.5: Series and Parallel Mapping
map() is a built-in function, which means that it is available everywhere without the need to use an 'import'
statement. It is available everywhere just like print() If you look at Example 5 you will see that I had to use an import
statement before I could use pretty print (import pprint). Thus pprint is not a built-in function
Series mapping
In this case each argument of the iterable is supplied as argument to the mapping function in ascending order. This
arises when we have just one iterable to map and the mapping function requires a single argument.
Example 1
insects = ['fly', 'ant', 'beetle', 'cankerworm']
f = lambda x: x + ' is an insect'
print(list(map(f, insects))) # the function defined by f is executed on each item of the iterable
GoalKicker.com – Python® Notes for Professionals
361insects
results in
['fly is an insect', 'ant is an insect', 'beetle is an insect', 'cankerworm is an insect']
Example 2
print(list(map(len, insects))) # the len function is executed each item in the insect list
results in
[3, 3, 6, 10]
Parallel mapping
In this case each argument of the mapping function is pulled from across all iterables (one from each iterable) in
parallel. Thus the number of iterables supplied must match the number of arguments required by the function.
carnivores = ['lion', 'tiger', 'leopard', 'arctic fox']
herbivores = ['african buffalo', 'moose', 'okapi', 'parakeet']
omnivores = ['chicken', 'dove', 'mouse', 'pig']
def animals(w, x, y, z):
return '{0}, {1}, {2}, and {3} ARE ALL ANIMALS'.format(w.title(), x, y, z)
Example 3
# Too many arguments
# observe here that map is trying to pass one item each from each of the four iterables to len. This
leads len to complain that
# it is being fed too many arguments
print(list(map(len, insects, carnivores, herbivores, omnivores)))
results in
TypeError: len() takes exactly one argument (4 given)
Example 4
# Too few arguments
# observe here that map is supposed to execute animal on individual elements of insects one-by-one.
But animals complain when
# it only gets one argument, whereas it was expecting four.
print(list(map(animals, insects)))
results in
TypeError: animals() missing 3 required positional arguments: 'x', 'y', and 'z'
Example 5
# here map supplies w, x, y, z with one value from across the list
import pprint
pprint.pprint(list(map(animals, insects, carnivores, herbivores, omnivores)))
GoalKicker.com – Python® Notes for Professionals
362results in
['Fly, lion, african buffalo, and chicken ARE ALL ANIMALS',
'Ant, tiger, moose, and dove ARE ALL ANIMALS',
'Beetle, leopard, okapi, and mouse ARE ALL ANIMALS',
'Cankerworm, arctic fox, parakeet, and pig ARE ALL ANIMALS']
GoalKicker.com – Python® Notes for Professionals
363VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 70: Exponentiation
Section 70.1: Exponentiation using builtins: ** and pow()
Exponentiation can be used by using the builtin pow-function or the ** operator:
2 ** 3
# 8
pow(2, 3) # 8
For most (all in Python 2.x) arithmetic operations the result's type will be that of the wider operand. This is not true
for **; the following cases are exceptions from this rule:
Base: int, exponent: int < 0:
2 ** -3
# Out: 0.125 (result is a float)
This is also valid for Python 3.x.
Before Python 2.2.0, this raised a ValueError.
Base: int < 0 or float < 0, exponent: float != int
(-2) ** (0.5) # also (-2.) ** (0.5)
# Out: (8.659560562354934e-17+1.4142135623730951j) (result is complex)
Before python 3.0.0, this raised a ValueError.
The operator module contains two functions that are equivalent to the **-operator:
import operator
operator.pow(4, 2)
operator.__pow__(4, 3)
# 16
# 64
or one could directly call the __pow__ method:
val1, val2 = 4, 2
val1.__pow__(val2)
# 16
val2.__rpow__(val1)
# 16
# in-place power operation isn't supported by immutable classes like int, float, complex:
# val1.__ipow__(val2)
Section 70.2: Square root: math.sqrt() and cmath.sqrt
The math module contains the math.sqrt()-function that can compute the square root of any number (that can be
converted to a float) and the result will always be a float:
import math
math.sqrt(9)
math.sqrt(11.11)
math.sqrt(Decimal('6.25'))
# 3.0
# 3.3331666624997918
# 2.5
The math.sqrt() function raises a ValueError if the result would be complex:
GoalKicker.com – Python® Notes for Professionals
365math.sqrt(-10)
ValueError: math domain error
math.sqrt(x) is faster than math.pow(x, 0.5) or x ** 0.5 but the precision of the results is the same. The cmath
module is extremely similar to the math module, except for the fact it can compute complex numbers and all of its
results are in the form of a + bi. It can also use .sqrt():
import cmath
cmath.sqrt(4) # 2+0j
cmath.sqrt(-4) # 2j
What's with the j? j is the equivalent to the square root of -1. All numbers can be put into the form a + bi, or in this
case, a + bj. a is the real part of the number like the 2 in 2+0j. Since it has no imaginary part, b is 0. b represents
part of the imaginary part of the number like the 2 in 2j. Since there is no real part in this, 2j can also be written as
0 + 2j.
Section 70.3: Modular exponentiation: pow() with 3 arguments
Supplying pow() with 3 arguments pow(a, b, c) evaluates the modular exponentiation ab mod c:
pow(3, 4, 17)
# 13
# equivalent unoptimized expression:
3 ** 4 % 17
# 13
# steps:
3 ** 4
81 % 17
# 81
# 13
For built-in types using modular exponentiation is only possible if:
First argument is an int
Second argument is an int >= 0
Third argument is an int != 0
These restrictions are also present in python 3.x
For example one can use the 3-argument form of pow to deﬁne a modular inverse function:
def modular_inverse(x, p):
"""Find a such as a·x ≡ 1 (mod p), assuming p is prime."""
return pow(x, p-2, p)
[modular_inverse(x, 13) for x in range(1,13)]
# Out: [1, 7, 9, 10, 8, 11, 2, 5, 3, 4, 6, 12]
Section 70.4: Computing large integer roots
Even though Python natively supports big integers, taking the nth root of very large numbers can fail in Python.
x = 2 ** 100
cube = x ** 3
GoalKicker.com – Python® Notes for Professionals
366root = cube ** (1.0 / 3)
OverﬂowError: long int too large to convert to ﬂoat
When dealing with such large integers, you will need to use a custom function to compute the nth root of a
number.
def nth_root(x, n):
# Start with some reasonable bounds around the nth root.
upper_bound = 1
while upper_bound ** n <= x:
upper_bound *= 2
lower_bound = upper_bound // 2
# Keep searching for a better result as long as the bounds make sense.
while lower_bound < upper_bound:
mid = (lower_bound + upper_bound) // 2
mid_nth = mid ** n
if lower_bound < mid and mid_nth < x:
lower_bound = mid
elif upper_bound > mid and mid_nth > x:
upper_bound = mid
else:
# Found perfect nth root.
return mid
return mid + 1
x = 2 ** 100
cube = x ** 3
root = nth_root(cube, 3)
x == root
# True
Section 70.5: Exponentiation using the math module:
math.pow()
The math-module contains another math.pow() function. The diﬀerence to the builtin pow()-function or ** operator
is that the result is always a float:
import math
math.pow(2, 2)
math.pow(-2., 2)
# 4.0
# 4.0
Which excludes computations with complex inputs:
math.pow(2, 2+0j)
TypeError: can't convert complex to ﬂoat
and computations that would lead to complex results:
math.pow(-2, 0.5)
ValueError: math domain error
GoalKicker.com – Python® Notes for Professionals
367Section 70.6: Exponential function: math.exp() and
cmath.exp()
Both the math and cmath-module contain the Euler number: e and using it with the builtin pow()-function or **-
operator works mostly like math.exp():
import math
math.e ** 2
math.exp(2)
# 7.3890560989306495
# 7.38905609893065
import cmath
cmath.e ** 2 # 7.3890560989306495
cmath.exp(2) # (7.38905609893065+0j)
However the result is diﬀerent and using the exponential function directly is more reliable than builtin
exponentiation with base math.e:
print(math.e ** 10)
# 22026.465794806703
print(math.exp(10))
# 22026.465794806718
print(cmath.exp(10).real) # 22026.465794806718
#
difference starts here ---------------^
Section 70.7: Exponential function minus 1: math.expm1()
The math module contains the expm1()-function that can compute the expression math.e ** x - 1 for very small x
with higher precision than math.exp(x) or cmath.exp(x) would allow:
import math
print(math.e ** 1e-3 - 1)
print(math.exp(1e-3) - 1)
print(math.expm1(1e-3))
#
# 0.0010005001667083846
# 0.0010005001667083846
# 0.0010005001667083417
------------------^
For very small x the diﬀerence gets bigger:
print(math.e ** 1e-15 - 1) # 1.1102230246251565e-15
print(math.exp(1e-15) - 1) # 1.1102230246251565e-15
print(math.expm1(1e-15))
# 1.0000000000000007e-15
#
^-------------------
The improvement is signiﬁcant in scientiﬁc computing. For example the Planck's law contains an exponential
function minus 1:
def planks_law(lambda_, T):
from scipy.constants import h, k, c # If no scipy installed hardcode these!
return 2 * h * c ** 2 / (lambda_ ** 5 * math.expm1(h * c / (lambda_ * k * T)))
def planks_law_naive(lambda_, T):
from scipy.constants import h, k, c # If no scipy installed hardcode these!
return 2 * h * c ** 2 / (lambda_ ** 5 * (math.e ** (h * c / (lambda_ * k * T)) - 1))
planks_law(100, 5000)
planks_law_naive(100, 5000)
#
# 4.139080074896474e-19
# 4.139080073488451e-19
^----------
GoalKicker.com – Python® Notes for Professionals
368planks_law(1000, 5000)
# 4.139080128493406e-23
planks_law_naive(1000, 5000) # 4.139080233183142e-23
#
^------------
Section 70.8: Magic methods and exponentiation: builtin,
math and cmath
Supposing you have a class that stores purely integer values:
class Integer(object):
def __init__(self, value):
self.value = int(value) # Cast to an integer
def __repr__(self):
return '{cls}({val})'.format(cls=self.__class__.__name__,
val=self.value)
def __pow__(self, other, modulo=None):
if modulo is None:
print('Using __pow__')
return self.__class__(self.value ** other)
else:
print('Using __pow__ with modulo')
return self.__class__(pow(self.value, other, modulo))
def __float__(self):
print('Using __float__')
return float(self.value)
def __complex__(self):
print('Using __complex__')
return complex(self.value, 0)
Using the builtin pow function or ** operator always calls __pow__:
Integer(2) ** 2
# Integer(4)
# Prints: Using __pow__
Integer(2) ** 2.5
# Integer(5)
# Prints: Using __pow__
pow(Integer(2), 0.5)
# Integer(1)
# Prints: Using __pow__
operator.pow(Integer(2), 3)
# Integer(8)
# Prints: Using __pow__
operator.__pow__(Integer(3), 3) # Integer(27)
# Prints: Using __pow__
The second argument of the __pow__() method can only be supplied by using the builtin-pow() or by directly calling
the method:
pow(Integer(2), 3, 4)
# Integer(0)
# Prints: Using __pow__ with modulo
Integer(2).__pow__(3, 4)
# Integer(0)
# Prints: Using __pow__ with modulo
While the math-functions always convert it to a float and use the ﬂoat-computation:
import math
GoalKicker.com – Python® Notes for Professionals
369math.pow(Integer(2), 0.5) # 1.4142135623730951
# Prints: Using __float__
cmath-functions try to convert it to complex but can also fallback to float if there is no explicit conversion to
complex:
import cmath
cmath.exp(Integer(2))
# (7.38905609893065+0j)
# Prints: Using __complex__
del Integer.__complex__
# Deleting __complex__ method - instances cannot be cast to complex
cmath.exp(Integer(2))
# (7.38905609893065+0j)
# Prints: Using __float__
Neither math nor cmath will work if also the __float__()-method is missing:
del Integer.__float__# Deleting __complex__ method
math.sqrt(Integer(2))# also cmath.exp(Integer(2))
TypeError: a ﬂoat is required
Section 70.9: Roots: nth-root with fractional exponents
While the math.sqrt function is provided for the speciﬁc case of square roots, it's often convenient to use the
exponentiation operator (**) with fractional exponents to perform nth-root operations, like cube roots.
The inverse of an exponentiation is exponentiation by the exponent's reciprocal. So, if you can cube a number by
putting it to the exponent of 3, you can ﬁnd the cube root of a number by putting it to the exponent of 1/3.
>>> x = 3
>>> y = x ** 3
>>> y
27
>>> z = y ** (1.0 / 3)
>>> z
3.0
>>> z == x
True
GoalKicker.com – Python® Notes for Professionals
370Chapter 71: Searching
Section 71.1: Searching for an element
All built-in collections in Python implement a way to check element membership using in.
List
alist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
5 in alist
# True
10 in alist # False
Tuple
atuple = ('0', '1', '2', '3', '4')
4 in atuple
# False
'4' in atuple # True
String
astring = 'i am a string'
'a' in astring
# True
'am' in astring # True
'I' in astring
# False
Set
aset = {(10, 10), (20, 20), (30, 30)}
(10, 10) in aset # True
10 in aset
# False
Dict
dict is a bit special: the normal in only checks the keys. If you want to search in values you need to specify it. The
same if you want to search for key-value pairs.
adict = {0: 'a', 1: 'b', 2: 'c', 3: 'd'}
1 in adict
# True
- implicitly searches in keys
'a' in adict
# False
2 in adict.keys()
# True
- explicitly searches in keys
'a' in adict.values()
# True
- explicitly searches in values
(0, 'a') in adict.items() # True
- explicitly searches key/value pairs
Section 71.2: Searching in custom classes: __contains__ and
__iter__
To allow the use of in for custom classes the class must either provide the magic method __contains__ or, failing
that, an __iter__-method.
Suppose you have a class containing a list of lists:
class ListList:
def __init__(self, value):
self.value = value
# Create a set of all values for fast access
self.setofvalues = set(item for sublist in self.value for item in sublist)
def __iter__(self):
print('Using __iter__.')
# A generator over all sublist elements
return (item for sublist in self.value for item in sublist)
GoalKicker.com – Python® Notes for Professionals
371def __contains__(self, value):
print('Using __contains__.')
# Just lookup if the value is in the set
return value in self.setofvalues
# Even without the set you could use the iter method for the contains-check:
# return any(item == value for item in iter(self))
Using membership testing is possible using in:
a = ListList([[1,1,1],[0,1,1],[1,5,1]])
10 in a
# False
# Prints: Using __contains__.
5 in a
# True
# Prints: Using __contains__.
even after deleting the __contains__ method:
del ListList.__contains__
5 in a
# True
# Prints: Using __iter__.
Note: The looping in (as in for i in a) will always use __iter__ even if the class implements a __contains__
method.
Section 71.3: Getting the index for strings: str.index(),
str.rindex() and str.ﬁnd(), str.rﬁnd()
String also have an index method but also more advanced options and the additional str.find. For both of these
there is a complementary reversed method.
astring = 'Hello on StackOverflow'
astring.index('o') # 4
astring.rindex('o') # 20
astring.find('o')
astring.rfind('o')
# 4
# 20
The diﬀerence between index/rindex and find/rfind is what happens if the substring is not found in the string:
astring.index('q') # ValueError: substring not found
astring.find('q') # -1
All of these methods allow a start and end index:
astring.index('o', 5)
# 6
astring.index('o', 6)
# 6 - start is inclusive
astring.index('o', 5, 7) # 6
astring.index('o', 5, 6) # - end is not inclusive
ValueError: substring not found
astring.rindex('o', 20) # 20
astring.rindex('o', 19) # 20 - still from left to right
GoalKicker.com – Python® Notes for Professionals
372astring.rindex('o', 4, 7) # 6
Section 71.4: Getting the index list and tuples: list.index(),
tuple.index()
list and tuple have an index-method to get the position of the element:
alist = [10, 16, 26, 5, 2, 19, 105, 26]
# search for 16 in the list
alist.index(16) # 1
alist[1]
# 16
alist.index(15)
ValueError: 15 is not in list
But only returns the position of the ﬁrst found element:
atuple = (10, 16, 26, 5, 2, 19, 105, 26)
atuple.index(26)
# 2
atuple[2]
# 26
atuple[7]
# 26 - is also 26!
Section 71.5: Searching key(s) for a value in dict
dict have no builtin method for searching a value or key because dictionaries are unordered. You can create a
function that gets the key (or keys) for a speciﬁed value:
def getKeysForValue(dictionary, value):
foundkeys = []
for keys in dictionary:
if dictionary[key] == value:
foundkeys.append(key)
return foundkeys
This could also be written as an equivalent list comprehension:
def getKeysForValueComp(dictionary, value):
return [key for key in dictionary if dictionary[key] == value]
If you only care about one found key:
def getOneKeyForValue(dictionary, value):
return next(key for key in dictionary if dictionary[key] == value)
The ﬁrst two functions will return a list of all keys that have the speciﬁed value:
adict = {'a': 10, 'b': 20, 'c': 10}
getKeysForValue(adict, 10)
# ['c', 'a'] - order is random could as well be ['a', 'c']
getKeysForValueComp(adict, 10) # ['c', 'a'] - dito
getKeysForValueComp(adict, 20) # ['b']
getKeysForValueComp(adict, 25) # []
The other one will only return one key:
GoalKicker.com – Python® Notes for Professionals
373getOneKeyForValue(adict, 10)
getOneKeyForValue(adict, 20)
# 'c'
# 'b'
- depending on the circumstances this could also be 'a'
and raise a StopIteration-Exception if the value is not in the dict:
getOneKeyForValue(adict, 25)
StopIteration
Section 71.6: Getting the index for sorted sequences:
bisect.bisect_left()
Sorted sequences allow the use of faster searching algorithms: bisect.bisect_left()1:
import bisect
def index_sorted(sorted_seq, value):
"""Locate the leftmost value exactly equal to x or raise a ValueError"""
i = bisect.bisect_left(sorted_seq, value)
if i != len(sorted_seq) and sorted_seq[i] == value:
return i
raise ValueError
alist = [i for i in range(1, 100000, 3)] # Sorted list from 1 to 100000 with step 3
index_sorted(alist, 97285) # 32428
index_sorted(alist, 4)
# 1
index_sorted(alist, 97286)
ValueError
For very large sorted sequences the speed gain can be quite high. In case for the ﬁrst search approximately 500
times as fast:
%timeit index_sorted(alist, 97285)
# 100000 loops, best of 3: 3 µs per loop
%timeit alist.index(97285)
# 1000 loops, best of 3: 1.58 ms per loop
While it's a bit slower if the element is one of the very ﬁrst:
%timeit index_sorted(alist, 4)
# 100000 loops, best of 3: 2.98 µs per loop
%timeit alist.index(4)
# 1000000 loops, best of 3: 580 ns per loop
Section 71.7: Searching nested sequences
Searching in nested sequences like a list of tuple requires an approach like searching the keys for values in dict
but needs customized functions.
The index of the outermost sequence if the value was found in the sequence:
GoalKicker.com – Python® Notes for Professionals
374def outer_index(nested_sequence, value):
return next(index for index, inner in enumerate(nested_sequence)
for item in inner
if item == value)
alist_of_tuples = [(4, 5, 6), (3, 1, 'a'), (7, 0, 4.3)]
outer_index(alist_of_tuples, 'a') # 1
outer_index(alist_of_tuples, 4.3) # 2
or the index of the outer and inner sequence:
def outer_inner_index(nested_sequence, value):
return next((oindex, iindex) for oindex, inner in enumerate(nested_sequence)
for iindex, item in enumerate(inner)
if item == value)
outer_inner_index(alist_of_tuples, 'a') # (1, 2)
alist_of_tuples[1][2] # 'a'
outer_inner_index(alist_of_tuples, 7)
alist_of_tuples[2][0] # 7
# (2, 0)
In general (not always) using next and a generator expression with conditions to ﬁnd the ﬁrst occurrence of the
searched value is the most eﬃcient approach.
GoalKicker.com – Python® Notes for Professionals
375Chapter 72: Sorting, Minimum and
Maximum
Section 72.1: Make custom classes orderable
min, max, and sorted all need the objects to be orderable. To be properly orderable, the class needs to deﬁne all of
the 6 methods __lt__, __gt__, __ge__, __le__, __ne__ and __eq__:
class IntegerContainer(object):
def __init__(self, value):
self.value = value
def __repr__(self):
return "{}({})".format(self.__class__.__name__, self.value)
def __lt__(self, other):
print('{!r} - Test less than {!r}'.format(self, other))
return self.value < other.value
def __le__(self, other):
print('{!r} - Test less than or equal to {!r}'.format(self, other))
return self.value <= other.value
def __gt__(self, other):
print('{!r} - Test greater than {!r}'.format(self, other))
return self.value > other.value
def __ge__(self, other):
print('{!r} - Test greater than or equal to {!r}'.format(self, other))
return self.value >= other.value
def __eq__(self, other):
print('{!r} - Test equal to {!r}'.format(self, other))
return self.value == other.value
def __ne__(self, other):
print('{!r} - Test not equal to {!r}'.format(self, other))
return self.value != other.value
Though implementing all these methods would seem unnecessary, omitting some of them will make your code
prone to bugs.
Examples:
alist = [IntegerContainer(5), IntegerContainer(3),
IntegerContainer(10), IntegerContainer(7)
]
res = max(alist)
# Out: IntegerContainer(3) - Test greater than IntegerContainer(5)
#
IntegerContainer(10) - Test greater than IntegerContainer(5)
#
IntegerContainer(7) - Test greater than IntegerContainer(10)
print(res)
# Out: IntegerContainer(10)
res = min(alist)
# Out: IntegerContainer(3) - Test less than IntegerContainer(5)
#
IntegerContainer(10) - Test less than IntegerContainer(3)
GoalKicker.com – Python® Notes for Professionals
376#
IntegerContainer(7) - Test less than IntegerContainer(3)
print(res)
# Out: IntegerContainer(3)
res = sorted(alist)
# Out: IntegerContainer(3) - Test less than IntegerContainer(5)
#
IntegerContainer(10) - Test less than IntegerContainer(3)
#
IntegerContainer(10) - Test less than IntegerContainer(5)
#
IntegerContainer(7) - Test less than IntegerContainer(5)
#
IntegerContainer(7) - Test less than IntegerContainer(10)
print(res)
# Out: [IntegerContainer(3), IntegerContainer(5), IntegerContainer(7), IntegerContainer(10)]
sorted with reverse=True also uses __lt__:
res = sorted(alist, reverse=True)
# Out: IntegerContainer(10) - Test less than IntegerContainer(7)
#
IntegerContainer(3) - Test less than IntegerContainer(10)
#
IntegerContainer(3) - Test less than IntegerContainer(10)
#
IntegerContainer(3) - Test less than IntegerContainer(7)
#
IntegerContainer(5) - Test less than IntegerContainer(7)
#
IntegerContainer(5) - Test less than IntegerContainer(3)
print(res)
# Out: [IntegerContainer(10), IntegerContainer(7), IntegerContainer(5), IntegerContainer(3)]
But sorted can use __gt__ instead if the default is not implemented:
del IntegerContainer.__lt__
# The IntegerContainer no longer implements "less than"
res = min(alist)
# Out: IntegerContainer(5) - Test greater than IntegerContainer(3)
#
IntegerContainer(3) - Test greater than IntegerContainer(10)
#
IntegerContainer(3) - Test greater than IntegerContainer(7)
print(res)
# Out: IntegerContainer(3)
Sorting methods will raise a TypeError if neither __lt__ nor __gt__ are implemented:
del IntegerContainer.__gt__
# The IntegerContainer no longer implements "greater then"
res = min(alist)
TypeError: unorderable types: IntegerContainer() < IntegerContainer()
functools.total_ordering decorator can be used simplifying the eﬀort of writing these rich comparison methods.
If you decorate your class with total_ordering, you need to implement __eq__, __ne__ and only one of the __lt__,
__le__, __ge__ or __gt__, and the decorator will ﬁll in the rest:
import functools
@functools.total_ordering
class IntegerContainer(object):
def __init__(self, value):
self.value = value
def __repr__(self):
return "{}({})".format(self.__class__.__name__, self.value)
GoalKicker.com – Python® Notes for Professionals
377def __lt__(self, other):
print('{!r} - Test less than {!r}'.format(self, other))
return self.value < other.value
def __eq__(self, other):
print('{!r} - Test equal to {!r}'.format(self, other))
return self.value == other.value
def __ne__(self, other):
print('{!r} - Test not equal to {!r}'.format(self, other))
return self.value != other.value
IntegerContainer(5) > IntegerContainer(6)
# Output: IntegerContainer(5) - Test less than IntegerContainer(6)
# Returns: False
IntegerContainer(6) > IntegerContainer(5)
# Output: IntegerContainer(6) - Test less than IntegerContainer(5)
# Output: IntegerContainer(6) - Test equal to IntegerContainer(5)
# Returns True
Notice how the > (greater than) now ends up calling the less than method, and in some cases even the __eq__
method. This also means that if speed is of great importance, you should implement each rich comparison method
yourself.
Section 72.2: Special case: dictionaries
Getting the minimum or maximum or using sorted depends on iterations over the object. In the case of dict, the
iteration is only over the keys:
adict = {'a': 3, 'b': 5, 'c': 1}
min(adict)
# Output: 'a'
max(adict)
# Output: 'c'
sorted(adict)
# Output: ['a', 'b', 'c']
To keep the dictionary structure, you have to iterate over the .items():
min(adict.items())
# Output: ('a', 3)
max(adict.items())
# Output: ('c', 1)
sorted(adict.items())
# Output: [('a', 3), ('b', 5), ('c', 1)]
For sorted, you could create an OrderedDict to keep the sorting while having a dict-like structure:
from collections import OrderedDict
OrderedDict(sorted(adict.items()))
# Output: OrderedDict([('a', 3), ('b', 5), ('c', 1)])
res = OrderedDict(sorted(adict.items()))
res['a']
# Output: 3
By value
GoalKicker.com – Python® Notes for Professionals
378Again this is possible using the key argument:
min(adict.items(), key=lambda x: x[1])
# Output: ('c', 1)
max(adict.items(), key=operator.itemgetter(1))
# Output: ('b', 5)
sorted(adict.items(), key=operator.itemgetter(1), reverse=True)
# Output: [('b', 5), ('a', 3), ('c', 1)]
Section 72.3: Using the key argument
Finding the minimum/maximum of a sequence of sequences is possible:
list_of_tuples = [(0, 10), (1, 15), (2, 8)]
min(list_of_tuples)
# Output: (0, 10)
but if you want to sort by a speciﬁc element in each sequence use the key-argument:
min(list_of_tuples, key=lambda x: x[0])
# Output: (0, 10)# Sorting by first element
min(list_of_tuples, key=lambda x: x[1])
# Output: (2, 8)# Sorting by second element
sorted(list_of_tuples, key=lambda x: x[0])
# Output: [(0, 10), (1, 15), (2, 8)]# Sorting by first element (increasing)
sorted(list_of_tuples, key=lambda x: x[1])
# Output: [(2, 8), (0, 10), (1, 15)]# Sorting by first element
import operator
# The operator module contains efficient alternatives to the lambda function
max(list_of_tuples, key=operator.itemgetter(0)) # Sorting by first element
# Output: (2, 8)
max(list_of_tuples, key=operator.itemgetter(1)) # Sorting by second element
# Output: (1, 15)
sorted(list_of_tuples, key=operator.itemgetter(0), reverse=True) # Reversed (decreasing)
# Output: [(2, 8), (1, 15), (0, 10)]
sorted(list_of_tuples, key=operator.itemgetter(1), reverse=True) # Reversed(decreasing)
# Output: [(1, 15), (0, 10), (2, 8)]
Section 72.4: Default Argument to max, min
You can't pass an empty sequence into max or min:
min([])
ValueError: min() arg is an empty sequence
However, with Python 3, you can pass in the keyword argument default with a value that will be returned if the
sequence is empty, instead of raising an exception:
GoalKicker.com – Python® Notes for Professionals
379max([], default=42)
# Output: 42
max([], default=0)
# Output: 0
Section 72.5: Getting a sorted sequence
Using one sequence:
sorted((7, 2, 1, 5))
# Output: [1, 2, 5, 7]# tuple
sorted(['c', 'A', 'b'])
# Output: ['A', 'b', 'c']# list
sorted({11, 8, 1})
# Output: [1, 8, 11]# set
sorted({'11': 5, '3': 2, '10': 15}) # dict
# Output: ['10', '11', '3']
# only iterates over the keys
sorted('bdca')
# Output: ['a','b','c','d']
# string
The result is always a new list; the original data remains unchanged.
Section 72.6: Extracting N largest or N smallest items from an
iterable
To ﬁnd some number (more than one) of largest or smallest values of an iterable, you can use the nlargest and
nsmallest of the heapq module:
import heapq
# get 5 largest items from the range
heapq.nlargest(5, range(10))
# Output: [9, 8, 7, 6, 5]
heapq.nsmallest(5, range(10))
# Output: [0, 1, 2, 3, 4]
This is much more eﬃcient than sorting the whole iterable and then slicing from the end or beginning. Internally
these functions use the binary heap priority queue data structure, which is very eﬃcient for this use case.
Like min, max and sorted, these functions accept the optional key keyword argument, which must be a function
that, given an element, returns its sort key.
Here is a program that extracts 1000 longest lines from a ﬁle:
import heapq
with open(filename) as f:
longest_lines = heapq.nlargest(1000, f, key=len)
Here we open the ﬁle, and pass the ﬁle handle f to nlargest. Iterating the ﬁle yields each line of the ﬁle as a
separate string; nlargest then passes each element (or line) is passed to the function len to determine its sort key.
GoalKicker.com – Python® Notes for Professionals
380len, given a string, returns the length of the line in characters.
This only needs storage for a list of 1000 largest lines so far, which can be contrasted with
longest_lines = sorted(f, key=len)[1000:]
which will have to hold the entire ﬁle in memory.
Section 72.7: Getting the minimum or maximum of several
values
min(7,2,1,5)
# Output: 1
max(7,2,1,5)
# Output: 7
Section 72.8: Minimum and Maximum of a sequence
Getting the minimum of a sequence (iterable) is equivalent of accessing the ﬁrst element of a sorted sequence:
min([2, 7, 5])
# Output: 2
sorted([2, 7, 5])[0]
# Output: 2
The maximum is a bit more complicated, because sorted keeps order and max returns the ﬁrst encountered value.
In case there are no duplicates the maximum is the same as the last element of the sorted return:
max([2, 7, 5])
# Output: 7
sorted([2, 7, 5])[-1]
# Output: 7
But not if there are multiple elements that are evaluated as having the maximum value:
class MyClass(object):
def __init__(self, value, name):
self.value = value
self.name = name
def __lt__(self, other):
return self.value < other.value
def __repr__(self):
return str(self.name)
sorted([MyClass(4, 'first'), MyClass(1, 'second'), MyClass(4, 'third')])
# Output: [second, first, third]
max([MyClass(4, 'first'), MyClass(1, 'second'), MyClass(4, 'third')])
# Output: first
Any iterable containing elements that support < or > operations are allowed.
GoalKicker.com – Python® Notes for Professionals
381Chapter 73: Counting
Section 73.1: Counting all occurrence of all items in an
iterable: collections.Counter
from collections import Counter
c = Counter(["a", "b", "c", "d", "a", "b", "a", "c", "d"])
c
# Out: Counter({'a': 3, 'b': 2, 'c': 2, 'd': 2})
c["a"]
# Out: 3
c[7]
# not in the list (7 occurred 0 times!)
# Out: 0
The collections.Counter can be used for any iterable and counts every occurrence for every element.
Note: One exception is if a dict or another collections.Mapping-like class is given, then it will not count them,
rather it creates a Counter with these values:
Counter({"e": 2})
# Out: Counter({"e": 2})
Counter({"e": "e"})
# warning Counter does not verify the values are int
# Out: Counter({"e": "e"})
Section 73.2: Getting the most common value(-s):
collections.Counter.most_common()
Counting the keys of a Mapping isn't possible with collections.Counter but we can count the values:
from collections import Counter
adict = {'a': 5, 'b': 3, 'c': 5, 'd': 2, 'e':2, 'q': 5}
Counter(adict.values())
# Out: Counter({2: 2, 3: 1, 5: 3})
The most common elements are available by the most_common-method:
# Sorting them from most-common to least-common value:
Counter(adict.values()).most_common()
# Out: [(5, 3), (2, 2), (3, 1)]
# Getting the most common value
Counter(adict.values()).most_common(1)
# Out: [(5, 3)]
# Getting the two most common values
Counter(adict.values()).most_common(2)
# Out: [(5, 3), (2, 2)]
Section 73.3: Counting the occurrences of one item in a
sequence: list.count() and tuple.count()
alist = [1, 2, 3, 4, 1, 2, 1, 3, 4]
GoalKicker.com – Python® Notes for Professionals
382alist.count(1)
# Out: 3
atuple = ('bear', 'weasel', 'bear', 'frog')
atuple.count('bear')
# Out: 2
atuple.count('fox')
# Out: 0
Section 73.4: Counting the occurrences of a substring in a
string: str.count()
astring = 'thisisashorttext'
astring.count('t')
# Out: 4
This works even for substrings longer than one character:
astring.count('th')
# Out: 1
astring.count('is')
# Out: 2
astring.count('text')
# Out: 1
which would not be possible with collections.Counter which only counts single characters:
from collections import Counter
Counter(astring)
# Out: Counter({'a': 1, 'e': 1, 'h': 2, 'i': 2, 'o': 1, 'r': 1, 's': 3, 't': 4, 'x': 1})
Section 73.5: Counting occurrences in numpy array
To count the occurrences of a value in a numpy array. This will work:
>>> import numpy as np
>>> a=np.array([0,3,4,3,5,4,7])
>>> print np.sum(a==3)
2
The logic is that the boolean statement produces a array where all occurrences of the requested values are 1 and
all others are zero. So summing these gives the number of occurencies. This works for arrays of any shape or dtype.
There are two methods I use to count occurrences of all unique values in numpy. Unique and bincount. Unique
automatically ﬂattens multidimensional arrays, while bincount only works with 1d arrays only containing positive
integers.
>>> unique,counts=np.unique(a,return_counts=True)
>>> print unique,counts # counts[i] is equal to occurrences of unique[i] in a
[0 3 4 5 7] [1 2 2 1 1]
>>> bin_count=np.bincount(a)
>>> print bin_count # bin_count[i] is equal to occurrences of i in a
[1 0 0 2 2 1 0 1]
If your data are numpy arrays it is generally much faster to use numpy methods then to convert your data to
generic methods.
GoalKicker.com – Python® Notes for Professionals
383Chapter 74: The Print Function
Section 74.1: Print basics
In Python 3 and higher, print is a function rather than a keyword.
print('hello world!')
# out: hello world!
foo = 1
bar = 'bar'
baz = 3.14
print(foo)
# out: 1
print(bar)
# out: bar
print(baz)
# out: 3.14
You can also pass a number of parameters to print:
print(foo, bar, baz)
# out: 1 bar 3.14
Another way to print multiple parameters is by using a +
print(str(foo) + " " + bar + " " + str(baz))
# out: 1 bar 3.14
What you should be careful about when using + to print multiple parameters, though, is that the type of the
parameters should be the same. Trying to print the above example without the cast to string ﬁrst would result in
an error, because it would try to add the number 1 to the string "bar" and add that to the number 3.14.
# Wrong:
# type:int str float
print(foo + bar + baz)
# will result in an error
This is because the content of print will be evaluated ﬁrst:
print(4 + 5)
# out: 9
print("4" + "5")
# out: 45
print([4] + [5])
# out: [4, 5]
Otherwise, using a + can be very helpful for a user to read output of variables In the example below the output is
very easy to read!
The script below demonstrates this
import random
#telling python to include a function to create random numbers
randnum = random.randint(0, 12)
GoalKicker.com – Python® Notes for Professionals
384#make a random number between 0 and 12 and assign it to a variable
print("The randomly generated number was - " + str(randnum))
You can prevent the print function from automatically printing a newline by using the end parameter:
print("this has no newline at the end of it... ", end="")
print("see?")
# out: this has no newline at the end of it... see?
If you want to write to a ﬁle, you can pass it as the parameter file:
with open('my_file.txt', 'w+') as my_file:
print("this goes to the file!", file=my_file)
this goes to the ﬁle!
Section 74.2: Print parameters
You can do more than just print text. print also has several parameters to help you.
Argument sep: place a string between arguments.
Do you need to print a list of words separated by a comma or some other string?
>>> print('apples','bananas', 'cherries', sep=', ')
apple, bananas, cherries
>>> print('apple','banana', 'cherries', sep=', ')
apple, banana, cherries
>>>
Argument end: use something other than a newline at the end
Without the end argument, all print() functions write a line and then go to the beginning of the next line. You can
change it to do nothing (use an empty string of ''), or double spacing between paragraphs by using two newlines.
>>> print("<a", end=''); print(" class='jidn'" if 1 else "", end=''); print("/>")
<a class='jidn'/>
>>> print("paragraph1", end="\n\n"); print("paragraph2")
paragraph1
paragraph2
>>>
Argument file: send output to someplace other than sys.stdout.
Now you can send your text to either stdout, a ﬁle, or StringIO and not care which you are given. If it quacks like a
ﬁle, it works like a ﬁle.
>>> def sendit(out, *values, sep=' ', end='\n'):
...
print(*values, sep=sep, end=end, file=out)
...
>>> sendit(sys.stdout, 'apples', 'bananas', 'cherries', sep='\t')
apples
bananas
cherries
>>> with open("delete-me.txt", "w+") as f:
...
sendit(f, 'apples', 'bananas', 'cherries', sep=' ', end='\n')
GoalKicker.com – Python® Notes for Professionals
385...
>>> with open("delete-me.txt", "rt") as f:
...
print(f.read())
...
apples bananas cherries
>>>
There is a fourth parameter flush which will forcibly ﬂush the stream.
GoalKicker.com – Python® Notes for Professionals
386VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 75: Regular Expressions (Regex)
Python makes regular expressions available through the re module.
Regular expressions are combinations of characters that are interpreted as rules for matching substrings. For
instance, the expression 'amount\D+\d+' will match any string composed by the word amount plus an integral
number, separated by one or more non-digits, such as:amount=100, amount is 3, amount is equal to: 33, etc.
Section 75.1: Matching the beginning of a string
The ﬁrst argument of re.match() is the regular expression, the second is the string to match:
import re
pattern = r"123"
string = "123zzb"
re.match(pattern, string)
# Out: <_sre.SRE_Match object; span=(0, 3), match='123'>
match = re.match(pattern, string)
match.group()
# Out: '123'
You may notice that the pattern variable is a string preﬁxed with r, which indicates that the string is a raw string
literal.
A raw string literal has a slightly diﬀerent syntax than a string literal, namely a backslash \ in a raw string literal
means "just a backslash" and there's no need for doubling up backlashes to escape "escape sequences" such as
newlines (\n), tabs (\t), backspaces (\), form-feeds (\r), and so on. In normal string literals, each backslash must be
doubled up to avoid being taken as the start of an escape sequence.
Hence, r"\n" is a string of 2 characters: \ and n. Regex patterns also use backslashes, e.g. \d refers to any digit
character. We can avoid having to double escape our strings ("\\d") by using raw strings (r"\d").
For instance:
string = "\\t123zzb" # here the backslash is escaped, so there's no tab, just '\' and 't'
pattern = "\\t123"
# this will match \t (escaping the backslash) followed by 123
re.match(pattern, string).group()
# no match
re.match(pattern, "\t123zzb").group() # matches '\t123'
pattern = r"\\t123"
re.match(pattern, string).group()
# matches '\\t123'
Matching is done from the start of the string only. If you want to match anywhere use re.search instead:
match = re.match(r"(123)", "a123zzb")
match is None
# Out: True
match = re.search(r"(123)", "a123zzb")
match.group()
GoalKicker.com – Python® Notes for Professionals
388# Out: '123'
Section 75.2: Searching
pattern = r"(your base)"
sentence = "All your base are belong to us."
match = re.search(pattern, sentence)
match.group(1)
# Out: 'your base'
match = re.search(r"(belong.*)", sentence)
match.group(1)
# Out: 'belong to us.'
Searching is done anywhere in the string unlike re.match. You can also use re.findall.
You can also search at the beginning of the string (use ^),
match = re.search(r"^123", "123zzb")
match.group(0)
# Out: '123'
match = re.search(r"^123", "a123zzb")
match is None
# Out: True
at the end of the string (use $),
match = re.search(r"123$", "zzb123")
match.group(0)
# Out: '123'
match = re.search(r"123$", "123zzb")
match is None
# Out: True
or both (use both ^ and $):
match = re.search(r"^123$", "123")
match.group(0)
# Out: '123'
Section 75.3: Precompiled patterns
import re
precompiled_pattern = re.compile(r"(\d+)")
matches = precompiled_pattern.search("The answer is 41!")
matches.group(1)
# Out: 41
matches = precompiled_pattern.search("Or was it 42?")
matches.group(1)
# Out: 42
Compiling a pattern allows it to be reused later on in a program. However, note that Python caches recently-used
GoalKicker.com – Python® Notes for Professionals
389expressions (docs, SO answer), so "programs that use only a few regular expressions at a time needn’t worry about
compiling regular expressions".
import re
precompiled_pattern = re.compile(r"(.*\d+)")
matches = precompiled_pattern.match("The answer is 41!")
print(matches.group(1))
# Out: The answer is 41
matches = precompiled_pattern.match("Or was it 42?")
print(matches.group(1))
# Out: Or was it 42
It can be used with re.match().
Section 75.4: Flags
For some special cases we need to change the behavior of the Regular Expression, this is done using ﬂags. Flags can
be set in two ways, through the flags keyword or directly in the expression.
Flags keyword
Below an example for re.search but it works for most functions in the re module.
m = re.search("b", "ABC")
m is None
# Out: True
m = re.search("b", "ABC", flags=re.IGNORECASE)
m.group()
# Out: 'B'
m = re.search("a.b", "A\nBC", flags=re.IGNORECASE)
m is None
# Out: True
m = re.search("a.b", "A\nBC", flags=re.IGNORECASE|re.DOTALL)
m.group()
# Out: 'A\nB'
Common Flags
Flag
Short Description
re.IGNORECASE, re.I Makes the pattern ignore the case
re.DOTALL, re.S
Makes . match everything including newlines
re.MULTILINE, re.M Makes ^ match the begin of a line and $ the end of a line
re.DEBUG
Turns on debug information
For the complete list of all available ﬂags check the docs
Inline ﬂags
From the docs:
(?iLmsux) (One or more letters from the set 'i', 'L', 'm', 's', 'u', 'x'.)
GoalKicker.com – Python® Notes for Professionals
390The group matches the empty string; the letters set the corresponding ﬂags: re.I (ignore case), re.L (locale
dependent), re.M (multi-line), re.S (dot matches all), re.U (Unicode dependent), and re.X (verbose), for the
entire regular expression. This is useful if you wish to include the ﬂags as part of the regular expression,
instead of passing a ﬂag argument to the re.compile() function.
Note that the (?x) ﬂag changes how the expression is parsed. It should be used ﬁrst in the expression
string, or after one or more whitespace characters. If there are non-whitespace characters before the ﬂag,
the results are undeﬁned.
Section 75.5: Replacing
Replacements can be made on strings using re.sub.
Replacing strings
re.sub(r"t[0-9][0-9]", "foo", "my name t13 is t44 what t99 ever t44")
# Out: 'my name foo is foo what foo ever foo'
Using group references
Replacements with a small number of groups can be made as follows:
re.sub(r"t([0-9])([0-9])", r"t\2\1", "t13 t19 t81 t25")
# Out: 't31 t91 t18 t52'
However, if you make a group ID like '10', this doesn't work: \10 is read as 'ID number 1 followed by 0'. So you have
to be more speciﬁc and use the \g<i> notation:
re.sub(r"t([0-9])([0-9])", r"t\g<2>\g<1>", "t13 t19 t81 t25")
# Out: 't31 t91 t18 t52'
Using a replacement function
items = ["zero", "one", "two"]
re.sub(r"a\[([0-3])\]", lambda match: items[int(match.group(1))], "Items: a[0], a[1], something,
a[2]")
# Out: 'Items: zero, one, something, two'
Section 75.6: Find All Non-Overlapping Matches
re.findall(r"[0-9]{2,3}", "some 1 text 12 is 945 here 4445588899")
# Out: ['12', '945', '444', '558', '889']
Note that the r before "[0-9]{2,3}" tells python to interpret the string as-is; as a "raw" string.
You could also use re.finditer() which works in the same way as re.findall() but returns an iterator with
SRE_Match objects instead of a list of strings:
results = re.finditer(r"([0-9]{2,3})", "some 1 text 12 is 945 here 4445588899")
print(results)
# Out: <callable-iterator object at 0x105245890>
for result in results:
print(result.group(0))
''' Out:
12
945
444
558
GoalKicker.com – Python® Notes for Professionals
391889
'''
Section 75.7: Checking for allowed characters
If you want to check that a string contains only a certain set of characters, in this case a-z, A-Z and 0-9, you can do
so like this,
import re
def is_allowed(string):
characherRegex = re.compile(r'[^a-zA-Z0-9.]')
string = characherRegex.search(string)
return not bool(string)
print (is_allowed("abyzABYZ0099"))
# Out: 'True'
print (is_allowed("#*@#$%^"))
# Out: 'False'
You can also adapt the expression line from [^a-zA-Z0-9.] to [^a-z0-9.], to disallow uppercase letters for
example.
Partial credit: http://stackoverﬂow.com/a/1325265/2697955
Section 75.8: Splitting a string using regular expressions
You can also use regular expressions to split a string. For example,
import re
data = re.split(r'\s+', 'James 94 Samantha 417 Scarlett 74')
print( data )
# Output: ['James', '94', 'Samantha', '417', 'Scarlett', '74']
Section 75.9: Grouping
Grouping is done with parentheses. Calling group() returns a string formed of the matching parenthesized
subgroups.
match.group() # Group without argument returns the entire match found
# Out: '123'
match.group(0) # Specifying 0 gives the same result as specifying no argument
# Out: '123'
Arguments can also be provided to group() to fetch a particular subgroup.
From the docs:
If there is a single argument, the result is a single string; if there are multiple arguments, the result is a
tuple with one item per argument.
Calling groups() on the other hand, returns a list of tuples containing the subgroups.
GoalKicker.com – Python® Notes for Professionals
392sentence = "This is a phone number 672-123-456-9910"
pattern = r".*(phone).*?([\d-]+)"
match = re.match(pattern, sentence)
match.groups()
# The entire match as a list of tuples of the paranthesized subgroups
# Out: ('phone', '672-123-456-9910')
m.group()
# The entire match as a string
# Out: 'This is a phone number 672-123-456-9910'
m.group(0)
# The entire match as a string
# Out: 'This is a phone number 672-123-456-9910'
m.group(1)
# Out: 'phone'
# The first parenthesized subgroup.
m.group(2)
# The second parenthesized subgroup.
# Out: '672-123-456-9910'
m.group(1, 2)
# Multiple arguments give us a tuple.
# Out: ('phone', '672-123-456-9910')
Named groups
match = re.search(r'My name is (?P<name>[A-Za-z ]+)', 'My name is John Smith')
match.group('name')
# Out: 'John Smith'
match.group(1)
# Out: 'John Smith'
Creates a capture group that can be referenced by name as well as by index.
Non-capturing groups
Using (?:) creates a group, but the group isn't captured. This means you can use it as a group, but it won't pollute
your "group space".
re.match(r'(\d+)(\+(\d+))?', '11+22').groups()
# Out: ('11', '+22', '22')
re.match(r'(\d+)(?:\+(\d+))?', '11+22').groups()
# Out: ('11', '22')
This example matches 11+22 or 11, but not 11+. This is since the + sign and the second term are grouped. On the
other hand, the + sign isn't captured.
Section 75.10: Escaping Special Characters
Special characters (like the character class brackets [ and ] below) are not matched literally:
match = re.search(r'[b]', 'a[b]c')
match.group()
# Out: 'b'
By escaping the special characters, they can be matched literally:
match = re.search(r'\[b\]', 'a[b]c')
match.group()
GoalKicker.com – Python® Notes for Professionals
393# Out: '[b]'
The re.escape() function can be used to do this for you:
re.escape('a[b]c')
# Out: 'a\\[b\\]c'
match = re.search(re.escape('a[b]c'), 'a[b]c')
match.group()
# Out: 'a[b]c'
The re.escape() function escapes all special characters, so it is useful if you are composing a regular expression
based on user input:
username = 'A.C.' # suppose this came from the user
re.findall(r'Hi {}!'.format(username), 'Hi A.C.! Hi ABCD!')
# Out: ['Hi A.C.!', 'Hi ABCD!']
re.findall(r'Hi {}!'.format(re.escape(username)), 'Hi A.C.! Hi ABCD!')
# Out: ['Hi A.C.!']
Section 75.11: Match an expression only in speciﬁc locations
Often you want to match an expression only in speciﬁc places (leaving them untouched in others, that is). Consider
the following sentence:
An apple a day keeps the doctor away (I eat an apple everyday).
Here the "apple" occurs twice which can be solved with so called backtracking control verbs which are supported by
the newer regex module. The idea is:
forget_this | or this | and this as well | (but keep this)
With our apple example, this would be:
import regex as re
string = "An apple a day keeps the doctor away (I eat an apple everyday)."
rx = re.compile(r'''
\([^()]*\) (*SKIP)(*FAIL) # match anything in parentheses and "throw it away"
|
# or
apple
# match an apple
''', re.VERBOSE)
apples = rx.findall(string)
print(apples)
# only one
This matches "apple" only when it can be found outside of the parentheses.
Here's how it works:
While looking from left to right, the regex engine consumes everything to the left, the (*SKIP) acts as an
"always-true-assertion". Afterwards, it correctly fails on (*FAIL) and backtracks.
Now it gets to the point of (*SKIP) from right to left (aka while backtracking) where it is forbidden to go any
further to the left. Instead, the engine is told to throw away anything to the left and jump to the point where
the (*SKIP) was invoked.
GoalKicker.com – Python® Notes for Professionals
394Section 75.12: Iterating over matches using `re.ﬁnditer`
You can use re.finditer to iterate over all matches in a string. This gives you (in comparison to re.findall extra
information, such as information about the match location in the string (indexes):
import re
text = 'You can try to find an ant in this string'
pattern = 'an?\w' # find 'an' either with or without a following word character
for match in re.finditer(pattern, text):
# Start index of match (integer)
sStart = match.start()
# Final index of match (integer)
sEnd = match.end()
# Complete match (string)
sGroup = match.group()
# Print match
print('Match "{}" found at: [{},{}]'.format(sGroup, sStart,sEnd))
Result:
Match "an" found at: [5,7]
Match "an" found at: [20,22]
Match "ant" found at: [23,26]
GoalKicker.com – Python® Notes for Professionals
395Chapter 76: Copying data
Section 76.1: Copy a dictionary
A dictionary object has the method copy. It performs a shallow copy of the dictionary.
>>> d1 = {1:[]}
>>> d2 = d1.copy()
>>> d1 is d2
False
>>> d1[1] is d2[1]
True
Section 76.2: Performing a shallow copy
A shallow copy is a copy of a collection without performing a copy of its elements.
>>> import copy
>>> c = [[1,2]]
>>> d = copy.copy(c)
>>> c is d
False
>>> c[0] is d[0]
True
Section 76.3: Performing a deep copy
If you have nested lists, it is desirable to clone the nested lists as well. This action is called deep copy.
>>> import copy
>>> c = [[1,2]]
>>> d = copy.deepcopy(c)
>>> c is d
False
>>> c[0] is d[0]
False
Section 76.4: Performing a shallow copy of a list
You can create shallow copies of lists using slices.
>>> l1 = [1,2,3]
>>> l2 = l1[:]
>>> l2
[1,2,3]
>>> l1 is l2
False
# Perform the shallow copy.
Section 76.5: Copy a set
Sets also have a copymethod. You can use this method to perform a shallow copy.
>>> s1 = {()}
>>> s2 = s1.copy()
>>> s1 is s2
GoalKicker.com – Python® Notes for Professionals
396False
>>> s2.add(3)
>>> s1
{[]}
>>> s2
{3,[]}
GoalKicker.com – Python® Notes for Professionals
397Chapter 77: Context Managers (“with”
Statement)
While Python's context managers are widely used, few understand the purpose behind their use. These statements,
commonly used with reading and writing ﬁles, assist the application in conserving system memory and improve
resource management by ensuring speciﬁc resources are only in use for certain processes. This topic explains and
demonstrates the use of Python's context managers.
Section 77.1: Introduction to context managers and the with
statement
A context manager is an object that is notiﬁed when a context (a block of code) starts and ends. You commonly use
one with the with statement. It takes care of the notifying.
For example, ﬁle objects are context managers. When a context ends, the ﬁle object is closed automatically:
open_file = open(filename)
with open_file:
file_contents = open_file.read()
# the open_file object has automatically been closed.
The above example is usually simpliﬁed by using the as keyword:
with open(filename) as open_file:
file_contents = open_file.read()
# the open_file object has automatically been closed.
Anything that ends execution of the block causes the context manager's exit method to be called. This includes
exceptions, and can be useful when an error causes you to prematurely exit from an open ﬁle or connection.
Exiting a script without properly closing ﬁles/connections is a bad idea, that may cause data loss or other problems.
By using a context manager you can ensure that precautions are always taken to prevent damage or loss in this
way. This feature was added in Python 2.5.
Section 77.2: Writing your own context manager
A context manager is any object that implements two magic methods __enter__() and __exit__() (although it can
implement other methods as well):
class AContextManager():
def __enter__(self):
print("Entered")
# optionally return an object
return "A-instance"
def __exit__(self, exc_type, exc_value, traceback):
print("Exited" + (" (with an exception)" if exc_type else ""))
# return True if you want to suppress the exception
If the context exits with an exception, the information about that exception will be passed as a triple exc_type,
exc_value, traceback (these are the same variables as returned by the sys.exc_info() function). If the context
GoalKicker.com – Python® Notes for Professionals
398exits normally, all three of these arguments will be None.
If an exception occurs and is passed to the __exit__ method, the method can return True in order to suppress the
exception, or the exception will be re-raised at the end of the __exit__ function.
with AContextManager() as a:
print("a is %r" % a)
# Entered
# a is 'A-instance'
# Exited
with AContextManager() as a:
print("a is %d" % a)
# Entered
# Exited (with an exception)
# Traceback (most recent call last):
#
File "<stdin>", line 2, in <module>
# TypeError: %d format: a number is required, not str
Note that in the second example even though an exception occurs in the middle of the body of the with-statement,
the __exit__ handler still gets executed, before the exception propagates to the outer scope.
If you only need an __exit__ method, you can return the instance of the context manager:
class MyContextManager:
def __enter__(self):
return self
def __exit__(self):
print('something')
Section 77.3: Writing your own contextmanager using
generator syntax
It is also possible to write a context manager using generator syntax thanks to the contextlib.contextmanager
decorator:
import contextlib
@contextlib.contextmanager
def context_manager(num):
print('Enter')
yield num + 1
print('Exit')
with context_manager(2) as cm:
# the following instructions are run when the 'yield' point of the context
# manager is reached.
# 'cm' will have the value that was yielded
print('Right in the middle with cm = {}'.format(cm))
produces:
Enter
Right in the middle with cm = 3
Exit
GoalKicker.com – Python® Notes for Professionals
399The decorator simpliﬁes the task of writing a context manager by converting a generator into one. Everything
before the yield expression becomes the __enter__ method, the value yielded becomes the value returned by the
generator (which can be bound to a variable in the with statement), and everything after the yield expression
becomes the __exit__ method.
If an exception needs to be handled by the context manager, a try..except..finally-block can be written in the
generator and any exception raised in the with-block will be handled by this exception block.
@contextlib.contextmanager
def error_handling_context_manager(num):
print("Enter")
try:
yield num + 1
except ZeroDivisionError:
print("Caught error")
finally:
print("Cleaning up")
print("Exit")
with error_handling_context_manager(-1) as cm:
print("Dividing by cm = {}".format(cm))
print(2 / cm)
This produces:
Enter
Dividing by cm = 0
Caught error
Cleaning up
Exit
Section 77.4: Multiple context managers
You can open several content managers at the same time:
with open(input_path) as input_file, open(output_path, 'w') as output_file:
# do something with both files.
# e.g. copy the contents of input_file into output_file
for line in input_file:
output_file.write(line + '\n')
It has the same eﬀect as nesting context managers:
with open(input_path) as input_file:
with open(output_path, 'w') as output_file:
for line in input_file:
output_file.write(line + '\n')
Section 77.5: Assigning to a target
Many context managers return an object when entered. You can assign that object to a new name in the with
statement.
For example, using a database connection in a with statement could give you a cursor object:
GoalKicker.com – Python® Notes for Professionals
400with database_connection as cursor:
cursor.execute(sql_query)
File objects return themselves, this makes it possible to both open the ﬁle object and use it as a context manager in
one expression:
with open(filename) as open_file:
file_contents = open_file.read()
Section 77.6: Manage Resources
class File():
def __init__(self, filename, mode):
self.filename = filename
self.mode = mode
def __enter__(self):
self.open_file = open(self.filename, self.mode)
return self.open_file
def __exit__(self, *args):
self.open_file.close()
__init__() method sets up the object, in this case setting up the ﬁle name and mode to open ﬁle. __enter__()
opens and returns the ﬁle and __exit__() just closes it.
Using these magic methods (__enter__, __exit__) allows you to implement objects which can be used easily with
the with statement.
Use File class:
for _ in range(10000):
with File('foo.txt', 'w') as f:
f.write('foo')
GoalKicker.com – Python® Notes for Professionals
401Chapter 78: The __name__ special
variable
The __name__ special variable is used to check whether a ﬁle has been imported as a module or not, and to identify
a function, class, module object by their __name__ attribute.
Section 78.1: __name__ == '__main__'
The special variable __name__ is not set by the user. It is mostly used to check whether or not the module is being
run by itself or run because an import was performed. To avoid your module to run certain parts of its code when it
gets imported, check if __name__ == '__main__'.
Let module_1.py be just one line long:
import module2.py
And let's see what happens, depending on module2.py
Situation 1
module2.py
print('hello')
Running module1.py will print hello
Running module2.py will print hello
Situation 2
module2.py
if __name__ == '__main__':
print('hello')
Running module1.py will print nothing
Running module2.py will print hello
Section 78.2: Use in logging
When conﬁguring the built-in logging functionality, a common pattern is to create a logger with the __name__ of the
current module:
logger = logging.getLogger(__name__)
This means that the fully-qualiﬁed name of the module will appear in the logs, making it easier to see where
messages have come from.
Section 78.3: function_class_or_module.__name__
The special attribute __name__ of a function, class or module is a string containing its name.
import os
GoalKicker.com – Python® Notes for Professionals
402class C:
pass
def f(x):
x += 2
return x
print(f)
# <function f at 0x029976B0>
print(f.__name__)
# f
print(C)
# <class '__main__.C'>
print(C.__name__)
# C
print(os)
# <module 'os' from '/spam/eggs/'>
print(os.__name__)
# os
The __name__ attribute is not, however, the name of the variable which references the class, method or function,
rather it is the name given to it when deﬁned.
def f():
pass
print(f.__name__)
# f - as expected
g = f
print(g.__name__)
# f - even though the variable is named g, the function is still named f
This can be used, among others, for debugging:
def enter_exit_info(func):
def wrapper(*arg, **kw):
print '-- entering', func.__name__
res = func(*arg, **kw)
print '-- exiting', func.__name__
return res
return wrapper
@enter_exit_info
def f(x):
print 'In:', x
res = x + 2
print 'Out:', res
return res
a = f(2)
# Outputs:
#
-- entering f
#
In: 2
#
Out: 4
#
-- exiting f
GoalKicker.com – Python® Notes for Professionals
403Chapter 79: Checking Path Existence and
Permissions
Parameter
Details
os.F_OK
Value to pass as the mode parameter of access() to test the existence of path.
os.R_OKValue to include in the mode parameter of access() to test the readability of path.
os.W_OKValue to include in the mode parameter of access() to test the writability of path.
os.X_OKValue to include in the mode parameter of access() to determine if path can be executed.
Section 79.1: Perform checks using os.access
os.access is much better solution to check whether directory exists and it's accessible for reading and writing.
import os
path = "/home/myFiles/directory1"
## Check if path exists
os.access(path, os.F_OK)
## Check if path is Readable
os.access(path, os.R_OK)
## Check if path is Writable
os.access(path, os.W_OK)
## Check if path is Executable
os.access(path, os.E_OK)
also it's possible to perform all checks together
os.access(path, os.F_OK & os.R_OK & os.W_OK & os.E_OK)
All the above returns True if access is allowed and False if not allowed. These are available on unix and windows.
GoalKicker.com – Python® Notes for Professionals
404VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 80: Creating Python packages
Section 80.1: Introduction
Every package requires a setup.py ﬁle which describes the package.
Consider the following directory structure for a simple package:
+-- package_name
|
|
|
+-- __init__.py
|
+-- setup.py
The __init__.py contains only the line def foo(): return 100.
The following setup.py will deﬁne the package:
from setuptools import setup
setup(
name='package_name',
version='0.1',
description='Package Description',
url='http://example.com',
install_requires=[],
packages=['package_name'],
# package name
# version
# short description
# package URL
# list of packages this package depends
# on.
# List of module names that installing
# this package will provide.
)
virtualenv is great to test package installs without modifying your other Python environments:
$ virtualenv .virtualenv
...
$ source .virtualenv/bin/activate
$ python setup.py install
running install
...
Installed .../package_name-0.1-....egg
...
$ python
>>> import package_name
>>> package_name.foo()
100
Section 80.2: Uploading to PyPI
Once your setup.py is fully functional (see Introduction), it is very easy to upload your package to PyPI.
Setup a .pypirc File
This ﬁle stores logins and passwords to authenticate your accounts. It is typically stored in your home directory.
# .pypirc file
GoalKicker.com – Python® Notes for Professionals
406[distutils]
index-servers =
pypi
pypitest
[pypi]
repository=https://pypi.python.org/pypi
username=your_username
password=your_password
[pypitest]
repository=https://testpypi.python.org/pypi
username=your_username
password=your_password
It is safer to use twine for uploading packages, so make sure that is installed.
$ pip install twine
Register and Upload to testpypi (optional)
Note: PyPI does not allow overwriting uploaded packages, so it is prudent to ﬁrst test your deployment on a
dedicated test server, e.g. testpypi. This option will be discussed. Consider a versioning scheme for your package
prior to uploading such as calendar versioning or semantic versioning.
Either log in, or create a new account at testpypi. Registration is only required the ﬁrst time, although registering
more than once is not harmful.
$ python setup.py register -r pypitest
While in the root directory of your package:
$ twine upload dist/* -r pypitest
Your package should now be accessible through your account.
Testing
Make a test virtual environment. Try to pip install your package from either testpypi or PyPI.
# Using virtualenv
$ mkdir testenv
$ cd testenv
$ virtualenv .virtualenv
...
$ source .virtualenv/bin/activate
# Test from testpypi
(.virtualenv) pip install --verbose --extra-index-url https://testpypi.python.org/pypi
package_name
...
# Or test from PyPI
(.virtualenv) $ pip install package_name
...
(.virtualenv) $ python
Python 3.5.1 (default, Jan 27 2016, 19:16:39)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import package_name
GoalKicker.com – Python® Notes for Professionals
407>>> package_name.foo()
100
If successful, your package is least importable. You might consider testing your API as well before your ﬁnal upload
to PyPI. If you package failed during testing, do not worry. You can still ﬁx it, re-upload to testpypi and test again.
Register and Upload to PyPI
Make sure twine is installed:
$ pip install twine
Either log in, or create a new account at PyPI.
$ python setup.py register -r pypi
$ twine upload dist/*
That's it! Your package is now live.
If you discover a bug, simply upload a new version of your package.
Documentation
Don't forget to include at least some kind of documentation for your package. PyPi takes as the default formatting
language reStructuredText.
Readme
If your package doesn't have a big documentation, include what can help other users in README.rst ﬁle. When the
ﬁle is ready, another one is needed to tell PyPi to show it.
Create setup.cfg ﬁle and put these two lines in it:
[metadata]
description-file = README.rst
Note that if you try to put Markdown ﬁle into your package, PyPi will read it as a pure text ﬁle without any
formatting.
Licensing
It's often more than welcome to put a LICENSE.txt ﬁle in your package with one of the OpenSource licenses to tell
users if they can use your package for example in commercial projects or if your code is usable with their license.
In more readable way some licenses are explained at TL;DR.
Section 80.3: Making package executable
If your package isn't only a library, but has a piece of code that can be used either as a showcase or a standalone
application when your package is installed, put that piece of code into __main__.py ﬁle.
Put the __main__.py in the package_name folder. This way you will be able to run it directly from console:
python -m package_name
GoalKicker.com – Python® Notes for Professionals
408If there's no __main__.py ﬁle available, the package won't run with this command and this error will be printed:
python: No module named package_name.__main__; 'package_name' is a package and cannot be directly
executed.
GoalKicker.com – Python® Notes for Professionals
409Chapter 81: Usage of "pip" module: PyPI
Package Manager
Sometimes you may need to use pip package manager inside python eg. when some imports may raise
ImportError and you want to handle the exception. If you unpack on Windows
Python_root/Scripts/pip.exeinside is stored __main__.py ﬁle, where main class from pip package is imported.
This means pip package is used whenever you use pip executable. For usage of pip as executable see: pip: PyPI
Package Manager
Section 81.1: Example use of commands
import pip
command = 'install'
parameter = 'selenium'
second_param = 'numpy' # You can give as many package names as needed
switch = '--upgrade'
pip.main([command, parameter, second_param, switch])
Only needed parameters are obligatory, so both pip.main(['freeze']) and pip.main(['freeze', '', '']) are
acceptable.
Batch install
It is possible to pass many package names in one call, but if one install/upgrade fails, whole installation process
stops and ends with status '1'.
import pip
installed = pip.get_installed_distributions()
list = []
for i in installed:
list.append(i.key)
pip.main(['install']+list+['--upgrade'])
If you don't want to stop when some installs fail, call installation in loop.
for i in installed:
pip.main(['install']+i.key+['--upgrade'])
Section 81.2: Handling ImportError Exception
When you use python ﬁle as module there is no need always check if package is installed but it is still useful for
scripts.
if __name__ == '__main__':
try:
import requests
except ImportError:
print("To use this module you need 'requests' module")
t = input('Install requests? y/n: ')
if t == 'y':
GoalKicker.com – Python® Notes for Professionals
410import pip
pip.main(['install', 'requests'])
import requests
import os
import sys
pass
else:
import os
import sys
print('Some functionality can be unavailable.')
else:
import requests
import os
import sys
Section 81.3: Force install
Many packages for example on version 3.4 would run on 3.6 just ﬁne, but if there are no distributions for speciﬁc
platform, they can't be installed, but there is workaround. In .whl ﬁles (known as wheels) naming convention decide
whether you can install package on speciﬁed platform. Eg.
scikit_learn‑0.18.1‑cp36‑cp36m‑win_amd64.whl[package_name]-[version]-[python interpreter]-[python-
interpreter]-[Operating System].whl. If name of wheel ﬁle is changed, so platform does match, pip tries to install
package even if platform or python version does not match. Removing platform or interpreter from name will rise
an error in newest version of pip module kjhfkjdf.whl is not a valid wheel filename..
Alternatively .whl ﬁle can be unpacked using an archiver as 7-zip. - It usually contains distribution meta folder and
folder with source ﬁles. These source ﬁles can be simply unpacked to site-packages directory unless this wheel
contain installation script, if so, it has to be run ﬁrst.
GoalKicker.com – Python® Notes for Professionals
411Chapter 82: pip: PyPI Package Manager
pip is the most widely-used package manager for the Python Package Index, installed by default with recent
versions of Python.
Section 82.1: Install Packages
To install the latest version of a package named SomePackage:
$ pip install SomePackage
To install a speciﬁc version of a package:
$ pip install SomePackage==1.0.4
To specify a minimum version to install for a package:
$ pip install SomePackage>=1.0.4
If commands shows permission denied error on Linux/Unix then use sudo with the commands
Install from requirements ﬁles
$ pip install -r requirements.txt
Each line of the requirements ﬁle indicates something to be installed, and like arguments to pip install, Details on
the format of the ﬁles are here: Requirements File Format.
After install the package you can check it using freeze command:
$ pip freeze
Section 82.2: To list all packages installed using `pip`
To list installed packages:
$ pip list
# example output
docutils (0.9.1)
Jinja2 (2.6)
Pygments (1.5)
Sphinx (1.1.2)
To list outdated packages, and show the latest version available:
$ pip list --outdated
# example output
docutils (Current: 0.9.1 Latest: 0.10)
Sphinx (Current: 1.1.2 Latest: 1.1.3)
Section 82.3: Upgrade Packages
Running
GoalKicker.com – Python® Notes for Professionals
412$ pip install --upgrade SomePackage
will upgrade package SomePackage and all its dependencies. Also, pip automatically removes older version of the
package before upgrade.
To upgrade pip itself, do
$ pip install --upgrade pip
on Unix or
$ python -m pip install --upgrade pip
on Windows machines.
Section 82.4: Uninstall Packages
To uninstall a package:
$ pip uninstall SomePackage
Section 82.5: Updating all outdated packages on Linux
pip doesn't current contain a ﬂag to allow a user to update all outdated packages in one shot. However, this can be
accomplished by piping commands together in a Linux environment:
pip list --outdated --local | grep -v '^\-e' | cut -d = -f 1
| xargs -n1 pip install -U
This command takes all packages in the local virtualenv and checks if they are outdated. From that list, it gets the
package name and then pipes that to a pip install -U command. At the end of this process, all local packages
should be updated.
Section 82.6: Updating all outdated packages on Windows
pip doesn't current contain a ﬂag to allow a user to update all outdated packages in one shot. However, this can be
accomplished by piping commands together in a Windows environment:
for /F "delims= " %i in ('pip list --outdated --local') do pip install -U %i
This command takes all packages in the local virtualenv and checks if they are outdated. From that list, it gets the
package name and then pipes that to a pip install -U command. At the end of this process, all local packages
should be updated.
Section 82.7: Create a requirements.txt ﬁle of all packages on
the system
pip assists in creating requirements.txt ﬁles by providing the freeze option.
pip freeze > requirements.txt
This will save a list of all packages and their version installed on the system to a ﬁle named requirements.txt in the
current folder.
GoalKicker.com – Python® Notes for Professionals
413Section 82.8: Using a certain Python version with pip
If you have both Python 3 and Python 2 installed, you can specify which version of Python you would like pip to use.
This is useful when packages only support Python 2 or 3 or when you wish to test with both.
If you want to install packages for Python 2, run either:
pip install [package]
or:
pip2 install [package]
If you would like to install packages for Python 3, do:
pip3 install [package]
You can also invoke installation of a package to a speciﬁc python installation with:
\path\to\that\python.exe -m pip install some_package # on Windows OR
/usr/bin/python25 -m pip install some_package # on OS-X/Linux
On OS-X/Linux/Unix platforms it is important to be aware of the distinction between the system version of python,
(which upgrading make render your system inoperable), and the user version(s) of python. You may, depending on
which you are trying to upgrade, need to preﬁx these commands with sudo and input a password.
Likewise on Windows some python installations, especially those that are a part of another package, can end up
installed in system directories - those you will have to upgrade from a command window running in Admin mode -
if you ﬁnd that it looks like you need to do this it is a very good idea to check which python installation you are
trying to upgrade with a command such as python -c"import sys;print(sys.path);" or py -3.5 -c"import
sys;print(sys.path);" you can also check which pip you are trying to run with pip --version
On Windows, if you have both python 2 and python 3 installed, and on your path and your python 3 is greater than
3.4 then you will probably also have the python launcher py on your system path. You can then do tricks like:
py -3 -m pip install -U some_package # Install/Upgrade some_package to the latest python 3
py -3.3 -m pip install -U some_package # Install/Upgrade some_package to python 3.3 if present
py -2 -m pip install -U some_package # Install/Upgrade some_package to the latest python 2 - 64 bit
if present
py -2.7-32 -m pip install -U some_package # Install/Upgrade some_package to python 2.7 - 32 bit if
present
If you are running & maintaining multiple versions of python I would strongly recommend reading up about the
python virtualenv or venv virtual environments which allow you to isolate both the version of python and which
packages are present.
Section 82.9: Create a requirements.txt ﬁle of packages only
in the current virtualenv
pip assists in creating requirements.txt ﬁles by providing the freeze option.
pip freeze --local > requirements.txt
The --local parameter will only output a list of packages and versions that are installed locally to a virtualenv.
GoalKicker.com – Python® Notes for Professionals
414Global packages will not be listed.
Section 82.10: Installing packages not yet on pip as wheels
Many, pure python, packages are not yet available on the Python Package Index as wheels but still install ﬁne.
However, some packages on Windows give the dreaded vcvarsall.bat not found error.
The problem is that the package that you are trying to install contains a C or C++ extension and is not currently
available as a pre-built wheel from the python package index, pypi, and on windows you do not have the tool chain
needed to build such items.
The simplest answer is to go to Christoph Gohlke's excellent site and locate the appropriate version of the libraries
that you need. By appropriate in the package name a -cpNN- has to match your version of python, i.e. if you are
using windows 32 bit python even on win64 the name must include -win32- and if using the 64 bit python it must
include -win_amd64- and then the python version must match, i.e. for Python 34 the ﬁlename must include -cp34-,
etc. this is basically the magic that pip does for you on the pypi site.
Alternatively, you need to get the appropriate windows development kit for the version of python that you are
using, the headers for any library that the package you are trying to build interfaces to, possibly the python headers
for the version of python, etc.
Python 2.7 used Visual Studio 2008, Python 3.3 and 3.4 used Visual Studio 2010, and Python 3.5+ uses Visual Studio
2015.
Install “Visual C++ Compiler Package for Python 2.7”, which is available from Microsoft’s website or
Install “Windows SDK for Windows 7 and .NET Framework 4” (v7.1), which is available from Microsoft’s
website or
Install Visual Studio 2015 Community Edition, (or any later version, when these are released), ensuring you
select the options to install C & C++ support no longer the default -I am told that this can take up to 8 hours
to download and install so make sure that those options are set on the ﬁrst try.
Then you may need to locate the header ﬁles, at the matching revision for any libraries that your desired package
links to and download those to an appropriate locations.
Finally you can let pip do your build - of course if the package has dependencies that you don't yet have you may
also need to ﬁnd the header ﬁles for them as well.
Alternatives: It is also worth looking out, both on pypi or Christop's site, for any slightly earlier version of the
package that you are looking for that is either pure python or pre-built for your platform and python version and
possibly using those, if found, until your package does become available. Likewise if you are using the very latest
version of python you may ﬁnd that it takes the package maintainers a little time to catch up so for projects that
really need a speciﬁc package you may have to use a slightly older python for the moment. You can also check the
packages source site to see if there is a forked version that is available pre-built or as pure python and searching for
alternative packages that provide the functionality that you require but are available - one example that springs to
mind is the Pillow, actively maintained, drop in replacement for PIL currently not updated in 6 years and not available
for python 3.
Afterword, I would encourage anybody who is having this problem to go to the bug tracker for the package and
add to, or raise if there isn't one already, a ticket politely requesting that the package maintainers provide a wheel
on pypi for your speciﬁc combination of platform and python, if this is done then normally things will get better
with time, some package maintainers don't realise that they have missed a given combination that people may be
using.
GoalKicker.com – Python® Notes for Professionals
415Note on Installing Pre-Releases
Pip follows the rules of Semantic Versioning and by default prefers released packages over pre-releases. So if a
given package has been released as V0.98 and there is also a release candidate V1.0-rc1 the default behaviour of
pip install will be to install V0.98 - if you wish to install the release candidate, you are advised to test in a virtual
environment ﬁrst, you can enable do so with --pip install --pre package-name or --pip install --pre --
upgrade package-name. In many cases pre-releases or release candidates may not have wheels built for all platform
& version combinations so you are more likely to encounter the issues above.
Note on Installing Development Versions
You can also use pip to install development versions of packages from github and other locations, since such code
is in ﬂux it is very unlikely to have wheels built for it, so any impure packages will require the presence of the build
tools, and they may be broken at any time so the user is strongly encouraged to only install such packages in a
virtual environment.
Three options exist for such installations:
1. Download compressed snapshot, most online version control systems have the option to download a
compressed snapshot of the code. This can be downloaded manually and then installed with pip install
path/to/downloaded/ﬁle note that for most compression formats pip will handle unpacking to a cache area,
etc.
2. Let pip handle the download & install for you with: pip install URL/of/package/repository - you may also
need to use the --trusted-host, --client-cert and/or --proxy ﬂags for this to work correctly, especially in
a corporate environment. e.g:
> py -3.5-32 -m venv demo-pip
> demo-pip\Scripts\activate.bat
> python -m pip install -U pip
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.1
Uninstalling pip-8.1.1:
Successfully uninstalled pip-8.1.1
Successfully installed pip-9.0.1
> pip install git+https://github.com/sphinx-doc/sphinx/
Collecting git+https://github.com/sphinx-doc/sphinx/
Cloning https://github.com/sphinx-doc/sphinx/ to c:\users\steve-
~1\appdata\local\temp\pip-04yn9hpp-build
Collecting six>=1.5 (from Sphinx==1.7.dev20170506)
Using cached six-1.10.0-py2.py3-none-any.whl
Collecting Jinja2>=2.3 (from Sphinx==1.7.dev20170506)
Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting Pygments>=2.0 (from Sphinx==1.7.dev20170506)
Using cached Pygments-2.2.0-py2.py3-none-any.whl
Collecting docutils>=0.11 (from Sphinx==1.7.dev20170506)
Using cached docutils-0.13.1-py3-none-any.whl
Collecting snowballstemmer>=1.1 (from Sphinx==1.7.dev20170506)
Using cached snowballstemmer-1.2.1-py2.py3-none-any.whl
Collecting babel!=2.0,>=1.3 (from Sphinx==1.7.dev20170506)
Using cached Babel-2.4.0-py2.py3-none-any.whl
Collecting alabaster<0.8,>=0.7 (from Sphinx==1.7.dev20170506)
Using cached alabaster-0.7.10-py2.py3-none-any.whl
Collecting imagesize (from Sphinx==1.7.dev20170506)
Using cached imagesize-0.7.1-py2.py3-none-any.whl
Collecting requests>=2.0.0 (from Sphinx==1.7.dev20170506)
Using cached requests-2.13.0-py2.py3-none-any.whl
GoalKicker.com – Python® Notes for Professionals
416Collecting typing (from Sphinx==1.7.dev20170506)
Using cached typing-3.6.1.tar.gz
Requirement already satisfied: setuptools in f:\toolbuild\temp\demo-pip\lib\site-packages (from
Sphinx==1.7.dev20170506)
Collecting sphinxcontrib-websupport (from Sphinx==1.7.dev20170506)
Downloading sphinxcontrib_websupport-1.0.0-py2.py3-none-any.whl
Collecting colorama>=0.3.5 (from Sphinx==1.7.dev20170506)
Using cached colorama-0.3.9-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.3->Sphinx==1.7.dev20170506)
Using cached MarkupSafe-1.0.tar.gz
Collecting pytz>=0a (from babel!=2.0,>=1.3->Sphinx==1.7.dev20170506)
Using cached pytz-2017.2-py2.py3-none-any.whl
Collecting sqlalchemy>=0.9 (from sphinxcontrib-websupport->Sphinx==1.7.dev20170506)
Downloading SQLAlchemy-1.1.9.tar.gz (5.2MB)
100% |################################| 5.2MB 220kB/s
Collecting whoosh>=2.0 (from sphinxcontrib-websupport->Sphinx==1.7.dev20170506)
Downloading Whoosh-2.7.4-py2.py3-none-any.whl (468kB)
100% |################################| 471kB 1.1MB/s
Installing collected packages: six, MarkupSafe, Jinja2, Pygments, docutils, snowballstemmer, pytz,
babel, alabaster, imagesize, requests, typing, sqlalchemy, whoosh, sphinxcontrib-websupport,
colorama, Sphinx
Running setup.py install for MarkupSafe ... done
Running setup.py install for typing ... done
Running setup.py install for sqlalchemy ... done
Running setup.py install for Sphinx ... done
Successfully installed Jinja2-2.9.6 MarkupSafe-1.0 Pygments-2.2.0 Sphinx-1.7.dev20170506
alabaster-0.7.10 babel-2.4.0 colorama-0.3.9 docutils-0.13.1 imagesize-0.7.1 pytz-2017.2
requests-2.13.0 six-1.10.0 snowballstemmer-1.2.1 sphinxcontrib-websupport-1.0.0 sqlalchemy-1.1.9
typing-3.6.1 whoosh-2.7.4
Note the git+ preﬁx to the URL.
3. Clone the repository using git, mercurial or other acceptable tool, preferably a DVCS tool, and use pip
install path/to/cloned/repo - this will both process any requires.text ﬁle and perform the build and setup
steps, you can manually change directory to your cloned repository and run pip install -r requires.txt and
then python setup.py install to get the same eﬀect. The big advantages of this approach is that while the
initial clone operation may take longer than the snapshot download you can update to the latest with, in the
case of git: git pull origin master and if the current version contains errors you can use pip uninstall
package-name then use git checkout commands to move back through the repository history to earlier
version(s) and re-try.
GoalKicker.com – Python® Notes for Professionals
417Chapter 83: Parsing Command Line
arguments
Most command line tools rely on arguments passed to the program upon its execution. Instead of prompting for
input, these programs expect data or speciﬁc ﬂags (which become booleans) to be set. This allows both the user
and other programs to run the Python ﬁle passing it data as it starts. This section explains and demonstrates the
implementation and usage of command line arguments in Python.
Section 83.1: Hello world in argparse
The following program says hello to the user. It takes one positional argument, the name of the user, and can also
be told the greeting.
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('name',
help='name of user'
)
parser.add_argument('-g', '--greeting',
default='Hello',
help='optional alternate greeting'
)
args = parser.parse_args()
print("{greeting}, {name}!".format(
greeting=args.greeting,
name=args.name)
)
$ python hello.py --help
usage: hello.py [-h] [-g GREETING] name
positional arguments:
name
name of user
optional arguments:
-h, --help
show this help message and exit
-g GREETING, --greeting GREETING
optional alternate greeting
$ python hello.py world
Hello, world!
$ python hello.py John -g Howdy
Howdy, John!
For more details please read the argparse documentation.
Section 83.2: Using command line arguments with argv
Whenever a Python script is invoked from the command line, the user may supply additional command line
arguments which will be passed on to the script. These arguments will be available to the programmer from the
system variable sys.argv ("argv" is a traditional name used in most programming languages, and it means
"argument vector").
GoalKicker.com – Python® Notes for Professionals
418By convention, the ﬁrst element in the sys.argv list is the name of the Python script itself, while the rest of the
elements are the tokens passed by the user when invoking the script.
# cli.py
import sys
print(sys.argv)
$ python cli.py
=> ['cli.py']
$ python cli.py fizz
=> ['cli.py', 'fizz']
$ python cli.py fizz buzz
=> ['cli.py', 'fizz', 'buzz']
Here's another example of how to use argv. We ﬁrst strip oﬀ the initial element of sys.argv because it contains the
script's name. Then we combine the rest of the arguments into a single sentence, and ﬁnally print that sentence
prepending the name of the currently logged-in user (so that it emulates a chat program).
import getpass
import sys
words = sys.argv[1:]
sentence = " ".join(words)
print("[%s] %s" % (getpass.getuser(), sentence))
The algorithm commonly used when "manually" parsing a number of non-positional arguments is to iterate over
the sys.argv list. One way is to go over the list and pop each element of it:
# reverse and copy sys.argv
argv = reversed(sys.argv)
# extract the first element
arg = argv.pop()
# stop iterating when there's no more args to pop()
while len(argv) > 0:
if arg in ('-f', '--foo'):
print('seen foo!')
elif arg in ('-b', '--bar'):
print('seen bar!')
elif arg in ('-a', '--with-arg'):
arg = arg.pop()
print('seen value: {}'.format(arg))
# get the next value
arg = argv.pop()
Section 83.3: Setting mutually exclusive arguments with
argparse
If you want two or more arguments to be mutually exclusive. You can use the function
argparse.ArgumentParser.add_mutually_exclusive_group(). In the example below, either foo or bar can exist
but not both at the same time.
import argparse
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group()
GoalKicker.com – Python® Notes for Professionals
419group.add_argument("-f", "--foo")
group.add_argument("-b", "--bar")
args = parser.parse_args()
print "foo = ", args.foo
print "bar = ", args.bar
If you try to run the script specifying both --foo and --bar arguments, the script will complain with the below
message.
error: argument -b/--bar: not allowed with argument -f/--foo
Section 83.4: Basic example with docopt
docopt turns command-line argument parsing on its head. Instead of parsing the arguments, you just write the
usage string for your program, and docopt parses the usage string and uses it to extract the command line
arguments.
"""
Usage:
script_name.py [-a] [-b] <path>
Options:
-a
Print all the things.
-b
Get more bees into the path.
"""
from docopt import docopt
if __name__ == "__main__":
args = docopt(__doc__)
import pprint; pprint.pprint(args)
Sample runs:
$ python script_name.py
Usage:
script_name.py [-a] [-b] <path>
$ python script_name.py something
{'-a': False,
'-b': False,
'<path>': 'something'}
$ python script_name.py something -a
{'-a': True,
'-b': False,
'<path>': 'something'}
$ python script_name.py -b something -a
{'-a': True,
'-b': True,
'<path>': 'something'}
Section 83.5: Custom parser error message with argparse
You can create parser error messages according to your script needs. This is through the
argparse.ArgumentParser.error function. The below example shows the script printing a usage and an error
message to stderr when --foo is given but not --bar.
import argparse
GoalKicker.com – Python® Notes for Professionals
420parser = argparse.ArgumentParser()
parser.add_argument("-f", "--foo")
parser.add_argument("-b", "--bar")
args = parser.parse_args()
if args.foo and args.bar is None:
parser.error("--foo requires --bar. You did not specify bar.")
print "foo =", args.foo
print "bar =", args.bar
Assuming your script name is sample.py, and we run: python sample.py --foo ds_in_fridge
The script will complain with the following:
usage: sample.py [-h] [-f FOO] [-b BAR]
sample.py: error: --foo requires --bar. You did not specify bar.
Section 83.6: Conceptual grouping of arguments with
argparse.add_argument_group()
When you create an argparse ArgumentParser() and run your program with '-h' you get an automated usage
message explaining what arguments you can run your software with. By default, positional arguments and
conditional arguments are separated into two categories, for example, here is a small script (example.py) and the
output when you run python example.py -h.
import argparse
parser = argparse.ArgumentParser(description='Simple example')
parser.add_argument('name', help='Who to greet', default='World')
parser.add_argument('--bar_this')
parser.add_argument('--bar_that')
parser.add_argument('--foo_this')
parser.add_argument('--foo_that')
args = parser.parse_args()
usage: example.py [-h] [--bar_this BAR_THIS] [--bar_that BAR_THAT]
[--foo_this FOO_THIS] [--foo_that FOO_THAT]
name
Simple example
positional arguments:
name
optional arguments:
-h, --help
--bar_this BAR_THIS
--bar_that BAR_THAT
--foo_this FOO_THIS
--foo_that FOO_THAT
Who to greet
show this help message and exit
There are some situations where you want to separate your arguments into further conceptual sections to assist
your user. For example, you may wish to have all the input options in one group, and all the output formatting
options in another. The above example can be adjusted to separate the --foo_* args from the --bar_* args like so.
import argparse
parser = argparse.ArgumentParser(description='Simple example')
GoalKicker.com – Python® Notes for Professionals
421parser.add_argument('name', help='Who to greet', default='World')
# Create two argument groups
foo_group = parser.add_argument_group(title='Foo options')
bar_group = parser.add_argument_group(title='Bar options')
# Add arguments to those groups
foo_group.add_argument('--bar_this')
foo_group.add_argument('--bar_that')
bar_group.add_argument('--foo_this')
bar_group.add_argument('--foo_that')
args = parser.parse_args()
Which produces this output when python example.py -h is run:
usage: example.py [-h] [--bar_this BAR_THIS] [--bar_that BAR_THAT]
[--foo_this FOO_THIS] [--foo_that FOO_THAT]
name
Simple example
positional arguments:
nameWho to greet
optional arguments:
-h, --helpshow this help message and exit
Foo options:
--bar_this BAR_THIS
--bar_that BAR_THAT
Bar options:
--foo_this FOO_THIS
--foo_that FOO_THAT
Section 83.7: Advanced example with docopt and
docopt_dispatch
As with docopt, with [docopt_dispatch] you craft your --help in the __doc__ variable of your entry-point module.
There, you call dispatch with the doc string as argument, so it can run the parser over it.
That being done, instead of handling manually the arguments (which usually ends up in a high cyclomatic if/else
structure), you leave it to dispatch giving only how you want to handle the set of arguments.
This is what the dispatch.on decorator is for: you give it the argument or sequence of arguments that should
trigger the function, and that function will be executed with the matching values as parameters.
"""Run something in development or production mode.
Usage: run.py --development <host> <port>
run.py --production <host> <port>
run.py items add <item>
run.py items delete <item>
"""
from docopt_dispatch import dispatch
@dispatch.on('--development')
def development(host, port, **kwargs):
print('in *development* mode')
GoalKicker.com – Python® Notes for Professionals
422@dispatch.on('--production')
def development(host, port, **kwargs):
print('in *production* mode')
@dispatch.on('items', 'add')
def items_add(item, **kwargs):
print('adding item...')
@dispatch.on('items', 'delete')
def items_delete(item, **kwargs):
print('deleting item...')
if __name__ == '__main__':
dispatch(__doc__)
GoalKicker.com – Python® Notes for Professionals
423Chapter 84: Subprocess Library
Parameter
argsDetails
A single executable, or sequence of executable and arguments - 'ls', ['ls', '-la']
shellRun under a shell? The default shell to /bin/sh on POSIX.
cwdWorking directory of the child process.
Section 84.1: More ﬂexibility with Popen
Using subprocess.Popen give more ﬁne-grained control over launched processes than subprocess.call.
Launching a subprocess
process = subprocess.Popen([r'C:\path\to\app.exe', 'arg1', '--flag', 'arg'])
The signature for Popen is very similar to the call function; however, Popen will return immediately instead of
waiting for the subprocess to complete like call does.
Waiting on a subprocess to complete
process = subprocess.Popen([r'C:\path\to\app.exe', 'arg1', '--flag', 'arg'])
process.wait()
Reading output from a subprocess
process = subprocess.Popen([r'C:\path\to\app.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# This will block until process completes
stdout, stderr = process.communicate()
print stdout
print stderr
Interactive access to running subprocesses
You can read and write on stdin and stdout even while the subprocess hasn't completed. This could be useful
when automating functionality in another program.
Writing to a subprocess
process = subprocess.Popen([r'C:\path\to\app.exe'], stdout = subprocess.PIPE, stdin =
subprocess.PIPE)
process.stdin.write('line of input\n') # Write input
line
= process.stdout.readline() # Read a line from stdout
# Do logic on line read.
However, if you only need one set of input and output, rather than dynamic interaction, you should use
communicate() rather than directly accessing stdin and stdout.
Reading a stream from a subprocess
In case you want to see the output of a subprocess line by line, you can use the following snippet:
process = subprocess.Popen(<your_command>, stdout=subprocess.PIPE)
while process.poll() is None:
output_line = process.stdout.readline()
GoalKicker.com – Python® Notes for Professionals
424in the case the subcommand output do not have EOL character, the above snippet does not work. You can then
read the output character by character as follows:
process = subprocess.Popen(<your_command>, stdout=subprocess.PIPE)
while process.poll() is None:
output_line = process.stdout.read(1)
The 1 speciﬁed as argument to the read method tells read to read 1 character at time. You can specify to read as
many characters you want using a diﬀerent number. Negative number or 0 tells to read to read as a single string
until the EOF is encountered (see here).
In both the above snippets, the process.poll() is None until the subprocess ﬁnishes. This is used to exit the loop
once there is no more output to read.
The same procedure could be applied to the stderr of the subprocess.
Section 84.2: Calling External Commands
The simplest use case is using the subprocess.call function. It accepts a list as the ﬁrst argument. The ﬁrst item in
the list should be the external application you want to call. The other items in the list are arguments that will be
passed to that application.
subprocess.call([r'C:\path\to\app.exe', 'arg1', '--flag', 'arg'])
For shell commands, set shell=True and provide the command as a string instead of a list.
subprocess.call('echo "Hello, world"', shell=True)
Note that the two command above return only the exit status of the subprocess. Moreover, pay attention when
using shell=True since it provides security issues (see here).
If you want to be able to get the standard output of the subprocess, then substitute the subprocess.call with
subprocess.check_output. For more advanced use, refer to this.
Section 84.3: How to create the command list argument
The subprocess method that allows running commands needs the command in form of a list (at least using
shell_mode=True).
The rules to create the list are not always straightforward to follow, especially with complex commands.
Fortunately, there is a very helpful tool that allows doing that: shlex. The easiest way of creating the list to be used
as command is the following:
import shlex
cmd_to_subprocess = shlex.split(command_used_in_the_shell)
A simple example:
import shlex
shlex.split('ls --color -l -t -r')
out: ['ls', '--color', '-l', '-t', '-r']
GoalKicker.com – Python® Notes for Professionals
425VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 85: setup.py
Parameter
Usage
nameName of your distribution.
versionVersion string of your distribution.
packagesList of Python packages (that is, directories containing modules) to include. This can be speciﬁed
manually, but a call to setuptools.find_packages() is typically used instead.
py_modules List of top-level Python modules (that is, single .py ﬁles) to include.
Section 85.1: Purpose of setup.py
The setup script is the center of all activity in building, distributing, and installing modules using the Distutils. Its
purpose is the correct installation of the software.
If all you want to do is distribute a module called foo, contained in a ﬁle foo.py, then your setup script can be as
simple as this:
from distutils.core import setup
setup(name='foo',
version='1.0',
py_modules=['foo'],
)
To create a source distribution for this module, you would create a setup script, setup.py, containing the above
code, and run this command from a terminal:
python setup.py sdist
sdist will create an archive ﬁle (e.g., tarball on Unix, ZIP ﬁle on Windows) containing your setup script setup.py, and
your module foo.py. The archive ﬁle will be named foo-1.0.tar.gz (or .zip), and will unpack into a directory foo-1.0.
If an end-user wishes to install your foo module, all she has to do is download foo-1.0.tar.gz (or .zip), unpack it,
and—from the foo-1.0 directory—run
python setup.py install
Section 85.2: Using source control metadata in setup.py
setuptools_scm is an oﬃcially-blessed package that can use Git or Mercurial metadata to determine the version
number of your package, and ﬁnd Python packages and package data to include in it.
from setuptools import setup, find_packages
setup(
setup_requires=['setuptools_scm'],
use_scm_version=True,
packages=find_packages(),
include_package_data=True,
)
This example uses both features; to only use SCM metadata for the version, replace the call to find_packages()
with your manual package list, or to only use the package ﬁnder, remove use_scm_version=True.
GoalKicker.com – Python® Notes for Professionals
427Section 85.3: Adding command line scripts to your python
package
Command line scripts inside python packages are common. You can organise your package in such a way that
when a user installs the package, the script will be available on their path.
If you had the greetings package which had the command line script hello_world.py.
greetings/
greetings/
__init__.py
hello_world.py
You could run that script by running:
python greetings/greetings/hello_world.py
However if you would like to run it like so:
hello_world.py
You can achieve this by adding scripts to your setup() in setup.py like this:
from setuptools import setup
setup(
name='greetings',
scripts=['hello_world.py']
)
When you install the greetings package now, hello_world.py will be added to your path.
Another possibility would be to add an entry point:
entry_points={'console_scripts': ['greetings=greetings.hello_world:main']}
This way you just have to run it like:
greetings
Section 85.4: Adding installation options
As seen in previous examples, basic use of this script is:
python setup.py install
But there is even more options, like installing the package and have the possibility to change the code and test it
without having to re-install it. This is done using:
python setup.py develop
If you want to perform speciﬁc actions like compiling a Sphinx documentation or building fortran code, you can
create your own option like this:
cmdclasses = dict()
GoalKicker.com – Python® Notes for Professionals
428class BuildSphinx(Command):
"""Build Sphinx documentation."""
description = 'Build Sphinx documentation'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import sphinx
sphinx.build_main(['setup.py', '-b', 'html', './doc', './doc/_build/html'])
sphinx.build_main(['setup.py', '-b', 'man', './doc', './doc/_build/man'])
cmdclasses['build_sphinx'] = BuildSphinx
setup(
...
cmdclass=cmdclasses,
)
initialize_options and finalize_options will be executed before and after the run function as their names
suggests it.
After that, you will be able to call your option:
python setup.py build_sphinx
GoalKicker.com – Python® Notes for Professionals
429Chapter 86: Recursion
Section 86.1: The What, How, and When of Recursion
Recursion occurs when a function call causes that same function to be called again before the original function call
terminates. For example, consider the well-known mathematical expression x! (i.e. the factorial operation). The
factorial operation is deﬁned for all nonnegative integers as follows:
If the number is 0, then the answer is 1.
Otherwise, the answer is that number times the factorial of one less than that number.
In Python, a naïve implementation of the factorial operation can be deﬁned as a function as follows:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
Recursion functions can be diﬃcult to grasp sometimes, so let's walk through this step-by-step. Consider the
expression factorial(3). This and all function calls create a new environment. An environment is basically just a
table that maps identiﬁers (e.g. n, factorial, print, etc.) to their corresponding values. At any point in time, you
can access the current environment using locals(). In the ﬁrst function call, the only local variable that gets
deﬁned is n = 3. Therefore, printing locals() would show {'n': 3}. Since n == 3, the return value becomes n *
factorial(n - 1).
At this next step is where things might get a little confusing. Looking at our new expression, we already know what
n is. However, we don't yet know what factorial(n - 1) is. First, n - 1 evaluates to 2. Then, 2 is passed to
factorial as the value for n. Since this is a new function call, a second environment is created to store this new n.
Let A be the ﬁrst environment and B be the second environment. A still exists and equals {'n': 3}, however, B
(which equals {'n': 2}) is the current environment. Looking at the function body, the return value is, again, n *
factorial(n - 1). Without evaluating this expression, let's substitute it into the original return expression. By
doing this, we're mentally discarding B, so remember to substitute n accordingly (i.e. references to B's n are
replaced with n - 1 which uses A's n). Now, the original return expression becomes n * ((n - 1) * factorial((n
- 1) - 1)). Take a second to ensure that you understand why this is so.
Now, let's evaluate the factorial((n - 1) - 1)) portion of that. Since A's n == 3, we're passing 1 into factorial.
Therefore, we are creating a new environment C which equals {'n': 1}. Again, the return value is n * factorial(n
- 1). So let's replace factorial((n - 1) - 1)) of the “original” return expression similarly to how we adjusted the
original return expression earlier. The “original” expression is now n * ((n - 1) * ((n - 2) * factorial((n -
2) - 1))).
Almost done. Now, we need to evaluate factorial((n - 2) - 1). This time, we're passing in 0. Therefore, this
evaluates to 1. Now, let's perform our last substitution. The “original” return expression is now n * ((n - 1) * ((n
- 2) * 1)). Recalling that the original return expression is evaluated under A, the expression becomes 3 * ((3 -
1) * ((3 - 2) * 1)). This, of course, evaluates to 6. To conﬁrm that this is the correct answer, recall that 3! == 3
* 2 * 1 == 6. Before reading any further, be sure that you fully understand the concept of environments and how
they apply to recursion.
The statement if n == 0: return 1 is called a base case. This is because, it exhibits no recursion. A base case is
absolutely required. Without one, you'll run into inﬁnite recursion. With that said, as long as you have at least one
base case, you can have as many cases as you want. For example, we could have equivalently written factorial as
GoalKicker.com – Python® Notes for Professionals
430follows:
def factorial(n):
if n == 0:
return 1
elif n == 1:
return 1
else:
return n * factorial(n - 1)
You may also have multiple recursion cases, but we won't get into that since it's relatively uncommon and is often
diﬃcult to mentally process.
You can also have “parallel” recursive function calls. For example, consider the Fibonacci sequence which is deﬁned
as follows:
If the number is 0, then the answer is 0.
If the number is 1, then the answer is 1.
Otherwise, the answer is the sum of the previous two Fibonacci numbers.
We can deﬁne this is as follows:
def fib(n):
if n == 0 or n == 1:
return n
else:
return fib(n - 2) + fib(n - 1)
I won't walk through this function as thoroughly as I did with factorial(3), but the ﬁnal return value of fib(5) is
equivalent to the following (syntactically invalid) expression:
(
fib((n - 2) - 2)
+
(
fib(((n - 2) - 1) - 2)
+
fib(((n - 2) - 1) - 1)
)
)
+
(
(
fib(((n - 1) - 2) - 2)
+
fib(((n - 1) - 2) - 1)
)
+
(
fib(((n - 1) - 1) - 2)
+
(
fib((((n - 1) - 1) - 1) - 2)
+
fib((((n - 1) - 1) - 1) - 1)
)
)
)
GoalKicker.com – Python® Notes for Professionals
431This becomes (1 + (0 + 1)) + ((0 + 1) + (1 + (0 + 1))) which of course evaluates to 5.
Now, let's cover a few more vocabulary terms:
A tail call is simply a recursive function call which is the last operation to be performed before returning a
value. To be clear, return foo(n - 1) is a tail call, but return foo(n - 1) + 1 is not (since the addition is
the last operation).
Tail call optimization (TCO) is a way to automatically reduce recursion in recursive functions.
Tail call elimination (TCE) is the reduction of a tail call to an expression that can be evaluated without
recursion. TCE is a type of TCO.
Tail call optimization is helpful for a number of reasons:
The interpreter can minimize the amount of memory occupied by environments. Since no computer has
unlimited memory, excessive recursive function calls would lead to a stack overﬂow.
The interpreter can reduce the number of stack frame switches.
Python has no form of TCO implemented for a number of a reasons. Therefore, other techniques are required to
skirt this limitation. The method of choice depends on the use case. With some intuition, the deﬁnitions of
factorial and fib can relatively easily be converted to iterative code as follows:
def factorial(n):
product = 1
while n > 1:
product *= n
n -= 1
return product
def fib(n):
a, b = 0, 1
while n > 0:
a, b = b, a + b
n -= 1
return a
This is usually the most eﬃcient way to manually eliminate recursion, but it can become rather diﬃcult for more
complex functions.
Another useful tool is Python's lru_cache decorator which can be used to reduce the number of redundant
calculations.
You now have an idea as to how to avoid recursion in Python, but when should you use recursion? The answer is
“not often”. All recursive functions can be implemented iteratively. It's simply a matter of ﬁguring out how to do so.
However, there are rare cases in which recursion is okay. Recursion is common in Python when the expected inputs
wouldn't cause a signiﬁcant number of a recursive function calls.
If recursion is a topic that interests you, I implore you to study functional languages such as Scheme or Haskell. In
such languages, recursion is much more useful.
Please note that the above example for the Fibonacci sequence, although good at showing how to apply the
deﬁnition in python and later use of the lru cache, has an ineﬃcient running time since it makes 2 recursive calls for
each non base case. The number of calls to the function grows exponentially to n.
Rather non-intuitively a more eﬃcient implementation would use linear recursion:
def fib(n):
if n <= 1:
GoalKicker.com – Python® Notes for Professionals
432return (n,0)
else:
(a, b) = fib(n - 1)
return (a + b, a)
But that one has the issue of returning a pair of numbers. This emphasizes that some functions really do not gain
much from recursion.
Section 86.2: Tree exploration with recursion
Say we have the following tree:
root
- A
- AA
- AB
- B
- BA
- BB
- BBA
Now, if we wish to list all the names of the elements, we could do this with a simple for-loop. We assume there is a
function get_name() to return a string of the name of a node, a function get_children() to return a list of all the
sub-nodes of a given node in the tree, and a function get_root() to get the root node.
root = get_root(tree)
for node in get_children(root):
print(get_name(node))
for child in get_children(node):
print(get_name(child))
for grand_child in get_children(child):
print(get_name(grand_child))
# prints: A, AA, AB, B, BA, BB, BBA
This works well and fast, but what if the sub-nodes, got sub-nodes of its own? And those sub-nodes might have
more sub-nodes... What if you don't know beforehand how many there will be? A method to solve this is the use of
recursion.
def list_tree_names(node):
for child in get_children(node):
print(get_name(child))
list_tree_names(node=child)
list_tree_names(node=get_root(tree))
# prints: A, AA, AB, B, BA, BB, BBA
Perhaps you wish to not print, but return a ﬂat list of all node names. This can be done by passing a rolling list as a
parameter.
def list_tree_names(node, lst=[]):
for child in get_children(node):
lst.append(get_name(child))
list_tree_names(node=child, lst=lst)
return lst
list_tree_names(node=get_root(tree))
# returns ['A', 'AA', 'AB', 'B', 'BA', 'BB', 'BBA']
GoalKicker.com – Python® Notes for Professionals
433Section 86.3: Sum of numbers from 1 to n
If I wanted to ﬁnd out the sum of numbers from 1 to n where n is a natural number, I can do 1 + 2 + 3 + 4 + ...
+ (several hours later) + n. Alternatively, I could write a for loop:
n = 0
for i in range (1, n+1):
n += i
Or I could use a technique known as recursion:
def recursion(n):
if n == 1:
return 1
return n + recursion(n - 1)
Recursion has advantages over the above two methods. Recursion takes less time than writing out 1 + 2 + 3 for a
sum from 1 to 3. For recursion(4), recursion can be used to work backwards:
Function calls: ( 4 -> 4 + 3 -> 4 + 3 + 2 -> 4 + 3 + 2 + 1 -> 10 )
Whereas the for loop is working strictly forwards: ( 1 -> 1 + 2 -> 1 + 2 + 3 -> 1 + 2 + 3 + 4 -> 10 ). Sometimes the
recursive solution is simpler than the iterative solution. This is evident when implementing a reversal of a linked list.
Section 86.4: Increasing the Maximum Recursion Depth
There is a limit to the depth of possible recursion, which depends on the Python implementation. When the limit is
reached, a RuntimeError exception is raised:
RuntimeError: Maximum Recursion Depth Exceeded
Here's a sample of a program that would cause this error:
def cursing(depth):
try:
cursing(depth + 1) # actually, re-cursing
except RuntimeError as RE:
print('I recursed {} times!'.format(depth))
cursing(0)
# Out: I recursed 1083 times!
It is possible to change the recursion depth limit by using
sys.setrecursionlimit(limit)
You can check what the current parameters of the limit are by running:
sys.getrecursionlimit()
Running the same method above with our new limit we get
sys.setrecursionlimit(2000)
cursing(0)
# Out: I recursed 1997 times!
GoalKicker.com – Python® Notes for Professionals
434From Python 3.5, the exception is a RecursionError, which is derived from RuntimeError.
Section 86.5: Tail Recursion - Bad Practice
When the only thing returned from a function is a recursive call, it is referred to as tail recursion.
Here's an example countdown written using tail recursion:
def countdown(n):
if n == 0:
print "Blastoff!"
else:
print n
countdown(n-1)
Any computation that can be made using iteration can also be made using recursion. Here is a version of ﬁnd_max
written using tail recursion:
def find_max(seq, max_so_far):
if not seq:
return max_so_far
if max_so_far < seq[0]:
return find_max(seq[1:], seq[0])
else:
return find_max(seq[1:], max_so_far)
Tail recursion is considered a bad practice in Python, since the Python compiler does not handle optimization for
tail recursive calls. The recursive solution in cases like this use more system resources than the equivalent iterative
solution.
Section 86.6: Tail Recursion Optimization Through Stack
Introspection
By default Python's recursion stack cannot exceed 1000 frames. This can be changed by setting the
sys.setrecursionlimit(15000) which is faster however, this method consumes more memory. Instead, we can
also solve the Tail Recursion problem using stack introspection.
#!/usr/bin/env python2.4
# This program shows off a python decorator which implements tail call optimization. It
# does this by throwing an exception if it is its own grandparent, and catching such
# exceptions to recall the stack.
import sys
class TailRecurseException:
def __init__(self, args, kwargs):
self.args = args
self.kwargs = kwargs
def tail_call_optimized(g):
"""
This function decorates a function with tail call
optimization. It does this by throwing an exception
if it is its own grandparent, and catching such
exceptions to fake the tail call optimization.
This function fails if the decorated
GoalKicker.com – Python® Notes for Professionals
435function recurses in a non-tail context.
"""
def func(*args, **kwargs):
f = sys._getframe()
if f.f_back and f.f_back.f_back and f.f_back.f_back.f_code == f.f_code:
raise TailRecurseException(args, kwargs)
else:
while 1:
try:
return g(*args, **kwargs)
except TailRecurseException, e:
args = e.args
kwargs = e.kwargs
func.__doc__ = g.__doc__
return func
To optimize the recursive functions, we can use the @tail_call_optimized decorator to call our function. Here's a
few of the common recursion examples using the decorator described above:
Factorial Example:
@tail_call_optimized
def factorial(n, acc=1):
"calculate a factorial"
if n == 0:
return acc
return factorial(n-1, n*acc)
print factorial(10000)
# prints a big, big number,
# but doesn't hit the recursion limit.
Fibonacci Example:
@tail_call_optimized
def fib(i, current = 0, next = 1):
if i == 0:
return current
else:
return fib(i - 1, next, current + next)
print fib(10000)
# also prints a big number,
# but doesn't hit the recursion limit.
GoalKicker.com – Python® Notes for Professionals
436Chapter 87: Type Hints
Section 87.1: Adding types to a function
Let's take an example of a function which receives two arguments and returns a value indicating their sum:
def two_sum(a, b):
return a + b
By looking at this code, one can not safely and without doubt indicate the type of the arguments for function
two_sum. It works both when supplied with int values:
print(two_sum(2, 1))
# result: 3
and with strings:
print(two_sum("a", "b"))
# result: "ab"
and with other values, such as lists, tuples et cetera.
Due to this dynamic nature of python types, where many are applicable for a given operation, any type checker
would not be able to reasonably assert whether a call for this function should be allowed or not.
To assist our type checker we can now provide type hints for it in the Function deﬁnition indicating the type that we
allow.
To indicate that we only want to allow int types we can change our function deﬁnition to look like:
def two_sum(a: int, b: int):
return a + b
Annotations follow the argument name and are separated by a : character.
Similarly, to indicate only str types are allowed, we'd change our function to specify it:
def two_sum(a: str, b: str):
return a + b
Apart from specifying the type of the arguments, one could also indicate the return value of a function call. This is
done by adding the -> character followed by the type after the closing parenthesis in the argument list but before
the : at the end of the function declaration:
def two_sum(a: int, b: int) -> int:
return a + b
Now we've indicated that the return value when calling two_sum should be of type int. Similarly we can deﬁne
appropriate values for str, float, list, set and others.
Although type hints are mostly used by type checkers and IDEs, sometimes you may need to retrieve them. This can
be done using the __annotations__ special attribute:
two_sum.__annotations__
# {'a': <class 'int'>, 'b': <class 'int'>, 'return': <class 'int'>}
GoalKicker.com – Python® Notes for Professionals
437Section 87.2: NamedTuple
Creating a namedtuple with type hints is done using the function NamedTuple from the typing module:
import typing
Point = typing.NamedTuple('Point', [('x', int), ('y', int)])
Note that the name of the resulting type is the ﬁrst argument to the function, but it should be assigned to a variable
with the same name to ease the work of type checkers.
Section 87.3: Generic Types
The typing.TypeVar is a generic type factory. It's primary goal is to serve as a parameter/placeholder for generic
function/class/method annotations:
import typing
T = typing.TypeVar("T")
def get_first_element(l: typing.Sequence[T]) -> T:
"""Gets the first element of a sequence."""
return l[0]
Section 87.4: Variables and Attributes
Variables are annotated using comments:
x = 3 # type: int
x = negate(x)
x = 'a type-checker might catch this error'
Python 3.x Version ≥ 3.6
Starting from Python 3.6, there is also new syntax for variable annotations. The code above might use the form
x: int = 3
Unlike with comments, it is also possible to just add a type hint to a variable that was not previously declared,
without setting a value to it:
y: int
Additionally if these are used in the module or the class level, the type hints can be retrieved using
typing.get_type_hints(class_or_module):
class Foo:
x: int
y: str = 'abc'
print(typing.get_type_hints(Foo))
# ChainMap({'x': <class 'int'>, 'y': <class 'str'>}, {})
Alternatively, they can be accessed by using the __annotations__ special variable or attribute:
x: int
print(__annotations__)
GoalKicker.com – Python® Notes for Professionals
438# {'x': <class 'int'>}
class C:
s: str
print(C.__annotations__)
# {'s': <class 'str'>}
Section 87.5: Class Members and Methods
class A:
x = None # type: float
def __init__(self, x: float) -> None:
"""
self should not be annotated
init should be annotated to return None
"""
self.x = x
@classmethod
def from_int(cls, x: int) -> 'A':
"""
cls should not be annotated
Use forward reference to refer to current class with string literal 'A'
"""
return cls(float(x))
Forward reference of the current class is needed since annotations are evaluated when the function is deﬁned.
Forward references can also be used when referring to a class that would cause a circular import if imported.
Section 87.6: Type hints for keyword arguments
def hello_world(greeting: str = 'Hello'):
print(greeting + ' world!')
Note the spaces around the equal sign as opposed to how keyword arguments are usually styled.
GoalKicker.com – Python® Notes for Professionals
439Chapter 88: Exceptions
Errors detected during execution are called exceptions and are not unconditionally fatal. Most exceptions are not
handled by programs; it is possible to write programs that handle selected exceptions. There are speciﬁc features
in Python to deal with exceptions and exception logic. Furthermore, exceptions have a rich type hierarchy, all
inheriting from the BaseException type.
Section 88.1: Catching Exceptions
Use try...except: to catch exceptions. You should specify as precise an exception as you can:
try:
x = 5 / 0
except ZeroDivisionError as e:
# `e` is the exception object
print("Got a divide by zero! The exception was:", e)
# handle exceptional case
x = 0
finally:
print "The END"
# it runs no matter what execute.
The exception class that is speciﬁed - in this case, ZeroDivisionError - catches any exception that is of that class or
of any subclass of that exception.
For example, ZeroDivisionError is a subclass of ArithmeticError:
>>> ZeroDivisionError.__bases__
(<class 'ArithmeticError'>,)
And so, the following will still catch the ZeroDivisionError:
try:
5 / 0
except ArithmeticError:
print("Got arithmetic error")
Section 88.2: Do not catch everything!
While it's often tempting to catch every Exception:
try:
very_difficult_function()
except Exception:
# log / try to reconnect / exit gratiously
finally:
print "The END"
# it runs no matter what execute.
Or even everything (that includes BaseException and all its children including Exception):
try:
even_more_difficult_function()
except:
pass # do whatever needed
GoalKicker.com – Python® Notes for Professionals
440In most cases it's bad practice. It might catch more than intended, such as SystemExit, KeyboardInterrupt and
MemoryError - each of which should generally be handled diﬀerently than usual system or logic errors. It also
means there's no clear understanding for what the internal code may do wrong and how to recover properly from
that condition. If you're catching every error, you won't know what error occurred or how to ﬁx it.
This is more commonly referred to as 'bug masking' and should be avoided. Let your program crash instead of
silently failing or even worse, failing at deeper level of execution. (Imagine it's a transactional system)
Usually these constructs are used at the very outer level of the program, and will log the details of the error so that
the bug can be ﬁxed, or the error can be handled more speciﬁcally.
Section 88.3: Re-raising exceptions
Sometimes you want to catch an exception just to inspect it, e.g. for logging purposes. After the inspection, you
want the exception to continue propagating as it did before.
In this case, simply use the raise statement with no parameters.
try:
5 / 0
except ZeroDivisionError:
print("Got an error")
raise
Keep in mind, though, that someone further up in the caller stack can still catch the exception and handle it
somehow. The done output could be a nuisance in this case because it will happen in any case (caught or not
caught). So it might be a better idea to raise a diﬀerent exception, containing your comment about the situation as
well as the original exception:
try:
5 / 0
except ZeroDivisionError as e:
raise ZeroDivisionError("Got an error", e)
But this has the drawback of reducing the exception trace to exactly this raise while the raise without argument
retains the original exception trace.
In Python 3 you can keep the original stack by using the raise-from syntax:
raise ZeroDivisionError("Got an error") from e
Section 88.4: Catching multiple exceptions
There are a few ways to catch multiple exceptions.
The ﬁrst is by creating a tuple of the exception types you wish to catch and handle in the same manner. This
example will cause the code to ignore KeyError and AttributeError exceptions.
try:
d = {}
a = d[1]
b = d.non_existing_field
except (KeyError, AttributeError) as e:
print("A KeyError or an AttributeError exception has been caught.")
GoalKicker.com – Python® Notes for Professionals
441If you wish to handle diﬀerent exceptions in diﬀerent ways, you can provide a separate exception block for each
type. In this example, we still catch the KeyError and AttributeError, but handle the exceptions in diﬀerent
manners.
try:
d = {}
a = d[1]
b = d.non_existing_field
except KeyError as e:
print("A KeyError has occurred. Exception message:", e)
except AttributeError as e:
print("An AttributeError has occurred. Exception message:", e)
Section 88.5: Exception Hierarchy
Exception handling occurs based on an exception hierarchy, determined by the inheritance structure of the
exception classes.
For example, IOError and OSError are both subclasses of EnvironmentError. Code that catches an IOError will not
catch an OSError. However, code that catches an EnvironmentError will catch both IOErrors and OSErrors.
The hierarchy of built-in exceptions:
Python 2.x Version ≥ 2.3
BaseException
+-- SystemExit
+-- KeyboardInterrupt
+-- GeneratorExit
+-- Exception
+-- StopIteration
+-- StandardError
| +-- BufferError
| +-- ArithmeticError
| | +-- FloatingPointError
| | +-- OverflowError
| | +-- ZeroDivisionError
| +-- AssertionError
| +-- AttributeError
| +-- EnvironmentError
| | +-- IOError
| | +-- OSError
| | +-- WindowsError (Windows)
| | +-- VMSError (VMS)
| +-- EOFError
| +-- ImportError
| +-- LookupError
| | +-- IndexError
| | +-- KeyError
| +-- MemoryError
| +-- NameError
| | +-- UnboundLocalError
| +-- ReferenceError
| +-- RuntimeError
| | +-- NotImplementedError
| +-- SyntaxError
| | +-- IndentationError
| | +-- TabError
| +-- SystemError
| +-- TypeError
| +-- ValueError
GoalKicker.com – Python® Notes for Professionals
442| +-- UnicodeError
| +-- UnicodeDecodeError
| +-- UnicodeEncodeError
| +-- UnicodeTranslateError
+-- Warning
+-- DeprecationWarning
+-- PendingDeprecationWarning
+-- RuntimeWarning
+-- SyntaxWarning
+-- UserWarning
+-- FutureWarning
+-- ImportWarning
+-- UnicodeWarning
+-- BytesWarning
Python 3.x Version ≥ 3.0
BaseException
+-- SystemExit
+-- KeyboardInterrupt
+-- GeneratorExit
+-- Exception
+-- StopIteration
+-- StopAsyncIteration
+-- ArithmeticError
| +-- FloatingPointError
| +-- OverflowError
| +-- ZeroDivisionError
+-- AssertionError
+-- AttributeError
+-- BufferError
+-- EOFError
+-- ImportError
+-- LookupError
| +-- IndexError
| +-- KeyError
+-- MemoryError
+-- NameError
| +-- UnboundLocalError
+-- OSError
| +-- BlockingIOError
| +-- ChildProcessError
| +-- ConnectionError
| | +-- BrokenPipeError
| | +-- ConnectionAbortedError
| | +-- ConnectionRefusedError
| | +-- ConnectionResetError
| +-- FileExistsError
| +-- FileNotFoundError
| +-- InterruptedError
| +-- IsADirectoryError
| +-- NotADirectoryError
| +-- PermissionError
| +-- ProcessLookupError
| +-- TimeoutError
+-- ReferenceError
+-- RuntimeError
| +-- NotImplementedError
| +-- RecursionError
+-- SyntaxError
| +-- IndentationError
| +-- TabError
+-- SystemError
+-- TypeError
GoalKicker.com – Python® Notes for Professionals
443+-- ValueError
| +-- UnicodeError
| +-- UnicodeDecodeError
| +-- UnicodeEncodeError
| +-- UnicodeTranslateError
+-- Warning
+-- DeprecationWarning
+-- PendingDeprecationWarning
+-- RuntimeWarning
+-- SyntaxWarning
+-- UserWarning
+-- FutureWarning
+-- ImportWarning
+-- UnicodeWarning
+-- BytesWarning
+-- ResourceWarning
Section 88.6: Else
Code in an else block will only be run if no exceptions were raised by the code in the try block. This is useful if you
have some code you don’t want to run if an exception is thrown, but you don’t want exceptions thrown by that
code to be caught.
For example:
try:
data = {1: 'one', 2: 'two'}
print(data[1])
except KeyError as e:
print('key not found')
else:
raise ValueError()
# Output: one
# Output: ValueError
Note that this kind of else: cannot be combined with an if starting the else-clause to an elif. If you have a
following if it needs to stay indented below that else::
try:
...
except ...:
...
else:
if ...:
...
elif ...:
...
else:
...
Section 88.7: Raising Exceptions
If your code encounters a condition it doesn't know how to handle, such as an incorrect parameter, it should raise
the appropriate exception.
def even_the_odds(odds):
if odds % 2 != 1:
raise ValueError("Did not get an odd number")
GoalKicker.com – Python® Notes for Professionals
444return odds + 1
Section 88.8: Creating custom exception types
Create a class inheriting from Exception:
class FooException(Exception):
pass
try:
raise FooException("insert description here")
except FooException:
print("A FooException was raised.")
or another exception type:
class NegativeError(ValueError):
pass
def foo(x):
# function that only accepts positive values of x
if x < 0:
raise NegativeError("Cannot process negative numbers")
... # rest of function body
try:
result = foo(int(input("Enter a positive integer: "))) # raw_input in Python 2.x
except NegativeError:
print("You entered a negative number!")
else:
print("The result was " + str(result))
Section 88.9: Practical examples of exception handling
User input
Imagine you want a user to enter a number via input. You want to ensure that the input is a number. You can use
try/except for this:
Python 3.x Version ≥ 3.0
while True:
try:
nb = int(input('Enter a number: '))
break
except ValueError:
print('This is not a number, try again.')
Note: Python 2.x would use raw_input instead; the function input exists in Python 2.x but has diﬀerent semantics.
In the above example, input would also accept expressions such as 2 + 2 which evaluate to a number.
If the input could not be converted to an integer, a ValueError is raised. You can catch it with except. If no
exception is raised, break jumps out of the loop. After the loop, nb contains an integer.
Dictionaries
Imagine you are iterating over a list of consecutive integers, like range(n), and you have a list of dictionaries d that
contains information about things to do when you encounter some particular integers, say skip the d[i] next ones.
GoalKicker.com – Python® Notes for Professionals
445d = [{7: 3}, {25: 9}, {38: 5}]
for i in range(len(d)):
do_stuff(i)
try:
dic = d[i]
i += dic[i]
except KeyError:
i += 1
A KeyError will be raised when you try to get a value from a dictionary for a key that doesn’t exist.
Section 88.10: Exceptions are Objects too
Exceptions are just regular Python objects that inherit from the built-in BaseException. A Python script can use the
raise statement to interrupt execution, causing Python to print a stack trace of the call stack at that point and a
representation of the exception instance. For example:
>>> def failing_function():
...
raise ValueError('Example error!')
>>> failing_function()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in failing_function
ValueError: Example error!
which says that a ValueError with the message 'Example error!' was raised by our failing_function(), which
was executed in the interpreter.
Calling code can choose to handle any and all types of exception that a call can raise:
>>> try:
...
failing_function()
... except ValueError:
...
print('Handled the error')
Handled the error
You can get hold of the exception objects by assigning them in the except... part of the exception handling code:
>>> try:
...
failing_function()
... except ValueError as e:
...
print('Caught exception', repr(e))
Caught exception ValueError('Example error!',)
A complete list of built-in Python exceptions along with their descriptions can be found in the Python
Documentation: https://docs.python.org/3.5/library/exceptions.html. And here is the full list arranged hierarchically:
Exception Hierarchy.
Section 88.11: Running clean-up code with ﬁnally
Sometimes, you may want something to occur regardless of whatever exception happened, for example, if you
have to clean up some resources.
The finally block of a try clause will happen regardless of whether any exceptions were raised.
GoalKicker.com – Python® Notes for Professionals
446resource = allocate_some_expensive_resource()
try:
do_stuff(resource)
except SomeException as e:
log_error(e)
raise # re-raise the error
finally:
free_expensive_resource(resource)
This pattern is often better handled with context managers (using the with statement).
Section 88.12: Chain exceptions with raise from
In the process of handling an exception, you may want to raise another exception. For example, if you get an
IOError while reading from a ﬁle, you may want to raise an application-speciﬁc error to present to the users of your
library, instead.
Python 3.x Version ≥ 3.0
You can chain exceptions to show how the handling of exceptions proceeded:
>>> try:
5 / 0
except ZeroDivisionError as e:
raise ValueError("Division failed") from e
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
ValueError: Division failed
GoalKicker.com – Python® Notes for Professionals
447Chapter 89: Raise Custom Errors /
Exceptions
Python has many built-in exceptions which force your program to output an error when something in it goes
wrong.
However, sometimes you may need to create custom exceptions that serve your purpose.
In Python, users can deﬁne such exceptions by creating a new class. This exception class has to be derived, either
directly or indirectly, from Exception class. Most of the built-in exceptions are also derived from this class.
Section 89.1: Custom Exception
Here, we have created a user-deﬁned exception called CustomError which is derived from the Exception class. This
new exception can be raised, like other exceptions, using the raise statement with an optional error message.
class CustomError(Exception):
pass
x = 1
if x == 1:
raise CustomError('This is custom error')
Output:
Traceback (most recent call last):
File "error_custom.py", line 8, in
raise CustomError('This is custom error')
__main__.CustomError: This is custom error
Section 89.2: Catch custom Exception
This example shows how to catch custom Exception
class CustomError(Exception):
pass
try:
raise CustomError('Can you catch me ?')
except CustomError as e:
print ('Catched CustomError :{}'.format(e))
except Exception as e:
print ('Generic exception: {}'.format(e))
Output:
Catched CustomError :Can you catch me ?
GoalKicker.com – Python® Notes for Professionals
448VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 90: Commonwealth Exceptions
Here in Stack Overﬂow we often see duplicates talking about the same errors: "ImportError: No module named
'??????', SyntaxError: invalid syntax or NameError: name '???' is not defined. This is an eﬀort to reduce
them and to have some documentation to link to.
Section 90.1: Other Errors
AssertError
The assert statement exists in almost every programming language. When you do:
assert condition
or:
assert condition, message
It's equivalent to this:
if __debug__:
if not condition: raise AssertionError(message)
Assertions can include an optional message, and you can disable them when you're done debugging.
Note: the built-in variable debug is True under normal circumstances, False when optimization is requested
(command line option -O). Assignments to debug are illegal. The value for the built-in variable is determined when
the interpreter starts.
KeyboardInterrupt
Error raised when the user presses the interrupt key, normally Ctrl + C or del .
ZeroDivisionError
You tried to calculate 1/0 which is undeﬁned. See this example to ﬁnd the divisors of a number:
Python 2.x Version ≥ 2.0 Version ≤ 2.7
div = float(raw_input("Divisors of: "))
for x in xrange(div+1): #includes the number itself and zero
if div/x == div//x:
print x, "is a divisor of", div
Python 3.x Version ≥ 3.0
div = int(input("Divisors of: "))
for x in range(div+1): #includes the number itself and zero
if div/x == div//x:
print(x, "is a divisor of", div)
It raises ZeroDivisionError because the for loop assigns that value to x. Instead it should be:
Python 2.x Version ≥ 2.0 Version ≤ 2.7
div = float(raw_input("Divisors of: "))
for x in xrange(1,div+1): #includes the number itself but not zero
if div/x == div//x:
GoalKicker.com – Python® Notes for Professionals
450print x, "is a divisor of", div
Python 3.x Version ≥ 3.0
div = int(input("Divisors of: "))
for x in range(1,div+1): #includes the number itself but not zero
if div/x == div//x:
print(x, "is a divisor of", div)
Section 90.2: NameError: name '???' is not deﬁned
Is raised when you tried to use a variable, method or function that is not initialized (at least not before). In other
words, it is raised when a requested local or global name is not found. It's possible that you misspelt the name of
the object or forgot to import something. Also maybe it's in another scope. We'll cover those with separate
examples.
It's simply not deﬁned nowhere in the code
It's possible that you forgot to initialize it, especially if it is a constant
foo
# This variable is not defined
bar() # This function is not defined
Maybe it's deﬁned later:
baz()
def baz():
pass
Or it wasn't imported:
#needs import math
def sqrt():
x = float(input("Value: "))
return math.sqrt(x)
Python scopes and the LEGB Rule:
The so-called LEGB Rule talks about the Python scopes. Its name is based on the diﬀerent scopes, ordered by the
correspondent priorities:
Local → Enclosed → Global → Built-in.
Local: Variables not declared global or assigned in a function.
Enclosing: Variables deﬁned in a function that is wrapped inside another function.
Global: Variables declared global, or assigned at the top-level of a ﬁle.
Built-in: Variables preassigned in the built-in names module.
As an example:
for i in range(4):
d = i * 2
print(d)
GoalKicker.com – Python® Notes for Professionals
451d is accessible because the for loop does not mark a new scope, but if it did, we would have an error and its
behavior would be similar to:
def noaccess():
for i in range(4):
d = i * 2
noaccess()
print(d)
Python says NameError: name 'd' is not defined
Section 90.3: TypeErrors
These exceptions are caused when the type of some object should be diﬀerent
TypeError: [deﬁnition/method] takes ? positional arguments but ? was given
A function or method was called with more (or less) arguments than the ones it can accept.
Example
If more arguments are given:
def foo(a): return a
foo(a,b,c,d) #And a,b,c,d are defined
If less arguments are given:
def foo(a,b,c,d): return a += b + c + d
foo(a) #And a is defined
Note: if you want use an unknown number of arguments, you can use *args or **kwargs. See *args and **kwargs
TypeError: unsupported operand type(s) for [operand]: '???' and '???'
Some types cannot be operated together, depending on the operand.
Example
For example: + is used to concatenate and add, but you can't use any of them for both types. For instance, trying to
make a set by concatenating (+ing) 'set1' and 'tuple1' gives the error. Code:
set1, tuple1 = {1,2}, (3,4)
a = set1 + tuple1
Some types (eg: int and string) use both + but for diﬀerent things:
b = 400 + 'foo'
Or they may not be even used for anything:
c = ["a","b"] - [1,2]
But you can for example add a float to an int:
GoalKicker.com – Python® Notes for Professionals
452d = 1 + 1.0
TypeError: '???' object is not iterable/subscriptable:
For an object to be iterable it can take sequential indexes starting from zero until the indexes are no longer valid
and a IndexError is raised (More technically: it has to have an __iter__ method which returns an __iterator__, or
which deﬁnes a __getitem__ method that does what was previously mentioned).
Example
Here we are saying that bar is the zeroth item of 1. Nonsense:
foo = 1
bar = foo[0]
This is a more discrete version: In this example for tries to set x to amount[0], the ﬁrst item in an iterable but it
can't because amount is an int:
amount = 10
for x in amount: print(x)
TypeError: '???' object is not callable
You are deﬁning a variable and calling it later (like what you do with a function or method)
Example
foo = "notAFunction"
foo()
Section 90.4: Syntax Error on good code
The gross majority of the time a SyntaxError which points to an uninteresting line means there is an issue on the
line before it (in this example, it's a missing parenthesis):
def my_print():
x = (1 + 1
print(x)
Returns
File "<input>", line 3
print(x)
^
SyntaxError: invalid syntax
The most common reason for this issue is mismatched parentheses/brackets, as the example shows.
There is one major caveat for print statements in Python 3:
Python 3.x Version ≥ 3.0
>>> print "hello world"
File "<stdin>", line 1
print "hello world"
^
GoalKicker.com – Python® Notes for Professionals
453SyntaxError: invalid syntax
Because the print statement was replaced with the print() function, so you want:
print("hello world")
# Note this is valid for both Py2 & Py3
Section 90.5: IndentationErrors (or indentation SyntaxErrors)
In most other languages indentation is not compulsory, but in Python (and other languages: early versions of
FORTRAN, Makeﬁles, Whitespace (esoteric language), etc.) that is not the case, what can be confusing if you come
from another language, if you were copying code from an example to your own, or simply if you are new.
IndentationError/SyntaxError: unexpected indent
This exception is raised when the indentation level increases with no reason.
Example
There is no reason to increase the level here:
Python 2.x Version ≥ 2.0 Version ≤ 2.7
print "This line is ok"
print "This line isn't ok"
Python 3.x Version ≥ 3.0
print("This line is ok")
print("This line isn't ok")
Here there are two errors: the last one and that the indentation does not match any indentation level. However just
one is shown:
Python 2.x Version ≥ 2.0 Version ≤ 2.7
print "This line is ok"
print "This line isn't ok"
Python 3.x Version ≥ 3.0
print("This line is ok")
print("This line isn't ok")
IndentationError/SyntaxError: unindent does not match any outer indentation level
Appears you didn't unindent completely.
Example
Python 2.x Version ≥ 2.0 Version ≤ 2.7
def foo():
print "This should be part of foo()"
print "ERROR!"
print "This is not a part of foo()"
Python 3.x Version ≥ 3.0
print("This line is ok")
print("This line isn't ok")
IndentationError: expected an indented block
GoalKicker.com – Python® Notes for Professionals
454After a colon (and then a new line) the indentation level has to increase. This error is raised when that didn't
happen.
Example
if ok:
doStuff()
Note: Use the keyword pass (that makes absolutely nothing) to just put an if, else, except, class, method or
definition but not say what will happen if called/condition is true (but do it later, or in the case of except: just do
nothing):
def foo():
pass
IndentationError: inconsistent use of tabs and spaces in indentation
Example
def foo():
if ok:
return "Two != Four != Tab"
return "i don't care i do whatever i want"
How to avoid this error
Don't use tabs. It is discouraged by PEP8, the style guide for Python.
1. Set your editor to use 4 spaces for indentation.
2. Make a search and replace to replace all tabs with 4 spaces.
3. Make sure your editor is set to display tabs as 8 spaces, so that you can realize easily that error and ﬁx it.
See this question if you want to learn more.
GoalKicker.com – Python® Notes for Professionals
455Chapter 91: urllib
Section 91.1: HTTP GET
Python 2.x Version ≤ 2.7
Python 2
import urllib
response = urllib.urlopen('http://stackoverflow.com/documentation/')
Using urllib.urlopen() will return a response object, which can be handled similar to a ﬁle.
print response.code
# Prints: 200
The response.code represents the http return value. 200 is OK, 404 is NotFound, etc.
print response.read()
'<!DOCTYPE html>\r\n<html>\r\n<head>\r\n\r\n<title>Documentation - Stack. etc'
response.read() and response.readlines() can be used to read the actual html ﬁle returned from the request.
These methods operate similarly to file.read*
Python 3.x Version ≥ 3.0
Python 3
import urllib.request
print(urllib.request.urlopen("http://stackoverflow.com/documentation/"))
# Prints: <http.client.HTTPResponse at 0x7f37a97e3b00>
response = urllib.request.urlopen("http://stackoverflow.com/documentation/")
print(response.code)
# Prints: 200
print(response.read())
# Prints: b'<!DOCTYPE html>\r\n<html>\r\n<head>\r\n\r\n<title>Documentation - Stack Overflow</title>
The module has been updated for Python 3.x, but use cases remain basically the same. urllib.request.urlopen
will return a similar ﬁle-like object.
Section 91.2: HTTP POST
To POST data pass the encoded query arguments as data to urlopen()
Python 2.x Version ≤ 2.7
Python 2
import urllib
query_parms = {'username':'stackoverflow', 'password':'me.me'}
encoded_parms = urllib.urlencode(query_parms)
response = urllib.urlopen("https://stackoverflow.com/users/login", encoded_parms)
response.code
# Output: 200
response.read()
# Output: '<!DOCTYPE html>\r\n<html>\r\n<head>\r\n\r\n<title>Log In - Stack Overflow'
GoalKicker.com – Python® Notes for Professionals
456Python 3.x Version ≥ 3.0
Python 3
import urllib
query_parms = {'username':'stackoverflow', 'password':'me.me'}
encoded_parms = urllib.parse.urlencode(query_parms).encode('utf-8')
response = urllib.request.urlopen("https://stackoverflow.com/users/login", encoded_parms)
response.code
# Output: 200
response.read()
# Output: b'<!DOCTYPE html>\r\n<html>....etc'
Section 91.3: Decode received bytes according to content type
encoding
The received bytes have to be decoded with the correct character encoding to be interpreted as text:
Python 3.x Version ≥ 3.0
import urllib.request
response = urllib.request.urlopen("http://stackoverflow.com/")
data = response.read()
encoding = response.info().get_content_charset()
html = data.decode(encoding)
Python 2.x Version ≤ 2.7
import urllib2
response = urllib2.urlopen("http://stackoverflow.com/")
data = response.read()
encoding = response.info().getencoding()
html = data.decode(encoding)
GoalKicker.com – Python® Notes for Professionals
457Chapter 92: Web scraping with Python
Web scraping is an automated, programmatic process through which data can be constantly 'scraped' oﬀ
webpages. Also known as screen scraping or web harvesting, web scraping can provide instant data from any
publicly accessible webpage. On some websites, web scraping may be illegal.
Section 92.1: Scraping using the Scrapy framework
First you have to set up a new Scrapy project. Enter a directory where you’d like to store your code and run:
scrapy startproject projectName
To scrape we need a spider. Spiders deﬁne how a certain site will be scraped. Here’s the code for a spider that
follows the links to the top voted questions on StackOverﬂow and scrapes some data from each page (source):
import scrapy
class StackOverflowSpider(scrapy.Spider):
name = 'stackoverflow' # each spider has a unique name
start_urls = ['http://stackoverflow.com/questions?sort=votes']
specific set of urls
# the parsing starts from a
def parse(self, response): # for each request this generator yields, its response is sent to
parse_question
for href in response.css('.question-summary h3 a::attr(href)'): # do some scraping stuff
using css selectors to find question urls
full_url = response.urljoin(href.extract())
yield scrapy.Request(full_url, callback=self.parse_question)
def parse_question(self, response):
yield {
'title': response.css('h1 a::text').extract_first(),
'votes': response.css('.question .vote-count-post::text').extract_first(),
'body': response.css('.question .post-text').extract_first(),
'tags': response.css('.question .post-tag::text').extract(),
'link': response.url,
}
Save your spider classes in the projectName\spiders directory. In this case -
projectName\spiders\stackoverflow_spider.py.
Now you can use your spider. For example, try running (in the project's directory):
scrapy crawl stackoverflow
Section 92.2: Scraping using Selenium WebDriver
Some websites don’t like to be scraped. In these cases you may need to simulate a real user working with a
browser. Selenium launches and controls a web browser.
from selenium import webdriver
browser = webdriver.Firefox()
# launch Firefox browser
browser.get('http://stackoverflow.com/questions?sort=votes')
GoalKicker.com – Python® Notes for Professionals
# load url
458title = browser.find_element_by_css_selector('h1').text
# page title (first h1 element)
questions = browser.find_elements_by_css_selector('.question-summary')
# question list
for question in questions: # iterate over questions
question_title = question.find_element_by_css_selector('.summary h3 a').text
question_excerpt = question.find_element_by_css_selector('.summary .excerpt').text
question_vote = question.find_element_by_css_selector('.stats .vote .votes .vote-count-
post').text
print "%s\n%s\n%s votes\n-----------\n" % (question_title, question_excerpt, question_vote)
Selenium can do much more. It can modify browser’s cookies, ﬁll in forms, simulate mouse clicks, take screenshots
of web pages, and run custom JavaScript.
Section 92.3: Basic example of using requests and lxml to
scrape some data
# For Python 2 compatibility.
from __future__ import print_function
import lxml.html
import requests
def main():
r = requests.get("https://httpbin.org")
html_source = r.text
root_element = lxml.html.fromstring(html_source)
# Note root_element.xpath() gives a *list* of results.
# XPath specifies a path to the element we want.
page_title = root_element.xpath('/html/head/title/text()')[0]
print(page_title)
if __name__ == '__main__':
main()
Section 92.4: Maintaining web-scraping session with requests
It is a good idea to maintain a web-scraping session to persist the cookies and other parameters. Additionally, it can
result into a performance improvement because requests.Session reuses the underlying TCP connection to a host:
import requests
with requests.Session() as session:
# all requests through session now have User-Agent header set
session.headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'}
# set cookies
session.get('http://httpbin.org/cookies/set?key=value')
# get cookies
response = session.get('http://httpbin.org/cookies')
print(response.text)
GoalKicker.com – Python® Notes for Professionals
459Section 92.5: Scraping using BeautifulSoup4
from bs4 import BeautifulSoup
import requests
# Use the requests module to obtain a page
res = requests.get('https://www.codechef.com/problems/easy')
# Create a BeautifulSoup object
page = BeautifulSoup(res.text, 'lxml')
# the text field contains the source of the page
# Now use a CSS selector in order to get the table containing the list of problems
datatable_tags = page.select('table.dataTable') # The problems are in the <table> tag,
# with class "dataTable"
# We extract the first tag from the list, since that's what we desire
datatable = datatable_tags[0]
# Now since we want problem names, they are contained in <b> tags, which are
# directly nested under <a> tags
prob_tags = datatable.select('a > b')
prob_names = [tag.getText().strip() for tag in prob_tags]
print prob_names
Section 92.6: Simple web content download with urllib.request
The standard library module urllib.request can be used to download web content:
from urllib.request import urlopen
response = urlopen('http://stackoverflow.com/questions?sort=votes')
data = response.read()
# The received bytes should usually be decoded according the response's character set
encoding = response.info().get_content_charset()
html = data.decode(encoding)
A similar module is also available in Python 2.
Section 92.7: Modify Scrapy user agent
Sometimes the default Scrapy user agent ("Scrapy/VERSION (+http://scrapy.org)") is blocked by the host. To
change the default user agent open settings.py, uncomment and edit the following line to whatever you want.
#USER_AGENT = 'projectName (+http://www.yourdomain.com)'
For example
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/51.0.2704.103 Safari/537.36'
Section 92.8: Scraping with curl
imports:
from subprocess import Popen, PIPE
from lxml import etree
GoalKicker.com – Python® Notes for Professionals
460from io import StringIO
Downloading:
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/55.0.2883.95 Safari/537.36'
url = 'http://stackoverflow.com'
get = Popen(['curl', '-s', '-A', user_agent, url], stdout=PIPE)
result = get.stdout.read().decode('utf8')
-s: silent download
-A: user agent ﬂag
Parsing:
tree = etree.parse(StringIO(result), etree.HTMLParser())
divs = tree.xpath('//div')
GoalKicker.com – Python® Notes for Professionals
461Chapter 93: HTML Parsing
Section 93.1: Using CSS selectors in BeautifulSoup
BeautifulSoup has a limited support for CSS selectors, but covers most commonly used ones. Use SELECT() method
to ﬁnd multiple elements and select_one() to ﬁnd a single element.
Basic example:
from bs4 import BeautifulSoup
data = """
<ul>
<li class="item">item1</li>
<li class="item">item2</li>
<li class="item">item3</li>
</ul>
"""
soup = BeautifulSoup(data, "html.parser")
for item in soup.select("li.item"):
print(item.get_text())
Prints:
item1
item2
item3
Section 93.2: PyQuery
pyquery is a jquery-like library for python. It has very well support for css selectors.
from pyquery import PyQuery
html = """
<h1>Sales</h1>
<table id="table">
<tr>
<td>Lorem</td>
<td>46</td>
</tr>
<tr>
<td>Ipsum</td>
<td>12</td>
</tr>
<tr>
<td>Dolor</td>
<td>27</td>
</tr>
<tr>
<td>Sit</td>
<td>90</td>
</tr>
</table>
"""
GoalKicker.com – Python® Notes for Professionals
462doc = PyQuery(html)
title = doc('h1').text()
print title
table_data = []
rows = doc('#table > tr')
for row in rows:
name = PyQuery(row).find('td').eq(0).text()
value = PyQuery(row).find('td').eq(1).text()
print "%s\t
%s" % (name, value)
Section 93.3: Locate a text after an element in BeautifulSoup
Imagine you have the following HTML:
<div>
<label>Name:</label>
John Smith
</div>
And you need to locate the text "John Smith" after the label element.
In this case, you can locate the label element by text and then use .next_sibling property:
from bs4 import BeautifulSoup
data = """
<div>
<label>Name:</label>
John Smith
</div>
"""
soup = BeautifulSoup(data, "html.parser")
label = soup.find("label", text="Name:")
print(label.next_sibling.strip())
Prints John Smith.
GoalKicker.com – Python® Notes for Professionals
463Chapter 94: Manipulating XML
Section 94.1: Opening and reading using an ElementTree
Import the ElementTree object, open the relevant .xml ﬁle and get the root tag:
import xml.etree.ElementTree as ET
tree = ET.parse("yourXMLfile.xml")
root = tree.getroot()
There are a few ways to search through the tree. First is by iteration:
for child in root:
print(child.tag, child.attrib)
Otherwise you can reference speciﬁc locations like a list:
print(root[0][1].text)
To search for speciﬁc tags by name, use the .find or .findall:
print(root.findall("myTag"))
print(root[0].find("myOtherTag"))
Section 94.2: Create and Build XML Documents
Import Element Tree module
import xml.etree.ElementTree as ET
Element() function is used to create XML elements
p=ET.Element('parent')
SubElement() function used to create sub-elements to a give element
c = ET.SubElement(p, 'child1')
dump() function is used to dump xml elements.
ET.dump(p)
# Output will be like this
#<parent><child1 /></parent>
If you want to save to a ﬁle create a xml tree with ElementTree() function and to save to a ﬁle use write() method
tree = ET.ElementTree(p)
tree.write("output.xml")
Comment() function is used to insert comments in xml ﬁle.
comment = ET.Comment('user comment')
p.append(comment) #this comment will be appended to parent element
GoalKicker.com – Python® Notes for Professionals
464Section 94.3: Modifying an XML File
Import Element Tree module and open xml ﬁle, get an xml element
import xml.etree.ElementTree as ET
tree = ET.parse('sample.xml')
root=tree.getroot()
element = root[0] #get first child of root element
Element object can be manipulated by changing its ﬁelds, adding and modifying attributes, adding and removing
children
element.set('attribute_name', 'attribute_value') #set the attribute to xml element
element.text="string_text"
If you want to remove an element use Element.remove() method
root.remove(element)
ElementTree.write() method used to output xml object to xml ﬁles.
tree.write('output.xml')
Section 94.4: Searching the XML with XPath
Starting with version 2.7 ElementTree has a better support for XPath queries. XPath is a syntax to enable you to
navigate through an xml like SQL is used to search through a database. Both find and findall functions support
XPath. The xml below will be used for this example
<Catalog>
<Books>
<Book id="1" price="7.95">
<Title>Do Androids Dream of Electric Sheep?</Title>
<Author>Philip K. Dick</Author>
</Book>
<Book id="5" price="5.95">
<Title>The Colour of Magic</Title>
<Author>Terry Pratchett</Author>
</Book>
<Book id="7" price="6.95">
<Title>The Eye of The World</Title>
<Author>Robert Jordan</Author>
</Book>
</Books>
</Catalog>
Searching for all books:
import xml.etree.cElementTree as ET
tree = ET.parse('sample.xml')
tree.findall('Books/Book')
Searching for the book with title = 'The Colour of Magic':
tree.find("Books/Book[Title='The Colour of Magic']")
# always use '' in the right side of the comparison
GoalKicker.com – Python® Notes for Professionals
465Searching for the book with id = 5:
tree.find("Books/Book[@id='5']")
# searches with xml attributes must have '@' before the name
Search for the second book:
tree.find("Books/Book[2]")
# indexes starts at 1, not 0
Search for the last book:
tree.find("Books/Book[last()]")
# 'last' is the only xpath function allowed in ElementTree
Search for all authors:
tree.findall(".//Author")
#searches with // must use a relative path
Section 94.5: Opening and reading large XML ﬁles using
iterparse (incremental parsing)
Sometimes we don't want to load the entire XML ﬁle in order to get the information we need. In these instances,
being able to incrementally load the relevant sections and then delete them when we are ﬁnished is useful. With
the iterparse function you can edit the element tree that is stored while parsing the XML.
Import the ElementTree object:
import xml.etree.ElementTree as ET
Open the .xml ﬁle and iterate over all the elements:
for event, elem in ET.iterparse("yourXMLfile.xml"):
... do something ...
Alternatively, we can only look for speciﬁc events, such as start/end tags or namespaces. If this option is omitted (as
above), only "end" events are returned:
events=("start", "end", "start-ns", "end-ns")
for event, elem in ET.iterparse("yourXMLfile.xml", events=events):
... do something ...
Here is the complete example showing how to clear elements from the in-memory tree when we are ﬁnished with
them:
for event, elem in ET.iterparse("yourXMLfile.xml", events=("start","end")):
if elem.tag == "record_tag" and event == "end":
print elem.text
elem.clear()
... do something else ...
GoalKicker.com – Python® Notes for Professionals
466VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 95: Python Requests Post
Documentation for the Python Requests module in the context of the HTTP POST method and its corresponding
Requests function
Section 95.1: Simple Post
from requests import post
foo = post('http://httpbin.org/post', data = {'key':'value'})
Will perform a simple HTTP POST operation. Posted data can be inmost formats, however key value pairs are most
prevalent.
Headers
Headers can be viewed:
print(foo.headers)
An example response:
{'Content-Length': '439', 'X-Processed-Time': '0.000802993774414', 'X-Powered-By': 'Flask',
'Server': 'meinheld/0.6.1', 'Connection': 'keep-alive', 'Via': '1.1 vegur', 'Access-Control-Allow-
Credentials': 'true', 'Date': 'Sun, 21 May 2017 20:56:05 GMT', 'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'}
Headers can also be prepared before post:
headers = {'Cache-Control':'max-age=0',
'Upgrade-Insecure-Requests':'1',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/54.0.2840.99 Safari/537.36',
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Referer':'https://www.groupon.com/signup',
'Accept-Encoding':'gzip, deflate, br',
'Accept-Language':'es-ES,es;q=0.8'
}
foo = post('http://httpbin.org/post', headers=headers, data = {'key':'value'})
Encoding
Encoding can be set and viewed in much the same way:
print(foo.encoding)
'utf-8'
foo.encoding = 'ISO-8859-1'
SSL Veriﬁcation
Requests by default validates SSL certiﬁcates of domains. This can be overridden:
GoalKicker.com – Python® Notes for Professionals
468foo = post('http://httpbin.org/post', data = {'key':'value'}, verify=False)
Redirection
Any redirection will be followed (e.g. http to https) this can also be changed:
foo = post('http://httpbin.org/post', data = {'key':'value'}, allow_redirects=False)
If the post operation has been redirected, this value can be accessed:
print(foo.url)
A full history of redirects can be viewed:
print(foo.history)
Section 95.2: Form Encoded Data
from requests import post
payload = {'key1' : 'value1',
'key2' : 'value2'
}
foo = post('http://httpbin.org/post', data=payload)
To pass form encoded data with the post operation, data must be structured as dictionary and supplied as the data
parameter.
If the data does not want to be form encoded, simply pass a string, or integer to the data parameter.
Supply the dictionary to the json parameter for Requests to format the data automatically:
from requests import post
payload = {'key1' : 'value1', 'key2' : 'value2'}
foo = post('http://httpbin.org/post', json=payload)
Section 95.3: File Upload
With the Requests module, it's only necessary to provide a ﬁle handle as opposed to the contents retrieved with
.read():
from requests import post
files = {'file' : open('data.txt', 'rb')}
foo = post('http://http.org/post', files=files)
Filename, content_type and headers can also be set:
files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires':
'0'})}
GoalKicker.com – Python® Notes for Professionals
469foo = requests.post('http://httpbin.org/post', files=files)
Strings can also be sent as a ﬁle, as long they are supplied as the files parameter.
Multiple Files
Multiple ﬁles can be supplied in much the same way as one ﬁle:
multiple_files = [
('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]
foo = post('http://httpbin.org/post', files=multiple_files)
Section 95.4: Responses
Response codes can be viewed from a post operation:
from requests import post
foo = post('http://httpbin.org/post', data={'data' : 'value'})
print(foo.status_code)
Returned Data
Accessing data that is returned:
foo = post('http://httpbin.org/post', data={'data' : 'value'})
print(foo.text)
Raw Responses
In the instances where you need to access the underlying urllib3 response.HTTPResponse object, this can be done
by the following:
foo = post('http://httpbin.org/post', data={'data' : 'value'})
res = foo.raw
print(res.read())
Section 95.5: Authentication
Simple HTTP Authentication
Simple HTTP Authentication can be achieved with the following:
from requests import post
foo = post('http://natas0.natas.labs.overthewire.org', auth=('natas0', 'natas0'))
This is technically short hand for the following:
from requests import post
from requests.auth import HTTPBasicAuth
GoalKicker.com – Python® Notes for Professionals
470foo = post('http://natas0.natas.labs.overthewire.org', auth=HTTPBasicAuth('natas0', 'natas0'))
HTTP Digest Authentication
HTTP Digest Authentication is done in a very similar way, Requests provides a diﬀerent object for this:
from requests import post
from requests.auth import HTTPDigestAuth
foo = post('http://natas0.natas.labs.overthewire.org', auth=HTTPDigestAuth('natas0', 'natas0'))
Custom Authentication
In some cases the built in authentication mechanisms may not be enough, imagine this example:
A server is conﬁgured to accept authentication if the sender has the correct user-agent string, a certain header
value and supplies the correct credentials through HTTP Basic Authentication. To achieve this a custom
authentication class should be prepared, subclassing AuthBase, which is the base for Requests authentication
implementations:
from requests.auth import AuthBase
from requests.auth import _basic_auth_str
from requests._internal_utils import to_native_string
class CustomAuth(AuthBase):
def __init__(self, secret_header, user_agent , username, password):
# setup any auth-related data here
self.secret_header = secret_header
self.user_agent = user_agent
self.username = username
self.password = password
def __call__(self, r):
# modify and return the request
r.headers['X-Secret'] = self.secret_header
r.headers['User-Agent'] = self.user_agent
r.headers['Authorization'] = _basic_auth_str(self.username, self.password)
return r
This can then be utilized with the following code:
foo = get('http://test.com/admin', auth=CustomAuth('SecretHeader', 'CustomUserAgent', 'user',
'password' ))
Section 95.6: Proxies
Each request POST operation can be conﬁgured to use network proxies
HTTP/S Proxies
from requests import post
proxies = {
'http': 'http://192.168.0.128:3128',
'https': 'http://192.168.0.127:1080',
}
GoalKicker.com – Python® Notes for Professionals
471foo = requests.post('http://httpbin.org/post', proxies=proxies)
HTTP Basic Authentication can be provided in this manner:
proxies = {'http': 'http://user:pass@192.168.0.128:312'}
foo = requests.post('http://httpbin.org/post', proxies=proxies)
SOCKS Proxies
The use of socks proxies requires 3rd party dependencies requests[socks], once installed socks proxies are used
in a very similar way to HTTPBasicAuth:
proxies = {
'http': 'socks5://user:pass@host:port',
'https': 'socks5://user:pass@host:port'
}
foo = requests.post('http://httpbin.org/post', proxies=proxies)
GoalKicker.com – Python® Notes for Professionals
472Chapter 96: Distribution
Section 96.1: py2app
To use the py2app framework you must install it ﬁrst. Do this by opening terminal and entering the following
command:
sudo easy_install -U py2app
You can also pip install the packages as:
pip install py2app
Then create the setup ﬁle for your python script:
py2applet --make-setup MyApplication.py
Edit the settings of the setup ﬁle to your liking, this is the default:
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['test.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
To add an icon ﬁle (this ﬁle must have a .icns extension), or include images in your application as reference, change
your options as shown:
DATA_FILES = ['myInsertedImage.jpg']
OPTIONS = {'argv_emulation': True, 'iconfile': 'myCoolIcon.icns'}
Finally enter this into terminal:
python setup.py py2app
The script should run and you will ﬁnd your ﬁnished application in the dist folder.
Use the following options for more customization:
optimize (-O)
optimization level: -O1 for "python -O", -O2 for
"python -OO", and -O0 to disable [default: -O0]
GoalKicker.com – Python® Notes for Professionals
473includes (-i)comma-separated list of modules to include
packages (-p)comma-separated list of packages to include
extensionBundle extension [default:.app for app, .plugin for
plugin]
extra-scriptscomma-separated list of additional scripts to include
in an application or plugin.
Section 96.2: cx_Freeze
Install cx_Freeze from here
Unzip the folder and run these commands from that directory:
python setup.py build
sudo python setup.py install
Create a new directory for your python script and create a "setup.py" ﬁle in the same directory with the following
content:
application_title = "My Application" # Use your own application name
main_python_file = "my_script.py" # Your python script
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
includes = ["atexit","re"]
setup(
name = application_title,
version = "0.1",
description = "Your Description",
options = {"build_exe" : {"includes" : includes }},
executables = [Executable(main_python_file, base = base)])
Now run your setup.py from terminal:
python setup.py bdist_mac
NOTE: On El Capitan this will need to be run as root with SIP mode disabled.
GoalKicker.com – Python® Notes for Professionals
474Chapter 97: Property Objects
Section 97.1: Using the @property decorator for read-write
properties
If you want to use @property to implement custom behavior for setting and getting, use this pattern:
class Cash(object):
def __init__(self, value):
self.value = value
@property
def formatted(self):
return '${:.2f}'.format(self.value)
@formatted.setter
def formatted(self, new):
self.value = float(new[1:])
To use this:
>>> wallet = Cash(2.50)
>>> print(wallet.formatted)
$2.50
>>> print(wallet.value)
2.5
>>> wallet.formatted = '$123.45'
>>> print(wallet.formatted)
$123.45
>>> print(wallet.value)
123.45
Section 97.2: Using the @property decorator
The @property decorator can be used to deﬁne methods in a class which act like attributes. One example where
this can be useful is when exposing information which may require an initial (expensive) lookup and simple retrieval
thereafter.
Given some module foobar.py:
class Foo(object):
def __init__(self):
self.__bar = None
@property
def bar(self):
if self.__bar is None:
self.__bar = some_expensive_lookup_operation()
return self.__bar
Then
>>> from foobar import Foo
>>> foo = Foo()
>>> print(foo.bar) # This will take some time since bar is None after initialization
42
>>> print(foo.bar) # This is much faster since bar has a value now
42
GoalKicker.com – Python® Notes for Professionals
475Section 97.3: Overriding just a getter, setter or a deleter of a
property object
When you inherit from a class with a property, you can provide a new implementation for one or more of the
property getter, setter or deleter functions, by referencing the property object on the parent class:
class BaseClass(object):
@property
def foo(self):
return some_calculated_value()
@foo.setter
def foo(self, value):
do_something_with_value(value)
class DerivedClass(BaseClass):
@BaseClass.foo.setter
def foo(self, value):
do_something_different_with_value(value)
You can also add a setter or deleter where there was not one on the base class before.
Section 97.4: Using properties without decorators
While using decorator syntax (with the @) is convenient, it also a bit concealing. You can use properties directly,
without decorators. The following Python 3.x example shows this:
class A:
p = 1234
def getX (self):
return self._x
def setX (self, value):
self._x = value
def getY (self):
return self._y
def setY (self, value):
self._y = 1000 + value
# Weird but possible
def getY2 (self):
return self._y
def setY2 (self, value):
self._y = value
def getT
(self):
return self._t
def setT (self, value):
self._t = value
def getU (self):
return self._u + 10000
def setU (self, value):
self._u = value - 5000
GoalKicker.com – Python® Notes for Professionals
476x, y, y2 = property (getX, setX), property (getY, setY), property (getY2, setY2)
t = property (getT, setT)
u = property (getU, setU)
A.q = 5678
class B:
def getZ (self):
return self.z_
def setZ (self, value):
self.z_ = value
z = property (getZ, setZ)
class C:
def __init__ (self):
self.offset = 1234
def getW (self):
return self.w_ + self.offset
def setW (self, value):
self.w_ = value - self.offset
w = property (getW, setW)
a1 = A ()
a2 = A ()
a1.y2 = 1000
a2.y2 = 2000
a1.x = 5
a1.y = 6
a2.x = 7
a2.y = 8
a1.t = 77
a1.u = 88
print (a1.x, a1.y, a1.y2)
print (a2.x, a2.y, a2.y2)
print (a1.p, a2.p, a1.q, a2.q)
print (a1.t, a1.u)
b = B ()
c = C ()
b.z = 100100
c.z = 200200
c.w = 300300
print (a1.x, b.z, c.z, c.w)
c.w = 400400
c.z = 500500
b.z = 600600
GoalKicker.com – Python® Notes for Professionals
477print (a1.x, b.z, c.z, c.w)
GoalKicker.com – Python® Notes for Professionals
478Chapter 98: Overloading
Section 98.1: Operator overloading
Below are the operators that can be overloaded in classes, along with the method deﬁnitions that are required, and
an example of the operator in use within an expression.
N.B. The use of other as a variable name is not mandatory, but is considered the norm.
Operator
Method
Expression
+ Addition__add__(self, other)a1 + a2
- Subtraction__sub__(self, other)a1 - a2
* Multiplication__mul__(self, other)a1 * a2
@ Matrix Multiplication__matmul__(self, other)a1 @ a2 (Python 3.5)
/ Division__div__(self, other)a1 / a2 (Python 2 only)
/ Division__truediv__(self, other)a1 / a2 (Python 3)
// Floor Division__floordiv__(self, other)a1 // a2
% Modulo/Remainder__mod__(self, other)a1 % a2
** Power__pow__(self, other[, modulo]) a1 ** a2
<< Bitwise Left Shift__lshift__(self, other)a1 << a2
>> Bitwise Right Shift__rshift__(self, other)a1 >> a2
& Bitwise AND__and__(self, other)a1 & a2
^ Bitwise XOR__xor__(self, other)a1 ^ a2
| (Bitwise OR)__or__(self, other)a1 | a2
- Negation (Arithmetic)__neg__(self)-a1
+ Positive__pos__(self)+a1
~ Bitwise NOT__invert__(self)~a1
< Less than__lt__(self, other)a1 < a2
<= Less than or Equal to__le__(self, other)a1 <= a2
== Equal to__eq__(self, other)a1 == a2
!= Not Equal to__ne__(self, other)a1 != a2
> Greater than__gt__(self, other)a1 > a2
>= Greater than or Equal to __ge__(self, other)a1 >= a2
[index] Index operator__getitem__(self, index)a1[index]
in In operator__contains__(self, other)a2 in a1
(*args, ...) Calling__call__(self, *args, **kwargs) a1(*args, **kwargs)
The optional parameter modulo for __pow__ is only used by the pow built-in function.
Each of the methods corresponding to a binary operator has a corresponding "right" method which start with __r,
for example __radd__:
class A:
def __init__(self, a):
self.a = a
def __add__(self, other):
return self.a + other
def __radd__(self, other):
print("radd")
GoalKicker.com – Python® Notes for Professionals
479return other + self.a
A(1) + 2
2 + A(1)
# Out: 3
# prints radd. Out: 3
as well as a corresponding inplace version, starting with __i:
class B:
def __init__(self, b):
self.b = b
def __iadd__(self, other):
self.b += other
print("iadd")
return self
b = B(2)
b.b
b += 1
b.b
# Out: 2
# prints iadd
# Out: 3
Since there's nothing special about these methods, many other parts of the language, parts of the standard library,
and even third-party modules add magic methods on their own, like methods to cast an object to a type or checking
properties of the object. For example, the builtin str() function calls the object's __str__ method, if it exists. Some
of these uses are listed below.
Function
Casting to int
Method
Expression
__int__(self)int(a1)
Absolute function__abs__(self)abs(a1)
Casting to str__str__(self)str(a1)
Casting to unicode__unicode__(self)unicode(a1) (Python 2 only)
String representation __repr__(self)
repr(a1)
Casting to bool__nonzero__(self)
bool(a1)
String formatting__format__(self, formatstr) "Hi {:abc}".format(a1)
Hashing__hash__(self)
hash(a1)
Length__len__(self)
len(a1)
Reversed__reversed__(self)
reversed(a1)
Floor__floor__(self)
math.floor(a1)
Ceiling__ceil__(self)
math.ceil(a1)
There are also the special methods __enter__ and __exit__ for context managers, and many more.
Section 98.2: Magic/Dunder Methods
Magic (also called dunder as an abbreviation for double-underscore) methods in Python serve a similar purpose to
operator overloading in other languages. They allow a class to deﬁne its behavior when it is used as an operand in
unary or binary operator expressions. They also serve as implementations called by some built-in functions.
Consider this implementation of two-dimensional vectors.
import math
class Vector(object):
# instantiation
def __init__(self, x, y):
GoalKicker.com – Python® Notes for Professionals
480self.x = x
self.y = y
# unary negation (-v)
def __neg__(self):
return Vector(-self.x, -self.y)
# addition (v + u)
def __add__(self, other):
return Vector(self.x + other.x, self.y + other.y)
# subtraction (v - u)
def __sub__(self, other):
return self + (-other)
# equality (v == u)
def __eq__(self, other):
return self.x == other.x and self.y == other.y
# abs(v)
def __abs__(self):
return math.hypot(self.x, self.y)
# str(v)
def __str__(self):
return '<{0.x}, {0.y}>'.format(self)
# repr(v)
def __repr__(self):
return 'Vector({0.x}, {0.y})'.format(self)
Now it is possible to naturally use instances of the Vector class in various expressions.
v = Vector(1, 4)
u = Vector(2, 0)
u + v
print(u + v)
u - v
u == v
u + v == v + u
abs(u + v)
# Vector(3, 4)
# "<3, 4>" (implicit string conversion)
# Vector(1, -4)
# False
# True
# 5.0
Section 98.3: Container and sequence types
It is possible to emulate container types, which support accessing values by key or index.
Consider this naive implementation of a sparse list, which stores only its non-zero elements to conserve memory.
class sparselist(object):
def __init__(self, size):
self.size = size
self.data = {}
# l[index]
def __getitem__(self, index):
if index < 0:
index += self.size
if index >= self.size:
raise IndexError(index)
GoalKicker.com – Python® Notes for Professionals
481try:
return self.data[index]
except KeyError:
return 0.0
# l[index] = value
def __setitem__(self, index, value):
self.data[index] = value
# del l[index]
def __delitem__(self, index):
if index in self.data:
del self.data[index]
# value in l
def __contains__(self, value):
return value == 0.0 or value in self.data.values()
# len(l)
def __len__(self):
return self.size
# for value in l: ...
def __iter__(self):
return (self[i] for i in range(self.size)) # use xrange for python2
Then, we can use a sparselist much like a regular list.
l = sparselist(10 ** 6)
0 in l
10 in l# list with 1 million elements
# True
# False
l[12345] = 10
10 in l
l[12345]# True
# 10
for v in l:
pass # 0, 0, 0, ... 10, 0, 0 ... 0
Section 98.4: Callable types
class adder(object):
def __init__(self, first):
self.first = first
# a(...)
def __call__(self, second):
return self.first + second
add2 = adder(2)
add2(1) # 3
add2(2) # 4
Section 98.5: Handling unimplemented behaviour
If your class doesn't implement a speciﬁc overloaded operator for the argument types provided, it should return
NotImplemented (note that this is a special constant, not the same as NotImplementedError). This will allow Python
to fall back to trying other methods to make the operation work:
GoalKicker.com – Python® Notes for Professionals
482When NotImplemented is returned, the interpreter will then try the reﬂected operation on the other type,
or some other fallback, depending on the operator. If all attempted operations return NotImplemented,
the interpreter will raise an appropriate exception.
For example, given x + y, if x.__add__(y) returns unimplemented, y.__radd__(x) is attempted instead.
class NotAddable(object):
def __init__(self, value):
self.value = value
def __add__(self, other):
return NotImplemented
class Addable(NotAddable):
def __add__(self, other):
return Addable(self.value + other.value)
__radd__ = __add__
As this is the reﬂected method we have to implement __add__ and __radd__ to get the expected behaviour in all
cases; fortunately, as they are both doing the same thing in this simple example, we can take a shortcut.
In use:
>>> x = NotAddable(1)
>>> y = Addable(2)
>>> x + x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'NotAddable' and 'NotAddable'
>>> y + y
<so.Addable object at 0x1095974d0>
>>> z = x + y
>>> z
<so.Addable object at 0x109597510>
>>> z.value
3
GoalKicker.com – Python® Notes for Professionals
483Chapter 99: Polymorphism
Section 99.1: Duck Typing
Polymorphism without inheritance in the form of duck typing as available in Python due to its dynamic typing
system. This means that as long as the classes contain the same methods the Python interpreter does not
distinguish between them, as the only checking of the calls occurs at run-time.
class Duck:
def quack(self):
print("Quaaaaaack!")
def feathers(self):
print("The duck has white and gray feathers.")
class Person:
def quack(self):
print("The person imitates a duck.")
def feathers(self):
print("The person takes a feather from the ground and shows it.")
def name(self):
print("John Smith")
def in_the_forest(obj):
obj.quack()
obj.feathers()
donald = Duck()
john = Person()
in_the_forest(donald)
in_the_forest(john)
The output is:
Quaaaaaack!
The duck has white and gray feathers.
The person imitates a duck.
The person takes a feather from the ground and shows it.
Section 99.2: Basic Polymorphism
Polymorphism is the ability to perform an action on an object regardless of its type. This is generally implemented
by creating a base class and having two or more subclasses that all implement methods with the same signature.
Any other function or method that manipulates these objects can call the same methods regardless of which type
of object it is operating on, without needing to do a type check ﬁrst. In object-oriented terminology when class X
extend class Y , then Y is called super class or base class and X is called subclass or derived class.
class Shape:
"""
This is a parent class that is intended to be inherited by other classes
"""
def calculate_area(self):
"""
This method is intended to be overridden in subclasses.
If a subclass doesn't implement it but it is called, NotImplemented will be raised.
GoalKicker.com – Python® Notes for Professionals
484"""
raise NotImplemented
class Square(Shape):
"""
This is a subclass of the Shape class, and represents a square
"""
side_length = 2
# in this example, the sides are 2 units long
def calculate_area(self):
"""
This method overrides Shape.calculate_area(). When an object of type
Square has its calculate_area() method called, this is the method that
will be called, rather than the parent class' version.
It performs the calculation necessary for this shape, a square, and
returns the result.
"""
return self.side_length * 2
class Triangle(Shape):
"""
This is also a subclass of the Shape class, and it represents a triangle
"""
base_length = 4
height = 3
def calculate_area(self):
"""
This method also overrides Shape.calculate_area() and performs the area
calculation for a triangle, returning the result.
"""
return 0.5 * self.base_length * self.height
def get_area(input_obj):
"""
This function accepts an input object, and will call that object's
calculate_area() method. Note that the object type is not specified. It
could be a Square, Triangle, or Shape object.
"""
print(input_obj.calculate_area())
# Create one object of each class
shape_obj = Shape()
square_obj = Square()
triangle_obj = Triangle()
# Now pass each object, one at a time, to the get_area() function and see the
# result.
get_area(shape_obj)
get_area(square_obj)
get_area(triangle_obj)
We should see this output:
None
4
GoalKicker.com – Python® Notes for Professionals
4856.0
What happens without polymorphism?
Without polymorphism, a type check may be required before performing an action on an object to determine the
correct method to call. The following counter example performs the same task as the previous code, but without
the use of polymorphism, the get_area() function has to do more work.
class Square:
side_length = 2
def calculate_square_area(self):
return self.side_length ** 2
class Triangle:
base_length = 4
height = 3
def calculate_triangle_area(self):
return (0.5 * self.base_length) * self.height
def get_area(input_obj):
# Notice the type checks that are now necessary here. These type checks
# could get very complicated for a more complex example, resulting in
# duplicate and difficult to maintain code.
if type(input_obj).__name__ == "Square":
area = input_obj.calculate_square_area()
elif type(input_obj).__name__ == "Triangle":
area = input_obj.calculate_triangle_area()
print(area)
# Create one object of each class
square_obj = Square()
triangle_obj = Triangle()
# Now pass each object, one at a time, to the get_area() function and see the
# result.
get_area(square_obj)
get_area(triangle_obj)
We should see this output:
4
6.0
Important Note
Note that the classes used in the counter example are "new style" classes and implicitly inherit from the object class
if Python 3 is being used. Polymorphism will work in both Python 2.x and 3.x, but the polymorphism
counterexample code will raise an exception if run in a Python 2.x interpreter because type(input_obj).name will
return "instance" instead of the class name if they do not explicitly inherit from object, resulting in area never being
assigned to.
GoalKicker.com – Python® Notes for Professionals
486VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 100: Method Overriding
Section 100.1: Basic method overriding
Here is an example of basic overriding in Python (for the sake of clarity and compatibility with both Python 2 and 3,
using new style class and print with ()):
class Parent(object):
def introduce(self):
print("Hello!")
def print_name(self):
print("Parent")
class Child(Parent):
def print_name(self):
print("Child")
p = Parent()
c = Child()
p.introduce()
p.print_name()
c.introduce()
c.print_name()
$ python basic_override.py
Hello!
Parent
Hello!
Child
When the Child class is created, it inherits the methods of the Parent class. This means that any methods that the
parent class has, the child class will also have. In the example, the introduce is deﬁned for the Child class because
it is deﬁned for Parent, despite not being deﬁned explicitly in the class deﬁnition of Child.
In this example, the overriding occurs when Child deﬁnes its own print_name method. If this method was not
declared, then c.print_name() would have printed "Parent". However, Child has overridden the Parent's
deﬁnition of print_name, and so now upon calling c.print_name(), the word "Child" is printed.
GoalKicker.com – Python® Notes for Professionals
488Chapter 101: User-Deﬁned Methods
Section 101.1: Creating user-deﬁned method objects
User-deﬁned method objects may be created when getting an attribute of a class (perhaps via an instance of that
class), if that attribute is a user-deﬁned function object, an unbound user-deﬁned method object, or a class method
object.
class A(object):
# func: A user-defined function object
#
# Note that func is a function object when it's defined,
# and an unbound method object when it's retrieved.
def func(self):
pass
# classMethod: A class method
@classmethod
def classMethod(self):
pass
class B(object):
# unboundMeth: A unbound user-defined method object
#
# Parent.func is an unbound user-defined method object here,
# because it's retrieved.
unboundMeth = A.func
a = A()
b = B()
print A.func
# output: <unbound method A.func>
print a.func
# output: <bound method A.func of <__main__.A object at 0x10e9ab910>>
print B.unboundMeth
# output: <unbound method A.func>
print b.unboundMeth
# output: <unbound method A.func>
print A.classMethod
# output: <bound method type.classMethod of <class '__main__.A'>>
print a.classMethod
# output: <bound method type.classMethod of <class '__main__.A'>>
When the attribute is a user-deﬁned method object, a new method object is only created if the class from which it is
being retrieved is the same as, or a derived class of, the class stored in the original method object; otherwise, the
original method object is used as it is.
# Parent: The class stored in the original method object
class Parent(object):
# func: The underlying function of original method object
def func(self):
pass
func2 = func
# Child: A derived class of Parent
class Child(Parent):
func = Parent.func
GoalKicker.com – Python® Notes for Professionals
489# AnotherClass: A different class, neither subclasses nor subclassed
class AnotherClass(object):
func = Parent.func
print Parent.func is Parent.func
print Parent.func2 is Parent.func2
print Child.func is Child.func
print AnotherClass.func is AnotherClass.func
# False, new object created
# False, new object created
# False, new object created
# True, original object used
Section 101.2: Turtle example
The following is an example of using an user-deﬁned function to be called multiple(∞) times in a script with ease.
import turtle, time, random #tell python we need 3 different modules
turtle.speed(0) #set draw speed to the fastest
turtle.colormode(255) #special colormode
turtle.pensize(4) #size of the lines that will be drawn
def triangle(size): #This is our own function, in the parenthesis is a variable we have defined that
will be used in THIS FUNCTION ONLY. This fucntion creates a right triangle
turtle.forward(size) #to begin this function we go forward, the amount to go forward by is the
variable size
turtle.right(90) #turn right by 90 degree
turtle.forward(size) #go forward, again with variable
turtle.right(135) #turn right again
turtle.forward(size * 1.5) #close the triangle. thanks to the Pythagorean theorem we know that
this line must be 1.5 times longer than the other two(if they are equal)
while(1): #INFINITE LOOP
turtle.setpos(random.randint(-200, 200), random.randint(-200, 200)) #set the draw point to a
random (x,y) position
turtle.pencolor(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
#randomize the RGB color
triangle(random.randint(5, 55)) #use our function, because it has only one variable we can
simply put a value in the parenthesis. The value that will be sent will be random between 5 - 55, end
the end it really just changes ow big the triangle is.
turtle.pencolor(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
#randomize color again
GoalKicker.com – Python® Notes for Professionals
490Chapter 102: String representations of
class instances: __str__ and __repr__
methods
Section 102.1: Motivation
So you've just created your ﬁrst class in Python, a neat little class that encapsulates a playing card:
class Card:
def __init__(self, suit, pips):
self.suit = suit
self.pips = pips
Elsewhere in your code, you create a few instances of this class:
ace_of_spades = Card('Spades', 1)
four_of_clubs = Card('Clubs', 4)
six_of_hearts = Card('Hearts', 6)
You've even created a list of cards, in order to represent a "hand":
my_hand = [ace_of_spades, four_of_clubs, six_of_hearts]
Now, during debugging, you want to see what your hand looks like, so you do what comes naturally and write:
print(my_hand)
But what you get back is a bunch of gibberish:
[<__main__.Card instance at 0x0000000002533788>,
<__main__.Card instance at 0x00000000025B95C8>,
<__main__.Card instance at 0x00000000025FF508>]
Confused, you try just printing a single card:
print(ace_of_spades)
And again, you get this weird output:
<__main__.Card instance at 0x0000000002533788>
Have no fear. We're about to ﬁx this.
First, however, it's important to understand what's going on here. When you wrote print(ace_of_spades) you told
Python you wanted it to print information about the Card instance your code is calling ace_of_spades. And to be
fair, it did.
That output is comprised of two important bits: the type of the object and the object's id. The second part alone
(the hexadecimal number) is enough to uniquely identify the object at the time of the print call.[1]
What really went on was that you asked Python to "put into words" the essence of that object and then display it to
you. A more explicit version of the same machinery might be:
GoalKicker.com – Python® Notes for Professionals
491string_of_card = str(ace_of_spades)
print(string_of_card)
In the ﬁrst line, you try to turn your Card instance into a string, and in the second you display it.
The Problem
The issue you're encountering arises due to the fact that, while you told Python everything it needed to know about
the Card class for you to create cards, you didn't tell it how you wanted Card instances to be converted to strings.
And since it didn't know, when you (implicitly) wrote str(ace_of_spades), it gave you what you saw, a generic
representation of the Card instance.
The Solution (Part 1)
But we can tell Python how we want instances of our custom classes to be converted to strings. And the way we do
this is with the __str__ "dunder" (for double-underscore) or "magic" method.
Whenever you tell Python to create a string from a class instance, it will look for a __str__ method on the class, and
call it.
Consider the following, updated version of our Card class:
class Card:
def __init__(self, suit, pips):
self.suit = suit
self.pips = pips
def __str__(self):
special_names = {1:'Ace', 11:'Jack', 12:'Queen', 13:'King'}
card_name = special_names.get(self.pips, str(self.pips))
return "%s of %s" % (card_name, self.suit)
Here, we've now deﬁned the __str__ method on our Card class which, after a simple dictionary lookup for face
cards, returns a string formatted however we decide.
(Note that "returns" is in bold here, to stress the importance of returning a string, and not simply printing it.
Printing it may seem to work, but then you'd have the card printed when you did something like
str(ace_of_spades), without even having a print function call in your main program. So to be clear, make sure that
__str__ returns a string.).
The __str__ method is a method, so the ﬁrst argument will be self and it should neither accept, nor be passed
additional arguments.
Returning to our problem of displaying the card in a more user-friendly manner, if we again run:
ace_of_spades = Card('Spades', 1)
print(ace_of_spades)
We'll see that our output is much better:
Ace of Spades
So great, we're done, right?
GoalKicker.com – Python® Notes for Professionals
492Well just to cover our bases, let's double check that we've solved the ﬁrst issue we encountered, printing the list of
Card instances, the hand.
So we re-check the following code:
my_hand = [ace_of_spades, four_of_clubs, six_of_hearts]
print(my_hand)
And, to our surprise, we get those funny hex codes again:
[<__main__.Card instance at 0x00000000026F95C8>,
<__main__.Card instance at 0x000000000273F4C8>,
<__main__.Card instance at 0x0000000002732E08>]
What's going on? We told Python how we wanted our Card instances to be displayed, why did it apparently seem to
forget?
The Solution (Part 2)
Well, the behind-the-scenes machinery is a bit diﬀerent when Python wants to get the string representation of
items in a list. It turns out, Python doesn't care about __str__ for this purpose.
Instead, it looks for a diﬀerent method, __repr__, and if that's not found, it falls back on the "hexadecimal thing".[2]
So you're saying I have to make two methods to do the same thing? One for when I want to print my card by itself and
another when it's in some sort of container?
No, but ﬁrst let's look at what our class would be like if we were to implement both __str__ and __repr__ methods:
class Card:
special_names = {1:'Ace', 11:'Jack', 12:'Queen', 13:'King'}
def __init__(self, suit, pips):
self.suit = suit
self.pips = pips
def __str__(self):
card_name = Card.special_names.get(self.pips, str(self.pips))
return "%s of %s (S)" % (card_name, self.suit)
def __repr__(self):
card_name = Card.special_names.get(self.pips, str(self.pips))
return "%s of %s (R)" % (card_name, self.suit)
Here, the implementation of the two methods __str__ and __repr__ are exactly the same, except that, to
diﬀerentiate between the two methods, (S) is added to strings returned by __str__ and (R) is added to strings
returned by __repr__.
Note that just like our __str__ method, __repr__ accepts no arguments and returns a string.
We can see now what method is responsible for each case:
ace_of_spades = Card('Spades', 1)
four_of_clubs = Card('Clubs', 4)
six_of_hearts = Card('Hearts', 6)
my_hand = [ace_of_spades, four_of_clubs, six_of_hearts]
GoalKicker.com – Python® Notes for Professionals
493print(my_hand)# [Ace of Spades (R), 4 of Clubs (R), 6 of Hearts (R)]
print(ace_of_spades)# Ace of Spades (S)
As was covered, the __str__ method was called when we passed our Card instance to print and the __repr__
method was called when we passed a list of our instances to print.
At this point it's worth pointing out that just as we can explicitly create a string from a custom class instance using
str() as we did earlier, we can also explicitly create a string representation of our class with a built-in function
called repr().
For example:
str_card = str(four_of_clubs)
print(str_card)# 4 of Clubs (S)
repr_card = repr(four_of_clubs)
print(repr_card)# 4 of Clubs (R)
And additionally, if deﬁned, we could call the methods directly (although it seems a bit unclear and unnecessary):
print(four_of_clubs.__str__())# 4 of Clubs (S)
print(four_of_clubs.__repr__())# 4 of Clubs (R)
About those duplicated functions...
Python developers realized, in the case you wanted identical strings to be returned from str() and repr() you
might have to functionally-duplicate methods -- something nobody likes.
So instead, there is a mechanism in place to eliminate the need for that. One I snuck you past up to this point. It
turns out that if a class implements the __repr__ method but not the __str__ method, and you pass an instance of
that class to str() (whether implicitly or explicitly), Python will fallback on your __repr__ implementation and use
that.
So, to be clear, consider the following version of the Card class:
class Card:
special_names = {1:'Ace', 11:'Jack', 12:'Queen', 13:'King'}
def __init__(self, suit, pips):
self.suit = suit
self.pips = pips
def __repr__(self):
card_name = Card.special_names.get(self.pips, str(self.pips))
return "%s of %s" % (card_name, self.suit)
Note this version only implements the __repr__ method. Nonetheless, calls to str() result in the user-friendly
version:
print(six_of_hearts)
print(str(six_of_hearts))
# 6 of Hearts
# 6 of Hearts
(implicit conversion)
(explicit conversion)
as do calls to repr():
print([six_of_hearts])
#[6 of Hearts] (implicit conversion)
GoalKicker.com – Python® Notes for Professionals
494print(repr(six_of_hearts))
# 6 of Hearts
(explicit conversion)
Summary
In order for you to empower your class instances to "show themselves" in user-friendly ways, you'll want to
consider implementing at least your class's __repr__ method. If memory serves, during a talk Raymond Hettinger
said that ensuring classes implement __repr__ is one of the ﬁrst things he looks for while doing Python code
reviews, and by now it should be clear why. The amount of information you could have added to debugging
statements, crash reports, or log ﬁles with a simple method is overwhelming when compared to the paltry, and
often less-than-helpful (type, id) information that is given by default.
If you want diﬀerent representations for when, for example, inside a container, you'll want to implement both
__repr__ and __str__ methods. (More on how you might use these two methods diﬀerently below).
Section 102.2: Both methods implemented, eval-round-trip
style __repr__()
class Card:
special_names = {1:'Ace', 11:'Jack', 12:'Queen', 13:'King'}
def __init__(self, suit, pips):
self.suit = suit
self.pips = pips
# Called when instance is converted to a string via str()
# Examples:
#
print(card1)
#
print(str(card1)
def __str__(self):
card_name = Card.special_names.get(self.pips, str(self.pips))
return "%s of %s" % (card_name, self.suit)
# Called when instance is converted to a string via repr()
# Examples:
#
print([card1, card2, card3])
#
print(repr(card1))
def __repr__(self):
return "Card(%s, %d)" % (self.suit, self.pips)
GoalKicker.com – Python® Notes for Professionals
495Chapter 103: Debugging
Section 103.1: Via IPython and ipdb
If IPython (or Jupyter) are installed, the debugger can be invoked using:
import ipdb
ipdb.set_trace()
When reached, the code will exit and print:
/home/usr/ook.py(3)<module>()
1 import ipdb
2 ipdb.set_trace()
----> 3 print("Hello world!")
ipdb>
Clearly, this means that one has to edit the code. There is a simpler way:
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(mode='Verbose',
color_scheme='Linux',
call_pdb=1)
This will cause the debugger to be called if there is an uncaught exception raised.
Section 103.2: The Python Debugger: Step-through Debugging
with _pdb_
The Python Standard Library includes an interactive debugging library called pdb. pdb has extensive capabilities, the
most commonly used being the ability to 'step-through' a program.
To immediately enter into step-through debugging use:
python -m pdb <my_file.py>
This will start the debugger at the ﬁrst line of the program.
Usually you will want to target a speciﬁc section of the code for debugging. To do this we import the pdb library and
use set_trace() to interrupt the ﬂow of this troubled example code.
import pdb
def divide(a, b):
pdb.set_trace()
return a/b
# What's wrong with this? Hint: 2 != 3
print divide(1, 2)
Running this program will launch the interactive debugger.
python foo.py
> ~/scratch/foo.py(5)divide()
GoalKicker.com – Python® Notes for Professionals
496-> return a/b
(Pdb)
Often this command is used on one line so it can be commented out with a single # character
import pdf; pdb.set_trace()
At the (Pdb) prompt commands can be entered. These commands can be debugger commands or python. To print
variables we can use p from the debugger, or python's print.
(Pdb) p a
1
(Pdb) print a
1
To see list of all local variables use
locals
build-in function
These are good debugger commands to know:
b | : set breakpoint at line *n* or function named *f*.
# b 3
# b divide
b: show all breakpoints.
c: continue until the next breakpoint.
s: step through this line (will enter a function).
n: step over this line (jumps over a function).
r: continue until the current function returns.
l: list a window of code around this line.
p : print variable named *var*.
# p x
q: quit debugger.
bt: print the traceback of the current execution call stack
up: move your scope up the function call stack to the caller of the current function
down: Move your scope back down the function call stack one level
step: Run the program until the next line of execution in the program, then return control back to
the debugger
next: run the program until the next line of execution in the current function, then return
control back to the debugger
return: run the program until the current function returns, then return control back to the
debugger
continue: continue running the program until the next breakpoint (or set_trace si called again)
The debugger can also evaluate python interactively:
-> return a/b
(Pdb) p a+b
3
(Pdb) [ str(m) for m in [a,b]]
['1', '2']
(Pdb) [ d for d in xrange(5)]
[0, 1, 2, 3, 4]
Note:
GoalKicker.com – Python® Notes for Professionals
497If any of your variable names coincide with the debugger commands, use an exclamation mark '!' before the var to
explicitly refer to the variable and not the debugger command. For example, often it might so happen that you use
the variable name 'c' for a counter, and you might want to print it while in the debugger. a simple 'c' command
would continue execution till the next breakpoint. Instead use '!c' to print the value of the variable as follows:
(Pdb) !c
4
Section 103.3: Remote debugger
Sometimes you need to debug python code which is executed by another process and in this cases rpdb comes in
handy.
rpdb is a wrapper around pdb that re-routes stdin and stdout to a socket handler. By default it opens the
debugger on port 4444
Usage:
# In the Python file you want to debug.
import rpdb
rpdb.set_trace()
And then you need run this in terminal to connect to this process.
# Call in a terminal to see the output
$ nc 127.0.0.1 4444
And you will get pdb promt
> /home/usr/ook.py(3)<module>()
-> print("Hello world!")
(Pdb)
GoalKicker.com – Python® Notes for Professionals
498Chapter 104: Reading and Writing CSV
Section 104.1: Using pandas
Write a CSV ﬁle from a dict or a DataFrame.
import pandas as pd
d = {'a': (1, 101), 'b': (2, 202), 'c': (3, 303)}
pd.DataFrame.from_dict(d, orient="index")
df.to_csv("data.csv")
Read a CSV ﬁle as a DataFrame and convert it to a dict:
df = pd.read_csv("data.csv")
d = df.to_dict()
Section 104.2: Writing a TSV ﬁle
Python
import csv
with open('/tmp/output.tsv', 'wt') as out_file:
tsv_writer = csv.writer(out_file, delimiter='\t')
tsv_writer.writerow(['name', 'field'])
tsv_writer.writerow(['Dijkstra', 'Computer Science'])
tsv_writer.writerow(['Shelah', 'Math'])
tsv_writer.writerow(['Aumann', 'Economic Sciences'])
Output ﬁle
$ cat /tmp/output.tsv
name
field
Dijkstra
Computer Science
Shelah
Math
Aumann
Economic Sciences
GoalKicker.com – Python® Notes for Professionals
499VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 105: Writing to CSV from String or
List
Parameter
open ("/path/", "mode")Details
Specify the path to your CSV ﬁle
open (path, "mode")Specify mode to open ﬁle in (read, write, etc.)
csv.writer(ﬁle, delimiter)Pass opened CSV ﬁle here
csv.writer(ﬁle, delimiter=' ') Specify delimiter character or pattern
Writing to a .csv ﬁle is not unlike writing to a regular ﬁle in most regards, and is fairly straightforward. I will, to the
best of my ability, cover the easiest, and most eﬃcient approach to the problem.
Section 105.1: Basic Write Example
import csv
#------ We will write to CSV in this function ------------
def csv_writer(data, path):
#Open CSV file whose path we passed.
with open(path, "wb") as csv_file:
writer = csv.writer(csv_file, delimiter=',')
for line in data:
writer.writerow(line)
#---- Define our list here, and call function ------------
if __name__ == "__main__":
"""
data = our list that we want to write.
Split it so we get a list of lists.
"""
data = ["first_name,last_name,age".split(","),
"John,Doe,22".split(","),
"Jane,Doe,31".split(","),
"Jack,Reacher,27".split(",")
]
# Path to CSV file we want to write to.
path = "output.csv"
csv_writer(data, path)
Section 105.2: Appending a String as a newline in a CSV ﬁle
def append_to_csv(input_string):
with open("fileName.csv", "a") as csv_file:
csv_file.write(input_row + "\n")
GoalKicker.com – Python® Notes for Professionals
501Chapter 106: Dynamic code execution with
`exec` and `eval`
Argument
Details
expression The expression code as a string, or a code object
objectThe statement code as a string, or a code object
globalsThe dictionary to use for global variables. If locals is not speciﬁed, this is also used for locals. If
omitted, the globals() of calling scope are used.
localsA mapping object that is used for local variables. If omitted, the one passed for globals is used
instead. If both are omitted, then the globals() and locals() of the calling scope are used for
globals and locals respectively.
Section 106.1: Executing code provided by untrusted user
using exec, eval, or ast.literal_eval
It is not possible to use eval or exec to execute code from untrusted user securely. Even ast.literal_eval is
prone to crashes in the parser. It is sometimes possible to guard against malicious code execution, but it doesn't
exclude the possibility of outright crashes in the parser or the tokenizer.
To evaluate code by an untrusted user you need to turn to some third-party module, or perhaps write your own
parser and your own virtual machine in Python.
Section 106.2: Evaluating a string containing a Python literal
with ast.literal_eval
If you have a string that contains Python literals, such as strings, ﬂoats etc, you can use ast.literal_eval to
evaluate its value instead of eval. This has the added feature of allowing only certain syntax.
>>> import ast
>>> code = """(1, 2, {'foo': 'bar'})"""
>>> object = ast.literal_eval(code)
>>> object
(1, 2, {'foo': 'bar'})
>>> type(object)
<class 'tuple'>
However, this is not secure for execution of code provided by untrusted user, and it is trivial to crash an
interpreter with carefully crafted input
>>> import ast
>>> ast.literal_eval('()' * 1000000)
[5]
21358 segmentation fault (core dumped)
python3
Here, the input is a string of () repeated one million times, which causes a crash in CPython parser. CPython
developers do not consider bugs in parser as security issues.
Section 106.3: Evaluating statements with exec
>>> code = """for i in range(5):\n
>>> exec(code)
Hello world!
Hello world!
Hello world!
print('Hello world!')"""
GoalKicker.com – Python® Notes for Professionals
502Hello world!
Hello world!
Section 106.4: Evaluating an expression with eval
>>> expression = '5 + 3 * a'
>>> a = 5
>>> result = eval(expression)
>>> result
20
Section 106.5: Precompiling an expression to evaluate it
multiple times
compile built-in function can be used to precompile an expression to a code object; this code object can then be
passed to eval. This will speed up the repeated executions of the evaluated code. The 3rd parameter to compile
needs to be the string 'eval'.
>>> code = compile('a * b + c', '<string>', 'eval')
>>> code
<code object <module> at 0x7f0e51a58830, file "<string>", line 1>
>>> a, b, c = 1, 2, 3
>>> eval(code)
5
Section 106.6: Evaluating an expression with eval using
custom globals
>>> variables = {'a': 6, 'b': 7}
>>> eval('a * b', globals=variables)
42
As a plus, with this the code cannot accidentally refer to the names deﬁned outside:
>>> eval('variables')
{'a': 6, 'b': 7}
>>> eval('variables', globals=variables)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
NameError: name 'variables' is not defined
Using defaultdict allows for example having undeﬁned variables set to zero:
>>> from collections import defaultdict
>>> variables = defaultdict(int, {'a': 42})
>>> eval('a * c', globals=variables) # note that 'c' is not explicitly defined
0
GoalKicker.com – Python® Notes for Professionals
503Chapter 107: PyInstaller - Distributing
Python Code
Section 107.1: Installation and Setup
Pyinstaller is a normal python package. It can be installed using pip:
pip install pyinstaller
Installation in Windows
For Windows, pywin32 or pypiwin32 is a prerequisite. The latter is installed automatically when pyinstaller is
installed using pip.
Installation in Mac OS X
PyInstaller works with the default Python 2.7 provided with current Mac OS X. If later versions of Python are to be
used or if any major packages such as PyQT, Numpy, Matplotlib and the like are to be used, it is recommended to
install them using either MacPorts or Homebrew.
Installing from the archive
If pip is not available, download the compressed archive from PyPI.
To test the development version, download the compressed archive from the develop branch of PyInstaller
Downloads page.
Expand the archive and ﬁnd the setup.py script. Execute python setup.py install with administrator privilege to
install or upgrade PyInstaller.
Verifying the installation
The command pyinstaller should exist on the system path for all platforms after a successful installation.
Verify it by typing pyinstaller --version in the command line. This will print the current version of pyinstaller.
Section 107.2: Using Pyinstaller
In the simplest use-case, just navigate to the directory your ﬁle is in, and type:
pyinstaller myfile.py
Pyinstaller analyzes the ﬁle and creates:
A myﬁle.spec ﬁle in the same directory as myfile.py
A build folder in the same directory as myfile.py
A dist folder in the same directory as myfile.py
Log ﬁles in the build folder
The bundled app can be found in the dist folder
Options
There are several options that can be used with pyinstaller. A full list of the options can be found here.
Once bundled your app can be run by opening 'dist\myﬁle\myﬁle.exe'.
GoalKicker.com – Python® Notes for Professionals
504Section 107.3: Bundling to One Folder
When PyInstaller is used without any options to bundle myscript.py , the default output is a single folder (named
myscript) containing an executable named myscript (myscript.exe in windows) along with all the necessary
dependencies.
The app can be distributed by compressing the folder into a zip ﬁle.
One Folder mode can be explicitly set using the option -D or --onedir
pyinstaller myscript.py -D
Advantages:
One of the major advantages of bundling to a single folder is that it is easier to debug problems. If any modules fail
to import, it can be veriﬁed by inspecting the folder.
Another advantage is felt during updates. If there are a few changes in the code but the dependencies used are
exactly the same, distributors can just ship the executable ﬁle (which is typically smaller than the entire folder).
Disadvantages
The only disadvantage of this method is that the users have to search for the executable among a large number of
ﬁles.
Also users can delete/modify other ﬁles which might lead to the app not being able to work correctly.
Section 107.4: Bundling to a Single File
pyinstaller myscript.py -F
The options to generate a single ﬁle are -F or --onefile. This bundles the program into a single myscript.exe ﬁle.
Single ﬁle executable are slower than the one-folder bundle. They are also harder to debug.
GoalKicker.com – Python® Notes for Professionals
505Chapter 108: Data Visualization with
Python
Section 108.1: Seaborn
Seaborn is a wrapper around Matplotlib that makes creating common statistical plots easy. The list of supported
plots includes univariate and bivariate distribution plots, regression plots, and a number of methods for plotting
categorical variables. The full list of plots Seaborn provides is in their API reference.
Creating graphs in Seaborn is as simple as calling the appropriate graphing function. Here is an example of creating
a histogram, kernel density estimation, and rug plot for randomly generated data.
import numpy as np # numpy used to create data from plotting
import seaborn as sns # common form of importing seaborn
# Generate normally distributed data
data = np.random.randn(1000)
# Plot a histogram with both a rugplot and kde graph superimposed
sns.distplot(data, kde=True, rug=True)
The style of the plot can also be controlled using a declarative syntax.
# Using previously created imports and data.
# Use a dark background with no grid.
sns.set_style('dark')
GoalKicker.com – Python® Notes for Professionals
506# Create the plot again
sns.distplot(data, kde=True, rug=True)
As an added bonus, normal matplotlib commands can still be applied to Seaborn plots. Here's an example of
adding axis titles to our previously created histogram.
# Using previously created data and style
# Access to matplotlib commands
import matplotlib.pyplot as plt
# Previously created plot.
sns.distplot(data, kde=True, rug=True)
# Set the axis labels.
plt.xlabel('This is my x-axis')
plt.ylabel('This is my y-axis')
GoalKicker.com – Python® Notes for Professionals
507Section 108.2: Matplotlib
Matplotlib is a mathematical plotting library for Python that provides a variety of diﬀerent plotting functionality.
The matplotlib documentation can be found here, with the SO Docs being available here.
Matplotlib provides two distinct methods for plotting, though they are interchangeable for the most part:
Firstly, matplotlib provides the pyplot interface, direct and simple-to-use interface that allows plotting of
complex graphs in a MATLAB-like style.
Secondly, matplotlib allows the user to control the diﬀerent aspects (axes, lines, ticks, etc) directly using an
object-based system. This is more diﬃcult but allows complete control over the entire plot.
Below is an example of using the pyplot interface to plot some generated data:
import matplotlib.pyplot as plt
# Generate some data for plotting.
x = [0, 1, 2, 3, 4, 5, 6]
y = [i**2 for i in x]
# Plot the data x, y with some keyword arguments that control the plot style.
# Use two different plot commands to plot both points (scatter) and a line (plot).
plt.scatter(x, y, c='blue', marker='x', s=100) # Create blue markers of shape "x" and size 100
plt.plot(x, y, color='red', linewidth=2) # Create a red line with linewidth 2.
# Add some text to the axes and a title.
plt.xlabel('x data')
GoalKicker.com – Python® Notes for Professionals
508plt.ylabel('y data')
plt.title('An example plot')
# Generate the plot and show to the user.
plt.show()
Note that plt.show() is known to be problematic in some environments due to running matplotlib.pyplot in
interactive mode, and if so, the blocking behaviour can be overridden explicitly by passing in an optional argument,
plt.show(block=True), to alleviate the issue.
Section 108.3: Plotly
Plotly is a modern platform for plotting and data visualization. Useful for producing a variety of plots, especially for
data sciences, Plotly is available as a library for Python, R, JavaScript, Julia and, MATLAB. It can also be used as a
web application with these languages.
Users can install plotly library and use it oﬄine after user authentication. The installation of this library and oﬄine
authentication is given here. Also, the plots can be made in Jupyter Notebooks as well.
Usage of this library requires an account with username and password. This gives the workspace to save plots and
data on the cloud.
The free version of the library has some slightly limited features and designed for making 250 plots per day. The
paid version has all the features, unlimited plot downloads and more private data storage. For more details, one
can visit the main page here.
GoalKicker.com – Python® Notes for Professionals
509For documentation and examples, one can go here
A sample plot from the documentation examples:
import plotly.graph_objs as go
import plotly as ply
# Create random data with numpy
import numpy as np
N = 100
random_x = np.linspace(0, 1, N)
random_y0 = np.random.randn(N)+5
random_y1 = np.random.randn(N)
random_y2 = np.random.randn(N)-5
# Create traces
trace0 = go.Scatter(
x = random_x,
y = random_y0,
mode = 'lines',
name = 'lines'
)
trace1 = go.Scatter(
x = random_x,
y = random_y1,
mode = 'lines+markers',
name = 'lines+markers'
)
trace2 = go.Scatter(
x = random_x,
y = random_y2,
mode = 'markers',
name = 'markers'
)
data = [trace0, trace1, trace2]
ply.offline.plot(data, filename='line-mode')
GoalKicker.com – Python® Notes for Professionals
510Section 108.4: MayaVI
MayaVI is a 3D visualization tool for scientiﬁc data. It uses the Visualization Tool Kit or VTK under the hood. Using
the power of VTK, MayaVI is capable of producing a variety of 3-Dimensional plots and ﬁgures. It is available as a
separate software application and also as a library. Similar to Matplotlib, this library provides an object oriented
programming language interface to create plots without having to know about VTK.
MayaVI is available only in Python 2.7x series! It is hoped to be available in Python 3-x series soon!
(Although some success is noticed when using its dependencies in Python 3)
Documentation can be found here. Some gallery examples are found here
Here is a sample plot created using MayaVI from the documentation.
# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>
# Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
from numpy import sin, cos, mgrid, pi, sqrt
from mayavi import mlab
mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
u, v = mgrid[- 0.035:pi:0.01, - 0.035:pi:0.01]
X = 2 / 3. * (cos(u) * cos(2 * v)
+ sqrt(2) * sin(u) * cos(v)) * cos(u) / (sqrt(2) -
sin(2 * u) * sin(3 * v))
Y = 2 / 3. * (cos(u) * sin(2 * v) -
sqrt(2) * sin(u) * sin(v)) * cos(u) / (sqrt(2)
- sin(2 * u) * sin(3 * v))
GoalKicker.com – Python® Notes for Professionals
511Z = -sqrt(2) * cos(u) * cos(u) / (sqrt(2) - sin(2 * u) * sin(3 * v))
S = sin(u)
mlab.mesh(X, Y, Z, scalars=S, colormap='YlGnBu', )
# Nice view from the front
mlab.view(.0, - 5.0, 4)
mlab.show()
GoalKicker.com – Python® Notes for Professionals
512Chapter 109: The Interpreter (Command
Line Console)
Section 109.1: Getting general help
If the help function is called in the console without any arguments, Python presents an interactive help console,
where you can ﬁnd out about Python modules, symbols, keywords and more.
>>> help()
Welcome to Python 3.4's help utility!
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/3.4/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics". Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".
Section 109.2: Referring to the last expression
To get the value of the last result from your last expression in the console, use an underscore _.
>>> 2 + 2
4
>>> _
4
>>> _ + 6
10
This magic underscore value is only updated when using a python expression that results in a value. Deﬁning
functions or for loops does not change the value. If the expression raises an exception there will be no changes to
_.
>>> "Hello, {0}".format("World")
'Hello, World'
>>> _
'Hello, World'
>>> def wontchangethings():
...
pass
>>> _
'Hello, World'
>>> 27 / 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
>>> _
'Hello, World'
Remember, this magic variable is only available in the interactive python interpreter. Running scripts will not do
this.
GoalKicker.com – Python® Notes for Professionals
513Section 109.3: Opening the Python console
The console for the primary version of Python can usually be opened by typing py into your windows console or
python on other platforms.
$ py
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
If you have multiple versions, then by default their executables will be mapped to python2 or python3 respectively.
This of course depends on the Python executables being in your PATH.
Section 109.4: The PYTHONSTARTUP variable
You can set an environment variable called PYTHONSTARTUP for Python's console. Whenever you enter the Python
console, this ﬁle will be executed, allowing for you to add extra functionality to the console such as importing
commonly-used modules automatically.
If the PYTHONSTARTUP variable was set to the location of a ﬁle containing this:
print("Welcome!")
Then opening the Python console would result in this extra output:
$ py
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Welcome!
>>>
Section 109.5: Command line arguments
Python has a variety of command-line switches which can be passed to py. These can be found by performing py --
help, which gives this output on Python 3.4:
Python Launcher
usage: py [ launcher-arguments ] [ python-arguments ] script [ script-arguments ]
Launcher arguments:
-2 : Launch the latest Python 2.x version
-3 : Launch the latest Python 3.x version
-X.Y : Launch the specified Python version
-X.Y-32: Launch the specified 32bit Python version
The following help text is from Python:
usage: G:\\Python34\\python.exe [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-b : issue warnings about str(bytes_instance), str(bytearray_instance)
and comparing bytes/bytearray with str. (-bb: issue errors)
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
GoalKicker.com – Python® Notes for Professionals
514-d : debug output from parser; also PYTHONDEBUG=x
-E : ignore PYTHON* environment variables (such as PYTHONPATH)
-h : print this help message and exit (also --help)
-i : inspect interactively after running script; forces a prompt even
if stdin does not appear to be a terminal; also PYTHONINSPECT=x
-I : isolate Python from the user's environment (implies -E and -s)
-m mod : run library module as a script (terminates option list)
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x
-OO : remove doc-strings in addition to the -O optimizations
-q : don't print version and copyright messages on interactive startup
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE
-S : don't imply 'import site' on initialization
-u : unbuffered binary stdout and stderr, stdin always buffered;
also PYTHONUNBUFFERED=x
see man page for details on internal buffering relating to '-u'
-v : verbose (trace import statements); also PYTHONVERBOSE=x
can be supplied multiple times to increase verbosity
-V : print the Python version number and exit (also --version)
-W arg : warning control; arg is action:message:category:module:lineno
also PYTHONWARNINGS=arg
-x : skip first line of source, allowing use of non-Unix forms of #!cmd
-X opt : set implementation-specific option
file : program read from script file
- : program read from stdin (default; interactive mode if a tty)
arg ...: arguments passed to program in sys.argv[1:]
Other environment variables:
PYTHONSTARTUP: file executed on interactive startup (no default)
PYTHONPATH : ';'-separated list of directories prefixed to the
default module search path. The result is sys.path.
PYTHONHOME : alternate directory (or ;).
The default module search path uses \\lib.
PYTHONCASEOK : ignore case in 'import' statements (Windows).
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.
PYTHONHASHSEED: if this variable is set to 'random', a random value is used
to seed the hashes of str, bytes and datetime objects. It can also be
set to an integer in the range [0,4294967295] to get hash values with a
predictable seed.
Section 109.6: Getting help about an object
The Python console adds a new function, help, which can be used to get information about a function or object.
For a function, help prints its signature (arguments) and its docstring, if the function has one.
>>> help(print)
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep:
string inserted between values, default a space.
end:
string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
For an object, help lists the object's docstring and the diﬀerent member functions which the object has.
GoalKicker.com – Python® Notes for Professionals
515>>> x = 2
>>> help(x)
Help on int object:
class int(object)
| int(x=0) -> integer
| int(x, base=10) -> integer
|
| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating point
| numbers, this truncates towards zero.
|
| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.
| >>> int('0b100', base=0)
| 4
|
| Methods defined here:
|
| __abs__(self, /)
|
abs(self)
|
| __add__(self, value, /)
|
Return self+value...
GoalKicker.com – Python® Notes for Professionals
516VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 110: *args and **kwargs
Section 110.1: Using **kwargs when writing functions
You can deﬁne a function that takes an arbitrary number of keyword (named) arguments by using the double star
** before a parameter name:
def print_kwargs(**kwargs):
print(kwargs)
When calling the method, Python will construct a dictionary of all keyword arguments and make it available in the
function body:
print_kwargs(a="two", b=3)
# prints: "{a: "two", b=3}"
Note that the **kwargs parameter in the function deﬁnition must always be the last parameter, and it will only
match the arguments that were passed in after the previous ones.
def example(a, **kw):
print kw
example(a=2, b=3, c=4) # => {'b': 3, 'c': 4}
Inside the function body, kwargs is manipulated in the same way as a dictionary; in order to access individual
elements in kwargs you just loop through them as you would with a normal dictionary:
def print_kwargs(**kwargs):
for key in kwargs:
print("key = {0}, value = {1}".format(key, kwargs[key]))
Now, calling print_kwargs(a="two", b=1) shows the following output:
print_kwargs(a = "two", b = 1)
key = a, value = "two"
key = b, value = 1
Section 110.2: Using *args when writing functions
You can use the star * when writing a function to collect all positional (ie. unnamed) arguments in a tuple:
def print_args(farg, *args):
print("formal arg: %s" % farg)
for arg in args:
print("another positional arg: %s" % arg)
Calling method:
print_args(1, "two", 3)
In that call, farg will be assigned as always, and the two others will be fed into the args tuple, in the order they were
received.
GoalKicker.com – Python® Notes for Professionals
518Section 110.3: Populating kwarg values with a dictionary
def foobar(foo=None, bar=None):
return "{}{}".format(foo, bar)
values = {"foo": "foo", "bar": "bar"}
foobar(**values) # "foobar"
Section 110.4: Keyword-only and Keyword-required
arguments
Python 3 allows you to deﬁne function arguments which can only be assigned by keyword, even without default
values. This is done by using star * to consume additional positional parameters without setting the keyword
parameters. All arguments after the * are keyword-only (i.e. non-positional) arguments. Note that if keyword-only
arguments aren't given a default, they are still required when calling the function.
def print_args(arg1, *args, keyword_required, keyword_only=True):
print("first positional arg: {}".format(arg1))
for arg in args:
print("another positional arg: {}".format(arg))
print("keyword_required value: {}".format(keyword_required))
print("keyword_only value: {}".format(keyword_only))
print(1, 2, 3, 4) # TypeError: print_args() missing 1 required keyword-only argument:
'keyword_required'
print(1, 2, 3, keyword_required=4)
# first positional arg: 1
# another positional arg: 2
# another positional arg: 3
# keyword_required value: 4
# keyword_only value: True
Section 110.5: Using **kwargs when calling functions
You can use a dictionary to assign values to the function's parameters; using parameters name as keys in the
dictionary and the value of these arguments bound to each key:
def test_func(arg1, arg2, arg3): # Usual function with three arguments
print("arg1: %s" % arg1)
print("arg2: %s" % arg2)
print("arg3: %s" % arg3)
# Note that dictionaries are unordered, so we can switch arg2 and arg3. Only the names matter.
kwargs = {"arg3": 3, "arg2": "two"}
# Bind the first argument (ie. arg1) to 1, and use the kwargs dictionary to bind the others
test_var_args_call(1, **kwargs)
Section 110.6: **kwargs and default values
To use default values with **kwargs
def fun(**kwargs):
print kwargs.get('value', 0)
GoalKicker.com – Python® Notes for Professionals
519fun()
# print 0
fun(value=1)
# print 1
Section 110.7: Using *args when calling functions
The eﬀect of using the * operator on an argument when calling a function is that of unpacking the list or a tuple
argument
def print_args(arg1, arg2):
print(str(arg1) + str(arg2))
a = [1,2]
b = tuple([3,4])
print_args(*a)
# 12
print_args(*b)
# 34
Note that the length of the starred argument need to be equal to the number of the function's arguments.
A common python idiom is to use the unpacking operator * with the zip function to reverse its eﬀects:
a = [1,3,5,7,9]
b = [2,4,6,8,10]
zipped = zip(a,b)
# [(1,2), (3,4), (5,6), (7,8), (9,10)]
zip(*zipped)
# (1,3,5,7,9), (2,4,6,8,10)
GoalKicker.com – Python® Notes for Professionals
520Chapter 111: Garbage Collection
Section 111.1: Reuse of primitive objects
An interesting thing to note which may help optimize your applications is that primitives are actually also
refcounted under the hood. Let's take a look at numbers; for all integers between -5 and 256, Python always reuses
the same object:
>>> import sys
>>> sys.getrefcount(1)
797
>>> a = 1
>>> b = 1
>>> sys.getrefcount(1)
799
Note that the refcount increases, meaning that a and b reference the same underlying object when they refer to the
1 primitive. However, for larger numbers, Python actually doesn't reuse the underlying object:
>>> a = 999999999
>>> sys.getrefcount(999999999)
3
>>> b = 999999999
>>> sys.getrefcount(999999999)
3
Because the refcount for 999999999 does not change when assigning it to a and b we can infer that they refer to
two diﬀerent underlying objects, even though they both are assigned the same primitive.
Section 111.2: Eects of the del command
Removing a variable name from the scope using del v, or removing an object from a collection using del v[item]
or del[i:j], or removing an attribute using del v.name, or any other way of removing references to an object, does
not trigger any destructor calls or any memory being freed in and of itself. Objects are only destructed when their
reference count reaches zero.
>>> import gc
>>> gc.disable() # disable garbage collector
>>> class Track:
def __init__(self):
print("Initialized")
def __del__(self):
print("Destructed")
>>> def bar():
return Track()
>>> t = bar()
Initialized
>>> another_t = t # assign another reference
>>> print("...")
...
>>> del t
# not destructed yet - another_t still refers to it
>>> del another_t # final reference gone, object is destructed
Destructed
GoalKicker.com – Python® Notes for Professionals
521Section 111.3: Reference Counting
The vast majority of Python memory management is handled with reference counting.
Every time an object is referenced (e.g. assigned to a variable), its reference count is automatically increased. When
it is dereferenced (e.g. variable goes out of scope), its reference count is automatically decreased.
When the reference count reaches zero, the object is immediately destroyed and the memory is immediately
freed. Thus for the majority of cases, the garbage collector is not even needed.
>>> import gc; gc.disable() # disable garbage collector
>>> class Track:
def __init__(self):
print("Initialized")
def __del__(self):
print("Destructed")
>>> def foo():
Track()
# destructed immediately since no longer has any references
print("---")
t = Track()
# variable is referenced, so it's not destructed yet
print("---")
# variable is destructed when function exits
>>> foo()
Initialized
Destructed
---
Initialized
---
Destructed
To demonstrate further the concept of references:
>>> def bar():
return Track()
>>> t = bar()
Initialized
>>> another_t = t # assign another reference
>>> print("...")
...
>>> t = None
# not destructed yet - another_t still refers to it
>>> another_t = None # final reference gone, object is destructed
Destructed
Section 111.4: Garbage Collector for Reference Cycles
The only time the garbage collector is needed is if you have a reference cycle. The simples example of a reference
cycle is one in which A refers to B and B refers to A, while nothing else refers to either A or B. Neither A or B are
accessible from anywhere in the program, so they can safely be destructed, yet their reference counts are 1 and so
they cannot be freed by the reference counting algorithm alone.
>>> import gc; gc.disable() # disable garbage collector
>>> class Track:
def __init__(self):
print("Initialized")
def __del__(self):
print("Destructed")
GoalKicker.com – Python® Notes for Professionals
522>>> A = Track()
Initialized
>>> B = Track()
Initialized
>>> A.other = B
>>> B.other = A
>>> del A; del B
>>> gc.collect()
Destructed
Destructed
4
# objects are not destructed due to reference cycle
# trigger collection
A reference cycle can be arbitrary long. If A points to B points to C points to ... points to Z which points to A, then
neither A through Z will be collected, until the garbage collection phase:
>>> objs = [Track() for _ in range(10)]
Initialized
Initialized
Initialized
Initialized
Initialized
Initialized
Initialized
Initialized
Initialized
Initialized
>>> for i in range(len(objs)-1):
...
objs[i].other = objs[i + 1]
...
>>> objs[-1].other = objs[0] # complete the cycle
>>> del objs
# no one can refer to objs now - still not destructed
>>> gc.collect()
Destructed
Destructed
Destructed
Destructed
Destructed
Destructed
Destructed
Destructed
Destructed
Destructed
20
Section 111.5: Forcefully deallocating objects
You can force deallocate objects even if their refcount isn't 0 in both Python 2 and 3.
Both versions use the ctypes module to do so.
WARNING: doing this will leave your Python environment unstable and prone to crashing without a traceback!
Using this method could also introduce security problems (quite unlikely) Only deallocate objects you're sure you'll
never reference again. Ever.
Python 3.x Version ≥ 3.0
import ctypes
deallocated = 12345
ctypes.pythonapi._Py_Dealloc(ctypes.py_object(deallocated))
Python 2.x Version ≥ 2.3
GoalKicker.com – Python® Notes for Professionals
523import ctypes, sys
deallocated = 12345
(ctypes.c_char * sys.getsizeof(deallocated)).from_address(id(deallocated))[:4] = '\x00' * 4
After running, any reference to the now deallocated object will cause Python to either produce undeﬁned behavior
or crash - without a traceback. There was probably a reason why the garbage collector didn't remove that object...
If you deallocate None, you get a special message - Fatal Python error: deallocating None before crashing.
Section 111.6: Viewing the refcount of an object
>>> import sys
>>> a = object()
>>> sys.getrefcount(a)
2
>>> b = a
>>> sys.getrefcount(a)
3
>>> del b
>>> sys.getrefcount(a)
2
Section 111.7: Do not wait for the garbage collection to clean
up
The fact that the garbage collection will clean up does not mean that you should wait for the garbage collection
cycle to clean up.
In particular you should not wait for garbage collection to close ﬁle handles, database connections and open
network connections.
for example:
In the following code, you assume that the ﬁle will be closed on the next garbage collection cycle, if f was the last
reference to the ﬁle.
>>> f = open("test.txt")
>>> del f
A more explicit way to clean up is to call f.close(). You can do it even more elegant, that is by using the with
statement, also known as the context manager :
>>> with open("test.txt") as f:
...
pass
...
# do something with f
>>> #now the f object still exists, but it is closed
The with statement allows you to indent your code under the open ﬁle. This makes it explicit and easier to see how
long a ﬁle is kept open. It also always closes a ﬁle, even if an exception is raised in the while block.
Section 111.8: Managing garbage collection
There are two approaches for inﬂuencing when a memory cleanup is performed. They are inﬂuencing how often
the automatic process is performed and the other is manually triggering a cleanup.
GoalKicker.com – Python® Notes for Professionals
524The garbage collector can be manipulated by tuning the collection thresholds which aﬀect the frequency at which
the collector runs. Python uses a generation based memory management system. New objects are saved in the
newest generation - generation0 and with each survived collection, objects are promoted to older generations.
After reaching the last generation - generation2, they are no longer promoted.
The thresholds can be changed using the following snippet:
import gc
gc.set_threshold(1000, 100, 10) # Values are just for demonstration purpose
The ﬁrst argument represents the threshold for collecting generation0. Every time the number of allocations
exceeds the number of deallocations by 1000 the garbage collector will be called.
The older generations are not cleaned at each run to optimize the process. The second and third arguments are
optional and control how frequently the older generations are cleaned. If generation0 was processed 100 times
without cleaning generation1, then generation1 will be processed. Similarly, objects in generation2 will be
processed only when the ones in generation1 were cleaned 10 times without touching generation2.
One instance in which manually setting the thresholds is beneﬁcial is when the program allocates a lot of small
objects without deallocating them which leads to the garbage collector running too often (each
generation0_threshold object allocations). Even though, the collector is pretty fast, when it runs on huge numbers
of objects it poses a performance issue. Anyway, there's no one size ﬁts all strategy for choosing the thresholds and
it's use case dependable.
Manually triggering a collection can be done as in the following snippet:
import gc
gc.collect()
The garbage collection is automatically triggered based on the number of allocations and deallocations, not on the
consumed or available memory. Consequently, when working with big objects, the memory might get depleted
before the automated cleanup is triggered. This makes a good use case for manually calling the garbage collector.
Even though it's possible, it's not an encouraged practice. Avoiding memory leaks is the best option. Anyway, in big
projects detecting the memory leak can be a tough task and manually triggering a garbage collection can be used
as a quick solution until further debugging.
For long-running programs, the garbage collection can be triggered on a time basis or on an event basis. An
example for the ﬁrst one is a web server that triggers a collection after a ﬁxed number of requests. For the later, a
web server that triggers a garbage collection when a certain type of request is received.
GoalKicker.com – Python® Notes for Professionals
525Chapter 112: Pickle data serialisation
Parameter
Details
object
The object which is to be stored
ﬁleThe open ﬁle which will contain the object
protocolThe protocol used for pickling the object (optional parameter)
buﬀerA bytes object that contains a serialized object
Section 112.1: Using Pickle to serialize and deserialize an object
The pickle module implements an algorithm for turning an arbitrary Python object into a series of bytes. This
process is also called serializing the object. The byte stream representing the object can then be transmitted or
stored, and later reconstructed to create a new object with the same characteristics.
For the simplest code, we use the dump() and load() functions.
To serialize the object
import pickle
# An arbitrary collection of objects supported by pickle.
data = {
'a': [1, 2.0, 3, 4+6j],
'b': ("character string", b"byte string"),
'c': {None, True, False}
}
with open('data.pickle', 'wb') as f:
# Pickle the 'data' dictionary using the highest protocol available.
pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
To deserialize the object
import pickle
with open('data.pickle', 'rb') as f:
# The protocol version used is detected automatically, so we do not
# have to specify it.
data = pickle.load(f)
Using pickle and byte objects
It is also possible to serialize into and deserialize out of byte objects, using the dumps and loads function, which are
equivalent to dump and load.
serialized_data = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
# type(serialized_data) is bytes
deserialized_data = pickle.loads(serialized_data)
# deserialized_data == data
Section 112.2: Customize Pickled Data
Some data cannot be pickled. Other data should not be pickled for other reasons.
What will be pickled can be deﬁned in __getstate__ method. This method must return something that is picklable.
GoalKicker.com – Python® Notes for Professionals
526On the opposite side is __setstate__: it will receive what __getstate__ created and has to initialize the object.
class A(object):
def __init__(self, important_data):
self.important_data = important_data
# Add data which cannot be pickled:
self.func = lambda: 7
# Add data which should never be pickled, because it expires quickly:
self.is_up_to_date = False
def __getstate__(self):
return [self.important_data] # only this is needed
def __setstate__(self, state):
self.important_data = state[0]
self.func = lambda: 7
# just some hard-coded unpicklable function
self.is_up_to_date = False
# even if it was before pickling
Now, this can be done:
>>> a1 = A('very important')
>>>
>>> s = pickle.dumps(a1) # calls a1.__getstate__()
>>>
>>> a2 = pickle.loads(s) # calls a1.__setstate__(['very important'])
>>> a2
<__main__.A object at 0x0000000002742470>
>>> a2.important_data
'very important'
>>> a2.func()
7
The implementation here pikles a list with one value: [self.important_data]. That was just an example,
__getstate__ could have returned anything that is picklable, as long as __setstate__ knows how to do the
opposite. A good alternative is a dictionary of all values: {'important_data': self.important_data}.
Constructor is not called! Note that in the previous example instance a2 was created in pickle.loads without
ever calling A.__init__, so A.__setstate__ had to initialize everything that __init__ would have initialized if it
were called.
GoalKicker.com – Python® Notes for Professionals
527Chapter 113: Binary Data
Section 113.1: Format a list of values into a byte object
from struct import pack
print(pack('I3c', 123, b'a', b'b', b'c'))
# b'{\x00\x00\x00abc'
Section 113.2: Unpack a byte object according to a format
string
from struct import unpack
print(unpack('I3c', b'{\x00\x00\x00abc'))
# (123, b'a', b'b', b'c')
Section 113.3: Packing a structure
The module "struct" provides facility to pack python objects as contiguous chunk of bytes or dissemble a chunk of
bytes to python structures.
The pack function takes a format string and one or more arguments, and returns a binary string. This looks very
much like you are formatting a string except that the output is not a string but a chunk of bytes.
import struct
import sys
print "Native byteorder: ", sys.byteorder
# If no byteorder is specified, native byteorder is used
buffer = struct.pack("ihb", 3, 4, 5)
print "Byte chunk: ", repr(buffer)
print "Byte chunk unpacked: ", struct.unpack("ihb", buffer)
# Last element as unsigned short instead of unsigned char ( 2 Bytes)
buffer = struct.pack("ihh", 3, 4, 5)
print "Byte chunk: ", repr(buffer)
Output:
Native byteorder: little Byte chunk: '\x03\x00\x00\x00\x04\x00\x05' Byte chunk unpacked: (3, 4, 5) Byte
chunk: '\x03\x00\x00\x00\x04\x00\x05\x00'
You could use network byte order with data received from network or pack data to send it to network.
import struct
# If no byteorder is specified, native byteorder is used
buffer = struct.pack("hhh", 3, 4, 5)
print "Byte chunk native byte order: ", repr(buffer)
buffer = struct.pack("!hhh", 3, 4, 5)
print "Byte chunk network byte order: ", repr(buffer)
Output:
Byte chunk native byte order: '\x03\x00\x04\x00\x05\x00'
GoalKicker.com – Python® Notes for Professionals
528Byte chunk network byte order: '\x00\x03\x00\x04\x00\x05'
You can optimize by avoiding the overhead of allocating a new buﬀer by providing a buﬀer that was created earlier.
import struct
from ctypes import create_string_buffer
bufferVar = create_string_buffer(8)
bufferVar2 = create_string_buffer(8)
# We use a buffer that has already been created
# provide format, buffer, offset and data
struct.pack_into("hhh", bufferVar, 0, 3, 4, 5)
print "Byte chunk: ", repr(bufferVar.raw)
struct.pack_into("hhh", bufferVar2, 2, 3, 4, 5)
print "Byte chunk: ", repr(bufferVar2.raw)
Output:
Byte chunk: '\x03\x00\x04\x00\x05\x00\x00\x00'
Byte chunk: '\x00\x00\x03\x00\x04\x00\x05\x00'
GoalKicker.com – Python® Notes for Professionals
529Chapter 114: Idioms
Section 114.1: Dictionary key initializations
Prefer dict.get method if you are not sure if the key is present. It allows you to return a default value if key is not
found. The traditional method dict[key] would raise a KeyError exception.
Rather than doing
def add_student():
try:
students['count'] += 1
except KeyError:
students['count'] = 1
Do
def add_student():
students['count'] = students.get('count', 0) + 1
Section 114.2: Switching variables
To switch the value of two variables you can use tuple unpacking.
x = True
y = False
x, y = y, x
x
# False
y
# True
Section 114.3: Use truth value testing
Python will implicitly convert any object to a Boolean value for testing, so use it wherever possible.
# Good examples, using implicit truth testing
if attr:
# do something
if not attr:
# do something
# Bad examples, using specific types
if attr == 1:
# do something
if attr == True:
# do something
if attr != '':
# do something
# If you are looking to specifically check for None, use 'is' or 'is not'
if attr is None:
# do something
GoalKicker.com – Python® Notes for Professionals
530This generally produces more readable code, and is usually much safer when dealing with unexpected types.
Click here for a list of what will be evaluated to False.
Section 114.4: Test for "__main__" to avoid unexpected code
execution
It is good practice to test the calling program's __name__ variable before executing your code.
import sys
def main():
# Your code starts here
# Don't forget to provide a return code
return 0
if __name__ == "__main__":
sys.exit(main())
Using this pattern ensures that your code is only executed when you expect it to be; for example, when you run
your ﬁle explicitly:
python my_program.py
The beneﬁt, however, comes if you decide to import your ﬁle in another program (for example if you are writing it
as part of a library). You can then import your ﬁle, and the __main__ trap will ensure that no code is executed
unexpectedly:
# A new program file
import my_program
# main() is not run
# But you can run main() explicitly if you really want it to run:
my_program.main()
GoalKicker.com – Python® Notes for Professionals
531VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 115: Data Serialization
Parameter
protocol
Details
Using pickle or cPickle, it is the method that objects are being Serialized/Unserialized. You probably
want to use pickle.HIGHEST_PROTOCOL here, which means the newest method.
Section 115.1: Serialization using JSON
JSON is a cross language, widely used method to serialize data
Supported data types : int, ﬂoat, boolean, string, list and dict. See -> JSON Wiki for more
Here is an example demonstrating the basic usage of JSON:
import json
families = (['John'], ['Mark', 'David', {'name': 'Avraham'}])
# Dumping it into string
json_families = json.dumps(families)
# [["John"], ["Mark", "David", {"name": "Avraham"}]]
# Dumping it to file
with open('families.json', 'w') as json_file:
json.dump(families, json_file)
# Loading it from string
json_families = json.loads(json_families)
# Loading it from file
with open('families.json', 'r') as json_file:
json_families = json.load(json_file)
See JSON-Module for detailed information about JSON.
Section 115.2: Serialization using Pickle
Here is an example demonstrating the basic usage of pickle:
# Importing pickle
try:
import cPickle as pickle # Python 2
except ImportError:
import pickle # Python 3
# Creating Pythonic object:
class Family(object):
def __init__(self, names):
self.sons = names
def __str__(self):
return ' '.join(self.sons)
my_family = Family(['John', 'David'])
# Dumping to string
pickle_data = pickle.dumps(my_family, pickle.HIGHEST_PROTOCOL)
GoalKicker.com – Python® Notes for Professionals
533# Dumping to file
with open('family.p', 'w') as pickle_file:
pickle.dump(families, pickle_file, pickle.HIGHEST_PROTOCOL)
# Loading from string
my_family = pickle.loads(pickle_data)
# Loading from file
with open('family.p', 'r') as pickle_file:
my_family = pickle.load(pickle_file)
See Pickle for detailed information about Pickle.
WARNING: The oﬃcial documentation for pickle makes it clear that there are no security guarantees. Don't load
any data you don't trust its origin.
GoalKicker.com – Python® Notes for Professionals
534Chapter 116: Multiprocessing
Section 116.1: Running Two Simple Processes
A simple example of using multiple processes would be two processes (workers) that are executed separately. In
the following example, two processes are started:
countUp() counts 1 up, every second.
countDown() counts 1 down, every second.
import multiprocessing
import time
from random import randint
def countUp():
i = 0
while i <= 3:
print('Up:\t{}'.format(i))
time.sleep(randint(1, 3)) # sleep 1, 2 or 3 seconds
i += 1
def countDown():
i = 3
while i >= 0:
print('Down:\t{}'.format(i))
time.sleep(randint(1, 3)) # sleep 1, 2 or 3 seconds
i -= 1
if __name__ == '__main__':
# Initiate the workers.
workerUp = multiprocessing.Process(target=countUp)
workerDown = multiprocessing.Process(target=countDown)
# Start the workers.
workerUp.start()
workerDown.start()
# Join the workers. This will block in the main (parent) process
# until the workers are complete.
workerUp.join()
workerDown.join()
The output is as follows:
Up: 0
Down: 3
Up: 1
Up: 2
Down: 2
Up: 3
Down: 1
Down: 0
Section 116.2: Using Pool and Map
from multiprocessing import Pool
GoalKicker.com – Python® Notes for Professionals
535def cube(x):
return x ** 3
if __name__ == "__main__":
pool = Pool(5)
result = pool.map(cube, [0, 1, 2, 3])
Pool is a class which manages multiple Workers (processes) behind the scenes and lets you, the programmer, use.
Pool(5) creates a new Pool with 5 processes, and pool.map works just like map but it uses multiple processes (the
amount deﬁned when creating the pool).
Similar results can be achieved using map_async, apply and apply_async which can be found in the documentation.
GoalKicker.com – Python® Notes for Professionals
536Chapter 117: Multithreading
Threads allow Python programs to handle multiple functions at once as opposed to running a sequence of
commands individually. This topic explains the principles behind threading and demonstrates its usage.
Section 117.1: Basics of multithreading
Using the threading module, a new thread of execution may be started by creating a new threading.Thread and
assigning it a function to execute:
import threading
def foo():
print "Hello threading!"
my_thread = threading.Thread(target=foo)
The target parameter references the function (or callable object) to be run. The thread will not begin execution
until start is called on the Thread object.
Starting a Thread
my_thread.start() # prints 'Hello threading!'
Now that my_thread has run and terminated, calling start again will produce a RuntimeError. If you'd like to run
your thread as a daemon, passing the daemon=True kwarg, or setting my_thread.daemon to True before calling
start(), causes your Thread to run silently in the background as a daemon.
Joining a Thread
In cases where you split up one big job into several small ones and want to run them concurrently, but need to wait
for all of them to ﬁnish before continuing, Thread.join() is the method you're looking for.
For example, let's say you want to download several pages of a website and compile them into a single page. You'd
do this:
import requests
from threading import Thread
from queue import Queue
q = Queue(maxsize=20)
def put_page_to_q(page_num):
q.put(requests.get('http://some-website.com/page_%s.html' % page_num)
def compile(q):
# magic function that needs all pages before being able to be executed
if not q.full():
raise ValueError
else:
print("Done compiling!")
threads = []
for page_num in range(20):
t = Thread(target=requests.get, args=(page_num,))
t.start()
threads.append(t)
GoalKicker.com – Python® Notes for Professionals
537# Next, join all threads to make sure all threads are done running before
# we continue. join() is a blocking call (unless specified otherwise using
# the kwarg blocking=False when calling join)
for t in threads:
t.join()
# Call compile() now, since all threads have completed
compile(q)
A closer look at how join() works can be found here.
Create a Custom Thread Class
Using threading.Thread class we can subclass new custom Thread class. we must override run method in a
subclass.
from threading import Thread
import time
class Sleepy(Thread):
def run(self):
time.sleep(5)
print("Hello form Thread")
if __name__ == "__main__":
t = Sleepy()
t.start()
# start method automatic call Thread class run method.
# print 'The main program continues to run in foreground.'
t.join()
print("The main program continues to run in the foreground.")
Section 117.2: Communicating between threads
There are multiple threads in your code and you need to safely communicate between them.
You can use a Queue from the queue library.
from queue import Queue
from threading import Thread
# create a data producer
def producer(output_queue):
while True:
data = data_computation()
output_queue.put(data)
# create a consumer
def consumer(input_queue):
while True:
# retrieve data (blocking)
data = input_queue.get()
# do something with the data
# indicate data has been consumed
input_queue.task_done()
GoalKicker.com – Python® Notes for Professionals
538Creating producer and consumer threads with a shared queue
q = Queue()
t1 = Thread(target=consumer, args=(q,))
t2 = Thread(target=producer, args=(q,))
t1.start()
t2.start()
Section 117.3: Creating a worker pool
Using threading & queue:
from socket import socket, AF_INET, SOCK_STREAM
from threading import Thread
from queue import Queue
def echo_server(addr, nworkers):
print('Echo server running at', addr)
# Launch the client workers
q = Queue()
for n in range(nworkers):
t = Thread(target=echo_client, args=(q,))
t.daemon = True
t.start()
# Run the server
sock = socket(AF_INET, SOCK_STREAM)
sock.bind(addr)
sock.listen(5)
while True:
client_sock, client_addr = sock.accept()
q.put((client_sock, client_addr))
echo_server(('',15000), 128)
Using concurrent.futures.Threadpoolexecutor:
from socket import AF_INET, SOCK_STREAM, socket
from concurrent.futures import ThreadPoolExecutor
def echo_server(addr):
print('Echo server running at', addr)
pool = ThreadPoolExecutor(128)
sock = socket(AF_INET, SOCK_STREAM)
sock.bind(addr)
sock.listen(5)
while True:
client_sock, client_addr = sock.accept()
pool.submit(echo_client, client_sock, client_addr)
echo_server(('',15000))
Python Cookbook, 3rd edition, by David Beazley and Brian K. Jones (O’Reilly). Copyright 2013 David Beazley and Brian
Jones, 978-1-449-34037-7.
Section 117.4: Advanced use of multithreads
This section will contain some of the most advanced examples realized using Multithreading.
GoalKicker.com – Python® Notes for Professionals
539Advanced printer (logger)
A thread that prints everything is received and modiﬁes the output according to the terminal width. The nice part is
that also the "already written" output is modiﬁed when the width of the terminal changes.
#!/usr/bin/env python2
import threading
import Queue
import time
import sys
import subprocess
from backports.shutil_get_terminal_size import get_terminal_size
printq = Queue.Queue()
interrupt = False
lines = []
def main():
ptt = threading.Thread(target=printer) # Turn the printer on
ptt.daemon = True
ptt.start()
# Stupid example of stuff to print
for i in xrange(1,100):
printq.put(' '.join([str(x) for x in range(1,i)]))
to the printer
time.sleep(.5)
# The actual way to send stuff
def split_line(line, cols):
if len(line) > cols:
new_line = ''
ww = line.split()
i = 0
while len(new_line) <= (cols - len(ww[i]) - 1):
new_line += ww[i] + ' '
i += 1
print len(new_line)
if new_line == '':
return (line, '')
return (new_line, ' '.join(ww[i:]))
else:
return (line, '')
def printer():
while True:
cols, rows = get_terminal_size() # Get the terminal dimensions
msg = '#' + '-' * (cols - 2) + '#\n' # Create the
try:
new_line = str(printq.get_nowait())
if new_line != '!@#EXIT#@!': # A nice way to turn the printer
# thread out gracefully
lines.append(new_line)
printq.task_done()
else:
printq.task_done()
sys.exit()
GoalKicker.com – Python® Notes for Professionals
540except Queue.Empty:
pass
# Build the new message to show and split too long lines
for line in lines:
res = line
# The following is to split lines which are
# longer than cols.
while len(res) !=0:
toprint, res = split_line(res, cols)
msg += '\n' + toprint
# Clear the shell and print the new output
subprocess.check_call('clear') # Keep the shell clean
sys.stdout.write(msg)
sys.stdout.flush()
time.sleep(.5)
Section 117.5: Stoppable Thread with a while Loop
import threading
import time
class StoppableThread(threading.Thread):
"""Thread class with a stop() method. The thread itself has to check
regularly for the stopped() condition."""
def __init__(self):
super(StoppableThread, self).__init__()
self._stop_event = threading.Event()
def stop(self):
self._stop_event.set()
def join(self, *args, **kwargs):
self.stop()
super(StoppableThread,self).join(*args, **kwargs)
def run()
while not self._stop_event.is_set():
print("Still running!")
time.sleep(2)
print("stopped!"
Based on this Question.
GoalKicker.com – Python® Notes for Professionals
541Chapter 118: Processes and Threads
Most programs are executed line by line, only running a single process at a time. Threads allow multiple processes
to ﬂow independent of each other. Threading with multiple processors permits programs to run multiple processes
simultaneously. This topic documents the implementation and usage of threads in Python.
Section 118.1: Global Interpreter Lock
Python multithreading performance can often suﬀer due to the Global Interpreter Lock. In short, even though
you can have multiple threads in a Python program, only one bytecode instruction can execute in parallel at any
one time, regardless of the number of CPUs.
As such, multithreading in cases where operations are blocked by external events - like network access - can be
quite eﬀective:
import threading
import time
def process():
time.sleep(2)
start = time.time()
process()
print("One run took %.2fs" % (time.time() - start))
start = time.time()
threads = [threading.Thread(target=process) for _ in range(4)]
for t in threads:
t.start()
for t in threads:
t.join()
print("Four runs took %.2fs" % (time.time() - start))
# Out: One run took 2.00s
# Out: Four runs took 2.00s
Note that even though each process took 2 seconds to execute, the four processes together were able to eﬀectively
run in parallel, taking 2 seconds total.
However, multithreading in cases where intensive computations are being done in Python code - such as a lot of
computation - does not result in much improvement, and can even be slower than running in parallel:
import threading
import time
def somefunc(i):
return i * i
def otherfunc(m, i):
return m + i
def process():
for j in range(100):
GoalKicker.com – Python® Notes for Professionals
542result = 0
for i in range(100000):
result = otherfunc(result, somefunc(i))
start = time.time()
process()
print("One run took %.2fs" % (time.time() - start))
start = time.time()
threads = [threading.Thread(target=process) for _ in range(4)]
for t in threads:
t.start()
for t in threads:
t.join()
print("Four runs took %.2fs" % (time.time() - start))
# Out: One run took 2.05s
# Out: Four runs took 14.42s
In the latter case, multiprocessing can be eﬀective as multiple processes can, of course, execute multiple
instructions simultaneously:
import multiprocessing
import time
def somefunc(i):
return i * i
def otherfunc(m, i):
return m + i
def process():
for j in range(100):
result = 0
for i in range(100000):
result = otherfunc(result, somefunc(i))
start = time.time()
process()
print("One run took %.2fs" % (time.time() - start))
start = time.time()
processes = [multiprocessing.Process(target=process) for _ in range(4)]
for p in processes:
p.start()
for p in processes:
p.join()
print("Four runs took %.2fs" % (time.time() - start))
# Out: One run took 2.07s
# Out: Four runs took 2.30s
Section 118.2: Running in Multiple Threads
Use threading.Thread to run a function in another thread.
GoalKicker.com – Python® Notes for Professionals
543import threading
import os
def process():
print("Pid is %s, thread id is %s" % (os.getpid(), threading.current_thread().name))
threads = [threading.Thread(target=process) for _ in range(4)]
for t in threads:
t.start()
for t in threads:
t.join()
# Out: Pid is 11240, thread id is Thread-1
# Out: Pid is 11240, thread id is Thread-2
# Out: Pid is 11240, thread id is Thread-3
# Out: Pid is 11240, thread id is Thread-4
Section 118.3: Running in Multiple Processes
Use multiprocessing.Process to run a function in another process. The interface is similar to threading.Thread:
import multiprocessing
import os
def process():
print("Pid is %s" % (os.getpid(),))
processes = [multiprocessing.Process(target=process) for _ in range(4)]
for p in processes:
p.start()
for p in processes:
p.join()
# Out: Pid is 11206
# Out: Pid is 11207
# Out: Pid is 11208
# Out: Pid is 11209
Section 118.4: Sharing State Between Threads
As all threads are running in the same process, all threads have access to the same data.
However, concurrent access to shared data should be protected with a lock to avoid synchronization issues.
import threading
obj = {}
obj_lock = threading.Lock()
def objify(key, val):
print("Obj has %d values" % len(obj))
with obj_lock:
obj[key] = val
print("Obj now has %d values" % len(obj))
ts = [threading.Thread(target=objify, args=(str(n), n)) for n in range(4)]
for t in ts:
t.start()
for t in ts:
GoalKicker.com – Python® Notes for Professionals
544t.join()
print("Obj final result:")
import pprint; pprint.pprint(obj)
# Out: Obj has 0 values
# Out: Obj has 0 values
# Out: Obj now has 1 values
# Out: Obj now has 2 valuesObj has 2 values
# Out: Obj now has 3 values
# Out:
# Out: Obj has 3 values
# Out: Obj now has 4 values
# Out: Obj final result:
# Out: {'0': 0, '1': 1, '2': 2, '3': 3}
Section 118.5: Sharing State Between Processes
Code running in diﬀerent processes do not, by default, share the same data. However, the multiprocessing
module contains primitives to help share values across multiple processes.
import multiprocessing
plain_num = 0
shared_num = multiprocessing.Value('d', 0)
lock = multiprocessing.Lock()
def increment():
global plain_num
with lock:
# ordinary variable modifications are not visible across processes
plain_num += 1
# multiprocessing.Value modifications are
shared_num.value += 1
ps = [multiprocessing.Process(target=increment) for n in range(4)]
for p in ps:
p.start()
for p in ps:
p.join()
print("plain_num is %d, shared_num is %d" % (plain_num, shared_num.value))
# Out: plain_num is 0, shared_num is 4
GoalKicker.com – Python® Notes for Professionals
545Chapter 119: Python concurrency
Section 119.1: The multiprocessing module
from __future__ import print_function
import multiprocessing
def countdown(count):
while count > 0:
print("Count value", count)
count -= 1
return
if __name__ == "__main__":
p1 = multiprocessing.Process(target=countdown, args=(10,))
p1.start()
p2 = multiprocessing.Process(target=countdown, args=(20,))
p2.start()
p1.join()
p2.join()
Here, each function is executed in a new process. Since a new instance of Python VM is running the code, there is
no GIL and you get parallelism running on multiple cores.
The Process.start method launches this new process and run the function passed in the target argument with
the arguments args. The Process.join method waits for the end of the execution of processes p1 and p2.
The new processes are launched diﬀerently depending on the version of python and the platform on which the
code is running e.g.:
Windows uses spawn to create the new process.
With unix systems and version earlier than 3.3, the processes are created using a fork.
Note that this method does not respect the POSIX usage of fork and thus leads to unexpected behaviors,
especially when interacting with other multiprocessing libraries.
With unix system and version 3.4+, you can choose to start the new processes with either fork, forkserver
or spawn using multiprocessing.set_start_method at the beginning of your program. forkserver and
spawn methods are slower than forking but avoid some unexpected behaviors.
POSIX fork usage:
After a fork in a multithreaded program, the child can safely call only async-signal-safe functions until
such time as it calls execve.
(see)
Using fork, a new process will be launched with the exact same state for all the current mutex but only the
MainThread will be launched. This is unsafe as it could lead to race conditions e.g.:
If you use a Lock in MainThread and pass it to another thread which is supposed to lock it at some point. If
the fork occurs simultaneously, the new process will start with a locked lock which will never be released as
the second thread does not exist in this new process.
GoalKicker.com – Python® Notes for Professionals
546Actually, this kind of behavior should not occurred in pure python as multiprocessing handles it properly but if
you are interacting with other library, this kind of behavior can occurs, leading to crash of your system (for instance
with numpy/accelerated on macOS).
Section 119.2: The threading module
from __future__ import print_function
import threading
def counter(count):
while count > 0:
print("Count value", count)
count -= 1
return
t1 = threading.Thread(target=countdown,args=(10,))
t1.start()
t2 = threading.Thread(target=countdown,args=(20,))
t2.start()
In certain implementations of Python such as CPython, true parallelism is not achieved using threads because of
using what is known as the GIL, or Global Interpreter Lock.
Here is an excellent overview of Python concurrency:
Python concurrency by David Beazley (YouTube)
Section 119.3: Passing data between multiprocessing
processes
Because data is sensitive when dealt with between two threads (think concurrent read and concurrent write can
conﬂict with one another, causing race conditions), a set of unique objects were made in order to facilitate the
passing of data back and forth between threads. Any truly atomic operation can be used between threads, but it is
always safe to stick with Queue.
import multiprocessing
import queue
my_Queue=multiprocessing.Queue()
#Creates a queue with an undefined maximum size
#this can be dangerous as the queue becomes increasingly large
#it will take a long time to copy data to/from each read/write thread
Most people will suggest that when using queue, to always place the queue data in a try: except: block instead of
using empty. However, for applications where it does not matter if you skip a scan cycle (data can be placed in the
queue while it is ﬂipping states from queue.Empty==True to queue.Empty==False) it is usually better to place read
and write access in what I call an Iftry block, because an 'if' statement is technically more performant than catching
the exception.
import multiprocessing
import queue
'''Import necessary Python standard libraries, multiprocessing for classes and queue for the queue
exceptions it provides'''
def Queue_Iftry_Get(get_queue, default=None, use_default=False, func=None, use_func=False):
'''This global method for the Iftry block is provided for its reuse and
standard functionality, the if also saves on performance as opposed to catching
the exception, which is expensive.
It also allows the user to specify a function for the outgoing data to use,
GoalKicker.com – Python® Notes for Professionals
547and a default value to return if the function cannot return the value from the queue'''
if get_queue.empty():
if use_default:
return default
else:
try:
value = get_queue.get_nowait()
except queue.Empty:
if use_default:
return default
else:
if use_func:
return func(value)
else:
return value
def Queue_Iftry_Put(put_queue, value):
'''This global method for the Iftry block is provided because of its reuse
and
standard functionality, the If also saves on performance as opposed to catching
the exception, which is expensive.
Return True if placing value in the queue was successful. Otherwise, false'''
if put_queue.full():
return False
else:
try:
put_queue.put_nowait(value)
except queue.Full:
return False
else:
return True
GoalKicker.com – Python® Notes for Professionals
548VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 120: Parallel computation
Section 120.1: Using the multiprocessing module to parallelise
tasks
import multiprocessing
def fib(n):
"""computing the Fibonacci in an inefficient way
was chosen to slow down the CPU."""
if n <= 2:
return 1
else:
return fib(n-1)+fib(n-2)
p = multiprocessing.Pool()
print(p.map(fib,[38,37,36,35,34,33]))
# Out: [39088169, 24157817, 14930352, 9227465, 5702887, 3524578]
As the execution of each call to fib happens in parallel, the time of execution of the full example is 1.8× faster than
if done in a sequential way on a dual processor.
Python 2.2+
Section 120.2: Using a C-extension to parallelize tasks
The idea here is to move the computationally intensive jobs to C (using special macros), independent of Python, and
have the C code release the GIL while it's working.
#include "Python.h"
...
PyObject *pyfunc(PyObject *self, PyObject *args) {
...
Py_BEGIN_ALLOW_THREADS
// Threaded C code
...
Py_END_ALLOW_THREADS
...
}
Section 120.3: Using Parent and Children scripts to execute
code in parallel
child.py
import time
def main():
print "starting work"
time.sleep(1)
print "work work work work work"
time.sleep(1)
print "done working"
if __name__ == '__main__':
main()
GoalKicker.com – Python® Notes for Professionals
550parent.py
import os
def main():
for i in range(5):
os.system("python child.py &")
if __name__ == '__main__':
main()
This is useful for parallel, independent HTTP request/response tasks or Database select/inserts. Command line
arguments can be given to the child.py script as well. Synchronization between scripts can be achieved by all
scripts regularly checking a separate server (like a Redis instance).
Section 120.4: Using PyPar module to parallelize
PyPar is a library that uses the message passing interface (MPI) to provide parallelism in Python. A simple example
in PyPar (as seen at https://github.com/daleroberts/pypar) looks like this:
import pypar as pp
ncpus = pp.size()
rank = pp.rank()
node = pp.get_processor_name()
print 'I am rank %d of %d on node %s' % (rank, ncpus, node)
if rank == 0:
msh = 'P0'
pp.send(msg, destination=1)
msg = pp.receive(source=rank-1)
print 'Processor 0 received message "%s" from rank %d' % (msg, rank-1)
else:
source = rank-1
destination = (rank+1) % ncpus
msg = pp.receive(source)
msg = msg + 'P' + str(rank)
pypar.send(msg, destination)
pp.finalize()
GoalKicker.com – Python® Notes for Professionals
551Chapter 121: Sockets
Parameter
socket.AF_UNIXDescription
UNIX Socket
socket.AF_INETIPv4
socket.AF_INET6IPv6
socket.SOCK_STREAM TCP
socket.SOCK_DGRAM UDP
Many programming languages use sockets to communicate across processes or between devices. This topic
explains proper usage the sockets module in Python to facilitate sending and receiving data over common
networking protocols.
Section 121.1: Raw Sockets on Linux
First you disable your network card's automatic checksumming:
sudo ethtool -K eth1 tx off
Then send your packet, using a SOCK_RAW socket:
#!/usr/bin/env python
from socket import socket, AF_PACKET, SOCK_RAW
s = socket(AF_PACKET, SOCK_RAW)
s.bind(("eth1", 0))
# We're putting together an ethernet frame here,
# but you could have anything you want instead
# Have a look at the 'struct' module for more
# flexible packing/unpacking of binary data
# and 'binascii' for 32 bit CRC
src_addr = "\x01\x02\x03\x04\x05\x06"
dst_addr = "\x01\x02\x03\x04\x05\x06"
payload = ("["*30)+"PAYLOAD"+("]"*30)
checksum = "\x1a\x2b\x3c\x4d"
ethertype = "\x08\x01"
s.send(dst_addr+src_addr+ethertype+payload+checksum)
Section 121.2: Sending data via UDP
UDP is a connectionless protocol. Messages to other processes or computers are sent without establishing any sort
of connection. There is no automatic conﬁrmation if your message has been received. UDP is usually used in
latency sensitive applications or in applications sending network wide broadcasts.
The following code sends a message to a process listening on localhost port 6667 using UDP
Note that there is no need to "close" the socket after the send, because UDP is connectionless.
from socket import socket, AF_INET, SOCK_DGRAM
s = socket(AF_INET, SOCK_DGRAM)
msg = ("Hello you there!").encode('utf-8') # socket.sendto() takes bytes as input, hence we must
encode the string first.
s.sendto(msg, ('localhost', 6667))
GoalKicker.com – Python® Notes for Professionals
552Section 121.3: Receiving data via UDP
UDP is a connectionless protocol. This means that peers sending messages do not require establishing a
connection before sending messages. socket.recvfromthus returns a tuple (msg [the message the socket received],
addr [the address of the sender])
A UDP server using solely the socket module:
from socket import socket, AF_INET, SOCK_DGRAM
sock = socket(AF_INET, SOCK_DGRAM)
sock.bind(('localhost', 6667))
while True:
msg, addr = sock.recvfrom(8192) # This is the amount of bytes to read at maximum
print("Got message from %s: %s" % (addr, msg))
Below is an alternative implementation using socketserver.UDPServer:
from socketserver import BaseRequestHandler, UDPServer
class MyHandler(BaseRequestHandler):
def handle(self):
print("Got connection from: %s" % self.client_address)
msg, sock = self.request
print("It said: %s" % msg)
sock.sendto("Got your message!".encode(), self.client_address) # Send reply
serv = UDPServer(('localhost', 6667), MyHandler)
serv.serve_forever()
By default, sockets block. This means that execution of the script will wait until the socket receives data.
Section 121.4: Sending data via TCP
Sending data over the internet is made possible using multiple modules. The sockets module provides low-level
access to the underlying Operating System operations responsible for sending or receiving data from other
computers or processes.
The following code sends the byte string b'Hello' to a TCP server listening on port 6667 on the host localhost and
closes the connection when ﬁnished:
from socket import socket, AF_INET, SOCK_STREAM
s = socket(AF_INET, SOCK_STREAM)
s.connect(('localhost', 6667)) # The address of the TCP server listening
s.send(b'Hello')
s.close()
Socket output is blocking by default, that means that the program will wait in the connect and send calls until the
action is 'completed'. For connect that means the server actually accepting the connection. For send it only means
that the operating system has enough buﬀer space to queue the data to be send later.
Sockets should always be closed after use.
Section 121.5: Multi-threaded TCP Socket Server
When run with no arguments, this program starts a TCP socket server that listens for connections to 127.0.0.1 on
GoalKicker.com – Python® Notes for Professionals
553port 5000. The server handles each connection in a separate thread.
When run with the -c argument, this program connects to the server, reads the client list, and prints it out. The
client list is transferred as a JSON string. The client name may be speciﬁed by passing the -n argument. By passing
diﬀerent names, the eﬀect on the client list may be observed.
client_list.py
import argparse
import json
import socket
import threading
def handle_client(client_list, conn, address):
name = conn.recv(1024)
entry = dict(zip(['name', 'address', 'port'], [name, address[0], address[1]]))
client_list[name] = entry
conn.sendall(json.dumps(client_list))
conn.shutdown(socket.SHUT_RDWR)
conn.close()
def server(client_list):
print "Starting server..."
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('127.0.0.1', 5000))
s.listen(5)
while True:
(conn, address) = s.accept()
t = threading.Thread(target=handle_client, args=(client_list, conn, address))
t.daemon = True
t.start()
def client(name):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 5000))
s.send(name)
data = s.recv(1024)
result = json.loads(data)
print json.dumps(result, indent=4)
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('-c', dest='client', action='store_true')
parser.add_argument('-n', dest='name', type=str, default='name')
result = parser.parse_args()
return result
def main():
client_list = dict()
args = parse_arguments()
if args.client:
client(args.name)
else:
try:
server(client_list)
except KeyboardInterrupt:
print "Keyboard interrupt"
if __name__ == '__main__':
GoalKicker.com – Python® Notes for Professionals
554main()
Server Output
$ python client_list.py
Starting server...
Client Output
$ python client_list.py -c -n name1
{
"name1": {
"address": "127.0.0.1",
"port": 62210,
"name": "name1"
}
}
The receive buﬀers are limited to 1024 bytes. If the JSON string representation of the client list exceeds this size, it
will be truncated. This will cause the following exception to be raised:
ValueError: Unterminated string starting at: line 1 column 1023 (char 1022)
GoalKicker.com – Python® Notes for Professionals
555Chapter 122: Websockets
Section 122.1: Simple Echo with aiohttp
aiohttp provides asynchronous websockets.
Python 3.x Version ≥ 3.5
import asyncio
from aiohttp import ClientSession
with ClientSession() as session:
async def hello_world():
websocket = await session.ws_connect("wss://echo.websocket.org")
websocket.send_str("Hello, world!")
print("Received:", (await websocket.receive()).data)
await websocket.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(hello_world())
Section 122.2: Wrapper Class with aiohttp
aiohttp.ClientSession may be used as a parent for a custom WebSocket class.
Python 3.x Version ≥ 3.5
import asyncio
from aiohttp import ClientSession
class EchoWebSocket(ClientSession):
URL = "wss://echo.websocket.org"
def __init__(self):
super().__init__()
self.websocket = None
async def connect(self):
"""Connect to the WebSocket."""
self.websocket = await self.ws_connect(self.URL)
async def send(self, message):
"""Send a message to the WebSocket."""
assert self.websocket is not None, "You must connect first!"
self.websocket.send_str(message)
print("Sent:", message)
async def receive(self):
"""Receive one message from the WebSocket."""
assert self.websocket is not None, "You must connect first!"
return (await self.websocket.receive()).data
async def read(self):
"""Read messages from the WebSocket."""
assert self.websocket is not None, "You must connect first!"
GoalKicker.com – Python® Notes for Professionals
556while self.websocket.receive():
message = await self.receive()
print("Received:", message)
if message == "Echo 9!":
break
async def send(websocket):
for n in range(10):
await websocket.send("Echo {}!".format(n))
await asyncio.sleep(1)
loop = asyncio.get_event_loop()
with EchoWebSocket() as websocket:
loop.run_until_complete(websocket.connect())
tasks = (
send(websocket),
websocket.read()
)
loop.run_until_complete(asyncio.wait(tasks))
loop.close()
Section 122.3: Using Autobahn as a Websocket Factory
The Autobahn package can be used for Python web socket server factories.
Python Autobahn package documentation
To install, typically one would simply use the terminal command
(For Linux):
sudo pip install autobahn
(For Windows):
python -m pip install autobahn
Then, a simple echo server can be created in a Python script:
from autobahn.asyncio.websocket import WebSocketServerProtocol
class MyServerProtocol(WebSocketServerProtocol):
'''When creating server protocol, the
user defined class inheriting the
WebSocketServerProtocol needs to override
the onMessage, onConnect, et-c events for
user specified functionality, these events
define your server's protocol, in essence'''
def onMessage(self,payload,isBinary):
'''The onMessage routine is called
when the server receives a message.
It has the required arguments payload
and the bool isBinary. The payload is the
actual contents of the "message" and isBinary
is simply a flag to let the user know that
GoalKicker.com – Python® Notes for Professionals
557the payload contains binary data. I typically
elsewise assume that the payload is a string.
In this example, the payload is returned to sender verbatim.'''
self.sendMessage(payload,isBinary)
if__name__=='__main__':
try:
importasyncio
except ImportError:
'''Trollius = 0.3 was renamed'''
import trollius as asyncio
from autobahn.asyncio.websocketimportWebSocketServerFactory
factory=WebSocketServerFactory()
'''Initialize the websocket factory, and set the protocol to the
above defined protocol(the class that inherits from
autobahn.asyncio.websocket.WebSocketServerProtocol)'''
factory.protocol=MyServerProtocol
'''This above line can be thought of as "binding" the methods
onConnect, onMessage, et-c that were described in the MyServerProtocol class
to the server, setting the servers functionality, ie, protocol'''
loop=asyncio.get_event_loop()
coro=loop.create_server(factory,'127.0.0.1',9000)
server=loop.run_until_complete(coro)
'''Run the server in an infinite loop'''
try:
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
server.close()
loop.close()
In this example, a server is being created on the localhost (127.0.0.1) on port 9000. This is the listening IP and port.
This is important information, as using this, you could identify your computer's LAN address and port forward from
your modem, though whatever routers you have to the computer. Then, using google to investigate your WAN IP,
you could design your website to send WebSocket messages to your WAN IP, on port 9000 (in this example).
It is important that you port forward from your modem back, meaning that if you have routers daisy chained to the
modem, enter into the modem's conﬁguration settings, port forward from the modem to the connected router, and
so forth until the ﬁnal router your computer is connected to is having the information being received on modem
port 9000 (in this example) forwarded to it.
GoalKicker.com – Python® Notes for Professionals
558Chapter 123: Sockets And Message
Encryption/Decryption Between Client and
Server
Cryptography is used for security purposes. There are not so many examples of Encryption/Decryption in Python
using IDEA encryption MODE CTR. Aim of this documentation :
Extend and implement of the RSA Digital Signature scheme in station-to-station communication. Using Hashing for
integrity of message, that is SHA-1. Produce simple Key Transport protocol. Encrypt Key with IDEA encryption. Mode
of Block Cipher is Counter Mode
Section 123.1: Server side Implementation
import socket
import hashlib
import os
import time
import itertools
import threading
import sys
import Crypto.Cipher.AES as AES
from Crypto.PublicKey import RSA
from CryptoPlus.Cipher import IDEA
#server address and port number input from admin
host= raw_input("Server Address - > ")
port = int(input("Port - > "))
#boolean for checking server and port
check = False
done = False
def animate():
for c in itertools.cycle(['....','.......','..........','............']):
if done:
break
sys.stdout.write('\rCHECKING IP ADDRESS AND NOT USED PORT '+c)
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write('\r -----SERVER STARTED. WAITING FOR CLIENT-----\n')
try:
#setting up socket
server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.bind((host,port))
server.listen(5)
check = True
except BaseException:
print "-----Check Server Address or Port-----"
check = False
if check is True:
# server Quit
shutdown = False
# printing "Server Started Message"
thread_load = threading.Thread(target=animate)
thread_load.start()
time.sleep(4)
GoalKicker.com – Python® Notes for Professionals
559done = True
#binding client and address
client,address = server.accept()
print ("CLIENT IS CONNECTED. CLIENT'S ADDRESS ->",address)
print ("\n-----WAITING FOR PUBLIC KEY & PUBLIC KEY HASH-----\n")
#client's message(Public Key)
getpbk = client.recv(2048)
#conversion of string to KEY
server_public_key = RSA.importKey(getpbk)
#hashing the public key in server side for validating the hash from client
hash_object = hashlib.sha1(getpbk)
hex_digest = hash_object.hexdigest()
if getpbk != "":
print (getpbk)
client.send("YES")
gethash = client.recv(1024)
print ("\n-----HASH OF PUBLIC KEY----- \n"+gethash)
if hex_digest == gethash:
# creating session key
key_128 = os.urandom(16)
#encrypt CTR MODE session key
en = AES.new(key_128,AES.MODE_CTR,counter = lambda:key_128)
encrypto = en.encrypt(key_128)
#hashing sha1
en_object = hashlib.sha1(encrypto)
en_digest = en_object.hexdigest()
print ("\n-----SESSION KEY-----\n"+en_digest)
#encrypting session key and public key
E = server_public_key.encrypt(encrypto,16)
print ("\n-----ENCRYPTED PUBLIC KEY AND SESSION KEY-----\n"+str(E))
print ("\n-----HANDSHAKE COMPLETE-----")
client.send(str(E))
while True:
#message from client
newmess = client.recv(1024)
#decoding the message from HEXADECIMAL to decrypt the encrypted version of the message only
decoded = newmess.decode("hex")
#making en_digest(session_key) as the key
key = en_digest[:16]
print ("\nENCRYPTED MESSAGE FROM CLIENT -> "+newmess)
#decrypting message from the client
ideaDecrypt = IDEA.new(key, IDEA.MODE_CTR, counter=lambda: key)
dMsg = ideaDecrypt.decrypt(decoded)
print ("\n**New Message** "+time.ctime(time.time()) +" > "+dMsg+"\n")
mess = raw_input("\nMessage To Client -> ")
if mess != "":
ideaEncrypt = IDEA.new(key, IDEA.MODE_CTR, counter=lambda : key)
eMsg = ideaEncrypt.encrypt(mess)
eMsg = eMsg.encode("hex").upper()
if eMsg != "":
print ("ENCRYPTED MESSAGE TO CLIENT-> " + eMsg)
client.send(eMsg)
client.close()
else:
print ("\n-----PUBLIC KEY HASH DOESNOT MATCH-----\n")
GoalKicker.com – Python® Notes for Professionals
560Section 123.2: Client side Implementation
import time
import socket
import threading
import hashlib
import itertools
import sys
from Crypto import Random
from Crypto.PublicKey import RSA
from CryptoPlus.Cipher import IDEA
#animating loading
done = False
def animate():
for c in itertools.cycle(['....','.......','..........','............']):
if done:
break
sys.stdout.write('\rCONFIRMING CONNECTION TO SERVER '+c)
sys.stdout.flush()
time.sleep(0.1)
#public key and private key
random_generator = Random.new().read
key = RSA.generate(1024,random_generator)
public = key.publickey().exportKey()
private = key.exportKey()
#hashing the public key
hash_object = hashlib.sha1(public)
hex_digest = hash_object.hexdigest()
#Setting up socket
server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#host and port input user
host = raw_input("Server Address To Be Connected -> ")
port = int(input("Port of The Server -> "))
#binding the address and port
server.connect((host, port))
# printing "Server Started Message"
thread_load = threading.Thread(target=animate)
thread_load.start()
time.sleep(4)
done = True
def send(t,name,key):
mess = raw_input(name + " : ")
key = key[:16]
#merging the message and the name
whole = name+" : "+mess
ideaEncrypt = IDEA.new(key, IDEA.MODE_CTR, counter=lambda : key)
eMsg = ideaEncrypt.encrypt(whole)
#converting the encrypted message to HEXADECIMAL to readable
eMsg = eMsg.encode("hex").upper()
if eMsg != "":
print ("ENCRYPTED MESSAGE TO SERVER-> "+eMsg)
server.send(eMsg)
def recv(t,key):
newmess = server.recv(1024)
GoalKicker.com – Python® Notes for Professionals
561print ("\nENCRYPTED MESSAGE FROM SERVER-> " + newmess)
key = key[:16]
decoded = newmess.decode("hex")
ideaDecrypt = IDEA.new(key, IDEA.MODE_CTR, counter=lambda: key)
dMsg = ideaDecrypt.decrypt(decoded)
print ("\n**New Message From Server** " + time.ctime(time.time()) + " : " + dMsg + "\n")
while True:
server.send(public)
confirm = server.recv(1024)
if confirm == "YES":
server.send(hex_digest)
#connected msg
msg = server.recv(1024)
en = eval(msg)
decrypt = key.decrypt(en)
# hashing sha1
en_object = hashlib.sha1(decrypt)
en_digest = en_object.hexdigest()
print ("\n-----ENCRYPTED PUBLIC KEY AND SESSION KEY FROM SERVER-----")
print (msg)
print ("\n-----DECRYPTED SESSION KEY-----")
print (en_digest)
print ("\n-----HANDSHAKE COMPLETE-----\n")
alais = raw_input("\nYour Name -> ")
while True:
thread_send = threading.Thread(target=send,args=("------Sending Message------
",alais,en_digest))
thread_recv = threading.Thread(target=recv,args=("------Receiving Message------
",en_digest))
thread_send.start()
thread_recv.start()
thread_send.join()
thread_recv.join()
time.sleep(0.5)
time.sleep(60)
server.close()
GoalKicker.com – Python® Notes for Professionals
562Chapter 124: Python Networking
Section 124.1: Creating a Simple Http Server
To share ﬁles or to host simple websites(http and javascript) in your local network, you can use Python's builtin
SimpleHTTPServer module. Python should be in your Path variable. Go to the folder where your ﬁles are and type:
For python 2:
$ python -m SimpleHTTPServer <portnumber>
For python 3:
$ python3 -m http.server <portnumber>
If port number is not given 8000 is the default port. So the output will be:
Serving HTTP on 0.0.0.0 port 8000 ...
You can access to your ﬁles through any device connected to the local network by typing
http://hostipaddress:8000/.
hostipaddress is your local IP address which probably starts with 192.168.x.x.
To ﬁnish the module simply press ctrl+c.
Section 124.2: Creating a TCP server
You can create a TCP server using the socketserver library. Here's a simple echo server.
Server side
from sockerserver import BaseRequestHandler, TCPServer
class EchoHandler(BaseRequestHandler):
def handle(self):
print('connection from:', self.client_address)
while True:
msg = self.request.recv(8192)
if not msg:
break
self.request.send(msg)
if __name__ == '__main__':
server = TCPServer(('', 5000), EchoHandler)
server.serve_forever()
Client side
from socket import socket, AF_INET, SOCK_STREAM
sock = socket(AF_INET, SOCK_STREAM)
sock.connect(('localhost', 5000))
sock.send(b'Monty Python')
sock.recv(8192) # returns b'Monty Python'
GoalKicker.com – Python® Notes for Professionals
563socketserver makes it relatively easy to create simple TCP servers. However, you should be aware that, by default,
the servers are single threaded and can only serve one client at a time. If you want to handle multiple clients, either
instantiate a ThreadingTCPServer instead.
from socketserver import ThreadingTCPServer
...
if __name__ == '__main__':
server = ThreadingTCPServer(('', 5000), EchoHandler)
server.serve_forever()
Section 124.3: Creating a UDP Server
A UDP server is easily created using the socketserver library.
a simple time server:
import time
from socketserver import BaseRequestHandler, UDPServer
class CtimeHandler(BaseRequestHandler):
def handle(self):
print('connection from: ', self.client_address)
# Get message and client socket
msg, sock = self.request
resp = time.ctime()
sock.sendto(resp.encode('ascii'), self.client_address)
if __name__ == '__main__':
server = UDPServer(('', 5000), CtimeHandler)
server.serve_forever()
Testing:
>>> from socket import socket, AF_INET, SOCK_DGRAM
>>> sock = socket(AF_INET, SOCK_DGRAM)
>>> sick.sendto(b'', ('localhost', 5000))
0
>>> sock.recvfrom(8192)
(b'Wed Aug 15 20:35:08 2012', ('127.0.0.1', 5000))
Section 124.4: Start Simple HttpServer in a thread and open
the browser
Useful if your program is outputting web pages along the way.
from http.server import HTTPServer, CGIHTTPRequestHandler
import webbrowser
import threading
def start_server(path, port=8000):
'''Start a simple webserver serving path on port'''
os.chdir(path)
httpd = HTTPServer(('', port), CGIHTTPRequestHandler)
httpd.serve_forever()
# Start the server in a new thread
port = 8000
daemon = threading.Thread(name='daemon_server',
GoalKicker.com – Python® Notes for Professionals
564target=start_server,
args=('.', port)
daemon.setDaemon(True) # Set as a daemon so it will be killed once the main thread is dead.
daemon.start()
# Open the web browser
webbrowser.open('http://localhost:{}'.format(port))
Section 124.5: The simplest Python socket client-server
example
Server side:
import socket
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind(('localhost', 8089))
serversocket.listen(5) # become a server socket, maximum 5 connections
while True:
connection, address = serversocket.accept()
buf = connection.recv(64)
if len(buf) > 0:
print(buf)
break
Client Side:
import socket
clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientsocket.connect(('localhost', 8089))
clientsocket.send('hello')
First run the SocketServer.py, and make sure the server is ready to listen/receive sth Then the client send info to the
server; After the server received sth, it terminates
GoalKicker.com – Python® Notes for Professionals
565VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 125: Python HTTP Server
Section 125.1: Running a simple HTTP server
Python 2.x Version ≥ 2.3
python -m SimpleHTTPServer 9000
Python 3.x Version ≥ 3.0
python -m http.server 9000
Running this command serves the ﬁles of the current directory at port 9000.
If no argument is provided as port number then server will run on default port 8000.
The -m ﬂag will search sys.path for the corresponding .py ﬁle to run as a module.
If you want to only serve on localhost you'll need to write a custom Python program such as:
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol
= "HTTP/1.0"
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('127.0.0.1', port)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
Section 125.2: Serving ﬁles
Assuming you have the following directory of ﬁles:
You can setup a web server to serve these ﬁles as follows:
Python 2.x Version ≥ 2.3
import SimpleHTTPServer
import SocketServer
GoalKicker.com – Python® Notes for Professionals
567PORT = 8000
handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("localhost", PORT), handler)
print "Serving files at port {}".format(PORT)
httpd.serve_forever()
Python 3.x Version ≥ 3.0
import http.server
import socketserver
PORT = 8000
handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), handler)
print("serving at port", PORT)
httpd.serve_forever()
The SocketServer module provides the classes and functionalities to setup a network server.
SocketServer's TCPServer class sets up a server using the TCP protocol. The constructor accepts a tuple
representing the address of the server (i.e. the IP address and port) and the class that handles the server requests.
The SimpleHTTPRequestHandler class of the SimpleHTTPServer module allows the ﬁles at the current directory to
be served.
Save the script at the same directory and run it.
Run the HTTP Server :
Python 2.x Version ≥ 2.3
python -m SimpleHTTPServer 8000
Python 3.x Version ≥ 3.0
python -m http.server 8000
The '-m' ﬂag will search 'sys.path' for the corresponding '.py' ﬁle to run as a module.
Open localhost:8000 in the browser, it will give you the following:
Section 125.3: Basic handling of GET, POST, PUT using
BaseHTTPRequestHandler
# from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer # python2
GoalKicker.com – Python® Notes for Professionals
568from http.server import BaseHTTPRequestHandler, HTTPServer # python3
class HandleRequests(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_GET(self):
self._set_headers()
self.wfile.write("received get request")
def do_POST(self):
'''Reads post request body'''
self._set_headers()
content_len = int(self.headers.getheader('content-length', 0))
post_body = self.rfile.read(content_len)
self.wfile.write("received post request:<br>{}".format(post_body))
def do_PUT(self):
self.do_POST()
host = ''
port = 80
HTTPServer((host, port), HandleRequests).serve_forever()
Example output using curl:
$ curl http://localhost/
received get request%
$ curl -X POST http://localhost/
received post request:<br>%
$ curl -X PUT http://localhost/
received post request:<br>%
$ echo 'hello world' | curl --data-binary @- http://localhost/
received post request:<br>hello world
Section 125.4: Programmatic API of SimpleHTTPServer
What happens when we execute python -m SimpleHTTPServer 9000?
To answer this question we should understand the construct of SimpleHTTPServer
(https://hg.python.org/cpython/ﬁle/2.7/Lib/SimpleHTTPServer.py) and
BaseHTTPServer(https://hg.python.org/cpython/ﬁle/2.7/Lib/BaseHTTPServer.py).
Firstly, Python invokes the SimpleHTTPServer module with 9000 as an argument. Now observing the
SimpleHTTPServer code,
def test(HandlerClass = SimpleHTTPRequestHandler,
ServerClass = BaseHTTPServer.HTTPServer):
BaseHTTPServer.test(HandlerClass, ServerClass)
GoalKicker.com – Python® Notes for Professionals
569if __name__ == '__main__':
test()
The test function is invoked following request handlers and ServerClass. Now BaseHTTPServer.test is invoked
def test(HandlerClass = BaseHTTPRequestHandler,
ServerClass = HTTPServer, protocol="HTTP/1.0"):
"""Test the HTTP request handler class.
This runs an HTTP server on port 8000 (or the first command line
argument).
"""
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('', port)
HandlerClass.protocol_version = protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
Hence here the port number, which the user passed as argument is parsed and is bound to the host address.
Further basic steps of socket programming with given port and protocol is carried out. Finally socket server is
initiated.
This is a basic overview of inheritance from SocketServer class to other classes:
+------------+
| BaseServer |
+------------+
|
v
+-----------+ +------------------+
| TCPServer |------->| UnixStreamServer |
+-----------+ +------------------+
|
v
+-----------+ +--------------------+
| UDPServer |------->| UnixDatagramServer |
+-----------+ +--------------------+
The links https://hg.python.org/cpython/ﬁle/2.7/Lib/BaseHTTPServer.py and
https://hg.python.org/cpython/ﬁle/2.7/Lib/SocketServer.py are useful for ﬁnding further information.
GoalKicker.com – Python® Notes for Professionals
570Chapter 126: Flask
Flask is a Python micro web framework used to run major websites including Pinterest, Twilio, and LinkedIn. This
topic explains and demonstrates the variety of features Flask oﬀers for both front and back end web development.
Section 126.1: Files and Templates
Instead of typing our HTML markup into the return statements, we can use the render_template() function:
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route("/about")
def about():
return render_template("about-us.html")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, debug=True)
This will use our template ﬁle about-us.html. To ensure our application can ﬁnd this ﬁle we must organize our
directory in the following format:
- application.py
/templates
- about-us.html
- login-form.html
/static
/styles
- about-style.css
- login-style.css
/scripts
- about-script.js
- login-script.js
Most importantly, references to these ﬁles in the HTML must look like this:
<link rel="stylesheet" type="text/css", href="{{url_for('static', filename='styles/about-
style.css')}}">
which will direct the application to look for about-style.css in the styles folder under the static folder. The same
format of path applies to all references to images, styles, scripts, or ﬁles.
Section 126.2: The basics
The following example is an example of a basic server:
# Imports the Flask class
from flask import Flask
# Creates an app and checks if it's the main or imported
app = Flask(__name__)
# Specifies what URL triggers hello_world()
@app.route('/')
# The function run on the index route
def hello_world():
# Returns the text to be displayed
GoalKicker.com – Python® Notes for Professionals
571return "Hello World!"
# If this script isn't an import
if __name__ == "__main__":
# Run the app until stopped
app.run()
Running this script (with all the right dependencies installed) should start up a local server. The host is 127.0.0.1
commonly known as localhost. This server by default runs on port 5000. To access your webserver, open a web
browser and enter the URL localhost:5000 or 127.0.0.1:5000 (no diﬀerence). Currently, only your computer can
access the webserver.
app.run() has three parameters, host, port, and debug. The host is by default 127.0.0.1, but setting this to
0.0.0.0 will make your web server accessible from any device on your network using your private IP address in the
URL. the port is by default 5000 but if the parameter is set to port 80, users will not need to specify a port number
as browsers use port 80 by default. As for the debug option, during the development process (never in production)
it helps to set this parameter to True, as your server will restart when changes made to your Flask project.
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, debug=True)
Section 126.3: Routing URLs
With Flask, URL routing is traditionally done using decorators. These decorators can be used for static routing, as
well as routing URLs with parameters. For the following example, imagine this Flask script is running the website
www.example.com.
@app.route("/")
def index():
return "You went to www.example.com"
@app.route("/about")
def about():
return "You went to www.example.com/about"
@app.route("/users/guido-van-rossum")
return "You went to www.example.com/guido-van-rossum"
With that last route, you can see that given a URL with /users/ and the proﬁle name, we could return a proﬁle. Since
it would be horribly ineﬃcient and messy to include a @app.route() for every user, Flask oﬀers to take parameters
from the URL:
@app.route("/users/<username>")
def profile(username):
return "Welcome to the profile of " + username
cities = ["OMAHA", "MELBOURNE", "NEPAL", "STUTTGART", "LIMA", "CAIRO", "SHANGHAI"]
@app.route("/stores/locations/<city>")
def storefronts(city):
if city in cities:
return "Yes! We are located in " + city
else:
return "No. We are not located in " + city
GoalKicker.com – Python® Notes for Professionals
572Section 126.4: HTTP Methods
The two most common HTTP methods are GET and POST. Flask can run diﬀerent code from the same URL
dependent on the HTTP method used. For example, in a web service with accounts, it is most convenient to route
the sign in page and the sign in process through the same URL. A GET request, the same that is made when you
open a URL in your browser should show the login form, while a POST request (carrying login data) should be
processed separately. A route is also created to handle the DELETE and PUT HTTP method.
@app.route("/login", methods=["GET"])
def login_form():
return "This is the login form"
@app.route("/login", methods=["POST"])
def login_auth():
return "Processing your data"
@app.route("/login", methods=["DELETE", "PUT"])
def deny():
return "This method is not allowed"
To simplify the code a bit, we can import the request package from ﬂask.
from flask import request
@app.route("/login", methods=["GET", "POST", "DELETE", "PUT"])
def login():
if request.method == "DELETE" or request.method == "PUT":
return "This method is not allowed"
elif request.method == "GET":
return "This is the login forum"
elif request.method == "POST":
return "Processing your data"
To retrieve data from the POST request, we must use the request package:
from flask import request
@app.route("/login", methods=["GET", "POST", "DELETE", "PUT"])
def login():
if request.method == "DELETE" or request.method == "PUT":
return "This method is not allowed"
elif request.method == "GET":
return "This is the login forum"
elif request.method == "POST":
return "Username was " + request.form["username"] + " and password was " +
request.form["password"]
Section 126.5: Jinja Templating
Similar to Meteor.js, Flask integrates well with front end templating services. Flask uses by default Jinja Templating.
Templates allow small snippets of code to be used in the HTML ﬁle such as conditionals or loops.
When we render a template, any parameters beyond the template ﬁle name are passed into the HTML templating
service. The following route will pass the username and joined date (from a function somewhere else) into the
HTML.
@app.route("/users/<username>)
def profile(username):
joinedDate = get_joined_date(username) # This function's code is irrelevant
awards = get_awards(username) # This function's code is irrelevant
GoalKicker.com – Python® Notes for Professionals
573# The joinDate is a string and awards is an array of strings
return render_template("profile.html", username=username, joinDate=joinDate, awards=awards)
When this template is rendered, it can use the variables passed to it from the render_template() function. Here
are the contents of profile.html:
<!DOCTYPE html>
<html>
<head>
# if username
<title>Profile of {{ username }}</title>
# else
<title>No User Found</title>
# endif
<head>
<body>
{% if username %}
<h1>{{ username }} joined on the date {{ date }}</h1>
{% if len(awards) > 0 %}
<h3>{{ username }} has the following awards:</h3>
<ul>
{% for award in awards %}
<li>{{award}}</li>
{% endfor %}
</ul>
{% else %}
<h3>{{ username }} has no awards</h3>
{% endif %}
{% else %}
<h1>No user was found under that username</h1>
{% endif %}
{# This is a comment and doesn't affect the output #}
</body>
</html>
The following delimiters are used for diﬀerent interpretations:
{% ... %} denotes a statement
{{ ... }} denotes an expression where a template is outputted
{# ... #} denotes a comment (not included in template output)
{# ... ## implies the rest of the line should be interpreted as a statement
Section 126.6: The Request Object
The request object provides information on the request that was made to the route. To utilize this object, it must
be imported from the ﬂask module:
from flask import request
URL Parameters
In previous examples request.method and request.form were used, however we can also use the request.args
property to retrieve a dictionary of the keys/values in the URL parameters.
@app.route("/api/users/<username>")
def user_api(username):
try:
token = request.args.get("key")
if key == "pA55w0Rd":
GoalKicker.com – Python® Notes for Professionals
574if isUser(username): # The code of this method is irrelevant
joined = joinDate(username) # The code of this method is irrelevant
return "User " + username + " joined on " + joined
else:
return "User not found"
else:
return "Incorrect key"
# If there is no key parameter
except KeyError:
return "No key provided"
To correctly authenticate in this context, the following URL would be needed (replacing the username with any
username:
www.example.com/api/users/guido-van-rossum?key=pa55w0Rd
File Uploads
If a ﬁle upload was part of the submitted form in a POST request, the ﬁles can be handled using the request object:
@app.route("/upload", methods=["POST"])
def upload_file():
f = request.files["wordlist-upload"]
f.save("/var/www/uploads/" + f.filename) # Store with the original filename
Cookies
The request may also include cookies in a dictionary similar to the URL parameters.
@app.route("/home")
def home():
try:
username = request.cookies.get("username")
return "Your stored username is " + username
except KeyError:
return "No username cookies was found")
GoalKicker.com – Python® Notes for Professionals
575Chapter 127: Introduction to RabbitMQ
using AMQPStorm
Section 127.1: How to consume messages from RabbitMQ
Start with importing the library.
from amqpstorm import Connection
When consuming messages, we ﬁrst need to deﬁne a function to handle the incoming messages. This can be any
callable function, and has to take a message object, or a message tuple (depending on the to_tuple parameter
deﬁned in start_consuming).
Besides processing the data from the incoming message, we will also have to Acknowledge or Reject the message.
This is important, as we need to let RabbitMQ know that we properly received and processed the message.
def on_message(message):
"""This function is called on message received.
:param message: Delivered message.
:return:
"""
print("Message:", message.body)
# Acknowledge that we handled the message without any issues.
message.ack()
# Reject the message.
# message.reject()
# Reject the message, and put it back in the queue.
# message.reject(requeue=True)
Next we need to set up the connection to the RabbitMQ server.
connection = Connection('127.0.0.1', 'guest', 'guest')
After that we need to set up a channel. Each connection can have multiple channels, and in general when
performing multi-threaded tasks, it's recommended (but not required) to have one per thread.
channel = connection.channel()
Once we have our channel set up, we need to let RabbitMQ know that we want to start consuming messages. In this
case we will use our previously deﬁned on_message function to handle all our consumed messages.
The queue we will be listening to on the RabbitMQ server is going to be simple_queue, and we are also telling
RabbitMQ that we will be acknowledging all incoming messages once we are done with them.
channel.basic.consume(callback=on_message, queue='simple_queue', no_ack=False)
Finally we need to start the IO loop to start processing messages delivered by the RabbitMQ server.
channel.start_consuming(to_tuple=False)
GoalKicker.com – Python® Notes for Professionals
576Section 127.2: How to publish messages to RabbitMQ
Start with importing the library.
from amqpstorm import Connection
from amqpstorm import Message
Next we need to open a connection to the RabbitMQ server.
connection = Connection('127.0.0.1', 'guest', 'guest')
After that we need to set up a channel. Each connection can have multiple channels, and in general when
performing multi-threaded tasks, it's recommended (but not required) to have one per thread.
channel = connection.channel()
Once we have our channel set up, we can start to prepare our message.
# Message Properties.
properties = {
'content_type': 'text/plain',
'headers': {'key': 'value'}
}
# Create the message.
message = Message.create(channel=channel, body='Hello World!', properties=properties)
Now we can publish the message by simply calling publish and providing a routing_key. In this case we are going
to send the message to a queue called simple_queue.
message.publish(routing_key='simple_queue')
Section 127.3: How to create a delayed queue in RabbitMQ
First we need to set up two basic channels, one for the main queue, and one for the delay queue. In my example at
the end, I include a couple of additional ﬂags that are not required, but makes the code more reliable; such as
confirm delivery, delivery_mode and durable. You can ﬁnd more information on these in the RabbitMQ manual.
After we have set up the channels we add a binding to the main channel that we can use to send messages from
the delay channel to our main queue.
channel.queue.bind(exchange='amq.direct', routing_key='hello', queue='hello')
Next we need to conﬁgure our delay channel to forward messages to the main queue once they have expired.
delay_channel.queue.declare(queue='hello_delay', durable=True, arguments={
'x-message-ttl': 5000,
'x-dead-letter-exchange': 'amq.direct',
'x-dead-letter-routing-key': 'hello'
})
x-message-ttl (Message - Time To Live)
This is normally used to automatically remove old messages in the queue after a speciﬁc duration, but by
GoalKicker.com – Python® Notes for Professionals
577adding two optional arguments we can change this behaviour, and instead have this parameter determine in
milliseconds how long messages will stay in the delay queue.
x-dead-letter-routing-key
This variable allows us to transfer the message to a diﬀerent queue once they have expired, instead of the
default behaviour of removing it completely.
x-dead-letter-exchange
This variable determines which Exchange used to transfer the message from hello_delay to hello queue.
Publishing to the delay queue
When we are done setting up all the basic Pika parameters you simply send a message to the delay queue using
basic publish.
delay_channel.basic.publish(exchange='',
routing_key='hello_delay',
body='test',
properties={'delivery_mod': 2})
Once you have executed the script you should see the following queues created in your RabbitMQ management
module.
Example.
from amqpstorm import Connection
connection = Connection('127.0.0.1', 'guest', 'guest')
# Create normal 'Hello World' type channel.
channel = connection.channel()
channel.confirm_deliveries()
channel.queue.declare(queue='hello', durable=True)
# We need to bind this channel to an exchange, that will be used to transfer
# messages from our delay queue.
channel.queue.bind(exchange='amq.direct', routing_key='hello', queue='hello')
# Create our delay channel.
delay_channel = connection.channel()
delay_channel.confirm_deliveries()
# This is where we declare the delay, and routing for our delay channel.
delay_channel.queue.declare(queue='hello_delay', durable=True, arguments={
'x-message-ttl': 5000, # Delay until the message is transferred in milliseconds.
'x-dead-letter-exchange': 'amq.direct', # Exchange used to transfer the message from A to B.
'x-dead-letter-routing-key': 'hello' # Name of the queue we want the message transferred to.
GoalKicker.com – Python® Notes for Professionals
578})
delay_channel.basic.publish(exchange='',
routing_key='hello_delay',
body='test',
properties={'delivery_mode': 2})
print("[x] Sent")
GoalKicker.com – Python® Notes for Professionals
579Chapter 128: Descriptor
Section 128.1: Simple descriptor
There are two diﬀerent types of descriptors. Data descriptors are deﬁned as objects that deﬁne both a __get__()
and a __set__() method, whereas non-data descriptors only deﬁne a __get__() method. This distinction is
important when considering overrides and the namespace of an instance's dictionary. If a data descriptor and an
entry in an instance's dictionary share the same name, the data descriptor will take precedence. However, if instead
a non-data descriptor and an entry in an instance's dictionary share the same name, the instance dictionary's entry
will take precedence.
To make a read-only data descriptor, deﬁne both get() and set() with the set() raising an AttributeError when called.
Deﬁning the set() method with an exception raising placeholder is enough to make it a data descriptor.
descr.__get__(self, obj, type=None) --> value
descr.__set__(self, obj, value) --> None
descr.__delete__(self, obj) --> None
An implemented example:
class DescPrinter(object):
"""A data descriptor that logs activity."""
_val = 7
def __get__(self, obj, objtype=None):
print('Getting ...')
return self._val
def __set__(self, obj, val):
print('Setting', val)
self._val = val
def __delete__(self, obj):
print('Deleting ...')
del self._val
class Foo():
x = DescPrinter()
i = Foo()
i.x
# Getting ...
# 7
i.x = 100
# Setting 100
i.x
# Getting ...
# 100
del i.x
# Deleting ...
i.x
# Getting ...
# 7
GoalKicker.com – Python® Notes for Professionals
580Section 128.2: Two-way conversions
Descriptor objects can allow related object attributes to react to changes automatically.
Suppose we want to model an oscillator with a given frequency (in Hertz) and period (in seconds). When we update
the frequency we want the period to update, and when we update the period we want the frequency to update:
>>> oscillator = Oscillator(freq=100.0) # Set frequency to 100.0 Hz
>>> oscillator.period # Period is 1 / frequency, i.e. 0.01 seconds
0.01
>>> oscillator.period = 0.02 # Set period to 0.02 seconds
>>> oscillator.freq # The frequency is automatically adjusted
50.0
>>> oscillator.freq = 200.0 # Set the frequency to 200.0 Hz
>>> oscillator.period # The period is automatically adjusted
0.005
We pick one of the values (frequency, in Hertz) as the "anchor," i.e. the one that can be set with no conversion, and
write a descriptor class for it:
class Hertz(object):
def __get__(self, instance, owner):
return self.value
def __set__(self, instance, value):
self.value = float(value)
The "other" value (period, in seconds) is deﬁned in terms of the anchor. We write a descriptor class that does our
conversions:
class Second(object):
def __get__(self, instance, owner):
# When reading period, convert from frequency
return 1 / instance.freq
def __set__(self, instance, value):
# When setting period, update the frequency
instance.freq = 1 / float(value)
Now we can write the Oscillator class:
class Oscillator(object):
period = Second() # Set the other value as a class attribute
def __init__(self, freq):
self.freq = Hertz() # Set the anchor value as an instance attribute
self.freq = freq # Assign the passed value - self.period will be adjusted
GoalKicker.com – Python® Notes for Professionals
581Chapter 129: tempﬁle
NamedTemporaryFile
param
description
mode mode to open ﬁle, default=w+b
deleteTo delete ﬁle on closure, default=True
suﬃxﬁlename suﬃx, default=''
preﬁxﬁlename preﬁx, default='tmp'
dirdirname to place tempﬁle, default=None
buﬀsize default=-1, (operating system default used)
Section 129.1: Create (and write to a) known, persistent
temporary ﬁle
You can create temporary ﬁles which has a visible name on the ﬁle system which can be accessed via the name
property. The ﬁle can, on unix systems, be conﬁgured to delete on closure (set by delete param, default is True) or
can be reopened later.
The following will create and open a named temporary ﬁle and write 'Hello World!' to that ﬁle. The ﬁlepath of the
temporary ﬁle can be accessed via name, in this example it is saved to the variable path and printed for the user.
The ﬁle is then re-opened after closing the ﬁle and the contents of the tempﬁle are read and printed for the user.
import tempfile
with tempfile.NamedTemporaryFile(delete=False) as t:
t.write('Hello World!')
path = t.name
print path
with open(path) as t:
print t.read()
Output:
/tmp/tmp6pireJ
Hello World!
GoalKicker.com – Python® Notes for Professionals
582VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 130: Input, Subset and Output
External Data Files using Pandas
This section shows basic code for reading, sub-setting and writing external data ﬁles using pandas.
Section 130.1: Basic Code to Import, Subset and Write External
Data Files Using Pandas
# Print the working directory
import os
print os.getcwd()
# C:\Python27\Scripts
# Set the working directory
os.chdir('C:/Users/general1/Documents/simple Python files')
print os.getcwd()
# C:\Users\general1\Documents\simple Python files
# load pandas
import pandas as pd
# read a csv data file named 'small_dataset.csv' containing 4 lines and 3 variables
my_data = pd.read_csv("small_dataset.csv")
my_data
#
x
y
z
# 0
1
2
3
# 1
4
5
6
# 2
7
8
9
# 3 10 11 12
my_data.shape
# (4, 3)# number of rows and columns in data set
my_data.shape[0]
# 4# number of rows in data set
my_data.shape[1]
# 3# number of columns in data set
# Python uses 0-based indexing. The first row or column in a data set is located
# at position 0. In R the first row or column in a data set is located
# at position 1.
# Select the first two rows
my_data[0:2]
#
x
y
z
#0
1
2
3
#1
4
5
6
# Select the second and third rows
my_data[1:3]
#
x y z
# 1 4 5 6
# 2 7 8 9
# Select the third row
my_data[2:3]
#
x
y
z
#2
7
8
9
GoalKicker.com – Python® Notes for Professionals
584# Select the first two elements of the first column
my_data.iloc[0:2, 0:1]
#
x
# 0 1
# 1 4
# Select the first element of the variables y and z
my_data.loc[0, ['y', 'z']]
# y
2
# z
3
# Select the first three elements of the variables y and z
my_data.loc[0:2, ['y', 'z']]
#
y z
# 0 2 3
# 1 5 6
# 2 8 9
# Write the first three elements of the variables y and z
# to an external file. Here index = 0 means do not write row names.
my_data2 = my_data.loc[0:2, ['y', 'z']]
my_data2.to_csv('my.output.csv', index = 0)
GoalKicker.com – Python® Notes for Professionals
585Chapter 131: Unzipping Files
To extract or uncompress a tarball, ZIP, or gzip ﬁle, Python's tarﬁle, zipﬁle, and gzip modules are provided
respectively. Python's tarﬁle module provides the TarFile.extractall(path=".", members=None) function for
extracting from a tarball ﬁle. Python's zipﬁle module provides the ZipFile.extractall([path[, members[,
pwd]]]) function for extracting or unzipping ZIP compressed ﬁles. Finally, Python's gzip module provides the
GzipFile class for decompressing.
Section 131.1: Using Python ZipFile.extractall() to decompress
a ZIP ﬁle
file_unzip = 'filename.zip'
unzip = zipfile.ZipFile(file_unzip, 'r')
unzip.extractall()
unzip.close()
Section 131.2: Using Python TarFile.extractall() to decompress
a tarball
file_untar = 'filename.tar.gz'
untar = tarfile.TarFile(file_untar)
untar.extractall()
untar.close()
GoalKicker.com – Python® Notes for Professionals
586Chapter 132: Working with ZIP archives
Section 132.1: Examining Zipﬁle Contents
There are a few ways to inspect the contents of a zipﬁle. You can use the printdir to just get a variety of
information sent to stdout
with zipfile.ZipFile(filename) as zip:
zip.printdir()
# Out:
# File Name
# pyexpat.pyd
# python.exe
# python3.dll
# python35.dll
# etc.
Modified
2016-06-25 22:13:34
2016-06-25 22:13:34
2016-06-25 22:13:34
2016-06-25 22:13:34
Size
157336
39576
51864
3127960
We can also get a list of ﬁlenames with the namelist method. Here, we simply print the list:
with zipfile.ZipFile(filename) as zip:
print(zip.namelist())
# Out: ['pyexpat.pyd', 'python.exe', 'python3.dll', 'python35.dll', ... etc. ...]
Instead of namelist, we can call the infolist method, which returns a list of ZipInfo objects, which contain
additional information about each ﬁle, for instance a timestamp and ﬁle size:
with zipfile.ZipFile(filename) as zip:
info = zip.infolist()
print(zip[0].filename)
print(zip[0].date_time)
print(info[0].file_size)
# Out: pyexpat.pyd
# Out: (2016, 6, 25, 22, 13, 34)
# Out: 157336
Section 132.2: Opening Zip Files
To start, import the zipfile module, and set the ﬁlename.
import zipfile
filename = 'zipfile.zip'
Working with zip archives is very similar to working with ﬁles, you create the object by opening the zipﬁle, which lets
you work on it before closing the ﬁle up again.
zip = zipfile.ZipFile(filename)
print(zip)
# <zipfile.ZipFile object at 0x0000000002E51A90>
zip.close()
In Python 2.7 and in Python 3 versions higher than 3.2, we can use the with context manager. We open the ﬁle in
"read" mode, and then print a list of ﬁlenames:
GoalKicker.com – Python® Notes for Professionals
587with zipfile.ZipFile(filename, 'r') as z:
print(zip)
# <zipfile.ZipFile object at 0x0000000002E51A90>
Section 132.3: Extracting zip ﬁle contents to a directory
Extract all ﬁle contents of a zip ﬁle
import zipfile
with zipfile.ZipFile('zipfile.zip','r') as zfile:
zfile.extractall('path')
If you want extract single ﬁles use extract method, it takes name list and path as input parameter
import zipfile
f=open('zipfile.zip','rb')
zfile=zipfile.ZipFile(f)
for cont in zfile.namelist():
zfile.extract(cont,path)
Section 132.4: Creating new archives
To create new archive open zipﬁle with write mode.
import zipfile
new_arch=zipfile.ZipFile("filename.zip",mode="w")
To add ﬁles to this archive use write() method.
new_arch.write('filename.txt','filename_in_archive.txt') #first parameter is filename and second
parameter is filename in archive by default filename will be taken if not provided
new_arch.close()
If you want to write string of bytes into the archive you can use writestr() method.
str_bytes="string buffer"
new_arch.writestr('filename_string_in_archive.txt',str_bytes)
new_arch.close()
GoalKicker.com – Python® Notes for Professionals
588Chapter 133: Getting start with GZip
This module provides a simple interface to compress and decompress ﬁles just like the GNU programs gzip and
gunzip would.
The data compression is provided by the zlib module.
The gzip module provides the GzipFile class which is modeled after Python’s File Object. The GzipFile class reads
and writes gzip-format ﬁles, automatically compressing or decompressing the data so that it looks like an ordinary
ﬁle object.
Section 133.1: Read and write GNU zip ﬁles
import gzip
import os
outfilename = 'example.txt.gz'
output = gzip.open(outfilename, 'wb')
try:
output.write('Contents of the example file go here.\n')
finally:
output.close()
print outfilename, 'contains', os.stat(outfilename).st_size, 'bytes of compressed data'
os.system('file -b --mime %s' % outfilename)
Save it as 1gzip_write.py1.Run it through terminal.
$ python gzip_write.py
application/x-gzip; charset=binary
example.txt.gz contains 68 bytes of compressed data
GoalKicker.com – Python® Notes for Professionals
589Chapter 134: Stack
A stack is a container of objects that are inserted and removed according to the last-in ﬁrst-out (LIFO) principle. In
the pushdown stacks only two operations are allowed: push the item into the stack, and pop the item out of
the stack. A stack is a limited access data structure - elements can be added and removed from the stack only
at the top. Here is a structural deﬁnition of a Stack: a stack is either empty or it consists of a top and the rest which
is a Stack.
Section 134.1: Creating a Stack class with a List Object
Using a list object you can create a fully functional generic Stack with helper methods such as peeking and
checking if the stack is Empty. Check out the oﬃcial python docs for using list as Stack here.
#define a stack class
class Stack:
def __init__(self):
self.items = []
#method to check the stack is empty or not
def isEmpty(self):
return self.items == []
#method for pushing an item
def push(self, item):
self.items.append(item)
#method for popping an item
def pop(self):
return self.items.pop()
#check what item is on top of the stack without removing it
def peek(self):
return self.items[-1]
#method to get the size
def size(self):
return len(self.items)
#to view the entire stack
def fullStack(self):
return self.items
An example run:
stack = Stack()
print('Current stack:', stack.fullStack())
print('Stack empty?:', stack.isEmpty())
print('Pushing integer 1')
stack.push(1)
print('Pushing string "Told you, I am generic stack!"')
stack.push('Told you, I am generic stack!')
print('Pushing integer 3')
stack.push(3)
print('Current stack:', stack.fullStack())
print('Popped item:', stack.pop())
print('Current stack:', stack.fullStack())
print('Stack empty?:', stack.isEmpty())
GoalKicker.com – Python® Notes for Professionals
590Output:
Current stack: []
Stack empty?: True
Pushing integer 1
Pushing string "Told you, I am generic stack!"
Pushing integer 3
Current stack: [1, 'Told you, I am generic stack!', 3]
Popped item: 3
Current stack: [1, 'Told you, I am generic stack!']
Stack empty?: False
Section 134.2: Parsing Parentheses
Stacks are often used for parsing. A simple parsing task is to check whether a string of parentheses are matching.
For example, the string ([]) is matching, because the outer and inner brackets form pairs. ()<>) is not matching,
because the last ) has no partner. ([)] is also not matching, because pairs must be either entirely inside or outside
other pairs.
def checkParenth(str):
stack = Stack()
pushChars, popChars = "<({[", ">)}]"
for c in str:
if c in pushChars:
stack.push(c)
elif c in popChars:
if stack.isEmpty():
return False
else:
stackTop = stack.pop()
# Checks to see whether the opening bracket matches the closing one
balancingBracket = pushChars[popChars.index(c)]
if stackTop != balancingBracket:
return False
else:
return False
return not stack.isEmpty()
GoalKicker.com – Python® Notes for Professionals
591VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 135: Working around the Global
Interpreter Lock (GIL)
Section 135.1: Multiprocessing.Pool
The simple answer, when asking how to use threads in Python is: "Don't. Use processes, instead." The
multiprocessing module lets you create processes with similar syntax to creating threads, but I prefer using their
convenient Pool object.
Using the code that David Beazley ﬁrst used to show the dangers of threads against the GIL, we'll rewrite it using
multiprocessing.Pool:
David Beazley's code that showed GIL threading problems
from threading import Thread
import time
def countdown(n):
while n > 0:
n -= 1
COUNT = 10000000
t1 = Thread(target=countdown,args=(COUNT/2,))
t2 = Thread(target=countdown,args=(COUNT/2,))
start = time.time()
t1.start();t2.start()
t1.join();t2.join()
end = time.time()
print end-start
Re-written using multiprocessing.Pool:
import multiprocessing
import time
def countdown(n):
while n > 0:
n -= 1
COUNT = 10000000
start = time.time()
with multiprocessing.Pool as pool:
pool.map(countdown, [COUNT/2, COUNT/2])
pool.close()
pool.join()
end = time.time()
print(end-start)
Instead of creating threads, this creates new processes. Since each process is its own interpreter, there are no GIL
collisions. multiprocessing.Pool will open as many processes as there are cores on the machine, though in the
example above, it would only need two. In a real-world scenario, you want to design your list to have at least as
much length as there are processors on your machine. The Pool will run the function you tell it to run with each
argument, up to the number of processes it creates. When the function ﬁnishes, any remaining functions in the list
will be run on that process.
I've found that, even using the with statement, if you don't close and join the pool, the processes continue to exist.
GoalKicker.com – Python® Notes for Professionals
593To clean up resources, I always close and join my pools.
Section 135.2: Cython nogil:
Cython is an alternative python interpreter. It uses the GIL, but lets you disable it. See their documentation
As an example, using the code that David Beazley ﬁrst used to show the dangers of threads against the GIL, we'll
rewrite it using nogil:
David Beazley's code that showed GIL threading problems
from threading import Thread
import time
def countdown(n):
while n > 0:
n -= 1
COUNT = 10000000
t1 = Thread(target=countdown,args=(COUNT/2,))
t2 = Thread(target=countdown,args=(COUNT/2,))
start = time.time()
t1.start();t2.start()
t1.join();t2.join()
end = time.time()
print end-start
Re-written using nogil (ONLY WORKS IN CYTHON):
from threading import Thread
import time
def countdown(n):
while n > 0:
n -= 1
COUNT = 10000000
with nogil:
t1 = Thread(target=countdown,args=(COUNT/2,))
t2 = Thread(target=countdown,args=(COUNT/2,))
start = time.time()
t1.start();t2.start()
t1.join();t2.join()
end = time.time()
print end-start
It's that simple, as long as you're using cython. Note that the documentation says you must make sure not to
change any python objects:
Code in the body of the statement must not manipulate Python objects in any way, and must not call
anything that manipulates Python objects without ﬁrst re-acquiring the GIL. Cython currently does not
check this.
GoalKicker.com – Python® Notes for Professionals
594Chapter 136: Deployment
Section 136.1: Uploading a Conda Package
Before starting you must have:
Anaconda installed on your system Account on Binstar If you are not using Anaconda 1.6+ install the binstar
command line client:
$ conda install binstar
$ conda update binstar
If you are not using Anaconda the Binstar is also available on pypi:
$ pip install binstar
Now we can login:
$ binstar login
Test your login with the whoami command:
$ binstar whoami
We are going to be uploading a package with a simple ‘hello world’ function. To follow along start by getting my
demonstration package repo from Github:
$ git clone https://github.com/<NAME>/<Package>
This a small directory that looks like this:
package/
setup.py
test_package/
__init__.py
hello.py
bld.bat
build.sh
meta.yaml
Setup.py is the standard python build ﬁle and hello.py has our single hello_world() function.
The bld.bat, build.sh, and meta.yaml are scripts and metadata for the Conda package. You can read the Conda
build page for more info on those three ﬁles and their purpose.
Now we create the package by running:
$ conda build test_package/
That is all it takes to create a Conda package.
The ﬁnal step is uploading to binstar by copying and pasting the last line of the print out after running the conda
build test_package/ command. On my system the command is:
GoalKicker.com – Python® Notes for Professionals
595$ binstar upload /home/xavier/anaconda/conda-bld/linux-64/test_package-0.1.0-py27_0.tar.bz2
Since it is your ﬁrst time creating a package and release you will be prompted to ﬁll out some text ﬁelds which could
alternatively be done through the web app.
You will see a done printed out to conﬁrm you have successfully uploaded your Conda package to Binstar.
GoalKicker.com – Python® Notes for Professionals
596Chapter 137: Logging
Section 137.1: Introduction to Python Logging
This module deﬁnes functions and classes which implement a ﬂexible event logging system for applications and
libraries.
The key beneﬁt of having the logging API provided by a standard library module is that all Python modules can
participate in logging, so your application log can include your own messages integrated with messages from third-
party modules.
So, let's start:
Example Conﬁguration Directly in Code
import logging
logger = logging.getLogger()
handler = logging.StreamHandler()
formatter = logging.Formatter(
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.debug('this is a %s test', 'debug')
Output example:
2016-07-26 18:53:55,332 root DEBUG this is a debug test
Example Conﬁguration via an INI File
Assuming the ﬁle is named logging_conﬁg.ini. More details for the ﬁle format are in the logging conﬁguration
section of the logging tutorial.
[loggers]
keys=root
[handlers]
keys=stream_handler
[formatters]
keys=formatter
[logger_root]
level=DEBUG
handlers=stream_handler
[handler_stream_handler]
class=StreamHandler
level=DEBUG
formatter=formatter
args=(sys.stderr,)
[formatter_formatter]
GoalKicker.com – Python® Notes for Professionals
597format=%(asctime)s %(name)-12s %(levelname)-8s %(message)s
Then use logging.config.fileConfig() in the code:
import logging
from logging.config import fileConfig
fileConfig('logging_config.ini')
logger = logging.getLogger()
logger.debug('often makes a very good meal of %s', 'visiting tourists')
Example Conﬁguration via a Dictionary
As of Python 2.7, you can use a dictionary with conﬁguration details. PEP 391 contains a list of the mandatory and
optional elements in the conﬁguration dictionary.
import logging
from logging.config import dictConfig
logging_config = dict(
version = 1,
formatters = {
'f': {'format':
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s'}
},
handlers = {
'h': {'class': 'logging.StreamHandler',
'formatter': 'f',
'level': logging.DEBUG}
},
root = {
'handlers': ['h'],
'level': logging.DEBUG,
},
)
dictConfig(logging_config)
logger = logging.getLogger()
logger.debug('often makes a very good meal of %s', 'visiting tourists')
Section 137.2: Logging exceptions
If you want to log exceptions you can and should make use of the logging.exception(msg) method:
>>> import logging
>>> logging.basicConfig()
>>> try:
...
raise Exception('foo')
... except:
...
logging.exception('bar')
...
ERROR:root:bar
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
Exception: foo
Do not pass the exception as argument:
GoalKicker.com – Python® Notes for Professionals
598As logging.exception(msg) expects a msg arg, it is a common pitfall to pass the exception into the logging call like
this:
>>> try:
...
raise Exception('foo')
... except Exception as e:
...
logging.exception(e)
...
ERROR:root:foo
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
Exception: foo
While it might look as if this is the right thing to do at ﬁrst, it is actually problematic due to the reason how
exceptions and various encoding work together in the logging module:
>>> try:
...
raise Exception(u'föö')
... except Exception as e:
...
logging.exception(e)
...
Traceback (most recent call last):
File "/.../python2.7/logging/__init__.py", line 861, in emit
msg = self.format(record)
File "/.../python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/.../python2.7/logging/__init__.py", line 469, in format
s = self._fmt % record.__dict__
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2: ordinal not in
range(128)
Logged from file <stdin>, line 4
Trying to log an exception that contains unicode chars, this way will fail miserably. It will hide the stacktrace of the
original exception by overriding it with a new one that is raised during formatting of your logging.exception(e)
call.
Obviously, in your own code, you might be aware of the encoding in exceptions. However, 3rd party libs might
handle this in a diﬀerent way.
Correct Usage:
If instead of the exception you just pass a message and let python do its magic, it will work:
>>> try:
...
raise Exception(u'föö')
... except Exception as e:
...
logging.exception('bar')
...
ERROR:root:bar
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
Exception: f\xf6\xf6
As you can see we don't actually use e in that case, the call to logging.exception(...) magically formats the most
recent exception.
Logging exceptions with non ERROR log levels
GoalKicker.com – Python® Notes for Professionals
599If you want to log an exception with another log level than ERROR, you can use the exc_info argument of the
default loggers:
logging.debug('exception occurred', exc_info=1)
logging.info('exception occurred', exc_info=1)
logging.warning('exception occurred', exc_info=1)
Accessing the exception's message
Be aware that libraries out there might throw exceptions with messages as any of unicode or (utf-8 if you're lucky)
byte-strings. If you really need to access an exception's text, the only reliable way, that will always work, is to use
repr(e) or the %r string formatting:
>>> try:
...
raise Exception(u'föö')
... except Exception as e:
...
logging.exception('received this exception: %r' % e)
...
ERROR:root:received this exception: Exception(u'f\xf6\xf6',)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
Exception: f\xf6\xf6
GoalKicker.com – Python® Notes for Professionals
600Chapter 138: Web Server Gateway
Interface (WSGI)
Parameter
Details
start_response A function used to process the start
Section 138.1: Server Object (Method)
Our server object is given an 'application' parameter which can be any callable application object (see other
examples). It writes ﬁrst the headers, then the body of data returned by our application to the system standard
output.
import os, sys
def run(application):
environ['wsgi.input']
environ['wsgi.errors']
= sys.stdin
= sys.stderr
headers_set = []
headers_sent = []
def write (data):
"""
Writes header data from 'start_response()' as well as body data from 'response'
to system standard output.
"""
if not headers_set:
raise AssertionError("write() before start_response()")
elif not headers_sent:
status, response_headers = headers_sent[:] = headers_set
sys.stdout.write('Status: %s\r\n' % status)
for header in response_headers:
sys.stdout.write('%s: %s\r\n' % header)
sys.stdout.write('\r\n')
sys.stdout.write(data)
sys.stdout.flush()
def start_response(status, response_headers):
""" Sets headers for the response returned by this server."""
if headers_set:
raise AssertionError("Headers already set!")
headers_set[:] = [status, response_headers]
return write
# This is the most important piece of the 'server object'
# Our result will be generated by the 'application' given to this method as a parameter
result = application(environ, start_response)
try:
for data in result:
if data:
write(data)
# Body isn't empty send its data to 'write()'
if not headers_sent:
write('')
# Body is empty, send empty string to 'write()'
GoalKicker.com – Python® Notes for Professionals
601Chapter 139: Python Server Sent Events
Server Sent Events (SSE) is a unidirectional connection between a server and a client (usually a web browser) that
allows the server to "push" information to the client. It is much like websockets and long polling. The main
diﬀerence between SSE and websockets is that SSE is unidirectional, only the server can send info to the client,
where as with websockets, both can send info to each other. SSE is typically considered to be much simpler to
use/implement than websockets.
Section 139.1: Flask SSE
@route("/stream")
def stream():
def event_stream():
while True:
if message_to_send:
yield "data:
{}\n\n".format(message_to_send)"
return Response(event_stream(), mimetype="text/event-stream")
Section 139.2: Asyncio SSE
This example uses the asyncio SSE library: https://github.com/brutasse/asyncio-sse
import asyncio
import sse
class Handler(sse.Handler):
@asyncio.coroutine
def handle_request(self):
yield from asyncio.sleep(2)
self.send('foo')
yield from asyncio.sleep(2)
self.send('bar', event='wakeup')
start_server = sse.serve(Handler, 'localhost', 8888)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
GoalKicker.com – Python® Notes for Professionals
602VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 140: Alternatives to switch
statement from other languages
Section 140.1: Use what the language oers: the if/else
construct
Well, if you want a switch/case construct, the most straightforward way to go is to use the good old if/else
construct:
def switch(value):
if value == 1:
return "one"
if value == 2:
return "two"
if value == 42:
return "the answer to the question about life, the universe and everything"
raise Exception("No case found!")
it might look redundant, and not always pretty, but that's by far the most eﬃcient way to go, and it does the job:
>>> switch(1)
one
>>> switch(2)
two
>>> switch(3)
…
Exception: No case found!
>>> switch(42)
the answer to the question about life the universe and everything
Section 140.2: Use a dict of functions
Another straightforward way to go is to create a dictionary of functions:
switch = {
1: lambda: 'one',
2: lambda: 'two',
42: lambda: 'the answer of life the universe and everything',
}
then you add a default function:
def default_case():
raise Exception('No case found!')
and you use the dictionary's get method to get the function given the value to check and run it. If value does not
exists in dictionary, then default_case is run.
>>> switch.get(1, default_case)()
one
>>> switch.get(2, default_case)()
two
>>> switch.get(3, default_case)()
…
Exception: No case found!
GoalKicker.com – Python® Notes for Professionals
604>>> switch.get(42, default_case)()
the answer of life the universe and everything
you can also make some syntactic sugar so the switch looks nicer:
def run_switch(value):
return switch.get(value, default_case)()
>>> run_switch(1)
one
Section 140.3: Use class introspection
You can use a class to mimic the switch/case structure. The following is using introspection of a class (using the
getattr() function that resolves a string into a bound method on an instance) to resolve the "case" part.
Then that introspecting method is aliased to the __call__ method to overload the () operator.
class SwitchBase:
def switch(self, case):
m = getattr(self, 'case_{}'.format(case), None)
if not m:
return self.default
return m
__call__ = switch
Then to make it look nicer, we subclass the SwitchBase class (but it could be done in one class), and there we deﬁne
all the case as methods:
class CustomSwitcher:
def case_1(self):
return 'one'
def case_2(self):
return 'two'
def case_42(self):
return 'the answer of life, the universe and everything!'
def default(self):
raise Exception('Not a case!')
so then we can ﬁnally use it:
>>> switch = CustomSwitcher()
>>> print(switch(1))
one
>>> print(switch(2))
two
>>> print(switch(3))
…
Exception: Not a case!
>>> print(switch(42))
the answer of life, the universe and everything!
GoalKicker.com – Python® Notes for Professionals
605Section 140.4: Using a context manager
Another way, which is very readable and elegant, but far less eﬃcient than an if/else structure, is to build a class
such as follows, that will read and store the value to compare with, expose itself within the context as a callable that
will return true if it matches the stored value:
class Switch:
def __init__(self, value):
self._val = value
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
return False # Allows traceback to occur
def __call__(self, cond, *mconds):
return self._val in (cond,)+mconds
then deﬁning the cases is almost a match to the real switch/case construct (exposed within a function below, to
make it easier to show oﬀ):
def run_switch(value):
with Switch(value) as case:
if case(1):
return 'one'
if case(2):
return 'two'
if case(3):
return 'the answer to the question about life, the universe and everything'
# default
raise Exception('Not a case!')
So the execution would be:
>>> run_switch(1)
one
>>> run_switch(2)
two
>>> run_switch(3)
…
Exception: Not a case!
>>> run_switch(42)
the answer to the question about life, the universe and everything
Nota Bene:
This solution is being oﬀered as the switch module available on pypi.
GoalKicker.com – Python® Notes for Professionals
606Chapter 141: List destructuring (aka
packing and unpacking)
Section 141.1: Destructuring assignment
In assignments, you can split an Iterable into values using the "unpacking" syntax:
Destructuring as values
a, b = (1, 2)
print(a)
# Prints: 1
print(b)
# Prints: 2
If you try to unpack more than the length of the iterable, you'll get an error:
a, b, c = [1]
# Raises: ValueError: not enough values to unpack (expected 3, got 1)
Python 3.x Version > 3.0
Destructuring as a list
You can unpack a list of unknown length using the following syntax:
head, *tail = [1, 2, 3, 4, 5]
Here, we extract the ﬁrst value as a scalar, and the other values as a list:
print(head)
# Prints: 1
print(tail)
# Prints: [2, 3, 4, 5]
Which is equivalent to:
l = [1, 2, 3, 4, 5]
head = l[0]
tail = l[1:]
It also works with multiple elements or elements form the end of the list:
a, b, *other, z = [1, 2, 3, 4, 5]
print(a, b, z, other)
# Prints: 1 2 5 [3, 4]
Ignoring values in destructuring assignments
If you're only interested in a given value, you can use _ to indicate you aren’t interested. Note: this will still set _, just
most people don’t use it as a variable.
a, _ = [1, 2]
print(a)
# Prints: 1
a, _, c = (1, 2, 3)
print(a)
# Prints: 1
GoalKicker.com – Python® Notes for Professionals
607print(c)
# Prints: 3
Python 3.x Version > 3.0
Ignoring lists in destructuring assignments
Finally, you can ignore many values using the *_ syntax in the assignment:
a, *_ = [1, 2, 3, 4, 5]
print(a)
# Prints: 1
which is not really interesting, as you could using indexing on the list instead. Where it gets nice is to keep ﬁrst and
last values in one assignment:
a, *_, b = [1, 2, 3, 4, 5]
print(a, b)
# Prints: 1 5
or extract several values at once:
a, _, b, _, c, *_ = [1, 2, 3, 4, 5, 6]
print(a, b, c)
# Prints: 1 3 5
Section 141.2: Packing function arguments
In functions, you can deﬁne a number of mandatory arguments:
def fun1(arg1, arg2, arg3):
return (arg1,arg2,arg3)
which will make the function callable only when the three arguments are given:
fun1(1, 2, 3)
and you can deﬁne the arguments as optional, by using default values:
def fun2(arg1='a', arg2='b', arg3='c'):
return (arg1,arg2,arg3)
so you can call the function in many diﬀerent ways, like:
fun2(1)→ (1,b,c)
fun2(1, 2)→ (1,2,c)
fun2(arg2=2, arg3=3) → (a,2,3)
...
But you can also use the destructuring syntax to pack arguments up, so you can assign variables using a list or a
dict.
Packing a list of arguments
Consider you have a list of values
GoalKicker.com – Python® Notes for Professionals
608l = [1,2,3]
You can call the function with the list of values as an argument using the * syntax:
fun1(*l)
# Returns: (1,2,3)
fun1(*['w', 't', 'f'])
# Returns: ('w','t','f')
But if you do not provide a list which length matches the number of arguments:
fun1(*['oops'])
# Raises: TypeError: fun1() missing 2 required positional arguments: 'arg2' and 'arg3'
Packing keyword arguments
Now, you can also pack arguments using a dictionary. You can use the ** operator to tell Python to unpack the dict
as parameter values:
d = {
'arg1': 1,
'arg2': 2,
'arg3': 3
}
fun1(**d)
# Returns: (1, 2, 3)
when the function only has positional arguments (the ones without default values) you need the dictionary to be
contain of all the expected parameters, and have no extra parameter, or you'll get an error:
fun1(**{'arg1':1, 'arg2':2})
# Raises: TypeError: fun1() missing 1 required positional argument: 'arg3'
fun1(**{'arg1':1, 'arg2':2, 'arg3':3, 'arg4':4})
# Raises: TypeError: fun1() got an unexpected keyword argument 'arg4'
For functions that have optional arguments, you can pack the arguments as a dictionary the same way:
fun2(**d)
# Returns: (1, 2, 3)
But there you can omit values, as they will be replaced with the defaults:
fun2(**{'arg2': 2})
# Returns: ('a', 2, 'c')
And the same as before, you cannot give extra values that are not existing parameters:
fun2(**{'arg1':1, 'arg2':2, 'arg3':3, 'arg4':4})
# Raises: TypeError: fun2() got an unexpected keyword argument 'arg4'
In real world usage, functions can have both positional and optional arguments, and it works the same:
def fun3(arg1, arg2='b', arg3='c')
return (arg1, arg2, arg3)
GoalKicker.com – Python® Notes for Professionals
609you can call the function with just an iterable:
fun3(*[1])
# Returns: (1, 'b', 'c')
fun3(*[1,2,3])
# Returns: (1, 2, 3)
or with just a dictionary:
fun3(**{'arg1':1})
# Returns: (1, 'b', 'c')
fun3(**{'arg1':1, 'arg2':2, 'arg3':3})
# Returns: (1, 2, 3)
or you can use both in the same call:
fun3(*[1,2], **{'arg3':3})
# Returns: (1,2,3)
Beware though that you cannot provide multiple values for the same argument:
fun3(*[1,2], **{'arg2':42, 'arg3':3})
# Raises: TypeError: fun3() got multiple values for argument 'arg2'
Section 141.3: Unpacking function arguments
When you want to create a function that can accept any number of arguments, and not enforce the position or the
name of the argument at "compile" time, it's possible and here's how:
def fun1(*args, **kwargs):
print(args, kwargs)
The *args and **kwargs parameters are special parameters that are set to a tuple and a dict, respectively:
fun1(1,2,3)
# Prints: (1, 2, 3) {}
fun1(a=1, b=2, c=3)
# Prints: () {'a': 1, 'b': 2, 'c': 3}
fun1('x', 'y', 'z', a=1, b=2, c=3)
# Prints: ('x', 'y', 'z') {'a': 1, 'b': 2, 'c': 3}
If you look at enough Python code, you'll quickly discover that it is widely being used when passing arguments over
to another function. For example if you want to extend the string class:
class MyString(str):
def __init__(self, *args, **kwarg):
print('Constructing MyString')
super(MyString, self).__init__(*args, **kwarg)
GoalKicker.com – Python® Notes for Professionals
610Chapter 142: Accessing Python source
code and bytecode
Section 142.1: Display the bytecode of a function
The Python interpreter compiles code to bytecode before executing it on the Python's virtual machine (see also
What is python bytecode?.
Here's how to view the bytecode of a Python function
import dis
def fib(n):
if n <= 2: return 1
return fib(n-1) + fib(n-2)
# Display the disassembled bytecode of the function.
dis.dis(fib)
The function dis.dis in the dis module will return a decompiled bytecode of the function passed to it.
Section 142.2: Display the source code of an object
Objects that are not built-in
To print the source code of a Python object use inspect. Note that this won't work for built-in objects nor for
objects deﬁned interactively. For these you will need other methods explained later.
Here's how to print the source code of the method randint from the random module:
import random
import inspect
print(inspect.getsource(random.randint))
# Output:
#
def randint(self, a, b):
#
"""Return random integer in range [a, b], including both end points.
#
"""
#
#
return self.randrange(a, b+1)
To just print the documentation string
print(inspect.getdoc(random.randint))
# Output:
# Return random integer in range [a, b], including both end points.
Print full path of the ﬁle where the method random.randint is deﬁned:
print(inspect.getfile(random.randint))
# c:\Python35\lib\random.py
print(random.randint.__code__.co_filename) # equivalent to the above
# c:\Python35\lib\random.py
Objects deﬁned interactively
GoalKicker.com – Python® Notes for Professionals
611If an object is deﬁned interactively inspect cannot provide the source code but you can use
dill.source.getsource instead
# define a new function in the interactive shell
def add(a, b):
return a + b
print(add.__code__.co_filename) # Output: <stdin>
import dill
print dill.source.getsource(add)
# def add(a, b):
return a + b
Built-in objects
The source code for Python's built-in functions is written in c and can only be accessed by looking at the Python's
source code (hosted on Mercurial or downloadable from https://www.python.org/downloads/source/).
print(inspect.getsource(sorted)) # raises a TypeError
type(sorted) # <class 'builtin_function_or_method'>
Section 142.3: Exploring the code object of a function
CPython allows access to the code object for a function object.
The __code__object contains the raw bytecode (co_code) of the function as well as other information such as
constants and variable names.
def fib(n):
if n <= 2: return 1
return fib(n-1) + fib(n-2)
dir(fib.__code__)
def fib(n):
if n <= 2: return 1
return fib(n-1) + fib(n-2)
dir(fib.__code__)
GoalKicker.com – Python® Notes for Professionals
612Chapter 143: Mixins
Section 143.1: Mixin
A Mixin is a set of properties and methods that can be used in diﬀerent classes, which don't come from a base
class. In Object Oriented Programming languages, you typically use inheritance to give objects of diﬀerent classes
the same functionality; if a set of objects have some ability, you put that ability in a base class that both objects
inherit from.
For instance, say you have the classes Car, Boat, and Plane. Objects from all of these classes have the
ability to travel, so they get the function travel. In this scenario, they all travel the same basic way, too;
by getting a route, and moving along it. To implement this function, you could derive all of the classes
from Vehicle, and put the function in that shared class:
class Vehicle(object):
"""A generic vehicle class."""
def __init__(self, position):
self.position = position
def travel(self, destination):
route = calculate_route(from=self.position, to=destination)
self.move_along(route)
class Car(Vehicle):
...
class Boat(Vehicle):
...
class Plane(Vehicle):
...
With this code, you can call travel on a car (car.travel("Montana")), boat (boat.travel("Hawaii")),
and plane (plane.travel("France"))
However, what if you have functionality that's not available to a base class? Say, for instance, you want to give Car a
radio and the ability to use it to play a song on a radio station, with play_song_on_station, but you also have a
Clock that can use a radio too. Car and Clock could share a base class (Machine). However, not all machines can
play songs; Boat and Plane can't (at least in this example). So how do you accomplish without duplicating code? You
can use a mixin. In Python, giving a class a mixin is as simple as adding it to the list of subclasses, like this
class Foo(main_super, mixin): ...
Foo will inherit all of the properties and methods of main_super, but also those of mixin as well.
So, to give the classes Car and clock the ability to use a radio, you could override Car from the last
example and write this:
class RadioUserMixin(object):
def __init__(self):
self.radio = Radio()
GoalKicker.com – Python® Notes for Professionals
613def play_song_on_station(self, station):
self.radio.set_station(station)
self.radio.play_song()
class Car(Vehicle, RadioUserMixin):
...
class Clock(Vehicle, RadioUserMixin):
...
Now you can call car.play_song_on_station(98.7) and clock.play_song_on_station(101.3), but not
something like boat.play_song_on_station(100.5)
The important thing with mixins is that they allow you to add functionality to much diﬀerent objects, that don't
share a "main" subclass with this functionality but still share the code for it nonetheless. Without mixins, doing
something like the above example would be much harder, and/or might require some repetition.
Section 143.2: Overriding Methods in Mixins
Mixins are a sort of class that is used to "mix in" extra properties and methods into a class. This is usually ﬁne
because many times the mixin classes don't override each other's, or the base class' methods. But if you do
override methods or properties in your mixins this can lead to unexpected results because in Python the class
hierarchy is deﬁned right to left.
For instance, take the following classes
class Mixin1(object):
def test(self):
print "Mixin1"
class Mixin2(object):
def test(self):
print "Mixin2"
class BaseClass(object):
def test(self):
print "Base"
class MyClass(BaseClass, Mixin1, Mixin2):
pass
In this case the Mixin2 class is the base class, extended by Mixin1 and ﬁnally by BaseClass. Thus, if we execute the
following code snippet:
>>> x = MyClass()
>>> x.test()
Base
We see the result returned is from the Base class. This can lead to unexpected errors in the logic of your code and
needs to be accounted for and kept in mind
GoalKicker.com – Python® Notes for Professionals
614Chapter 144: Attribute Access
Section 144.1: Basic Attribute Access using the Dot Notation
Let's take a sample class.
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
book1 = Book(title="Right Ho, Jeeves", author="P.G. Wodehouse")
In Python you can access the attribute title of the class using the dot notation.
>>> book1.title
'P.G. Wodehouse'
If an attribute doesn't exist, Python throws an error:
>>> book1.series
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Book' object has no attribute 'series'
Section 144.2: Setters, Getters & Properties
For the sake of data encapsulation, sometimes you want to have an attribute which value comes from other
attributes or, in general, which value shall be computed at the moment. The standard way to deal with this situation
is to create a method, called getter or a setter.
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
In the example above, it's easy to see what happens if we create a new Book that contains a title and a author. If all
books we're to add to our Library have authors and titles, then we can skip the getters and setters and use the dot
notation. However, suppose we have some books that do not have an author and we want to set the author to
"Unknown". Or if they have multiple authors and we plan to return a list of authors.
In this case we can create a getter and a setter for the author attribute.
class P:
def __init__(self,title,author):
self.title = title
self.setAuthor(author)
def get_author(self):
return self.author
def set_author(self, author):
if not author:
self.author = "Unknown"
else:
GoalKicker.com – Python® Notes for Professionals
615self.author = author
This scheme is not recommended.
One reason is that there is a catch: Let's assume we have designed our class with the public attribute and no
methods. People have already used it a lot and they have written code like this:
>>> book = Book(title="Ancient Manuscript", author="Some Guy")
>>> book.author = "" #Cos Some Guy didn't write this one!
Now we have a problem. Because author is not an attribute! Python oﬀers a solution to this problem called
properties. A method to get properties is decorated with the @property before it's header. The method that we
want to function as a setter is decorated with @attributeName.setter before it.
Keeping this in mind, we now have our new updated class.
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
@property
def author(self):
return self.__author
@author.setter
def author(self, author):
if not author:
self.author = "Unknown"
else:
self.author = author
Note, normally Python doesn't allow you to have multiple methods with the same name and diﬀerent number of
parameters. However, in this case Python allows this because of the decorators used.
If we test the code:
>>> book = Book(title="Ancient Manuscript", author="Some Guy")
>>> book.author = "" #Cos Some Guy didn't write this one!
>>> book.author
Unknown
GoalKicker.com – Python® Notes for Professionals
616VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 145: ArcPy
Section 145.1: createDissolvedGDB to create a ﬁle gdb on the
workspace
def createDissolvedGDB(workspace, gdbName):
gdb_name = workspace + "/" + gdbName + ".gdb"
if(arcpy.Exists(gdb_name):
arcpy.Delete_management(gdb_name)
arcpy.CreateFileGDB_management(workspace, gdbName, "")
else:
arcpy.CreateFileGDB_management(workspace, gdbName, "")
return gdb_name
Section 145.2: Printing one ﬁeld's value for all rows of feature
class in ﬁle geodatabase using Search Cursor
To print a test ﬁeld (TestField) from a test feature class (TestFC) in a test ﬁle geodatabase (Test.gdb) located in a
temporary folder (C:\Temp):
with arcpy.da.SearchCursor(r"C:\Temp\Test.gdb\TestFC",["TestField"]) as cursor:
for row in cursor:
print row[0]
GoalKicker.com – Python® Notes for Professionals
618Chapter 146: Abstract Base Classes (abc)
Section 146.1: Setting the ABCMeta metaclass
Abstract classes are classes that are meant to be inherited but avoid implementing speciﬁc methods, leaving
behind only method signatures that subclasses must implement.
Abstract classes are useful for deﬁning and enforcing class abstractions at a high level, similar to the concept of
interfaces in typed languages, without the need for method implementation.
One conceptual approach to deﬁning an abstract class is to stub out the class methods, and then raise a
NotImplementedError if accessed. This prevents children classes from accessing parent methods without
overriding them ﬁrst. Like so:
class Fruit:
def check_ripeness(self):
raise NotImplementedError("check_ripeness method not implemented!")
class Apple(Fruit):
pass
a = Apple()
a.check_ripeness() # raises NotImplementedError
Creating an abstract class in this way prevents improper usage of methods that are not overridden, and certainly
encourages methods to be deﬁned in child classes, but it does not enforce their deﬁnition. With the abc module we
can prevent child classes from being instantiated when they fail to override abstract class methods of their parents
and ancestors:
from abc import ABCMeta
class AbstractClass(object):
# the metaclass attribute must always be set as a class variable
__metaclass__ = ABCMeta
# the abstractmethod decorator registers this method as undefined
@abstractmethod
def virtual_method_subclasses_must_define(self):
# Can be left completely blank, or a base implementation can be provided
# Note that ordinarily a blank interpretation implicitly returns `None`,
# but by registering, this behaviour is no longer enforced.
It is now possible to simply subclass and override:
class Subclass(AbstractClass):
def virtual_method_subclasses_must_define(self):
return
Section 146.2: Why/How to use ABCMeta and
@abstractmethod
Abstract base classes (ABCs) enforce what derived classes implement particular methods from the base class.
GoalKicker.com – Python® Notes for Professionals
619To understand how this works and why we should use it, let's take a look at an example that Van Rossum would
enjoy. Let's say we have a Base class "MontyPython" with two methods (joke & punchline) that must be
implemented by all derived classes.
class MontyPython:
def joke(self):
raise NotImplementedError()
def punchline(self):
raise NotImplementedError()
class ArgumentClinic(MontyPython):
def joke(self):
return "Hahahahahah"
When we instantiate an object and call it's two methods, we'll get an error (as expected) with the punchline()
method.
>>> sketch = ArgumentClinic()
>>> sketch.punchline()
NotImplementedError
However, this still allows us to instantiate an object of the ArgumentClinic class without getting an error. In fact we
don't get an error until we look for the punchline().
This is avoided by using the Abstract Base Class (ABC) module. Let's see how this works with the same example:
from abc import ABCMeta, abstractmethod
class MontyPython(metaclass=ABCMeta):
@abstractmethod
def joke(self):
pass
@abstractmethod
def punchline(self):
pass
class ArgumentClinic(MontyPython):
def joke(self):
return "Hahahahahah"
This time when we try to instantiate an object from the incomplete class, we immediately get a TypeError!
>>> c = ArgumentClinic()
TypeError:
"Can't instantiate abstract class ArgumentClinic with abstract methods punchline"
In this case, it's easy to complete the class to avoid any TypeErrors:
class ArgumentClinic(MontyPython):
def joke(self):
return "Hahahahahah"
def punchline(self):
return "Send in the constable!"
This time when you instantiate an object it works!
GoalKicker.com – Python® Notes for Professionals
620Chapter 147: Plugin and Extension Classes
Section 147.1: Mixins
In Object oriented programming language, a mixin is a class that contains methods for use by other classes without
having to be the parent class of those other classes. How those other classes gain access to the mixin's methods
depends on the language.
It provides a mechanism for multiple inheritance by allowing multiple classes to use the common functionality, but
without the complex semantics of multiple inheritance. Mixins are useful when a programmer wants to share
functionality between diﬀerent classes. Instead of repeating the same code over and over again, the common
functionality can simply be grouped into a mixin and then inherited into each class that requires it.
When we use more than one mixins, Order of mixins are important. here is a simple example:
class Mixin1(object):
def test(self):
print "Mixin1"
class Mixin2(object):
def test(self):
print "Mixin2"
class MyClass(Mixin1, Mixin2):
pass
In this example we call MyClass and test method,
>>> obj = MyClass()
>>> obj.test()
Mixin1
Result must be Mixin1 because Order is left to right. This could be show unexpected results when super classes add
with it. So reverse order is more good just like this:
class MyClass(Mixin2, Mixin1):
pass
Result will be:
>>> obj = MyClass()
>>> obj.test()
Mixin2
Mixins can be used to deﬁne custom plugins.
Python 3.x Version ≥ 3.0
class Base(object):
def test(self):
print("Base.")
class PluginA(object):
def test(self):
super().test()
print("Plugin A.")
GoalKicker.com – Python® Notes for Professionals
621class PluginB(object):
def test(self):
super().test()
print("Plugin B.")
plugins = PluginA, PluginB
class PluginSystemA(PluginA, Base):
pass
class PluginSystemB(PluginB, Base):
pass
PluginSystemA().test()
# Base.
# Plugin A.
PluginSystemB().test()
# Base.
# Plugin B.
Section 147.2: Plugins with Customized Classes
In Python 3.6, PEP 487 added the __init_subclass__ special method, which simpliﬁes and extends class
customization without using metaclasses. Consequently, this feature allows for creating simple plugins. Here we
demonstrate this feature by modifying a prior example:
Python 3.x Version ≥ 3.6
class Base:
plugins = []
def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)
cls.plugins.append(cls)
def test(self):
print("Base.")
class PluginA(Base):
def test(self):
super().test()
print("Plugin A.")
class PluginB(Base):
def test(self):
super().test()
print("Plugin B.")
Results:
PluginA().test()
# Base.
# Plugin A.
PluginB().test()
# Base.
# Plugin B.
Base.plugins
GoalKicker.com – Python® Notes for Professionals
622# [__main__.PluginA, __main__.PluginB]
GoalKicker.com – Python® Notes for Professionals
623Chapter 148: Immutable datatypes(int,
ﬂoat, str, tuple and frozensets)
Section 148.1: Individual characters of strings are not
assignable
foo = "bar"
foo[0] = "c" # Error
Immutable variable value can not be changed once they are created.
Section 148.2: Tuple's individual members aren't assignable
foo = ("bar", 1, "Hello!",)
foo[1] = 2 # ERROR!!
Second line would return an error since tuple members once created aren't assignable. Because of tuple's
immutability.
Section 148.3: Frozenset's are immutable and not assignable
foo = frozenset(["bar", 1, "Hello!"])
foo[2] = 7 # ERROR
foo.add(3) # ERROR
Second line would return an error since frozenset members once created aren't assignable. Third line would return
error as frozensets do not support functions that can manipulate members.
GoalKicker.com – Python® Notes for Professionals
624Chapter 149: Incompatibilities moving
from Python 2 to Python 3
Unlike most languages, Python supports two major versions. Since 2008 when Python 3 was released, many have
made the transition, while many have not. In order to understand both, this section covers the important
diﬀerences between Python 2 and Python 3.
Section 149.1: Integer Division
The standard division symbol (/) operates diﬀerently in Python 3 and Python 2 when applied to integers.
When dividing an integer by another integer in Python 3, the division operation x / y represents a true division
(uses __truediv__ method) and produces a ﬂoating point result. Meanwhile, the same operation in Python 2
represents a classic division that rounds the result down toward negative inﬁnity (also known as taking the ﬂoor).
For example:
3 / 2 1
Code Python 2 output
Python 3 output
1.5
2 / 3 00.6666666666666666
-3 / 2 -2-1.5
The rounding-towards-zero behavior was deprecated in Python 2.2, but remains in Python 2.7 for the sake of
backward compatibility and was removed in Python 3.
Note: To get a ﬂoat result in Python 2 (without ﬂoor rounding) we can specify one of the operands with the decimal
point. The above example of 2/3 which gives 0 in Python 2 shall be used as 2 / 3.0 or 2.0 / 3 or 2.0/3.0 to get
0.6666666666666666
Code
Python 2 output
3.0 / 2.0 1.5
2 / 3.0
Python 3 output
1.5
0.6666666666666666 0.6666666666666666
-3.0 / 2 -1.5
-1.5
There is also the ﬂoor division operator (//), which works the same way in both versions: it rounds down to the
nearest integer. (although a ﬂoat is returned when used with ﬂoats) In both versions the // operator maps to
__floordiv__.
3 // 2
Code
Python 2 output Python 3 output
1
1
2 // 30
0
-3 // 2-2
-2
3.0 // 2.0 1.0
1.0
0.0
0.0
-3 // 2.0 -2.0
-2.0
2.0 // 3
One can explicitly enforce true division or ﬂoor division using native functions in the operator module:
from operator import truediv, floordiv
assert truediv(10, 8) == 1.25
assert floordiv(10, 8) == 1
# equivalent to `/` in Python 3
# equivalent to `//`
GoalKicker.com – Python® Notes for Professionals
625While clear and explicit, using operator functions for every division can be tedious. Changing the behavior of the /
operator will often be preferred. A common practice is to eliminate typical division behavior by adding from
__future__ import division as the ﬁrst statement in each module:
# needs to be the first statement in a module
from __future__ import division
Code
Python 2 output
3 / 2 1.5
Python 3 output
1.5
2 / 3 0.6666666666666666 0.6666666666666666
-3 / 2 -1.5
-1.5
from __future__ import division guarantees that the / operator represents true division and only within the
modules that contain the __future__ import, so there are no compelling reasons for not enabling it in all new
modules.
Note: Some other programming languages use rounding toward zero (truncation) rather than rounding down toward
negative inﬁnity as Python does (i.e. in those languages -3 / 2 == -1). This behavior may create confusion when
porting or comparing code.
Note on ﬂoat operands: As an alternative to from __future__ import division, one could use the usual division
symbol / and ensure that at least one of the operands is a ﬂoat: 3 / 2.0 == 1.5. However, this can be considered
bad practice. It is just too easy to write average = sum(items) / len(items) and forget to cast one of the
arguments to ﬂoat. Moreover, such cases may frequently evade notice during testing, e.g., if you test on an array
containing floats but receive an array of ints in production. Additionally, if the same code is used in Python 3,
programs that expect 3 / 2 == 1 to be True will not work correctly.
See PEP 238 for more detailed rationale why the division operator was changed in Python 3 and why old-style
division should be avoided.
See the Simple Math topic for more about division.
Section 149.2: Unpacking Iterables
Python 3.x Version ≥ 3.0
In Python 3, you can unpack an iterable without knowing the exact number of items in it, and even have a variable
hold the end of the iterable. For that, you provide a variable that may collect a list of values. This is done by placing
an asterisk before the name. For example, unpacking a list:
first, second, *tail, last = [1, 2, 3, 4, 5]
print(first)
# Out: 1
print(second)
# Out: 2
print(tail)
# Out: [3, 4]
print(last)
# Out: 5
Note: When using the *variable syntax, the variable will always be a list, even if the original type wasn't a list. It
may contain zero or more elements depending on the number of elements in the original list.
first, second, *tail, last = [1, 2, 3, 4]
print(tail)
GoalKicker.com – Python® Notes for Professionals
626# Out: [3]
first, second, *tail, last = [1, 2, 3]
print(tail)
# Out: []
print(last)
# Out: 3
Similarly, unpacking a str:
begin, *tail = "Hello"
print(begin)
# Out: 'H'
print(tail)
# Out: ['e', 'l', 'l', 'o']
Example of unpacking a date; _ is used in this example as a throwaway variable (we are interested only in year
value):
person = ('John', 'Doe', (10, 16, 2016))
*_, (*_, year_of_birth) = person
print(year_of_birth)
# Out: 2016
It is worth mentioning that, since * eats up a variable number of items, you cannot have two *s for the same iterable
in an assignment - it wouldn't know how many elements go into the ﬁrst unpacking, and how many in the second:
*head, *tail = [1, 2]
# Out: SyntaxError: two starred expressions in assignment
Python 3.x Version ≥ 3.5
So far we have discussed unpacking in assignments. * and ** were extended in Python 3.5. It's now possible to
have several unpacking operations in one expression:
{*range(4), 4, *(5, 6, 7)}
# Out: {0, 1, 2, 3, 4, 5, 6, 7}
Python 2.x Version ≥ 2.0
It is also possible to unpack an iterable into function arguments:
iterable = [1, 2, 3, 4, 5]
print(iterable)
# Out: [1, 2, 3, 4, 5]
print(*iterable)
# Out: 1 2 3 4 5
Python 3.x Version ≥ 3.5
Unpacking a dictionary uses two adjacent stars ** (PEP 448):
tail = {'y': 2, 'z': 3}
{'x': 1, **tail}
# Out: {'x': 1, 'y': 2, 'z': 3}
This allows for both overriding old values and merging dictionaries.
dict1 = {'x': 1, 'y': 1}
GoalKicker.com – Python® Notes for Professionals
627dict2 = {'y': 2, 'z': 3}
{**dict1, **dict2}
# Out: {'x': 1, 'y': 2, 'z': 3}
Python 3.x Version ≥ 3.0
Python 3 removed tuple unpacking in functions. Hence the following doesn't work in Python 3
# Works in Python 2, but syntax error in Python 3:
map(lambda (x, y): x + y, zip(range(5), range(5)))
# Same is true for non-lambdas:
def example((x, y)):
pass
# Works in both Python 2 and Python 3:
map(lambda x: x[0] + x[1], zip(range(5), range(5)))
# And non-lambdas, too:
def working_example(x_y):
x, y = x_y
pass
See PEP 3113 for detailed rationale.
Section 149.3: Strings: Bytes versus Unicode
Python 2.x Version ≤ 2.7
In Python 2 there are two variants of string: those made of bytes with type (str) and those made of text with type
(unicode).
In Python 2, an object of type str is always a byte sequence, but is commonly used for both text and binary data.
A string literal is interpreted as a byte string.
s = 'Cafe'
# type(s) == str
There are two exceptions: You can deﬁne a Unicode (text) literal explicitly by preﬁxing the literal with u:
s = u'Café'
# type(s) == unicode
b = 'Lorem ipsum' # type(b) == str
Alternatively, you can specify that a whole module's string literals should create Unicode (text) literals:
from __future__ import unicode_literals
s = 'Café'
# type(s) == unicode
b = 'Lorem ipsum' # type(b) == unicode
In order to check whether your variable is a string (either Unicode or a byte string), you can use:
isinstance(s, basestring)
Python 3.x Version ≥ 3.0
In Python 3, the str type is a Unicode text type.
s = 'Cafe'
# type(s) == str
GoalKicker.com – Python® Notes for Professionals
628s = 'Café'
# type(s) == str (note the accented trailing e)
Additionally, Python 3 added a bytes object, suitable for binary "blobs" or writing to encoding-independent ﬁles. To
create a bytes object, you can preﬁx b to a string literal or call the string's encode method:
# Or, if you really need a byte string:
s = b'Cafe'
# type(s) == bytes
s = 'Café'.encode() # type(s) == bytes
To test whether a value is a string, use:
isinstance(s, str)
Python 3.x Version ≥ 3.3
It is also possible to preﬁx string literals with a u preﬁx to ease compatibility between Python 2 and Python 3 code
bases. Since, in Python 3, all strings are Unicode by default, prepending a string literal with u has no eﬀect:
u'Cafe' == 'Cafe'
Python 2’s raw Unicode string preﬁx ur is not supported, however:
>>> ur'Café'
File "<stdin>", line 1
ur'Café'
^
SyntaxError: invalid syntax
Note that you must encode a Python 3 text (str) object to convert it into a bytes representation of that text. The
default encoding of this method is UTF-8.
You can use decode to ask a bytes object for what Unicode text it represents:
>>> b.decode()
'Café'
Python 2.x Version ≥ 2.6
While the bytes type exists in both Python 2 and 3, the unicode type only exists in Python 2. To use Python 3's
implicit Unicode strings in Python 2, add the following to the top of your code ﬁle:
from __future__ import unicode_literals
print(repr("hi"))
# u'hi'
Python 3.x Version ≥ 3.0
Another important diﬀerence is that indexing bytes in Python 3 results in an int output like so:
b"abc"[0] == 97
Whilst slicing in a size of one results in a length 1 bytes object:
b"abc"[0:1] == b"a"
In addition, Python 3 ﬁxes some unusual behavior with unicode, i.e. reversing byte strings in Python 2. For example,
the following issue is resolved:
GoalKicker.com – Python® Notes for Professionals
629# -*- coding: utf8 -*-
print("Hi, my name is Łukasz Langa.")
print(u"Hi, my name is Łukasz Langa."[::-1])
print("Hi, my name is Łukasz Langa."[::-1])
# Output in Python 2
# Hi, my name is Łukasz Langa.
# .agnaL zsakuŁ si eman ym ,iH
# .agnaL zsaku�� si eman ym ,iH
# Output in Python 3
# Hi, my name is Łukasz Langa.
# .agnaL zsakuŁ si eman ym ,iH
# .agnaL zsakuŁ si eman ym ,iH
Section 149.4: Print statement vs. Print function
In Python 2, print is a statement:
Python 2.x Version ≤ 2.7
print "Hello World"
print
print "No newline",
print >>sys.stderr, "Error"
print("hello")
print()
print 1, 2, 3
print(1, 2, 3)
# print a newline
# add trailing comma to remove newline
# print to stderr
# print "hello", since ("hello") == "hello"
# print an empty tuple "()"
# print space-separated arguments: "1 2 3"
# print tuple "(1, 2, 3)"
In Python 3, print() is a function, with keyword arguments for common uses:
Python 3.x Version ≥ 3.0
print "Hello World"
# SyntaxError
print("Hello World")
print()
# print a newline (must use parentheses)
print("No newline", end="")
# end specifies what to append (defaults to newline)
print("Error", file=sys.stderr) # file specifies the output buffer
print("Comma", "separated", "output", sep=",") # sep specifies the separator
print("A", "B", "C", sep="")
# null string for sep: prints as ABC
print("Flush this", flush=True) # flush the output buffer, added in Python 3.3
print(1, 2, 3)
# print space-separated arguments: "1 2 3"
print((1, 2, 3))
# print tuple "(1, 2, 3)"
The print function has the following parameters:
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
sep is what separates the objects you pass to print. For example:
print('foo', 'bar', sep='~') # out: foo~bar
print('foo', 'bar', sep='.') # out: foo.bar
end is what the end of the print statement is followed by. For example:
print('foo', 'bar', end='!') # out: foo bar!
GoalKicker.com – Python® Notes for Professionals
630Printing again following a non-newline ending print statement will print to the same line:
print('foo', end='~')
print('bar')
# out: foo~bar
Note: For future compatibility, print function is also available in Python 2.6 onwards; however it cannot be used
unless parsing of the print statement is disabled with
from __future__ import print_function
This function has exactly same format as Python 3's, except that it lacks the flush parameter.
See PEP 3105 for rationale.
Section 149.5: Dierences between range and xrange
functions
In Python 2, range function returns a list while xrange creates a special xrange object, which is an immutable
sequence, which unlike other built-in sequence types, doesn't support slicing and has neither index nor count
methods:
Python 2.x Version ≥ 2.3
print(range(1, 10))
# Out: [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(isinstance(range(1, 10), list))
# Out: True
print(xrange(1, 10))
# Out: xrange(1, 10)
print(isinstance(xrange(1, 10), xrange))
# Out: True
In Python 3, xrange was expanded to the range sequence, which thus now creates a range object. There is no
xrange type:
Python 3.x Version ≥ 3.0
print(range(1, 10))
# Out: range(1, 10)
print(isinstance(range(1, 10), range))
# Out: True
# print(xrange(1, 10))
# The output will be:
#Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
#NameError: name 'xrange' is not defined
Additionally, since Python 3.2, range also supports slicing, index and count:
print(range(1, 10)[3:7])
# Out: range(3, 7)
print(range(1, 10).count(5))
# Out: 1
GoalKicker.com – Python® Notes for Professionals
631print(range(1, 10).index(7))
# Out: 6
The advantage of using a special sequence type instead of a list is that the interpreter does not have to allocate
memory for a list and populate it:
Python 2.x Version ≥ 2.3
# range(10000000000000000)
# The output would be:
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# MemoryError
print(xrange(100000000000000000))
# Out: xrange(100000000000000000)
Since the latter behaviour is generally desired, the former was removed in Python 3. If you still want to have a list in
Python 3, you can simply use the list() constructor on a range object:
Python 3.x Version ≥ 3.0
print(list(range(1, 10)))
# Out: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Compatibility
In order to maintain compatibility between both Python 2.x and Python 3.x versions, you can use the builtins
module from the external package future to achieve both forward-compatibility and backward-compatibility:
Python 2.x Version ≥ 2.0
#forward-compatible
from builtins import range
for i in range(10**8):
pass
Python 3.x Version ≥ 3.0
#backward-compatible
from past.builtins import xrange
for i in xrange(10**8):
pass
The range in future library supports slicing, index and count in all Python versions, just like the built-in method on
Python 3.2+.
Section 149.6: Raising and handling Exceptions
This is the Python 2 syntax, note the commas , on the raise and except lines:
Python 2.x Version ≥ 2.3
try:
raise IOError, "input/output error"
except IOError, exc:
print exc
In Python 3, the , syntax is dropped and replaced by parenthesis and the as keyword:
GoalKicker.com – Python® Notes for Professionals
632try:
raise IOError("input/output error")
except IOError as exc:
print(exc)
For backwards compatibility, the Python 3 syntax is also available in Python 2.6 onwards, so it should be used for all
new code that does not need to be compatible with previous versions.
Python 3.x Version ≥ 3.0
Python 3 also adds exception chaining, wherein you can signal that some other exception was the cause for this
exception. For example
try:
file = open('database.db')
except FileNotFoundError as e:
raise DatabaseError('Cannot open {}') from e
The exception raised in the except statement is of type DatabaseError, but the original exception is marked as the
__cause__ attribute of that exception. When the traceback is displayed, the original exception will also be displayed
in the traceback:
Traceback (most recent call last):
File "", line 2, in
FileNotFoundError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "", line 4, in
DatabaseError('Cannot open database.db')
If you throw in an except block without explicit chaining:
try:
file = open('database.db')
except FileNotFoundError as e:
raise DatabaseError('Cannot open {}')
The traceback is
Traceback (most recent call last):
File "", line 2, in
FileNotFoundError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 4, in
DatabaseError('Cannot open database.db')
Python 2.x Version ≥ 2.0
Neither one is supported in Python 2.x; the original exception and its traceback will be lost if another exception is
raised in the except block. The following code can be used for compatibility:
GoalKicker.com – Python® Notes for Professionals
633import sys
import traceback
try:
funcWithError()
except:
sys_vers = getattr(sys, 'version_info', (0,))
if sys_vers < (3, 0):
traceback.print_exc()
raise Exception("new exception")
Python 3.x Version ≥ 3.3
To "forget" the previously thrown exception, use raise from None
try:
file = open('database.db')
except FileNotFoundError as e:
raise DatabaseError('Cannot open {}') from None
Now the traceback would simply be
Traceback (most recent call last):
File "", line 4, in
DatabaseError('Cannot open database.db')
Or in order to make it compatible with both Python 2 and 3 you may use the six package like so:
import six
try:
file = open('database.db')
except FileNotFoundError as e:
six.raise_from(DatabaseError('Cannot open {}'), None)
Section 149.7: Leaked variables in list comprehension
Python 2.x Version ≥ 2.3
x = 'hello world!'
vowels = [x for x in 'AEIOU']
print (vowels)
# Out: ['A', 'E', 'I', 'O', 'U']
print(x)
# Out: 'U'
Python 3.x Version ≥ 3.0
x = 'hello world!'
vowels = [x for x in 'AEIOU']
print (vowels)
# Out: ['A', 'E', 'I', 'O', 'U']
print(x)
# Out: 'hello world!'
As can be seen from the example, in Python 2 the value of x was leaked: it masked hello world! and printed out U,
since this was the last value of x when the loop ended.
However, in Python 3 x prints the originally deﬁned hello world!, since the local variable from the list
GoalKicker.com – Python® Notes for Professionals
634comprehension does not mask variables from the surrounding scope.
Additionally, neither generator expressions (available in Python since 2.5) nor dictionary or set comprehensions
(which were backported to Python 2.7 from Python 3) leak variables in Python 2.
Note that in both Python 2 and Python 3, variables will leak into the surrounding scope when using a for loop:
x = 'hello world!'
vowels = []
for x in 'AEIOU':
vowels.append(x)
print(x)
# Out: 'U'
Section 149.8: True, False and None
In Python 2, True, False and None are built-in constants. Which means it's possible to reassign them.
Python 2.x Version ≥ 2.0
True, False = False, True
True
# False
False # True
You can't do this with None since Python 2.4.
Python 2.x Version ≥ 2.4
None = None
# SyntaxError: cannot assign to None
In Python 3, True, False, and None are now keywords.
Python 3.x Version ≥ 3.0
True, False = False, True
None = None
# SyntaxError: can't assign to keyword
# SyntaxError: can't assign to keyword
Section 149.9: User Input
In Python 2, user input is accepted using the raw_input function,
Python 2.x Version ≥ 2.3
user_input = raw_input()
While in Python 3 user input is accepted using the input function.
Python 3.x Version ≥ 3.0
user_input = input()
In Python 2, the input function will accept input and interpret it. While this can be useful, it has several security
considerations and was removed in Python 3. To access the same functionality, eval(input()) can be used.
To keep a script portable across the two versions, you can put the code below near the top of your Python script:
try:
input = raw_input
except NameError:
GoalKicker.com – Python® Notes for Professionals
635pass
Section 149.10: Comparison of dierent types
Python 2.x Version ≥ 2.3
Objects of diﬀerent types can be compared. The results are arbitrary, but consistent. They are ordered such that
None is less than anything else, numeric types are smaller than non-numeric types, and everything else is ordered
lexicographically by type. Thus, an int is less than a str and a tuple is greater than a list:
[1, 2] > 'foo'
# Out: False
(1, 2) > 'foo'
# Out: True
[1, 2] > (1, 2)
# Out: False
100 < [1, 'x'] < 'xyz' < (1, 'x')
# Out: True
This was originally done so a list of mixed types could be sorted and objects would be grouped together by type:
l = [7, 'x', (1, 2), [5, 6], 5, 8.0, 'y', 1.2, [7, 8], 'z']
sorted(l)
# Out: [1.2, 5, 7, 8.0, [5, 6], [7, 8], 'x', 'y', 'z', (1, 2)]
Python 3.x Version ≥ 3.0
An exception is raised when comparing diﬀerent (non-numeric) types:
1 < 1.5
# Out: True
[1, 2] > 'foo'
# TypeError: unorderable types: list() > str()
(1, 2) > 'foo'
# TypeError: unorderable types: tuple() > str()
[1, 2] > (1, 2)
# TypeError: unorderable types: list() > tuple()
To sort mixed lists in Python 3 by types and to achieve compatibility between versions, you have to provide a key to
the sorted function:
>>> list = [1, 'hello', [3, 4], {'python': 2}, 'stackoverflow', 8, {'python': 3}, [5, 6]]
>>> sorted(list, key=str)
# Out: [1, 8, [3, 4], [5, 6], 'hello', 'stackoverflow', {'python': 2}, {'python': 3}]
Using str as the key function temporarily converts each item to a string only for the purposes of comparison. It
then sees the string representation starting with either [, ', { or 0-9 and it's able to sort those (and all the following
characters).
Section 149.11: .next() method on iterators renamed
In Python 2, an iterator can be traversed by using a method called next on the iterator itself:
Python 2.x Version ≥ 2.3
g = (i for i in range(0, 3))
g.next() # Yields 0
GoalKicker.com – Python® Notes for Professionals
636g.next()
g.next()
# Yields 1
# Yields 2
In Python 3 the .next method has been renamed to .__next__, acknowledging its “magic” role, so calling .next will
raise an AttributeError. The correct way to access this functionality in both Python 2 and Python 3 is to call the
next function with the iterator as an argument.
Python 3.x Version ≥ 3.0
g = (i for i in range(0, 3))
next(g) # Yields 0
next(g) # Yields 1
next(g) # Yields 2
This code is portable across versions from 2.6 through to current releases.
Section 149.12: ﬁlter(), map() and zip() return iterators instead
of sequences
Python 2.x Version ≤ 2.7
In Python 2 filter, map and zip built-in functions return a sequence. map and zip always return a list while with
filter the return type depends on the type of given parameter:
>>> s = filter(lambda x: x.isalpha(), 'a1b2c3')
>>> s
'abc'
>>> s = map(lambda x: x * x, [0, 1, 2])
>>> s
[0, 1, 4]
>>> s = zip([0, 1, 2], [3, 4, 5])
>>> s
[(0, 3), (1, 4), (2, 5)]
Python 3.x Version ≥ 3.0
In Python 3 filter, map and zip return iterator instead:
>>> it = filter(lambda x: x.isalpha(), 'a1b2c3')
>>> it
<filter object at 0x00000098A55C2518>
>>> ''.join(it)
'abc'
>>> it = map(lambda x: x * x, [0, 1, 2])
>>> it
<map object at 0x000000E0763C2D30>
>>> list(it)
[0, 1, 4]
>>> it = zip([0, 1, 2], [3, 4, 5])
>>> it
<zip object at 0x000000E0763C52C8>
>>> list(it)
[(0, 3), (1, 4), (2, 5)]
Since Python 2 itertools.izip is equivalent of Python 3 zip izip has been removed on Python 3.
Section 149.13: Renamed modules
A few modules in the standard library have been renamed:
GoalKicker.com – Python® Notes for Professionals
637Old name
_winreg
New name
winreg
ConﬁgParserconﬁgparser
copy_regcopyreg
Queuequeue
SocketServersocketserver
_markupbasemarkupbase
reprreprlib
test.test_support test.support
Tkintertkinter
tkFileDialogtkinter.ﬁledialog
urllib / urllib2urllib, urllib.parse, urllib.error, urllib.response, urllib.request, urllib.robotparser
Some modules have even been converted from ﬁles to libraries. Take tkinter and urllib from above as an example.
Compatibility
When maintaining compatibility between both Python 2.x and 3.x versions, you can use the future external
package to enable importing top-level standard library packages with Python 3.x names on Python 2.x versions.
Section 149.14: Removed operators <> and ``, synonymous
with != and repr()
In Python 2, <> is a synonym for !=; likewise, `foo` is a synonym for repr(foo).
Python 2.x Version ≤ 2.7
>>> 1 <> 2
True
>>> 1 <> 1
False
>>> foo = 'hello world'
>>> repr(foo)
"'hello world'"
>>> `foo`
"'hello world'"
Python 3.x Version ≥ 3.0
>>> 1 <> 2
File "<stdin>", line 1
1 <> 2
^
SyntaxError: invalid syntax
>>> `foo`
File "<stdin>", line 1
`foo`
^
SyntaxError: invalid syntax
Section 149.15: long vs. int
In Python 2, any integer larger than a C ssize_t would be converted into the long data type, indicated by an L suﬃx
on the literal. For example, on a 32 bit build of Python:
Python 2.x Version ≤ 2.7
GoalKicker.com – Python® Notes for Professionals
638>>> 2**31
2147483648L
>>> type(2**31)
<type 'long'>
>>> 2**30
1073741824
>>> type(2**30)
<type 'int'>
>>> 2**31 - 1 # 2**31 is long and long - int is long
2147483647L
However, in Python 3, the long data type was removed; no matter how big the integer is, it will be an int.
Python 3.x Version ≥ 3.0
2**1024
# Output:
17976931348623159077293051907890247336179769789423065727343008115773267580550096313270847732240753602
11201138798713933576587897688144166224928474306394741243777678934248654852763022196012460941194530829
52085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224
137216
print(-(2**1024))
# Output:
-1797693134862315907729305190789024733617976978942306572734300811577326758055009631327084773224075360
21120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082
95208500576883815068234246288147391311054082723716335051068458629823994724593847971630483535632962422
4137216
type(2**1024)
# Output: <class 'int'>
Section 149.16: All classes are "new-style classes" in Python 3
In Python 3.x all classes are new-style classes; when deﬁning a new class python implicitly makes it inherit from
object. As such, specifying object in a class deﬁnition is a completely optional:
Python 3.x Version ≥ 3.0
class X: pass
class Y(object): pass
Both of these classes now contain object in their mro (method resolution order):
Python 3.x Version ≥ 3.0
>>> X.__mro__
(__main__.X, object)
>>> Y.__mro__
(__main__.Y, object)
In Python 2.x classes are, by default, old-style classes; they do not implicitly inherit from object. This causes the
semantics of classes to diﬀer depending on if we explicitly add object as a base class:
Python 2.x Version ≥ 2.3
class X: pass
class Y(object): pass
In this case, if we try to print the __mro__ of Y, similar output as that in the Python 3.x case will appear:
Python 2.x Version ≥ 2.3
GoalKicker.com – Python® Notes for Professionals
639>>> Y.__mro__
(<class '__main__.Y'>, <type 'object'>)
This happens because we explicitly made Y inherit from object when deﬁning it: class Y(object): pass. For class
X which does not inherit from object the __mro__ attribute does not exist, trying to access it results in an
AttributeError.
In order to ensure compatibility between both versions of Python, classes can be deﬁned with object as a base
class:
class mycls(object):
"""I am fully compatible with Python 2/3"""
Alternatively, if the __metaclass__ variable is set to type at global scope, all subsequently deﬁned classes in a given
module are implicitly new-style without needing to explicitly inherit from object:
__metaclass__ = type
class mycls:
"""I am also fully compatible with Python 2/3"""
Section 149.17: Reduce is no longer a built-in
In Python 2, reduce is available either as a built-in function or from the functools package (version 2.6 onwards),
whereas in Python 3 reduce is available only from functools. However the syntax for reduce in both Python2 and
Python3 is the same and is reduce(function_to_reduce, list_to_reduce).
As an example, let us consider reducing a list to a single value by dividing each of the adjacent numbers. Here we
use truediv function from the operator library.
In Python 2.x it is as simple as:
Python 2.x Version ≥ 2.3
>>> my_list = [1, 2, 3, 4, 5]
>>> import operator
>>> reduce(operator.truediv, my_list)
0.008333333333333333
In Python 3.x the example becomes a bit more complicated:
Python 3.x Version ≥ 3.0
>>> my_list = [1, 2, 3, 4, 5]
>>> import operator, functools
>>> functools.reduce(operator.truediv, my_list)
0.008333333333333333
We can also use from functools import reduce to avoid calling reduce with the namespace name.
Section 149.18: Absolute/Relative Imports
In Python 3, PEP 404 changes the way imports work from Python 2. Implicit relative imports are no longer allowed in
packages and from ... import * imports are only allowed in module level code.
To achieve Python 3 behavior in Python 2:
GoalKicker.com – Python® Notes for Professionals
640the absolute imports feature can be enabled with from __future__ import absolute_import
explicit relative imports are encouraged in place of implicit relative imports
For clariﬁcation, in Python 2, a module can import the contents of another module located in the same directory as
follows:
import foo
Notice the location of foo is ambiguous from the import statement alone. This type of implicit relative import is
thus discouraged in favor of explicit relative imports, which look like the following:
from .moduleY import spam
from .moduleY import spam as ham
from . import moduleY
from ..subpackage1 import moduleY
from ..subpackage2.moduleZ import eggs
from ..moduleA import foo
from ...package import bar
from ...sys import path
The dot . allows an explicit declaration of the module location within the directory tree.
More on Relative Imports
Consider some user deﬁned package called shapes. The directory structure is as follows:
shapes
├── __init__.py
|
├── circle.py
|
├── square.py
|
└── triangle.py
circle.py, square.py and triangle.py all import util.py as a module. How will they refer to a module in the
same level?
from . import util # use util.PI, util.sq(x), etc
OR
from .util import * #use PI, sq(x), etc to call functions
The . is used for same-level relative imports.
Now, consider an alternate layout of the shapes module:
shapes
├── __init__.py
|
├── circle
│├── __init__.py
│
|└── circle.py
GoalKicker.com – Python® Notes for Professionals
641├── square
│
├── __init__.py
│ └── square.py
|
├── triangle
│
├── __init__.py
│ ├── triangle.py
|
└── util.py
Now, how will these 3 classes refer to util.py?
from .. import util # use util.PI, util.sq(x), etc
OR
from ..util import * # use PI, sq(x), etc to call functions
The .. is used for parent-level relative imports. Add more .s with number of levels between the parent and child.
Section 149.19: map()
map() is a builtin that is useful for applying a function to elements of an iterable. In Python 2, map returns a list. In
Python 3, map returns a map object, which is a generator.
# Python 2.X
>>> map(str, [1, 2, 3, 4, 5])
['1', '2', '3', '4', '5']
>>> type(_)
>>> <class 'list'>
# Python 3.X
>>> map(str, [1, 2, 3, 4, 5])
<map object at 0x*>
>>> type(_)
<class 'map'>
# We need to apply map again because we "consumed" the previous map....
>>> map(str, [1, 2, 3, 4, 5])
>>> list(_)
['1', '2', '3', '4', '5']
In Python 2, you can pass None to serve as an identity function. This no longer works in Python 3.
Python 2.x Version ≥ 2.3
>>> map(None, [0, 1, 2, 3, 0, 4])
[0, 1, 2, 3, 0, 4]
Python 3.x Version ≥ 3.0
>>> list(map(None, [0, 1, 2, 3, 0, 5]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
Moreover, when passing more than one iterable as argument in Python 2, map pads the shorter iterables with None
(similar to itertools.izip_longest). In Python 3, iteration stops after the shortest iterable.
GoalKicker.com – Python® Notes for Professionals
642In Python 2:
Python 2.x Version ≥ 2.3
>>> map(None, [1, 2, 3], [1, 2], [1, 2, 3, 4, 5])
[(1, 1, 1), (2, 2, 2), (3, None, 3), (None, None, 4), (None, None, 5)]
In Python 3:
Python 3.x Version ≥ 3.0
>>> list(map(lambda x, y, z: (x, y, z), [1, 2, 3], [1, 2], [1, 2, 3, 4, 5]))
[(1, 1, 1), (2, 2, 2)]
# to obtain the same padding as in Python 2 use zip_longest from itertools
>>> import itertools
>>> list(itertools.zip_longest([1, 2, 3], [1, 2], [1, 2, 3, 4, 5]))
[(1, 1, 1), (2, 2, 2), (3, None, 3), (None, None, 4), (None, None, 5)]
Note: instead of map consider using list comprehensions, which are Python 2/3 compatible. Replacing map(str, [1,
2, 3, 4, 5]):
>>> [str(i) for i in [1, 2, 3, 4, 5]]
['1', '2', '3', '4', '5']
Section 149.20: The round() function tie-breaking and return
type
round() tie breaking
In Python 2, using round() on a number equally close to two integers will return the one furthest from 0. For
example:
Python 2.x Version ≤ 2.7
round(1.5) # Out: 2.0
round(0.5) # Out: 1.0
round(-0.5) # Out: -1.0
round(-1.5) # Out: -2.0
In Python 3 however, round() will return the even integer (aka bankers' rounding). For example:
Python 3.x Version ≥ 3.0
round(1.5) # Out: 2
round(0.5) # Out: 0
round(-0.5) # Out: 0
round(-1.5) # Out: -2
The round() function follows the half to even rounding strategy that will round half-way numbers to the nearest even
integer (for example, round(2.5) now returns 2 rather than 3.0).
As per reference in Wikipedia, this is also known as unbiased rounding, convergent rounding, statistician's rounding,
Dutch rounding, Gaussian rounding, or odd-even rounding.
Half to even rounding is part of the IEEE 754 standard and it's also the default rounding mode in Microsoft's .NET.
This rounding strategy tends to reduce the total rounding error. Since on average the amount of numbers that are
rounded up is the same as the amount of numbers that are rounded down, rounding errors cancel out. Other
GoalKicker.com – Python® Notes for Professionals
643rounding methods instead tend to have an upwards or downwards bias in the average error.
round() return type
The round() function returns a float type in Python 2.7
Python 2.x Version ≤ 2.7
round(4.8)
# 5.0
Starting from Python 3.0, if the second argument (number of digits) is omitted, it returns an int.
Python 3.x Version ≥ 3.0
round(4.8)
# 5
Section 149.21: File I/O
file is no longer a builtin name in 3.x (open still works).
Internal details of ﬁle I/O have been moved to the standard library io module, which is also the new home of
StringIO:
import io
assert io.open is open # the builtin is an alias
buffer = io.StringIO()
buffer.write('hello, ') # returns number of characters written
buffer.write('world!\n')
buffer.getvalue() # 'hello, world!\n'
The ﬁle mode (text vs binary) now determines the type of data produced by reading a ﬁle (and type required for
writing):
with open('data.txt') as f:
first_line = next(f)
assert type(first_line) is str
with open('data.bin', 'rb') as f:
first_kb = f.read(1024)
assert type(first_kb) is bytes
The encoding for text ﬁles defaults to whatever is returned by locale.getpreferredencoding(False). To specify
an encoding explicitly, use the encoding keyword parameter:
with open('old_japanese_poetry.txt', 'shift_jis') as text:
haiku = text.read()
Section 149.22: cmp function removed in Python 3
In Python 3 the cmp built-in function was removed, together with the __cmp__ special method.
From the documentation:
The cmp() function should be treated as gone, and the __cmp__() special method is no longer supported.
GoalKicker.com – Python® Notes for Professionals
644Use __lt__() for sorting, __eq__() with __hash__(), and other rich comparisons as needed. (If you really
need the cmp() functionality, you could use the expression (a > b) - (a < b) as the equivalent for
cmp(a, b).)
Moreover all built-in functions that accepted the cmp parameter now only accept the key keyword only parameter.
In the functools module there is also useful function cmp_to_key(func) that allows you to convert from a cmp-style
function to a key-style function:
Transform an old-style comparison function to a key function. Used with tools that accept key functions
(such as sorted(), min(), max(), heapq.nlargest(), heapq.nsmallest(), itertools.groupby()). This
function is primarily used as a transition tool for programs being converted from Python 2 which
supported the use of comparison functions.
Section 149.23: Octal Constants
In Python 2, an octal literal could be deﬁned as
>>> 0755 # only Python 2
To ensure cross-compatibility, use
0o755 # both Python 2 and Python 3
Section 149.24: Return value when writing to a ﬁle object
In Python 2, writing directly to a ﬁle handle returns None:
Python 2.x Version ≥ 2.3
hi = sys.stdout.write('hello world\\n')
# Out: hello world
type(hi)
# Out: <type 'NoneType'>
In Python 3, writing to a handle will return the number of characters written when writing text, and the number of
bytes written when writing bytes:
Python 3.x Version ≥ 3.0
import sys
char_count = sys.stdout.write('hello world ?\\n')
# Out: hello world ?
char_count
# Out: 14
byte_count = sys.stdout.buffer.write(b'hello world \\xf0\\x9f\\x90\\x8d\\n')
# Out: hello world ?
byte_count
# Out: 17
Section 149.25: exec statement is a function in Python 3
In Python 2, exec is a statement, with special syntax: exec code [in globals[, locals]]. In Python 3 exec is now
GoalKicker.com – Python® Notes for Professionals
645a function: exec(code, [, globals[, locals]]), and the Python 2 syntax will raise a SyntaxError.
As print was changed from statement into a function, a __future__ import was also added. However, there is no
from __future__ import exec_function, as it is not needed: the exec statement in Python 2 can be also used with
syntax that looks exactly like the exec function invocation in Python 3. Thus you can change the statements
Python 2.x Version ≥ 2.3
exec 'code'
exec 'code' in global_vars
exec 'code' in global_vars, local_vars
to forms
Python 3.x Version ≥ 3.0
exec('code')
exec('code', global_vars)
exec('code', global_vars, local_vars)
and the latter forms are guaranteed to work identically in both Python 2 and Python 3.
Section 149.26: encode/decode to hex no longer available
Python 2.x Version ≤ 2.7
"1deadbeef3".decode('hex')
# Out: '\x1d\xea\xdb\xee\xf3'
'\x1d\xea\xdb\xee\xf3'.encode('hex')
# Out: 1deadbeef3
Python 3.x Version ≥ 3.0
"1deadbeef3".decode('hex')
# Traceback (most recent call last):
#
File "<stdin>", line 1, in <module>
# AttributeError: 'str' object has no attribute 'decode'
b"1deadbeef3".decode('hex')
# Traceback (most recent call last):
#
File "<stdin>", line 1, in <module>
# LookupError: 'hex' is not a text encoding; use codecs.decode() to handle arbitrary codecs
'\x1d\xea\xdb\xee\xf3'.encode('hex')
# Traceback (most recent call last):
#
File "<stdin>", line 1, in <module>
# LookupError: 'hex' is not a text encoding; use codecs.encode() to handle arbitrary codecs
b'\x1d\xea\xdb\xee\xf3'.encode('hex')
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# AttributeError: 'bytes' object has no attribute 'encode'
However, as suggested by the error message, you can use the codecs module to achieve the same result:
import codecs
codecs.decode('1deadbeef4', 'hex')
# Out: b'\x1d\xea\xdb\xee\xf4'
codecs.encode(b'\x1d\xea\xdb\xee\xf4', 'hex')
# Out: b'1deadbeef4'
Note that codecs.encode returns a bytes object. To obtain a str object just decode to ASCII:
GoalKicker.com – Python® Notes for Professionals
646codecs.encode(b'\x1d\xea\xdb\xee\xff', 'hex').decode('ascii')
# Out: '1deadbeeff'
Section 149.27: Dictionary method changes
In Python 3, many of the dictionary methods are quite diﬀerent in behaviour from Python 2, and many were
removed as well: has_key, iter* and view* are gone. Instead of d.has_key(key), which had been long deprecated,
one must now use key in d.
In Python 2, dictionary methods keys, values and items return lists. In Python 3 they return view objects instead;
the view objects are not iterators, and they diﬀer from them in two ways, namely:
they have size (one can use the len function on them)
they can be iterated over many times
Additionally, like with iterators, the changes in the dictionary are reﬂected in the view objects.
Python 2.7 has backported these methods from Python 3; they're available as viewkeys, viewvalues and
viewitems. To transform Python 2 code to Python 3 code, the corresponding forms are:
d.keys(), d.values() and d.items() of Python 2 should be changed to list(d.keys()), list(d.values())
and list(d.items())
d.iterkeys(), d.itervalues() and d.iteritems() should be changed to iter(d.keys()), or even better,
iter(d); iter(d.values()) and iter(d.items()) respectively
and ﬁnally Python 2.7 method calls d.viewkeys(), d.viewvalues() and d.viewitems() can be replaced with
d.keys(), d.values() and d.items().
Porting Python 2 code that iterates over dictionary keys, values or items while mutating it is sometimes tricky.
Consider:
d = {'a': 0, 'b': 1, 'c': 2, '!': 3}
for key in d.keys():
if key.isalpha():
del d[key]
The code looks as if it would work similarly in Python 3, but there the keys method returns a view object, not a list,
and if the dictionary changes size while being iterated over, the Python 3 code will crash with RuntimeError:
dictionary changed size during iteration. The solution is of course to properly write for key in list(d).
Similarly, view objects behave diﬀerently from iterators: one cannot use next() on them, and one cannot resume
iteration; it would instead restart; if Python 2 code passes the return value of d.iterkeys(), d.itervalues() or
d.iteritems() to a method that expects an iterator instead of an iterable, then that should be iter(d),
iter(d.values()) or iter(d.items()) in Python 3.
Section 149.28: Class Boolean Value
Python 2.x Version ≤ 2.7
In Python 2, if you want to deﬁne a class boolean value by yourself, you need to implement the __nonzero__
method on your class. The value is True by default.
class MyClass:
def __nonzero__(self):
return False
GoalKicker.com – Python® Notes for Professionals
647my_instance = MyClass()
print bool(MyClass)
print bool(my_instance)
# True
# False
Python 3.x Version ≥ 3.0
In Python 3, __bool__ is used instead of __nonzero__
class MyClass:
def __bool__(self):
return False
my_instance = MyClass()
print(bool(MyClass))
print(bool(my_instance))
# True
# False
Section 149.29: hasattr function bug in Python 2
In Python 2, when a property raise an error, hasattr will ignore this property, returning False.
class A(object):
@property
def get(self):
raise IOError
class B(object):
@property
def get(self):
return 'get in b'
a = A()
b = B()
print 'a hasattr get: ', hasattr(a, 'get')
# output False in Python 2 (fixed, True in Python 3)
print 'b hasattr get', hasattr(b, 'get')
# output True in Python 2 and Python 3
This bug is ﬁxed in Python3. So if you use Python 2, use
try:
a.get
except AttributeError:
print("no get property!")
or use getattr instead
p = getattr(a, "get", None)
if p is not None:
print(p)
else:
print("no get property!")
GoalKicker.com – Python® Notes for Professionals
648VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 150: 2to3 tool
Parameter
ﬁlename / directory_name
Description
2to3 accepts a list of ﬁles or directories which is to be transformed as its
argument. The directories are recursively traversed for Python sources.
OptionOption Description
-f FIX, --ﬁx=FIXSpecify transformations to be applied; default: all. List available
transformations with --list-fixes
-j PROCESSES, --processes=PROCESSESRun 2to3 concurrently
-x NOFIX, --noﬁx=NOFIXExclude a transformation
-l, --list-ﬁxesList available transformations
-p, --print-functionChange the grammar so that print() is considered a function
-v, --verboseMore verbose output
--no-diﬀsDo not output diﬀs of the refactoring
-wWrite back modiﬁed ﬁles
-n, --nobackupsDo not create backups of modiﬁed ﬁles
-o OUTPUT_DIR, --output-
dir=OUTPUT_DIRPlace output ﬁles in this directory instead of overwriting input ﬁles.
Requires the -n ﬂag, as backup ﬁles are unnecessary when the input
ﬁles are not modiﬁed.
-W, --write-unchanged-ﬁlesWrite output ﬁles even is no changes were required. Useful with -o so
that a complete source tree is translated and copied. Implies -w.
--add-suﬃx=ADD_SUFFIXSpecify a string to be appended to all output ﬁlenames. Requires -n if
non-empty. Ex.: --add-suffix='3' will generate .py3 ﬁles.
Section 150.1: Basic Usage
Consider the following Python2.x code. Save the ﬁle as example.py
Python 2.x Version ≥ 2.0
def greet(name):
print "Hello, {0}!".format(name)
print "What's your name?"
name = raw_input()
greet(name)
In the above ﬁle, there are several incompatible lines. The raw_input() method has been replaced with input() in
Python 3.x and print is no longer a statement, but a function. This code can be converted to Python 3.x code using
the 2to3 tool.
Unix
$ 2to3 example.py
Windows
> path/to/2to3.py example.py
Running the above code will output the diﬀerences against the original source ﬁle as shown below.
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
GoalKicker.com – Python® Notes for Professionals
650RefactoringTool: Refactored example.py
--- example.py
(original)
+++ example.py
(refactored)
@@ -1,5 +1,5 @@
def greet(name):
-
print "Hello, {0}!".format(name)
-print "What's your name?"
-name = raw_input()
+
print("Hello, {0}!".format(name))
+print("What's your name?")
+name = input()
greet(name)
RefactoringTool: Files that need to be modified:
RefactoringTool: example.py
The modiﬁcations can be written back to the source ﬁle using the -w ﬂag. A backup of the original ﬁle called
example.py.bak is created, unless the -n ﬂag is given.
Unix
$ 2to3 -w example.py
Windows
> path/to/2to3.py -w example.py
Now the example.py ﬁle has been converted from Python 2.x to Python 3.x code.
Once ﬁnished, example.py will contain the following valid Python3.x code:
Python 3.x Version ≥ 3.0
def greet(name):
print("Hello, {0}!".format(name))
print("What's your name?")
name = input()
greet(name)
GoalKicker.com – Python® Notes for Professionals
651Chapter 151: Non-ocial Python
implementations
Section 151.1: IronPython
Open-source implementation for .NET and Mono written in C#, licensed under Apache License 2.0. It relies on DLR
(Dynamic Language Runtime). It supports only version 2.7, version 3 is currently being developed.
Diﬀerences with CPython:
Tight integration with .NET Framework.
Strings are Unicode by default.
Does not support extensions for CPython written in C.
Does not suﬀer from Global Interpreter Lock.
Performance is usually lower, though it depends on tests.
Hello World
print "Hello World!"
You can also use .NET functions:
import clr
from System import Console
Console.WriteLine("Hello World!")
External links
Oﬃcial website
GitHub repository
Section 151.2: Jython
Open-source implementation for JVM written in Java, licensed under Python Software Foundation License. It
supports only version 2.7, version 3 is currently being developed.
Diﬀerences with CPython:
Tight integration with JVM.
Strings are Unicode.
Does not support extensions for CPython written in C.
Does not suﬀer from Global Interpreter Lock.
Performance is usually lower, though it depends on tests.
Hello World
print "Hello World!"
You can also use Java functions:
from java.lang import System
System.out.println("Hello World!")
External links
Oﬃcial website
Mercurial repository
GoalKicker.com – Python® Notes for Professionals
652Section 151.3: Transcrypt
Transcrypt is a tool to precompile a fairly extensive subset of Python into compact, readable Javascript. It has the
following characteristics:
Allows for classical OO programming with multiple inheritance using pure Python syntax, parsed by
CPython’s native parser
Seamless integration with the universe of high-quality web-oriented JavaScript libraries, rather than the
desktop-oriented Python ones
Hierarchical URL based module system allowing module distribution via PyPi
Simple relation between Python source and generated JavaScript code for easy debugging
Multi-level sourcemaps and optional annotation of target code with source references
Compact downloads, kB’s rather than MB’s
Optimized JavaScript code, using memoization (call caching) to optionally bypass the prototype lookup chain
Operator overloading can be switched on and oﬀ locally to facilitate readable numerical math
Code size and speed
Experience has shown that 650 kB of Python sourcecode roughly translates in the same amount of JavaScript
source code. The speed matches the speed of handwritten JavaScript and can surpass it if call memoizing is
switched on.
Integration with HTML
<script src="__javascript__/hello.js"></script>
<h2>Hello demo</h2>
<p>
<div id = "greet">...</div>
<button onclick="hello.solarSystem.greet ()">Click me repeatedly!</button>
<p>
<div id = "explain">...</div>
<button onclick="hello.solarSystem.explain ()">And click me repeatedly too!</button>
Integration with JavaScript and DOM
from itertools import chain
class SolarSystem:
planets = [list (chain (planet, (index + 1,))) for index, planet in enumerate ((
('Mercury', 'hot', 2240),
('Venus', 'sulphurous', 6052),
('Earth', 'fertile', 6378),
('Mars', 'reddish', 3397),
('Jupiter', 'stormy', 71492),
('Saturn', 'ringed', 60268),
('Uranus', 'cold', 25559),
('Neptune', 'very cold', 24766)
))]
lines = (
'{} is a {} planet',
'The radius of {} is {} km',
'{} is planet nr. {} counting from the sun'
)
def __init__ (self):
self.lineIndex = 0
GoalKicker.com – Python® Notes for Professionals
653def greet (self):
self.planet = self.planets [int (Math.random () * len (self.planets))]
document.getElementById ('greet') .innerHTML = 'Hello {}'.format (self.planet [0])
self.explain ()
def explain (self):
document.getElementById ('explain').innerHTML = (
self.lines [self.lineIndex] .format (self.planet [0], self.planet [self.lineIndex + 1])
)
self.lineIndex = (self.lineIndex + 1) % 3
solarSystem = SolarSystem ()
Integration with other JavaScript libraries
Transcrypt can be used in combination with any JavaScript library without special measures or syntax. In the
documentation examples are given for a.o. react.js, riot.js, fabric.js and node.js.
Relation between Python and JavaScript code
Python
class A:
def __init__ (self, x):
self.x = x
def show (self, label):
print ('A.show', label, self.x)
class B:
def __init__ (self, y):
alert ('In B constructor')
self.y = y
def show (self, label):
print ('B.show', label, self.y)
class C (A, B):
def __init__ (self, x, y):
alert ('In C constructor')
A.__init__ (self, x)
B.__init__ (self, y)
self.show ('constructor')
def show (self, label):
B.show (self, label)
print ('C.show', label, self.x, self.y)
a = A (1001)
a.show ('america')
b = B (2002)
b.show ('russia')
c = C (3003, 4004)
c.show ('netherlands')
show2 = c.show
show2 ('copy')
JavaScript
GoalKicker.com – Python® Notes for Professionals
654var A = __class__ ('A', [object], {
get __init__ () {return __get__ (this, function (self, x) {
self.x = x;
});},
get show () {return __get__ (this, function (self, label) {
print ('A.show', label, self.x);
});}
});
var B = __class__ ('B', [object], {
get __init__ () {return __get__ (this, function (self, y) {
alert ('In B constructor');
self.y = y;
});},
get show () {return __get__ (this, function (self, label) {
print ('B.show', label, self.y);
});}
});
var C = __class__ ('C', [A, B], {
get __init__ () {return __get__ (this, function (self, x, y) {
alert ('In C constructor');
A.__init__ (self, x);
B.__init__ (self, y);
self.show ('constructor');
});},
get show () {return __get__ (this, function (self, label) {
B.show (self, label);
print ('C.show', label, self.x, self.y);
});}
});
var a = A (1001);
a.show ('america');
var b = B (2002);
b.show ('russia');
var c = C (3003, 4004);
c.show ('netherlands');
var show2 = c.show;
show2 ('copy');
External links
Oﬃcial website: http://www.transcrypt.org/
Repository: https://github.com/JdeH/Transcrypt
GoalKicker.com – Python® Notes for Professionals
655Chapter 152: Abstract syntax tree
Section 152.1: Analyze functions in a python script
This analyzes a python script and, for each deﬁned function, reports the line number where the function began,
where the signature ends, where the docstring ends, and where the function deﬁnition ends.
#!/usr/local/bin/python3
import ast
import sys
""" The data we collect. Each key is a function name; each value is a dict
with keys: firstline, sigend, docend, and lastline and values of line numbers
where that happens. """
functions = {}
def process(functions):
""" Handle the function data stored in functions. """
for funcname,data in functions.items():
print("function:",funcname)
print("\tstarts at line:",data['firstline'])
print("\tsignature ends at line:",data['sigend'])
if ( data['sigend'] < data['docend'] ):
print("\tdocstring ends at line:",data['docend'])
else:
print("\tno docstring")
print("\tfunction ends at line:",data['lastline'])
print()
class FuncLister(ast.NodeVisitor):
def visit_FunctionDef(self, node):
""" Recursively visit all functions, determining where each function
starts, where its signature ends, where the docstring ends, and where
the function ends. """
functions[node.name] = {'firstline':node.lineno}
sigend = max(node.lineno,lastline(node.args))
functions[node.name]['sigend'] = sigend
docstring = ast.get_docstring(node)
docstringlength = len(docstring.split('\n')) if docstring else -1
functions[node.name]['docend'] = sigend+docstringlength
functions[node.name]['lastline'] = lastline(node)
self.generic_visit(node)
def lastline(node):
""" Recursively find the last line of a node """
return max( [ node.lineno if hasattr(node,'lineno') else -1 , ]
+[lastline(child) for child in ast.iter_child_nodes(node)] )
def readin(pythonfilename):
""" Read the file name and store the function data into functions. """
with open(pythonfilename) as f:
code = f.read()
FuncLister().visit(ast.parse(code))
def analyze(file,process):
""" Read the file and process the function data. """
readin(file)
process(functions)
GoalKicker.com – Python® Notes for Professionals
656if __name__ == '__main__':
if len(sys.argv)>1:
for file in sys.argv[1:]:
analyze(file,process)
else:
analyze(sys.argv[0],process)
GoalKicker.com – Python® Notes for Professionals
657Chapter 153: Unicode and bytes
Parameter
Details
encoding The encoding to use, e.g. 'ascii', 'utf8', etc...
errors
The errors mode, e.g. 'replace' to replace bad characters with question marks, 'ignore' to ignore
bad characters, etc...
Section 153.1: Encoding/decoding error handling
.encode and .decode both have error modes.
The default is 'strict', which raises exceptions on error. Other modes are more forgiving.
Encoding
>>> "£13.55".encode('ascii', errors='replace')
b'?13.55'
>>> "£13.55".encode('ascii', errors='ignore')
b'13.55'
>>> "£13.55".encode('ascii', errors='namereplace')
b'\\N{POUND SIGN}13.55'
>>> "£13.55".encode('ascii', errors='xmlcharrefreplace')
b'&#163;13.55'
>>> "£13.55".encode('ascii', errors='backslashreplace')
b'\\xa313.55'
Decoding
>>> b = "£13.55".encode('utf8')
>>> b.decode('ascii', errors='replace')
'��13.55'
>>> b.decode('ascii', errors='ignore')
'13.55'
>>> b.decode('ascii', errors='backslashreplace')
'\\xc2\\xa313.55'
Morale
It is clear from the above that it is vital to keep your encodings straight when dealing with unicode and bytes.
Section 153.2: File I/O
Files opened in a non-binary mode (e.g. 'r' or 'w') deal with strings. The default encoding is 'utf8'.
open(fn, mode='r')
open(fn, mode='r', encoding='utf16')
# opens file for reading in utf8
# opens file for reading utf16
# ERROR: cannot write bytes when a string is expected:
open("foo.txt", "w").write(b"foo")
Files opened in a binary mode (e.g. 'rb' or 'wb') deal with bytes. No encoding argument can be speciﬁed as there
is no encoding.
open(fn, mode='wb')
# open file for writing bytes
# ERROR: cannot write string when bytes is expected:
open(fn, mode='wb').write("hi")
GoalKicker.com – Python® Notes for Professionals
658Section 153.3: Basics
In Python 3 str is the type for unicode-enabled strings, while bytes is the type for sequences of raw bytes.
type("f") == type(u"f")
type(b"f")
# True, <class 'str'>
# <class 'bytes'>
In Python 2 a casual string was a sequence of raw bytes by default and the unicode string was every string with "u"
preﬁx.
type("f") == type(b"f")
type(u"f")
# True, <type 'str'>
# <type 'unicode'>
Unicode to bytes
Unicode strings can be converted to bytes with .encode(encoding).
Python 3
>>> "£13.55".encode('utf8')
b'\xc2\xa313.55'
>>> "£13.55".encode('utf16')
b'\xff\xfe\xa3\x001\x003\x00.\x005\x005\x00'
Python 2
in py2 the default console encoding is sys.getdefaultencoding() == 'ascii' and not utf-8 as in py3, therefore
printing it as in the previous example is not directly possible.
>>> print type(u"£13.55".encode('utf8'))
<type 'str'>
>>> print u"£13.55".encode('utf8')
SyntaxError: Non-ASCII character '\xc2' in...
# with encoding set inside a file
# -*- coding: utf-8 -*-
>>> print u"£13.55".encode('utf8')
┬ú13.55
If the encoding can't handle the string, a `UnicodeEncodeError` is raised:
>>> "£13.55".encode('ascii')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character '\xa3' in position 0: ordinal not in
range(128)
Bytes to unicode
Bytes can be converted to unicode strings with .decode(encoding).
A sequence of bytes can only be converted into a unicode string via the appropriate encoding!
>>> b'\xc2\xa313.55'.decode('utf8')
GoalKicker.com – Python® Notes for Professionals
659'£13.55'
If the encoding can't handle the string, a UnicodeDecodeError is raised:
>>> b'\xc2\xa313.55'.decode('utf16')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/csaftoiu/csaftoiu-github/yahoo-groups-
backup/.virtualenv/bin/../lib/python3.5/encodings/utf_16.py", line 16, in decode
return codecs.utf_16_decode(input, errors, True)
UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x35 in position 6: truncated data
GoalKicker.com – Python® Notes for Professionals
660Chapter 154: Python Serial Communication
(pyserial)
parameter
details
port
Device name e.g. /dev/ttyUSB0 on GNU/Linux or COM3 on Windows.
baudrate
baudrate type: int default: 9600 standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
4800, 9600, 19200, 38400, 57600, 115200
Section 154.1: Initialize serial device
import serial
#Serial takes these two parameters: serial device and baudrate
ser = serial.Serial('/dev/ttyUSB0', 9600)
Section 154.2: Read from serial port
Initialize serial device
import serial
#Serial takes two parameters: serial device and baudrate
ser = serial.Serial('/dev/ttyUSB0', 9600)
to read single byte from serial device
data = ser.read()
to read given number of bytes from the serial device
data = ser.read(size=5)
to read one line from serial device.
data = ser.readline()
to read the data from serial device while something is being written over it.
#for python2.7
data = ser.read(ser.inWaiting())
#for python3
ser.read(ser.inWaiting)
Section 154.3: Check what serial ports are available on your
machine
To get a list of available serial ports use
python -m serial.tools.list_ports
at a command prompt or
from serial.tools import list_ports
GoalKicker.com – Python® Notes for Professionals
661list_ports.comports()
# Outputs list of available serial ports
from the Python shell.
GoalKicker.com – Python® Notes for Professionals
662VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 155: Neo4j and Cypher using
Py2Neo
Section 155.1: Adding Nodes to Neo4j Graph
results = News.objects.todays_news()
for r in results:
article = graph.merge_one("NewsArticle", "news_id", r)
article.properties["title"] = results[r]['news_title']
article.properties["timestamp"] = results[r]['news_timestamp']
article.push()
[...]
Adding nodes to the graph is pretty simple,graph.merge_one is important as it prevents duplicate items. (If you run
the script twice, then the second time it would update the title and not create new nodes for the same articles)
timestamp should be an integer and not a date string as neo4j doesn't really have a date datatype. This causes
sorting issues when you store date as '05-06-1989'
article.push() is an the call that actually commits the operation into neo4j. Don't forget this step.
Section 155.2: Importing and Authenticating
from py2neo import authenticate, Graph, Node, Relationship
authenticate("localhost:7474", "neo4j", "<pass>")
graph = Graph()
You have to make sure your Neo4j Database exists at localhost:7474 with the appropriate credentials.
the graph object is your interface to the neo4j instance in the rest of your python code. Rather than making this a
global variable, you should keep it in a class's __init__ method.
Section 155.3: Adding Relationships to Neo4j Graph
results = News.objects.todays_news()
for r in results:
article = graph.merge_one("NewsArticle", "news_id", r)
if 'LOCATION' in results[r].keys():
for loc in results[r]['LOCATION']:
loc = graph.merge_one("Location", "name", loc)
try:
rel = graph.create_unique(Relationship(article, "about_place", loc))
except Exception, e:
print e
create_unique is important for avoiding duplicates. But otherwise it's a pretty straightforward operation. The
relationship name is also important as you would use it in advanced cases.
Section 155.4: Query 1 : Autocomplete on News Titles
def get_autocomplete(text):
query = """
start n = node(*) where n.name =~ '(?i)%s.*' return n.name,labels(n) limit 10;
"""
GoalKicker.com – Python® Notes for Professionals
664query = query % (text)
obj = []
for res in graph.cypher.execute(query):
# print res[0],res[1]
obj.append({'name':res[0],'entity_type':res[1]})
return res
This is a sample cypher query to get all nodes with the property name that starts with the argument text.
Section 155.5: Query 2 : Get News Articles by Location on a
particular date
def search_news_by_entity(location,timestamp):
query = """
MATCH (n)-[]->(l)
where l.name='%s' and n.timestamp='%s'
RETURN n.news_id limit 10
"""
query = query % (location,timestamp)
news_ids = []
for res in graph.cypher.execute(query):
news_ids.append(str(res[0]))
return news_ids
You can use this query to ﬁnd all news articles (n) connected to a location (l) by a relationship.
Section 155.6: Cypher Query Samples
Count articles connected to a particular person over time
MATCH (n)-[]->(l)
where l.name='Donald Trump'
RETURN n.date,count(*) order by n.date
Search for other People / Locations connected to the same news articles as Trump with at least 5 total relationship
nodes.
MATCH (n:NewsArticle)-[]->(l)
where l.name='Donald Trump'
MATCH (n:NewsArticle)-[]->(m)
with m,count(n) as num where num>5
return labels(m)[0],(m.name), num order by num desc limit 10
GoalKicker.com – Python® Notes for Professionals
665Chapter 156: Basic Curses with Python
Section 156.1: The wrapper() helper function
While the basic invocation above is easy enough, the curses package provides the wrapper(func, ...) helper
function. The example below contains the equivalent of above:
main(scr, *args):
# -- Perform an action with Screen --
scr.border(0)
scr.addstr(5, 5, 'Hello from Curses!', curses.A_BOLD)
scr.addstr(6, 5, 'Press q to close this screen', curses.A_NORMAL)
while True:
# stay in this loop till the user presses 'q'
ch = scr.getch()
if ch == ord('q'):
curses.wrapper(main)
Here, wrapper will initialize curses, create stdscr, a WindowObject and pass both stdscr, and any further
arguments to func. When func returns, wrapper will restore the terminal before the program exits.
Section 156.2: Basic Invocation Example
import curses
import traceback
try:
# -- Initialize --
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
# initialize curses screen
# turn off auto echoing of keypress on to screen
# enter break mode where pressing Enter key
# after keystroke is not required for it to register
# enable special Key values such as curses.KEY_LEFT etc
# -- Perform an action with Screen --
stdscr.border(0)
stdscr.addstr(5, 5, 'Hello from Curses!', curses.A_BOLD)
stdscr.addstr(6, 5, 'Press q to close this screen', curses.A_NORMAL)
while True:
# stay in this loop till the user presses 'q'
ch = stdscr.getch()
if ch == ord('q'):
break
# -- End of user code --
except:
traceback.print_exc()
# print trace back log of the error
finally:
# --- Cleanup on exit ---
stdscr.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
GoalKicker.com – Python® Notes for Professionals
666Chapter 157: Templates in python
Section 157.1: Simple data output program using template
from string import Template
data = dict(item = "candy", price = 8, qty = 2)
# define the template
t = Template("Simon bought $qty $item for $price dollar")
print(t.substitute(data))
Output:
Simon bought 2 candy for 8 dollar
Templates support $-based substitutions instead of %-based substitution. Substitute (mapping, keywords)
performs template substitution, returning a new string.
Mapping is any dictionary-like object with keys that match with the template placeholders. In this example, price
and qty are placeholders. Keyword arguments can also be used as placeholders. Placeholders from keywords take
precedence if both are present.
Section 157.2: Changing delimiter
You can change the "$" delimiter to any other. The following example:
from string import Template
class MyOtherTemplate(Template):
delimiter = "#"
data = dict(id = 1, name = "Ricardo")
t = MyOtherTemplate("My name is #name and I have the id: #id")
print(t.substitute(data))
You can read de docs here
GoalKicker.com – Python® Notes for Professionals
667Chapter 158: Pillow
Section 158.1: Read Image File
from PIL import Image
im = Image.open("Image.bmp")
Section 158.2: Convert ﬁles to JPEG
from __future__ import print_function
import os, sys
from PIL import Image
for infile in sys.argv[1:]:
f, e = os.path.splitext(infile)
outfile = f + ".jpg"
if infile != outfile:
try:
Image.open(infile).save(outfile)
except IOError:
print("cannot convert", infile)
GoalKicker.com – Python® Notes for Professionals
668Chapter 159: The pass statement
Section 159.1: Ignore an exception
try:
metadata = metadata['properties']
except KeyError:
pass
Section 159.2: Create a new Exception that can be caught
class CompileError(Exception):
pass
GoalKicker.com – Python® Notes for Professionals
669VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 160: CLI subcommands with
precise help output
Diﬀerent ways to create subcommands like in hg or svn with the exact command line interface and help output as
shown in Remarks section.
Parsing Command Line arguments covers broader topic of arguments parsing.
Section 160.1: Native way (no libraries)
"""
usage: sub <command>
commands:
status -
list
-
"""
show status
print list
import sys
def check():
print("status")
return 0
if sys.argv[1:] == ['status']:
sys.exit(check())
elif sys.argv[1:] == ['list']:
print("list")
else:
print(__doc__.strip())
Output without arguments:
usage: sub
commands:
status - show status
list - print list
Pros:
no deps
everybody should be able to read that
complete control over help formatting
Section 160.2: argparse (default help formatter)
import argparse
import sys
def check():
print("status")
return 0
GoalKicker.com – Python® Notes for Professionals
671parser = argparse.ArgumentParser(prog="sub", add_help=False)
subparser = parser.add_subparsers(dest="cmd")
subparser.add_parser('status', help='show status')
subparser.add_parser('list', help='print list')
# hack to show help when no arguments supplied
if len(sys.argv) == 1:
parser.print_help()
sys.exit(0)
args = parser.parse_args()
if args.cmd == 'list':
print('list')
elif args.cmd == 'status':
sys.exit(check())
Output without arguments:
usage: sub {status,list} ...
positional arguments:
{status,list}
status
show status
list
print list
Pros:
comes with Python
option parsing is included
Section 160.3: argparse (custom help formatter)
import argparse
import sys
class CustomHelpFormatter(argparse.HelpFormatter):
def _format_action(self, action):
if type(action) == argparse._SubParsersAction:
# inject new class variable for subcommand formatting
subactions = action._get_subactions()
invocations = [self._format_action_invocation(a) for a in subactions]
self._subcommand_max_length = max(len(i) for i in invocations)
if type(action) == argparse._SubParsersAction._ChoicesPseudoAction:
# format subcommand help line
subcommand = self._format_action_invocation(action) # type: str
width = self._subcommand_max_length
help_text = ""
if action.help:
help_text = self._expand_help(action)
return " {:{width}} - {}\n".format(subcommand, help_text, width=width)
elif type(action) == argparse._SubParsersAction:
# process subcommand help section
msg = '\n'
for subaction in action._get_subactions():
msg += self._format_action(subaction)
return msg
GoalKicker.com – Python® Notes for Professionals
672else:
return super(CustomHelpFormatter, self)._format_action(action)
def check():
print("status")
return 0
parser = argparse.ArgumentParser(usage="sub <command>", add_help=False,
formatter_class=CustomHelpFormatter)
subparser = parser.add_subparsers(dest="cmd")
subparser.add_parser('status', help='show status')
subparser.add_parser('list', help='print list')
# custom help message
parser._positionals.title = "commands"
# hack to show help when no arguments supplied
if len(sys.argv) == 1:
parser.print_help()
sys.exit(0)
args = parser.parse_args()
if args.cmd == 'list':
print('list')
elif args.cmd == 'status':
sys.exit(check())
Output without arguments:
usage: sub <command>
commands:
status -
list
-
show status
print list
GoalKicker.com – Python® Notes for Professionals
673Chapter 161: Database Access
Section 161.1: SQLite
SQLite is a lightweight, disk-based database. Since it does not require a separate database server, it is often used
for prototyping or for small applications that are often used by a single user or by one user at a given time.
import sqlite3
conn = sqlite3.connect("users.db")
c = conn.cursor()
c.execute("CREATE TABLE user (name text, age integer)")
c.execute("INSERT INTO user VALUES ('User A', 42)")
c.execute("INSERT INTO user VALUES ('User B', 43)")
conn.commit()
c.execute("SELECT * FROM user")
print(c.fetchall())
conn.close()
The code above connects to the database stored in the ﬁle named users.db, creating the ﬁle ﬁrst if it doesn't
already exist. You can interact with the database via SQL statements.
The result of this example should be:
[(u'User A', 42), (u'User B', 43)]
The SQLite Syntax: An in-depth analysis
Getting started
1. Import the sqlite module using
>>> import sqlite3
2. To use the module, you must ﬁrst create a Connection object that represents the database. Here the data will
be stored in the example.db ﬁle:
>>> conn = sqlite3.connect('users.db')
Alternatively, you can also supply the special name :memory: to create a temporary database in RAM, as
follows:
>>> conn = sqlite3.connect(':memory:')
3. Once you have a Connection, you can create a Cursor object and call its execute() method to perform SQL
commands:
c = conn.cursor()
GoalKicker.com – Python® Notes for Professionals
674# Create table
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')
# Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
# Save (commit) the changes
conn.commit()
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
Important Attributes and Functions of Connection
1. isolation_level
It is an attribute used to get or set the current isolation level. None for autocommit mode or one of DEFERRED,
IMMEDIATE or EXCLUSIVE.
2. cursor
The cursor object is used to execute SQL commands and queries.
3. commit()
Commits the current transaction.
4. rollback()
Rolls back any changes made since the previous call to commit()
5. close()
Closes the database connection. It does not call commit() automatically. If close() is called without ﬁrst
calling commit() (assuming you are not in autocommit mode) then all changes made will be lost.
6. total_changes
An attribute that logs the total number of rows modiﬁed, deleted or inserted since the database was opened.
7. execute, executemany, and executescript
These functions perform the same way as those of the cursor object. This is a shortcut since calling these
functions through the connection object results in the creation of an intermediate cursor object and calls the
corresponding method of the cursor object
GoalKicker.com – Python® Notes for Professionals
6758. row_factory
You can change this attribute to a callable that accepts the cursor and the original row as a tuple and will
return the real result row.
def dict_factory(cursor, row):
d = {}
for i, col in enumerate(cursor.description):
d[col[0]] = row[i]
return d
conn = sqlite3.connect(":memory:")
conn.row_factory = dict_factory
Important Functions of Cursor
1. execute(sql[, parameters])
Executes a single SQL statement. The SQL statement may be parametrized (i. e. placeholders instead of SQL
literals). The sqlite3 module supports two kinds of placeholders: question marks ? (“qmark style”) and named
placeholders :name (“named style”).
import sqlite3
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
cur.execute("create table people (name, age)")
who = "Sophia"
age = 37
# This IS the qmark STYLE:
cur.execute("insert into people values (?, ?)",
(who, age))
# AND this IS the named STYLE:
cur.execute("select * from people where name=:who and age=:age",
{"who": who, "age": age}) # the KEYS correspond TO the placeholders IN SQL
print(cur.fetchone())
Beware: don't use %s for inserting strings into SQL commands as it can make your program vulnerable to
an SQL injection attack (see SQL Injection ).
2. executemany(sql, seq_of_parameters)
Executes an SQL command against all parameter sequences or mappings found in the sequence sql. The
sqlite3 module also allows using an iterator yielding parameters instead of a sequence.
L = [(1, 'abcd', 'dfj', 300),
# A list OF tuples TO be inserted INTO the DATABASE
(2, 'cfgd', 'dyfj', 400),
(3, 'sdd', 'dfjh', 300.50)]
conn = sqlite3.connect("test1.db")
conn.execute("create table if not exists book (id int, name text, author text, price real)")
conn.executemany("insert into book values (?, ?, ?, ?)", L)
GoalKicker.com – Python® Notes for Professionals
676FOR ROW IN conn.execute("select * from book"):
print(ROW)
You can also pass iterator objects as a parameter to executemany, and the function will iterate over the each
tuple of values that the iterator returns. The iterator must return a tuple of values.
import sqlite3
class IterChars:
def __init__(SELF):
SELF.count = ord('a')
def __iter__(SELF):
RETURN SELF
def __next__(SELF):
# (USE NEXT(SELF) FOR Python 2)
IF SELF.count > ord('z'):
raise StopIteration
SELF.count += 1
RETURN (chr(SELF.count - 1),)
conn = sqlite3.connect("abc.db")
cur = conn.cursor()
cur.execute("create table characters(c)")
theIter = IterChars()
cur.executemany("insert into characters(c) values (?)", theIter)
ROWS = cur.execute("select c from characters")
FOR ROW IN ROWS:
print(ROW[0]),
3. executescript(sql_script)
This is a nonstandard convenience method for executing multiple SQL statements at once. It issues a COMMIT
statement ﬁrst, then executes the SQL script it gets as a parameter.
sql_script can be an instance of str or bytes.
import sqlite3
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
cur.executescript("""
create table person(
firstname,
lastname,
age
);
create table book(
title,
author,
published
);
insert into book(title, author, published)
values (
'Dirk Gently''s Holistic Detective Agency',
'Douglas Adams',
1987
GoalKicker.com – Python® Notes for Professionals
677);
""")
The next set of functions are used in conjunction with SELECT statements in SQL. To retrieve data after
executing a SELECT statement, you can either treat the cursor as an iterator, call the cursor’s fetchone()
method to retrieve a single matching row, or call fetchall() to get a list of the matching rows.
Example of the iterator form:
import sqlite3
stocks = [('2006-01-05', 'BUY', 'RHAT', 100, 35.14),
('2006-03-28', 'BUY', 'IBM', 1000, 45.0),
('2006-04-06', 'SELL', 'IBM', 500, 53.0),
('2006-04-05', 'BUY', 'MSFT', 1000, 72.0)]
conn = sqlite3.connect(":memory:")
conn.execute("create table stocks (date text, buysell text, symb text, amount int, price
real)")
conn.executemany("insert into stocks values (?, ?, ?, ?, ?)", stocks)
cur = conn.cursor()
FOR ROW IN cur.execute('SELECT * FROM stocks ORDER BY price'):
print(ROW)
# Output:
# ('2006-01-05', 'BUY', 'RHAT', 100, 35.14)
# ('2006-03-28', 'BUY', 'IBM', 1000, 45.0)
# ('2006-04-06', 'SELL', 'IBM', 500, 53.0)
# ('2006-04-05', 'BUY', 'MSFT', 1000, 72.0)
4. fetchone()
Fetches the next row of a query result set, returning a single sequence, or None when no more data is
available.
cur.execute('SELECT * FROM stocks ORDER BY price')
i = cur.fetchone()
while(i):
print(i)
i = cur.fetchone()
# Output:
# ('2006-01-05', 'BUY', 'RHAT', 100, 35.14)
# ('2006-03-28', 'BUY', 'IBM', 1000, 45.0)
# ('2006-04-06', 'SELL', 'IBM', 500, 53.0)
# ('2006-04-05', 'BUY', 'MSFT', 1000, 72.0)
5. fetchmany(size=cursor.arraysize)
Fetches the next set of rows of a query result (speciﬁed by size), returning a list. If size is omitted, fetchmany
returns a single row. An empty list is returned when no more rows are available.
cur.execute('SELECT * FROM stocks ORDER BY price')
print(cur.fetchmany(2))
# Output:
# [('2006-01-05', 'BUY', 'RHAT', 100, 35.14), ('2006-03-28', 'BUY', 'IBM', 1000, 45.0)]
GoalKicker.com – Python® Notes for Professionals
6786. fetchall()
Fetches all (remaining) rows of a query result, returning a list.
cur.execute('SELECT * FROM stocks ORDER BY price')
print(cur.fetchall())
# Output:
# [('2006-01-05', 'BUY', 'RHAT', 100, 35.14), ('2006-03-28', 'BUY', 'IBM', 1000, 45.0),
('2006-04-06', 'SELL', 'IBM', 500, 53.0), ('2006-04-05', 'BUY', 'MSFT', 1000, 72.0)]
SQLite and Python data types
SQLite natively supports the following types: NULL, INTEGER, REAL, TEXT, BLOB.
This is how the data types are converted when moving from SQL to Python or vice versa.
None
int
float
str
bytes
<->
<->
<->
<->
<->
NULL
INTEGER/INT
REAL/FLOAT
TEXT/VARCHAR(n)
BLOB
Section 161.2: Accessing MySQL database using MySQLdb
The ﬁrst thing you need to do is create a connection to the database using the connect method. After that, you will
need a cursor that will operate with that connection.
Use the execute method of the cursor to interact with the database, and every once in a while, commit the changes
using the commit method of the connection object.
Once everything is done, don't forget to close the cursor and the connection.
Here is a Dbconnect class with everything you'll need.
import MySQLdb
class Dbconnect(object):
def __init__(self):
self.dbconection = MySQLdb.connect(host='host_example',
port=int('port_example'),
user='user_example',
passwd='pass_example',
db='schema_example')
self.dbcursor = self.dbconection.cursor()
def commit_db(self):
self.dbconection.commit()
def close_db(self):
self.dbcursor.close()
self.dbconection.close()
Interacting with the database is simple. After creating the object, just use the execute method.
GoalKicker.com – Python® Notes for Professionals
679db = Dbconnect()
db.dbcursor.execute('SELECT * FROM %s' % 'table_example')
If you want to call a stored procedure, use the following syntax. Note that the parameters list is optional.
db = Dbconnect()
db.callproc('stored_procedure_name', [parameters] )
After the query is done, you can access the results multiple ways. The cursor object is a generator that can fetch all
the results or be looped.
results = db.dbcursor.fetchall()
for individual_row in results:
first_field = individual_row[0]
If you want a loop using directly the generator:
for individual_row in db.dbcursor:
first_field = individual_row[0]
If you want to commit changes to the database:
db.commit_db()
If you want to close the cursor and the connection:
db.close_db()
Section 161.3: Connection
Creating a connection
According to PEP 249, the connection to a database should be established using a connect() constructor, which
returns a Connection object. The arguments for this constructor are database dependent. Refer to the database
speciﬁc topics for the relevant arguments.
import MyDBAPI
con = MyDBAPI.connect(*database_dependent_args)
This connection object has four methods:
1: close
con.close()
Closes the connection instantly. Note that the connection is automatically closed if the Connection.__del___
method is called. Any pending transactions will implicitly be rolled back.
2: commit
con.commit()
Commits any pending transaction to the database.
GoalKicker.com – Python® Notes for Professionals
6803: rollback
con.rollback()
Rolls back to the start of any pending transaction. In other words: this cancels any non-committed transaction to
the database.
4: cursor
cur = con.cursor()
Returns a Cursor object. This is used to do transactions on the database.
Section 161.4: PostgreSQL Database access using psycopg2
psycopg2 is the most popular PostgreSQL database adapter that is both lightweight and eﬃcient. It is the current
implementation of the PostgreSQL adapter.
Its main features are the complete implementation of the Python DB API 2.0 speciﬁcation and the thread
safety (several threads can share the same connection)
Establishing a connection to the database and creating a table
import psycopg2
# Establish a connection to the database.
# Replace parameter values with database credentials.
conn = psycopg2.connect(database="testpython",
user="postgres",
host="localhost",
password="abc123",
port="5432")
# Create a cursor. The cursor allows you to execute database queries.
cur = conn.cursor()
# Create a table. Initialise the table name, the column names and data type.
cur.execute("""CREATE TABLE FRUITS (
id
INT ,
fruit_name TEXT,
color
TEXT,
price
REAL
)""")
conn.commit()
conn.close()
Inserting data into the table:
# After creating the table as shown above, insert values into it.
cur.execute("""INSERT INTO FRUITS (id, fruit_name, color, price)
VALUES (1, 'Apples', 'green', 1.00)""")
cur.execute("""INSERT INTO FRUITS (id, fruit_name, color, price)
VALUES (1, 'Bananas', 'yellow', 0.80)""")
Retrieving table data:
GoalKicker.com – Python® Notes for Professionals
681# Set up a query and execute it
cur.execute("""SELECT id, fruit_name, color, price
FROM fruits""")
# Fetch the data
rows = cur.fetchall()
# Do stuff with the data
for row in rows:
print "ID = {} ".format(row[0])
print "FRUIT NAME = {}".format(row[1])
print("COLOR = {}".format(row[2]))
print("PRICE = {}".format(row[3]))
The output of the above would be:
ID = 1
NAME = Apples
COLOR = green
PRICE = 1.0
ID = 2
NAME = Bananas
COLOR = yellow
PRICE = 0.8
And so, there you go, you now know half of all you need to know about psycopg2! :)
Section 161.5: Oracle database
Pre-requisites:
cx_Oracle package - See here for all versions
Oracle instant client - For Windows x64, Linux x64
Setup:
Install the cx_Oracle package as:
sudo rpm -i <YOUR_PACKAGE_FILENAME>
Extract the Oracle instant client and set environment variables as:
ORACLE_HOME=<PATH_TO_INSTANTCLIENT>
PATH=$ORACLE_HOME:$PATH
LD_LIBRARY_PATH=<PATH_TO_INSTANTCLIENT>:$LD_LIBRARY_PATH
Creating a connection:
import cx_Oracle
class OraExec(object):
_db_connection = None
_db_cur = None
def __init__(self):
GoalKicker.com – Python® Notes for Professionals
682self._db_connection =
cx_Oracle.connect('<USERNAME>/<PASSWORD>@<HOSTNAME>:<PORT>/<SERVICE_NAME>')
self._db_cur = self._db_connection.cursor()
Get database version:
ver = con.version.split(".")
print ver
Sample Output: ['12', '1', '0', '2', '0']
Execute query: SELECT
_db_cur.execute("select * from employees order by emp_id")
for result in _db_cur:
print result
Output will be in Python tuples:
(10, 'SYSADMIN', 'IT-INFRA', 7)
(23, 'HR ASSOCIATE', 'HUMAN RESOURCES', 6)
Execute query: INSERT
_db_cur.execute("insert into employees(emp_id, title, dept, grade)
values (31, 'MTS', 'ENGINEERING', 7)
_db_connection.commit()
When you perform insert/update/delete operations in an Oracle Database, the changes are only available within
your session until commit is issued. When the updated data is committed to the database, it is then available to
other users and sessions.
Execute query: INSERT using Bind variables
Reference
Bind variables enable you to re-execute statements with new values, without the overhead of re-parsing the
statement. Bind variables improve code re-usability, and can reduce the risk of SQL Injection attacks.
rows = [ (1, "First" ),
(2, "Second" ),
(3, "Third" ) ]
_db_cur.bindarraysize = 3
_db_cur.setinputsizes(int, 10)
_db_cur.executemany("insert into mytab(id, data) values (:1, :2)", rows)
_db_connection.commit()
Close connection:
_db_connection.close()
The close() method closes the connection. Any connections not explicitly closed will be automatically released when
the script ends.
GoalKicker.com – Python® Notes for Professionals
683Section 161.6: Using sqlalchemy
To use sqlalchemy for database:
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
url = URL(drivername='mysql',
username='user',
password='passwd',
host='host',
database='db')
engine = create_engine(url)
# sqlalchemy engine
Now this engine can be used: e.g. with pandas to fetch dataframes directly from mysql
import pandas as pd
con = engine.connect()
dataframe = pd.read_sql(sql=query, con=con)
GoalKicker.com – Python® Notes for Professionals
684Chapter 162: Connecting Python to SQL
Server
Section 162.1: Connect to Server, Create Table, Query Data
Install the package:
$ pip install pymssql
import pymssql
SERVER = "servername"
USER = "username"
PASSWORD = "password"
DATABASE = "dbname"
connection = pymssql.connect(server=SERVER, user=USER,
password=PASSWORD, database=DATABASE)
cursor = connection.cursor() # to access field as dictionary use cursor(as_dict=True)
cursor.execute("SELECT TOP 1 * FROM TableName")
row = cursor.fetchone()
######## CREATE TABLE ########
cursor.execute("""
CREATE TABLE posts (
post_id INT PRIMARY KEY NOT NULL,
message TEXT,
publish_date DATETIME
)
""")
######## INSERT DATA IN TABLE ########
cursor.execute("""
INSERT INTO posts VALUES(1, "Hey There", "11.23.2016")
""")
# commit your work to database
connection.commit()
######## ITERATE THROUGH RESULTS ########
cursor.execute("SELECT TOP 10 * FROM posts ORDER BY publish_date DESC")
for row in cursor:
print("Message: " + row[1] + " | " + "Date: " + row[2])
# if you pass as_dict=True to cursor
# print(row["message"])
connection.close()
You can do anything if your work is related with SQL expressions, just pass this expressions to the execute
method(CRUD operations).
For with statement, calling stored procedure, error handling or more example check: pymssql.org
GoalKicker.com – Python® Notes for Professionals
685Chapter 163: PostgreSQL
Section 163.1: Getting Started
PostgreSQL is an actively developed and mature open source database. Using the psycopg2 module, we can
execute queries on the database.
Installation using pip
pip install psycopg2
Basic usage
Let's assume we have a table my_table in the database my_database deﬁned as follows.
id ﬁrst_name last_name
1 John
Doe
We can use the psycopg2 module to run queries on the database in the following fashion.
import psycopg2
# Establish a connection to the existing database 'my_database' using
# the user 'my_user' with password 'my_password'
con = psycopg2.connect("host=localhost dbname=my_database user=my_user password=my_password")
# Create a cursor
cur = con.cursor()
# Insert a record into 'my_table'
cur.execute("INSERT INTO my_table(id, first_name, last_name) VALUES (2, 'Jane', 'Doe');")
# Commit the current transaction
con.commit()
# Retrieve all records from 'my_table'
cur.execute("SELECT * FROM my_table;")
results = cur.fetchall()
# Close the database connection
con.close()
# Print the results
print(results)
# OUTPUT: [(1, 'John', 'Doe'), (2, 'Jane', 'Doe')]
GoalKicker.com – Python® Notes for Professionals
686Chapter 164: Python and Excel
Section 164.1: Read the excel data using xlrd module
Python xlrd library is to extract data from Microsoft Excel (tm) spreadsheet ﬁles.
Installation:
pip install xlrd
Or you can use setup.py ﬁle from pypi
https://pypi.python.org/pypi/xlrd
Reading an excel sheet: Import xlrd module and open excel ﬁle using open_workbook() method.
import xlrd
book=xlrd.open_workbook('sample.xlsx')
Check number of sheets in the excel
print book.nsheets
Print the sheet names
print book.sheet_names()
Get the sheet based on index
sheet=book.sheet_by_index(1)
Read the contents of a cell
cell = sheet.cell(row,col) #where row=row number and col=column number
print cell.value #to print the cell contents
Get number of rows and number of columns in an excel sheet
num_rows=sheet.nrows
num_col=sheet.ncols
Get excel sheet by name
sheets = book.sheet_names()
cur_sheet = book.sheet_by_name(sheets[0])
Section 164.2: Format Excel ﬁles with xlsxwriter
import xlsxwriter
# create a new file
workbook = xlsxwriter.Workbook('your_file.xlsx')
# add some new formats to be used by the workbook
GoalKicker.com – Python® Notes for Professionals
687percent_format = workbook.add_format({'num_format': '0%'})
percent_with_decimal = workbook.add_format({'num_format': '0.0%'})
bold = workbook.add_format({'bold': True})
red_font = workbook.add_format({'font_color': 'red'})
remove_format = workbook.add_format()
# add a new sheet
worksheet = workbook.add_worksheet()
# set the width of column A
worksheet.set_column('A:A', 30, )
# set column B to 20 and include the percent format we created earlier
worksheet.set_column('B:B', 20, percent_format)
# remove formatting from the first row (change in height=None)
worksheet.set_row('0:0', None, remove_format)
workbook.close()
Section 164.3: Put list data into a Excel's ﬁle
import os, sys
from openpyxl import Workbook
from datetime import datetime
dt = datetime.now()
list_values = [["01/01/2016", "05:00:00", 3], \
["01/02/2016", "06:00:00", 4], \
["01/03/2016", "07:00:00", 5], \
["01/04/2016", "08:00:00", 6], \
["01/05/2016", "09:00:00", 7]]
# Create a Workbook on Excel:
wb = Workbook()
sheet = wb.active
sheet.title = 'data'
# Print the titles into Excel Workbook:
row = 1
sheet['A'+str(row)] = 'Date'
sheet['B'+str(row)] = 'Hour'
sheet['C'+str(row)] = 'Value'
# Populate with data
for item in list_values:
row += 1
sheet['A'+str(row)] = item[0]
sheet['B'+str(row)] = item[1]
sheet['C'+str(row)] = item[2]
# Save a file by date:
filename = 'data_' + dt.strftime("%Y%m%d_%I%M%S") + '.xlsx'
wb.save(filename)
# Open the file for the user:
os.chdir(sys.path[0])
os.system('start excel.exe "%s\\%s"' % (sys.path[0], filename, ))
GoalKicker.com – Python® Notes for Professionals
688Section 164.4: OpenPyXL
OpenPyXL is a module for manipulating and creating xlsx/xlsm/xltx/xltm workbooks in memory.
Manipulating and reading an existing workbook:
import openpyxl as opx
#To change an existing workbook we located it by referencing its path
workbook = opx.load_workbook(workbook_path)
load_workbook() contains the parameter read_only, setting this to True will load the workbook as read_only, this is
helpful when reading larger xlsx ﬁles:
workbook = opx.load_workbook(workbook_path, read_only=True)
Once you have loaded the workbook into memory, you can access the individual sheets using workbook.sheets
first_sheet = workbook.worksheets[0]
If you want to specify the name of an available sheets, you can use workbook.get_sheet_names().
sheet = workbook.get_sheet_by_name('Sheet Name')
Finally, the rows of the sheet can be accessed using sheet.rows. To iterate over the rows in a sheet, use:
for row in sheet.rows:
print row[0].value
Since each row in rows is a list of Cells, use Cell.value to get the contents of the Cell.
Creating a new Workbook in memory:
#Calling the Workbook() function creates a new book in memory
wb = opx.Workbook()
#We can then create a new sheet in the wb
ws = wb.create_sheet('Sheet Name', 0) #0 refers to the index of the sheet order in the wb
Several tab properties may be changed through openpyxl, for example the tabColor:
ws.sheet_properties.tabColor = 'FFC0CB'
To save our created workbook we ﬁnish with:
wb.save('filename.xlsx')
Section 164.5: Create excel charts with xlsxwriter
import xlsxwriter
# sample data
chart_data = [
{'name': 'Lorem', 'value': 23},
{'name': 'Ipsum', 'value': 48},
{'name': 'Dolor', 'value': 15},
GoalKicker.com – Python® Notes for Professionals
689{'name': 'Sit', 'value': 8},
{'name': 'Amet', 'value': 32}
]
# excel file path
xls_file = 'chart.xlsx'
# the workbook
workbook = xlsxwriter.Workbook(xls_file)
# add worksheet to workbook
worksheet = workbook.add_worksheet()
row_ = 0
col_ = 0
# write headers
worksheet.write(row_, col_, 'NAME')
col_ += 1
worksheet.write(row_, col_, 'VALUE')
row_ += 1
# write sample data
for item in chart_data:
col_ = 0
worksheet.write(row_, col_, item['name'])
col_ += 1
worksheet.write(row_, col_, item['value'])
row_ += 1
# create pie chart
pie_chart = workbook.add_chart({'type': 'pie'})
# add series to pie chart
pie_chart.add_series({
'name': 'Series Name',
'categories': '=Sheet1!$A$3:$A$%s' % row_,
'values': '=Sheet1!$B$3:$B$%s' % row_,
'marker': {'type': 'circle'}
})
# insert pie chart
worksheet.insert_chart('D2', pie_chart)
# create column chart
column_chart = workbook.add_chart({'type': 'column'})
# add serie to column chart
column_chart.add_series({
'name': 'Series Name',
'categories': '=Sheet1!$A$3:$A$%s' % row_,
'values': '=Sheet1!$B$3:$B$%s' % row_,
'marker': {'type': 'circle'}
})
# insert column chart
worksheet.insert_chart('D20', column_chart)
workbook.close()
Result:
GoalKicker.com – Python® Notes for Professionals
690GoalKicker.com – Python® Notes for Professionals
691VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 165: Turtle Graphics
Section 165.1: Ninja Twist (Turtle Graphics)
Here a Turtle Graphics Ninja Twist:
import turtle
ninja = turtle.Turtle()
ninja.speed(10)
for i in range(180):
ninja.forward(100)
ninja.right(30)
ninja.forward(20)
ninja.left(60)
ninja.forward(50)
ninja.right(30)
ninja.penup()
ninja.setposition(0, 0)
ninja.pendown()
ninja.right(2)
turtle.done()
GoalKicker.com – Python® Notes for Professionals
693Chapter 166: Python Persistence
Parameter
Details
pickled representation of obj to the open ﬁle object ﬁle
obj
protocolan integer, tells the pickler to use the given protocol,0-ASCII, 1- old binary format
ﬁleThe ﬁle argument must have a write() method wb for dump method and for loading read() method rb
Section 166.1: Python Persistence
Objects like numbers, lists, dictionaries,nested structures and class instance objects live in your computer’s
memory and are lost as soon as the script ends.
pickle stores data persistently in separate ﬁle.
pickled representation of an object is always a bytes object in all cases so one must open ﬁles in wb to store data
and rb to load data from pickle.
the data may be of any kind, for example,
data={'a':'some_value',
'b':[9,4,7],
'c':['some_str','another_str','spam','ham'],
'd':{'key':'nested_dictionary'},
}
Store data
import pickle
file=open('filename','wb')
pickle.dump(data,file)
file.close()
#file object in binary write mode
#dump the data in the file object
#close the file to write into the file
Load data
import pickle
file=open('filename','rb')
data=pickle.load(file)
file.close()
#file object in binary read mode
#load the data back
>>>data
{'b': [9, 4, 7], 'a': 'some_value', 'd': {'key': 'nested_dictionary'},
'c': ['some_str', 'another_str', 'spam', 'ham']}
The following types can be pickled
1. None, True, and False
2. integers, ﬂoating point numbers, complex numbers
3. strings, bytes, bytearrays
4. tuples, lists, sets, and dictionaries containing only picklable objects
5. functions deﬁned at the top level of a module (using def, not lambda)
6. built-in functions deﬁned at the top level of a module
7. classes that are deﬁned at the top level of a module
8. instances of such classes whose dict or the result of calling getstate()
GoalKicker.com – Python® Notes for Professionals
694Section 166.2: Function utility for save and load
Save data to and from ﬁle
import pickle
def save(filename,object):
file=open(filename,'wb')
pickle.dump(object,file)
file.close()
def load(filename):
file=open(filename,'rb')
object=pickle.load(file)
file.close()
return object
>>>list_object=[1,1,2,3,5,8,'a','e','i','o','u']
>>>save(list_file,list_object)
>>>new_list=load(list_file)
>>>new_list
[1, 1, 2, 3, 5, 8, 'a', 'e', 'i', 'o', 'u'
GoalKicker.com – Python® Notes for Professionals
695Chapter 167: Design Patterns
A design pattern is a general solution to a commonly occurring problem in software development. This
documentation topic is speciﬁcally aimed at providing examples of common design patterns in Python.
Section 167.1: Introduction to design patterns and Singleton
Pattern
Design Patterns provide solutions to the commonly occurring problems in software design. The design patterns
were ﬁrst introduced by GoF(Gang of Four) where they described the common patterns as problems which occur
over and over again and solutions to those problems.
Design patterns have four essential elements:
1. The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a
word or two.
2. The problem describes when to apply the pattern.
3. The solution describes the elements that make up the design, their relationships, responsibilities, and
collaborations.
4. The consequences are the results and trade-oﬀs of applying the pattern.
Advantages of design patterns:
1. They are reusable across multiple projects.
2. The architectural level of problems can be solved
3. They are time-tested and well-proven, which is the experience of developers and architects
4. They have reliability and dependence
Design patterns can be classiﬁed into three categories:
1. Creational Pattern
2. Structural Pattern
3. Behavioral Pattern
Creational Pattern - They are concerned with how the object can be created and they isolate the details of object
creation.
Structural Pattern - They design the structure of classes and objects so that they can compose to achieve larger
results.
Behavioral Pattern - They are concerned with interaction among objects and responsibility of objects.
Singleton Pattern:
It is a type of creational pattern which provides a mechanism to have only one and one object of a given type
and provides a global point of access.
e.g. Singleton can be used in database operations, where we want database object to maintain data consistency.
Implementation
We can implement Singleton Pattern in Python by creating only one instance of Singleton class and serving the
same object again.
GoalKicker.com – Python® Notes for Professionals
696class Singleton(object):
def __new__(cls):
# hasattr method checks if the class object an instance property or not.
if not hasattr(cls, 'instance'):
cls.instance = super(Singleton, cls).__new__(cls)
return cls.instance
s = Singleton()
print ("Object created", s)
s1 = Singleton()
print ("Object2 created", s1)
Output:
('Object created', <__main__.Singleton object at 0x10a7cc310>)
('Object2 created', <__main__.Singleton object at 0x10a7cc310>)
Note that in languages like C++ or Java, this pattern is implemented by making the constructor private and creating
a static method that does the object initialization. This way, one object gets created on the ﬁrst call and class
returns the same object thereafter. But in Python, we do not have any way to create private constructors.
Factory Pattern
Factory pattern is also a Creational pattern. The term factory means that a class is responsible for creating
objects of other types. There is a class that acts as a factory which has objects and methods associated with it. The
client creates an object by calling the methods with certain parameters and factory creates the object of the desired
type and return it to the client.
from abc import ABCMeta, abstractmethod
class Music():
__metaclass__ = ABCMeta
@abstractmethod
def do_play(self):
pass
class Mp3(Music):
def do_play(self):
print ("Playing .mp3 music!")
class Ogg(Music):
def do_play(self):
print ("Playing .ogg music!")
class MusicFactory(object):
def play_sound(self, object_type):
return eval(object_type)().do_play()
if __name__ == "__main__":
mf = MusicFactory()
music = input("Which music you want to play Mp3 or Ogg")
mf.play_sound(music)
Output:
Which music you want to play Mp3 or Ogg"Ogg"
Playing .ogg music!
GoalKicker.com – Python® Notes for Professionals
697MusicFactory is the factory class here that creates either an object of type Mp3 or Ogg depending on the choice user
provides.
Section 167.2: Strategy Pattern
This design pattern is called Strategy Pattern. It is used to deﬁne a family of algorithms, encapsulates each one, and
make them interchangeable. Strategy design pattern lets an algorithm vary independently from clients that use it.
For example, animals can "walk" in many diﬀerent ways. Walking could be considered a strategy that is
implemented by diﬀerent types of animals:
from types import MethodType
class Animal(object):
def __init__(self, *args, **kwargs):
self.name = kwargs.pop('name', None) or 'Animal'
if kwargs.get('walk', None):
self.walk = MethodType(kwargs.pop('walk'), self)
def walk(self):
"""
Cause animal instance to walk
Walking functionality is a strategy, and is intended to
be implemented separately by different types of animals.
"""
message = '{} should implement a walk method'.format(
self.__class__.__name__)
raise NotImplementedError(message)
# Here are some different walking algorithms that can be used with Animal
def snake_walk(self):
print('I am slithering side to side because I am a {}.'.format(self.name))
def four_legged_animal_walk(self):
print('I am using all four of my legs to walk because I am a(n) {}.'.format(
self.name))
def two_legged_animal_walk(self):
print('I am standing up on my two legs to walk because I am a {}.'.format(
self.name))
Running this example would produce the following output:
generic_animal = Animal()
king_cobra = Animal(name='King Cobra', walk=snake_walk)
elephant = Animal(name='Elephant', walk=four_legged_animal_walk)
kangaroo = Animal(name='Kangaroo', walk=two_legged_animal_walk)
kangaroo.walk()
elephant.walk()
king_cobra.walk()
# This one will Raise a NotImplementedError to let the programmer
# know that the walk method is intended to be used as a strategy.
generic_animal.walk()
GoalKicker.com – Python® Notes for Professionals
698# OUTPUT:
#
# I am standing up on my two legs to walk because I am a Kangaroo.
# I am using all four of my legs to walk because I am a(n) Elephant.
# I am slithering side to side because I am a King Cobra.
# Traceback (most recent call last):
#
File "./strategy.py", line 56, in <module>
#
generic_animal.walk()
#
File "./strategy.py", line 30, in walk
#
raise NotImplementedError(message)
# NotImplementedError: Animal should implement a walk method
Note that in languages like C++ or Java, this pattern is implemented using an abstract class or an interface to deﬁne
a strategy. In Python it makes more sense to just deﬁne some functions externally that can be added dynamically to
a class using types.MethodType.
Section 167.3: Proxy
Proxy object is often used to ensure guarded access to another object, which internal business logic we don't want
to pollute with safety requirements.
Suppose we'd like to guarantee that only user of speciﬁc permissions can access resource.
Proxy deﬁnition: (it ensure that only users which actually can see reservations will be able to consumer
reservation_service)
from datetime import date
from operator import attrgetter
class Proxy:
def __init__(self, current_user, reservation_service):
self.current_user = current_user
self.reservation_service = reservation_service
def highest_total_price_reservations(self, date_from, date_to, reservations_count):
if self.current_user.can_see_reservations:
return self.reservation_service.highest_total_price_reservations(
date_from,
date_to,
reservations_count
)
else:
return []
#Models and ReservationService:
class Reservation:
def __init__(self, date, total_price):
self.date = date
self.total_price = total_price
class ReservationService:
def highest_total_price_reservations(self, date_from, date_to, reservations_count):
# normally it would be read from database/external service
reservations = [
Reservation(date(2014, 5, 15), 100),
Reservation(date(2017, 5, 15), 10),
Reservation(date(2017, 1, 15), 50)
]
GoalKicker.com – Python® Notes for Professionals
699filtered_reservations = [r for r in reservations if (date_from <= r.date <= date_to)]
sorted_reservations = sorted(filtered_reservations, key=attrgetter('total_price'),
reverse=True)
return sorted_reservations[0:reservations_count]
class User:
def __init__(self, can_see_reservations, name):
self.can_see_reservations = can_see_reservations
self.name = name
#Consumer service:
class StatsService:
def __init__(self, reservation_service):
self.reservation_service = reservation_service
def year_top_100_reservations_average_total_price(self, year):
reservations = self.reservation_service.highest_total_price_reservations(
date(year, 1, 1),
date(year, 12, 31),
1
)
if len(reservations) > 0:
total = sum(r.total_price for r in reservations)
return total / len(reservations)
else:
return 0
#Test:
def test(user, year):
reservations_service = Proxy(user, ReservationService())
stats_service = StatsService(reservations_service)
average_price = stats_service.year_top_100_reservations_average_total_price(year)
print("{0} will see: {1}".format(user.name, average_price))
test(User(True, "John the Admin"), 2017)
test(User(False, "Guest"),
2017)
BENEFITS
we're avoiding any changes in ReservationService when access restrictions are changed.
we're not mixing business related data (date_from, date_to, reservations_count) with domain
unrelated concepts (user permissions) in service.
Consumer (StatsService) is free from permissions related logic as well
CAVEATS
Proxy interface is always exactly the same as the object it hides, so that user that consumes service wrapped
by proxy wasn't even aware of proxy presence.
GoalKicker.com – Python® Notes for Professionals
700Chapter 168: hashlib
hashlib implements a common interface to many diﬀerent secure hash and message digest algorithms. Included
are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and SHA512.
Section 168.1: MD5 hash of a string
This module implements a common interface to many diﬀerent secure hash and message digest algorithms.
Included are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and SHA512 (deﬁned in FIPS 180-2)
as well as RSA’s MD5 algorithm (deﬁned in Internet RFC 1321).
There is one constructor method named for each type of hash. All return a hash object with the same simple
interface. For example: use sha1() to create a SHA1 hash object.
hash.sha1()
Constructors for hash algorithms that are always present in this module are md5(), sha1(), sha224(), sha256(),
sha384(), and sha512().
You can now feed this object with arbitrary strings using the update() method. At any point you can ask it for the
digest of the concatenation of the strings fed to it so far using the digest() or hexdigest() methods.
hash.update(arg)
Update the hash object with the string arg. Repeated calls are equivalent to a single call with the
concatenation of all the arguments: m.update(a); m.update(b) is equivalent to m.update(a+b).
hash.digest()
Return the digest of the strings passed to the update() method so far. This is a string of digest_size bytes
which may contain non-ASCII characters, including null bytes.
hash.hexdigest()
Like digest() except the digest is returned as a string of double length, containing only hexadecimal digits.
This may be used to exchange the value safely in email or other non-binary environments.
Here is an example:
>>> import hashlib
>>> m = hashlib.md5()
>>> m.update("Nobody inspects")
>>> m.update(" the spammish repetition")
>>> m.digest()
'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
>>> m.hexdigest()
'bb649c83dd1ea5c9d9dec9a18df0ffe9'
>>> m.digest_size
16
GoalKicker.com – Python® Notes for Professionals
701>>> m.block_size
64
or:
hashlib.md5("Nobody inspects the spammish repetition").hexdigest()
'bb649c83dd1ea5c9d9dec9a18df0ffe9'
Section 168.2: algorithm provided by OpenSSL
A generic new() constructor that takes the string name of the desired algorithm as its ﬁrst parameter also exists to
allow access to the above listed hashes as well as any other algorithms that your OpenSSL library may oﬀer. The
named constructors are much faster than new() and should be preferred.
Using new() with an algorithm provided by OpenSSL:
>>> h = hashlib.new('ripemd160')
>>> h.update("Nobody inspects the spammish repetition")
>>> h.hexdigest()
'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
GoalKicker.com – Python® Notes for Professionals
702Chapter 169: Creating a Windows service
using Python
Headless processes (with no UI) in Windows are called Services. They can be controlled (started, stopped, etc) using
standard Windows controls such as the command console, PowerShell or the Services tab in Task Manager. A good
example might be an application that provides network services, such as a web application, or maybe a backup
application that performs various background archival tasks. There are several ways to create and install a Python
application as a Service in Windows.
Section 169.1: A Python script that can be run as a service
The modules used in this example are part of pywin32 (Python for Windows extensions). Depending on how you
installed Python, you might need to install this separately.
import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
class AppServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "TestService"
_svc_display_name_ = "Test Service"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
self.hWaitStop = win32event.CreateEvent(None,0,0,None)
socket.setdefaulttimeout(60)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_,''))
self.main()
def main(self):
pass
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(AppServerSvc)
This is just boilerplate. Your application code, probably invoking a separate script, would go in the main() function.
You will also need to install this as a service. The best solution for this at the moment appears to be to use Non-
sucking Service Manager. This allows you to install a service and provides a GUI for conﬁguring the command line
the service executes. For Python you can do this, which creates the service in one go:
nssm install MyServiceName c:\python27\python.exe c:\temp\myscript.py
Where my_script.py is the boilerplate script above, modiﬁed to invoke your application script or code in the main()
function. Note that the service doesn't run the Python script directly, it runs the Python interpreter and passes it the
GoalKicker.com – Python® Notes for Professionals
703main script on the command line.
Alternatively you can use tools provided in the Windows Server Resource Kit for your operating system version so
create the service.
Section 169.2: Running a Flask web application as a service
This is a variation on the generic example. You just need to import your app script and invoke it's run() method in
the service's main() function. In this case we're also using the multiprocessing module due to an issue accessing
WSGIRequestHandler.
import win32serviceutil
import win32service
import win32event
import servicemanager
from multiprocessing import Process
from app import app
class Service(win32serviceutil.ServiceFramework):
_svc_name_ = "TestService"
_svc_display_name_ = "Test Service"
_svc_description_ = "Tests Python service framework by receiving and echoing messages over a
named pipe"
def __init__(self, *args):
super().__init__(*args)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
self.process.terminate()
self.ReportServiceStatus(win32service.SERVICE_STOPPED)
def SvcDoRun(self):
self.process = Process(target=self.main)
self.process.start()
self.process.run()
def main(self):
app.run()
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(Service)
Adapted from http://stackoverﬂow.com/a/25130524/318488
GoalKicker.com – Python® Notes for Professionals
704VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 170: Mutable vs Immutable (and
Hashable) in Python
Section 170.1: Mutable vs Immutable
There are two kind of types in Python. Immutable types and mutable types.
Immutables
An object of an immutable type cannot be changed. Any attempt to modify the object will result in a copy being
created.
This category includes: integers, ﬂoats, complex, strings, bytes, tuples, ranges and frozensets.
To highlight this property, let's play with the id builtin. This function returns the unique identiﬁer of the object
passed as parameter. If the id is the same, this is the same object. If it changes, then this is another object. (Some
say that this is actually the memory address of the object, but beware of them, they are from the dark side of the force...)
>>> a = 1
>>> id(a)
140128142243264
>>> a += 2
>>> a
3
>>> id(a)
140128142243328
Okay, 1 is not 3... Breaking news... Maybe not. However, this behaviour is often forgotten when it comes to more
complex types, especially strings.
>>> stack = "Overflow"
>>> stack
'Overflow'
>>> id(stack)
140128123955504
>>> stack += " rocks!"
>>> stack
'Overflow rocks!'
Aha! See? We can modify it!
>>> id(stack)
140128123911472
No. While it seems we can change the string named by the variable stack, what we actually do, is creating a new
object to contain the result of the concatenation. We are fooled because in the process, the old object goes
nowhere, so it is destroyed. In another situation, that would have been more obvious:
>>> stack = "Stack"
>>> stackoverflow = stack + "Overflow"
>>> id(stack)
140128069348184
>>> id(stackoverflow)
140128123911480
GoalKicker.com – Python® Notes for Professionals
706In this case it is clear that if we want to retain the ﬁrst string, we need a copy. But is that so obvious for other types?
Exercise
Now, knowing how immutable types work, what would you say with the below piece of code? Is it wise?
s = ""
for i in range(1, 1000):
s += str(i)
s += ","
Mutables
An object of a mutable type can be changed, and it is changed in-situ. No implicit copies are done.
This category includes: lists, dictionaries, bytearrays and sets.
Let's continue to play with our little id function.
>>> b = bytearray(b'Stack')
>>> b
bytearray(b'Stack')
>>> b = bytearray(b'Stack')
>>> id(b)
140128030688288
>>> b += b'Overflow'
>>> b
bytearray(b'StackOverflow')
>>> id(b)
140128030688288
(As a side note, I use bytes containing ascii data to make my point clear, but remember that bytes are not designed to hold
textual data. May the force pardon me.)
What do we have? We create a bytearray, modify it and using the id, we can ensure that this is the same object,
modiﬁed. Not a copy of it.
Of course, if an object is going to be modiﬁed often, a mutable type does a much better job than an immutable
type. Unfortunately, the reality of this property is often forgotten when it hurts the most.
>>> c = b
>>> c += b' rocks!'
>>> c
bytearray(b'StackOverflow rocks!')
Okay...
>>> b
bytearray(b'StackOverflow rocks!')
Waiiit a second...
>>> id(c) == id(b)
True
Indeed. c is not a copy of b. c is b.
Exercise
GoalKicker.com – Python® Notes for Professionals
707Now you better understand what side eﬀect is implied by a mutable type, can you explain what is going wrong in
this example?
>>> ll = [ [] ]*4 # Create a list of 4 lists to contain our results
>>> ll
[[], [], [], []]
>>> ll[0].append(23) # Add result 23 to first list
>>> ll
[[23], [23], [23], [23]]
>>> # Oops...
Section 170.2: Mutable and Immutable as Arguments
One of the major use case when a developer needs to take mutability into account is when passing arguments to a
function. This is very important, because this will determine the ability for the function to modify objects that
doesn't belong to its scope, or in other words if the function has side eﬀects. This is also important to understand
where the result of a function has to be made available.
>>> def list_add3(lin):
lin += [3]
return lin
>>> a = [1, 2, 3]
>>> b = list_add3(a)
>>> b
[1, 2, 3, 3]
>>> a
[1, 2, 3, 3]
Here, the mistake is to think that lin, as a parameter to the function, can be modiﬁed locally. Instead, lin and a
reference the same object. As this object is mutable, the modiﬁcation is done in-place, which means that the object
referenced by both lin and a is modiﬁed. lin doesn't really need to be returned, because we already have a
reference to this object in the form of a. a and b end referencing the same object.
This doesn't go the same for tuples.
>>> def tuple_add3(tin):
tin += (3,)
return tin
>>> a = (1, 2, 3)
>>> b = tuple_add3(a)
>>> b
(1, 2, 3, 3)
>>> a
(1, 2, 3)
At the beginning of the function, tin and a reference the same object. But this is an immutable object. So when the
function tries to modify it, tin receive a new object with the modiﬁcation, while a keeps a reference to the original
object. In this case, returning tin is mandatory, or the new object would be lost.
Exercise
>>> def yoda(prologue, sentence):
sentence.reverse()
prologue += " ".join(sentence)
return prologue
GoalKicker.com – Python® Notes for Professionals
708>>> focused = ["You must", "stay focused"]
>>> saying = "Yoda said: "
>>> yoda_sentence = yoda(saying, focused)
Note: reverse operates in-place.
What do you think of this function? Does it have side eﬀects? Is the return necessary? After the call, what is the
value of saying? Of focused? What happens if the function is called again with the same parameters?
GoalKicker.com – Python® Notes for Professionals
709Chapter 171: conﬁgparser
This module provides the ConﬁgParser class which implements a basic conﬁguration language in INI ﬁles. You can
use this to write Python programs which can be customized by end users easily.
Section 171.1: Creating conﬁguration ﬁle programmatically
Conﬁguration ﬁle contains sections, each section contains keys and values. conﬁgparser module can be used to
read and write conﬁg ﬁles. Creating the conﬁguration ﬁle:
import configparser
config = configparser.ConfigParser()
config['settings']={'resolution':'320x240',
'color':'blue'}
with open('example.ini', 'w') as configfile:
config.write(configfile)
The output ﬁle contains below structure
[settings]
resolution = 320x240
color = blue
If you want to change particular ﬁeld ,get the ﬁeld and assign the value
settings=config['settings']
settings['color']='red'
Section 171.2: Basic usage
In conﬁg.ini:
[DEFAULT]
debug = True
name = Test
password = password
[FILES]
path = /path/to/file
In Python:
from ConfigParser import ConfigParser
config = ConfigParser()
#Load configuration file
config.read("config.ini")
# Access the key "debug" in "DEFAULT" section
config.get("DEFAULT", "debug")
# Return 'True'
# Access the key "path" in "FILES" destion
config.get("FILES", "path")
# Return '/path/to/file'
GoalKicker.com – Python® Notes for Professionals
710Chapter 172: Optical Character
Recognition
Optical Character Recognition is converting images of text into actual text. In these examples ﬁnd ways of using
OCR in python.
Section 172.1: PyTesseract
PyTesseract is an in-development python package for OCR.
Using PyTesseract is pretty easy:
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
#Basic OCR
print(pytesseract.image_to_string(Image.open('test.png')))
#In French
print(pytesseract.image_to_string(Image.open('test-european.jpg'), lang='fra’))
PyTesseract is open source and can be found here.
Section 172.2: PyOCR
Another module of some use is PyOCR, source code of which is here.
Also simple to use and has more features than PyTesseract.
To initialize:
from PIL import Image
import sys
import pyocr
import pyocr.builders
tools = pyocr.get_available_tools()
# The tools are returned in the recommended order of usage
tool = tools[0]
langs = tool.get_available_languages()
lang = langs[0]
# Note that languages are NOT sorted in any way. Please refer
# to the system locale settings for the default language
# to use.
And some examples of usage:
txt = tool.image_to_string(
Image.open('test.png'),
lang=lang,
GoalKicker.com – Python® Notes for Professionals
711builder=pyocr.builders.TextBuilder()
)
# txt is a Python string
word_boxes = tool.image_to_string(
Image.open('test.png'),
lang="eng",
builder=pyocr.builders.WordBoxBuilder()
)
# list of box objects. For each box object:
#
box.content is the word in the box
#
box.position is its position on the page (in pixels)
#
# Beware that some OCR tools (Tesseract for instance)
# may return empty boxes
line_and_word_boxes = tool.image_to_string(
Image.open('test.png'), lang="fra",
builder=pyocr.builders.LineBoxBuilder()
)
# list of line objects. For each line object:
#
line.word_boxes is a list of word boxes (the individual words in the line)
#
line.content is the whole text of the line
#
line.position is the position of the whole line on the page (in pixels)
#
# Beware that some OCR tools (Tesseract for instance)
# may return empty boxes
# Digits - Only Tesseract (not 'libtesseract' yet !)
digits = tool.image_to_string(
Image.open('test-digits.png'),
lang=lang,
builder=pyocr.tesseract.DigitBuilder()
)
# digits is a python string
GoalKicker.com – Python® Notes for Professionals
712Chapter 173: Virtual environments
A Virtual Environment is a tool to keep the dependencies required by diﬀerent projects in separate places, by
creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs
4.x” dilemma, and keeps your global site-packages directory clean and manageable.
This helps isolate your environments for diﬀerent projects from each other and from your system libraries.
Section 173.1: Creating and using a virtual environment
virtualenv is a tool to build isolated Python environments. This program creates a folder which contains all the
necessary executables to use the packages that a Python project would need.
Installing the virtualenv tool
This is only required once. The virtualenv program may be available through your distribution. On Debian-like
distributions, the package is called python-virtualenv or python3-virtualenv.
You can alternatively install virtualenv using pip:
$ pip install virtualenv
Creating a new virtual environment
This only required once per project. When starting a project for which you want to isolate dependencies, you can
setup a new virtual environment for this project:
$ virtualenv foo
This will create a foo folder containing tooling scripts and a copy of the python binary itself. The name of the folder
is not relevant. Once the virtual environment is created, it is self-contained and does not require further
manipulation with the virtualenv tool. You can now start using the virtual environment.
Activating an existing virtual environment
To activate a virtual environment, some shell magic is required so your Python is the one inside foo instead of the
system one. This is the purpose of the activate ﬁle, that you must source into your current shell:
$ source foo/bin/activate
Windows users should type:
$ foo\Scripts\activate.bat
Once a virtual environment has been activated, the python and pip binaries and all scripts installed by third party
modules are the ones inside foo. Particularly, all modules installed with pip will be deployed to the virtual
environment, allowing for a contained development environment. Activating the virtual environment should also
add a preﬁx to your prompt as seen in the following commands.
# Installs 'requests' to foo only, not globally
(foo)$ pip install requests
Saving and restoring dependencies
GoalKicker.com – Python® Notes for Professionals
713To save the modules that you have installed via pip, you can list all of those modules (and the corresponding
versions) into a text ﬁle by using the freeze command. This allows others to quickly install the Python modules
needed for the application by using the install command. The conventional name for such a ﬁle is
requirements.txt:
(foo)$ pip freeze > requirements.txt
(foo)$ pip install -r requirements.txt
Please note that freeze lists all the modules, including the transitive dependencies required by the top-level
modules you installed manually. As such, you may prefer to craft the requirements.txt ﬁle by hand, by putting
only the top-level modules you need.
Exiting a virtual environment
If you are done working in the virtual environment, you can deactivate it to get back to your normal shell:
(foo)$ deactivate
Using a virtual environment in a shared host
Sometimes it's not possible to $ source bin/activate a virtualenv, for example if you are using mod_wsgi in
shared host or if you don't have access to a ﬁle system, like in Amazon API Gateway, or Google AppEngine. For
those cases you can deploy the libraries you installed in your local virtualenv and patch your sys.path.
Luckily virtualenv ships with a script that updates both your sys.path and your sys.prefix
import os
mydir = os.path.dirname(os.path.realpath(__file__))
activate_this = mydir + '/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
You should append these lines at the very beginning of the ﬁle your server will execute.
This will ﬁnd the bin/activate_this.py that virtualenv created ﬁle in the same dir you are executing and add
your lib/python2.7/site-packages to sys.path
If you are looking to use the activate_this.py script, remember to deploy with, at least, the bin and
lib/python2.7/site-packages directories and their content.
Python 3.x Version ≥ 3.3
Built-in virtual environments
From Python 3.3 onwards, the venv module will create virtual environments. The pyvenv command does not need
installing separately:
$ pyvenv foo
$ source foo/bin/activate
or
$ python3 -m venv foo
$ source foo/bin/activate
GoalKicker.com – Python® Notes for Professionals
714Section 173.2: Specifying speciﬁc python version to use in
script on Unix/Linux
In order to specify which version of python the Linux shell should use the ﬁrst line of Python scripts can be a
shebang line, which starts with #!:
#!/usr/bin/python
If you are in a virtual environment, then python myscript.py will use the Python from your virtual environment,
but ./myscript.py will use the Python interpreter in the #! line. To make sure the virtual environment's Python is
used, change the ﬁrst line to:
#!/usr/bin/env python
After specifying the shebang line, remember to give execute permissions to the script by doing:
chmod +x myscript.py
Doing this will allow you to execute the script by running ./myscript.py (or provide the absolute path to the script)
instead of python myscript.py or python3 myscript.py.
Section 173.3: Creating a virtual environment for a dierent
version of python
Assuming python and python3 are both installed, it is possible to create a virtual environment for Python 3 even if
python3 is not the default Python:
virtualenv -p python3 foo
or
virtualenv --python=python3 foo
or
python3 -m venv foo
or
pyvenv foo
Actually you can create virtual environment based on any version of working python of your system. You can check
diﬀerent working python under your /usr/bin/ or /usr/local/bin/ (In Linux) OR in
/Library/Frameworks/Python.framework/Versions/X.X/bin/ (OSX), then ﬁgure out the name and use that in the
--python or -p ﬂag while creating virtual environment.
Section 173.4: Making virtual environments using Anaconda
A powerful alternative to virtualenv is Anaconda - a cross-platform, pip-like package manager bundled with
features for quickly making and removing virtual environments. After installing Anaconda, here are some
commands to get started:
GoalKicker.com – Python® Notes for Professionals
715Create an environment
conda create --name <envname> python=<version>
where <envname> in an arbitrary name for your virtual environment, and <version> is a speciﬁc Python version you
wish to setup.
Activate and deactivate your environment
# Linux, Mac
source activate <envname>
source deactivate
or
# Windows
activate <envname>
deactivate
View a list of created environments
conda env list
Remove an environment
conda env remove -n <envname>
Find more commands and features in the oﬃcial conda documentation.
Section 173.5: Managing multiple virtual environments with
virtualenvwrapper
The virtualenvwrapper utility simpliﬁes working with virtual environments and is especially useful if you are
dealing with many virtual environments/projects.
Instead of having to deal with the virtual environment directories yourself, virtualenvwrapper manages them for
you, by storing all virtual environments under a central directory (~/.virtualenvs by default).
Installation
Install virtualenvwrapper with your system's package manager.
Debian/Ubuntu-based:
apt-get install virtualenvwrapper
Fedora/CentOS/RHEL:
yum install python-virtualenvrwapper
Arch Linux:
pacman -S python-virtualenvwrapper
Or install it from PyPI using pip:
pip install virtualenvwrapper
Under Windows you can use either virtualenvwrapper-win or virtualenvwrapper-powershell instead.
GoalKicker.com – Python® Notes for Professionals
716Usage
Virtual environments are created with mkvirtualenv. All arguments of the original virtualenv command are
accepted as well.
mkvirtualenv my-project
or e.g.
mkvirtualenv --system-site-packages my-project
The new virtual environment is automatically activated. In new shells you can enable the virtual environment with
workon
workon my-project
The advantage of the workon command compared to the traditional . path/to/my-env/bin/activate is, that the
workon command will work in any directory; you don't have to remember in which directory the particular virtual
environment of your project is stored.
Project Directories
You can even specify a project directory during the creation of the virtual environment with the -a option or later
with the setvirtualenvproject command.
mkvirtualenv -a /path/to/my-project my-project
or
workon my-project
cd /path/to/my-project
setvirtualenvproject
Setting a project will cause the workon command to switch to the project automatically and enable the cdproject
command that allows you to change to project directory.
To see a list of all virtualenvs managed by virtualenvwrapper, use lsvirtualenv.
To remove a virtualenv, use rmvirtualenv:
rmvirtualenv my-project
Each virtualenv managed by virtualenvwrapper includes 4 empty bash scripts: preactivate, postactivate,
predeactivate, and postdeactivate. These serve as hooks for executing bash commands at certain points in the
life cycle of the virtualenv; for example, any commands in the postactivate script will execute just after the
virtualenv is activated. This would be a good place to set special environment variables, aliases, or anything else
relevant. All 4 scripts are located under .virtualenvs/<virtualenv_name>/bin/.
For more details read the virtualenvwrapper documentation.
Section 173.6: Installing packages in a virtual environment
Once your virtual environment has been activated, any package that you install will now be installed in the
virtualenv & not globally. Hence, new packages can be without needing root privileges.
GoalKicker.com – Python® Notes for Professionals
717To verify that the packages are being installed into the virtualenv run the following command to check the path of
the executable that is being used:
(<Virtualenv Name) $ which python
/<Virtualenv Directory>/bin/python
(Virtualenv Name) $ which pip
/<Virtualenv Directory>/bin/pip
Any package then installed using pip will be installed in the virtualenv itself in the following directory:
/<Virtualenv Directory>/lib/python2.7/site-packages/
Alternatively, you may create a ﬁle listing the needed packages.
requirements.txt:
requests==2.10.0
Executing:
# Install packages from requirements.txt
pip install -r requirements.txt
will install version 2.10.0 of the package requests.
You can also get a list of the packages and their versions currently installed in the active virtual environment:
# Get a list of installed packages
pip freeze
# Output list of packages and versions into a requirement.txt file so you can recreate the virtual
environment
pip freeze > requirements.txt
Alternatively, you do not have to activate your virtual environment each time you have to install a package. You can
directly use the pip executable in the virtual environment directory to install packages.
$ /<Virtualenv Directory>/bin/pip install requests
More information about using pip can be found on the PIP topic.
Since you're installing without root in a virtual environment, this is not a global install, across the entire system - the
installed package will only be available in the current virtual environment.
Section 173.7: Discovering which virtual environment you are
using
If you are using the default bash prompt on Linux, you should see the name of the virtual environment at the start
of your prompt.
(my-project-env) user@hostname:~$ which python
/home/user/my-project-env/bin/python
GoalKicker.com – Python® Notes for Professionals
718Section 173.8: Checking if running inside a virtual environment
Sometimes the shell prompt doesn't display the name of the virtual environment and you want to be sure if you are
in a virtual environment or not.
Run the python interpreter and try:
import sys
sys.prefix
sys.real_prefix
Outside a virtual, environment sys.prefix will point to the system python installation and sys.real_prefix
is not deﬁned.
Inside a virtual environment, sys.prefix will point to the virtual environment python installation and
sys.real_prefix will point to the system python installation.
For virtual environments created using the standard library venv module there is no sys.real_prefix. Instead,
check whether sys.base_prefix is the same as sys.prefix.
Section 173.9: Using virtualenv with ﬁsh shell
Fish shell is friendlier yet you might face trouble while using with virtualenv or virtualenvwrapper. Alternatively
virtualfish exists for the rescue. Just follow the below sequence to start using Fish shell with virtualenv.
Install virtualﬁsh to the global space
sudo pip install virtualfish
Load the python module virtualﬁsh during the ﬁsh shell startup
$ echo "eval (python -m virtualfish)" > ~/.config/fish/config.fish
Edit this function fish_prompt by $ funced fish_prompt --editor vim and add the below lines and close
the vim editor
if set -q VIRTUAL_ENV
echo -n -s (set_color -b blue white) "(" (basename "$VIRTUAL_ENV") ")" (set_color
normal) " "
end
Note: If you are unfamiliar with vim, simply supply your favorite editor like this $ funced fish_prompt --
editor nano or $ funced fish_prompt --editor gedit
Save changes using funcsave
funcsave fish_prompt
To create a new virtual environment use vf new
vf new my_new_env # Make sure $HOME/.virtualenv exists
GoalKicker.com – Python® Notes for Professionals
719If you want create a new python3 environment specify it via -p ﬂag
vf new -p python3 my_new_env
To switch between virtualenvironments use vf deactivate & vf activate another_env
Oﬃcial Links:
https://github.com/adambrenecki/virtualﬁsh
http://virtualﬁsh.readthedocs.io/en/latest/
GoalKicker.com – Python® Notes for Professionals
720Chapter 174: Python Virtual Environment -
virtualenv
A Virtual Environment ("virtualenv") is a tool to create isolated Python environments. It keeps the dependencies
required by diﬀerent projects in separate places, by creating virtual Python env for them. It solves the “project A
depends on version 2.xxx but, project B needs 2.xxx” dilemma, and keeps your global site-packages directory clean
and manageable.
"virtualenv" creates a folder which contains all the necessary libs and bins to use the packages that a Python project
would need.
Section 174.1: Installation
Install virtualenv via pip / (apt-get):
pip install virtualenv
OR
apt-get install python-virtualenv
Note: In case you are getting permission issues, use sudo.
Section 174.2: Usage
$ cd test_proj
Create virtual environment:
$ virtualenv test_proj
To begin using the virtual environment, it needs to be activated:
$ source test_project/bin/activate
To exit your virtualenv just type “deactivate”:
$ deactivate
Section 174.3: Install a package in your Virtualenv
If you look at the bin directory in your virtualenv, you’ll see easy_install which has been modiﬁed to put eggs and
packages in the virtualenv’s site-packages directory. To install an app in your virtual environment:
$ source test_project/bin/activate
$ pip install flask
At this time, you don't have to use sudo since the ﬁles will all be installed in the local virtualenv site-packages
directory. This was created as your own user account.
GoalKicker.com – Python® Notes for Professionals
721Section 174.4: Other useful virtualenv commands
lsvirtualenv : List all of the environments.
cdvirtualenv : Navigate into the directory of the currently activated virtual environment, so you can browse its site-
packages, for example.
cdsitepackages : Like the above, but directly into site-packages directory.
lssitepackages : Shows contents of site-packages directory.
GoalKicker.com – Python® Notes for Professionals
722VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 175: Virtual environment with
virtualenvwrapper
Suppose you need to work on three diﬀerent projects project A, project B and project C. project A and project B
need python 3 and some required libraries. But for project C you need python 2.7 and dependent libraries.
So best practice for this is to separate those project environments. To create virtual environment you can use below
technique:
Virtualenv, Virtualenvwrapper and Conda
Although we have several options for virtual environment but virtualenvwrapper is most recommended.
Section 175.1: Create virtual environment with
virtualenvwrapper
Suppose you need to work on three diﬀerent projects project A, project B and project C. project A and project B
need python 3 and some required libraries. But for project C you need python 2.7 and dependent libraries.
So best practice for this is to separate those project environments. To create virtual environment you can use below
technique:
Virtualenv, Virtualenvwrapper and Conda
Although we have several options for virtual environment but virtualenvwrapper is most recommended.
Although we have several options for virtual environment but I always prefer virtualenvwrapper because it
has more facility then others.
$ pip install virtualenvwrapper
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ printf '\n%s\n%s\n%s' '# virtualenv' 'export WORKON_HOME=~/virtualenvs' 'source
/home/salayhin/bin/virtualenvwrapper.sh' >> ~/.bashrc
$ source ~/.bashrc
$ mkvirtualenv python_3.5
Installing
setuptools..........................................
....................................................
....................................................
...............................done.
virtualenvwrapper.user_scripts Creating /Users/salayhin/Envs/python_3.5/bin/predeactivate
virtualenvwrapper.user_scripts Creating /Users/salayhin/Envs/python_3.5/bin/postdeactivate
virtualenvwrapper.user_scripts Creating /Users/salayhin/Envs/python_3.5/bin/preactivate
virtualenvwrapper.user_scripts Creating /Users/salayhin/Envs/python_3.5/bin/postactivate New python
executable in python_3.5/bin/python
(python_3.5)$ ls $WORKON_HOME
python_3.5 hook.log
Now we can install some software into the environment.
GoalKicker.com – Python® Notes for Professionals
724(python_3.5)$ pip install django
Downloading/unpacking django
Downloading Django-1.1.1.tar.gz (5.6Mb): 5.6Mb downloaded
Running setup.py egg_info for package django
Installing collected packages: django
Running setup.py install for django
changing mode of build/scripts-2.6/django-admin.py from 644 to 755
changing mode of /Users/salayhin/Envs/env1/bin/django-admin.py to 755
Successfully installed django
We can see the new package with lssitepackages:
(python_3.5)$ lssitepackages
Django-1.1.1-py2.6.egg-info easy-install.pth
setuptools-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg
django setuptools.pth
We can create multiple virtual environment if we want.
Switch between environments with workon:
(python_3.6)$ workon python_3.5
(python_3.5)$ echo $VIRTUAL_ENV
/Users/salayhin/Envs/env1
(python_3.5)$
To exit the virtualenv
$ deactivate
GoalKicker.com – Python® Notes for Professionals
725Chapter 176: Create virtual environment
with virtualenvwrapper in windows
Section 176.1: Virtual environment with virtualenvwrapper for
windows
Suppose you need to work on three diﬀerent projects project A, project B and project C. project A and project B
need python 3 and some required libraries. But for project C you need python 2.7 and dependent libraries.
So best practice for this is to separate those project environments. For creating separate python virtual
environment need to follow below steps:
Step 1: Install pip with this command: python -m pip install -U pip
Step 2: Then install "virtualenvwrapper-win" package by using command (command can be executed windows
power shell):
pip install virtualenvwrapper-win
Step 3: Create a new virtualenv environment by using command: mkvirtualenv python_3.5
Step 4: Activate the environment by using command:
workon < environment name>
Main commands for virtualenvwrapper:
mkvirtualenv <name>
Create a new virtualenv environment named <name>. The environment will be created in WORKON_HOME.
lsvirtualenv
List all of the environments stored in WORKON_HOME.
rmvirtualenv <name>
Remove the environment <name>. Uses folder_delete.bat.
workon [<name>]
If <name> is specified, activate the environment named <name> (change the working virtualenv to
<name>). If a project directory has been defined, we will change into it. If no argument is
specified, list the available environments. One can pass additional option -c after virtualenv name
to cd to virtualenv directory if no projectdir is set.
deactivate
Deactivate the working virtualenv and switch back to the default system Python.
add2virtualenv <full or relative path>
If a virtualenv environment is active, appends <path> to virtualenv_path_extensions.pth inside the
environment’s site-packages, which effectively adds <path> to the environment’s PYTHONPATH. If a
virtualenv environment is not active, appends <path> to virtualenv_path_extensions.pth inside the
default Python’s site-packages. If <path> doesn’t exist, it will be created.
GoalKicker.com – Python® Notes for Professionals
726Chapter 177: sys
The sys module provides access to functions and values concerning the program's runtime environment, such as
the command line parameters in sys.argv or the function sys.exit() to end the current process from any point in
the program ﬂow.
While cleanly separated into a module, it's actually built-in and as such will always be available under normal
circumstances.
Section 177.1: Command line arguments
if len(sys.argv) != 4:
# The script name needs to be accounted for as well.
raise RuntimeError("expected 3 command line arguments")
f = open(sys.argv[1], 'rb')
start_line = int(sys.argv[2])
end_line = int(sys.argv[3])
# Use first command line argument.
# All arguments come as strings, so need to be
# converted explicitly if other types are required.
Note that in larger and more polished programs you would use modules such as click to handle command line
arguments instead of doing it yourself.
Section 177.2: Script name
# The name of the executed script is at the beginning of the argv list.
print('usage:', sys.argv[0], '<filename> <start> <end>')
# You can use it to generate the path prefix of the executed program
# (as opposed to the current module) to access files relative to that,
# which would be good for assets of a game, for instance.
program_file = sys.argv[0]
import pathlib
program_path = pathlib.Path(program_file).resolve().parent
Section 177.3: Standard error stream
# Error messages should not go to standard output, if possible.
print('ERROR: We have no cheese at all.', file=sys.stderr)
try:
f = open('nonexistent-file.xyz', 'rb')
except OSError as e:
print(e, file=sys.stderr)
Section 177.4: Ending the process prematurely and returning
an exit code
def main():
if len(sys.argv) != 4 or '--help' in sys.argv[1:]:
print('usage: my_program <arg1> <arg2> <arg3>', file=sys.stderr)
sys.exit(1)
# use an exit code to signal the program was unsuccessful
process_data()
GoalKicker.com – Python® Notes for Professionals
727Chapter 178: ChemPy - python package
ChemPy is a python package designed mainly to solve and address problems in physical, analytical and inorganic
Chemistry. It is a free, open-source Python toolkit for chemistry, chemical engineering, and materials science
applications.
Section 178.1: Parsing formulae
from chempy import Substance
ferricyanide = Substance.from_formula('Fe(CN)6-3')
ferricyanide.composition == {0: -3, 26: 1, 6: 6, 7: 6}
True
print(ferricyanide.unicode_name)
Fe(CN)₆³⁻
print(ferricyanide.latex_name + ", " + ferricyanide.html_name)
Fe(CN)_{6}^{3-}, Fe(CN)<sub>6</sub><sup>3-</sup>
print('%.3f' % ferricyanide.mass)
211.955
In composition, the atomic numbers (and 0 for charge) is used as keys and the count of each kind became
respective value.
Section 178.2: Balancing stoichiometry of a chemical reaction
from chempy import balance_stoichiometry # Main reaction in NASA's booster rockets:
reac, prod = balance_stoichiometry({'NH4ClO4', 'Al'}, {'Al2O3', 'HCl', 'H2O', 'N2'})
from pprint import pprint
pprint(reac)
{'Al': 10, 'NH4ClO4': 6}
pprint(prod)
{'Al2O3': 5, 'H2O': 9, 'HCl': 6, 'N2': 3}
from chempy import mass_fractions
for fractions in map(mass_fractions, [reac, prod]):
...
pprint({k: '{0:.3g} wt%'.format(v*100) for k, v in fractions.items()})
...
{'Al': '27.7 wt%', 'NH4ClO4': '72.3 wt%'}
{'Al2O3': '52.3 wt%', 'H2O': '16.6 wt%', 'HCl': '22.4 wt%', 'N2': '8.62 wt%'}
Section 178.3: Balancing reactions
from chempy import Equilibrium
from sympy import symbols
K1, K2, Kw = symbols('K1 K2 Kw')
e1 = Equilibrium({'MnO4-': 1, 'H+': 8, 'e-': 5}, {'Mn+2': 1, 'H2O': 4}, K1)
e2 = Equilibrium({'O2': 1, 'H2O': 2, 'e-': 4}, {'OH-': 4}, K2)
coeff = Equilibrium.eliminate([e1, e2], 'e-')
coeff
[4, -5]
redox = e1*coeff[0] + e2*coeff[1]
print(redox)
20 OH- + 32 H+ + 4 MnO4- = 26 H2O + 4 Mn+2 + 5 O2; K1**4/K2**5
autoprot = Equilibrium({'H2O': 1}, {'H+': 1, 'OH-': 1}, Kw)
n = redox.cancel(autoprot)
n
20
redox2 = redox + n*autoprot
print(redox2)
GoalKicker.com – Python® Notes for Professionals
72812 H+ + 4 MnO4- = 4 Mn+2 + 5 O2 + 6 H2O; K1**4*Kw**20/K2**5
Section 178.4: Chemical equilibria
from chempy import Equilibrium
from chempy.chemistry import Species
water_autop = Equilibrium({'H2O'}, {'H+', 'OH-'}, 10**-14) # unit "molar" assumed
ammonia_prot = Equilibrium({'NH4+'}, {'NH3', 'H+'}, 10**-9.24) # same here
from chempy.equilibria import EqSystem
substances = map(Species.from_formula, 'H2O OH- H+ NH3 NH4+'.split())
eqsys = EqSystem([water_autop, ammonia_prot], substances)
print('\n'.join(map(str, eqsys.rxns))) # "rxns" short for "reactions"
H2O = H+ + OH-; 1e-14
NH4+ = H+ + NH3; 5.75e-10
from collections import defaultdict
init_conc = defaultdict(float, {'H2O': 1, 'NH3': 0.1})
x, sol, sane = eqsys.root(init_conc)
assert sol['success'] and sane
print(sorted(sol.keys())) # see package "pyneqsys" for more info
['fun', 'intermediate_info', 'internal_x_vecs', 'nfev', 'njev', 'success', 'x', 'x_vecs']
print(', '.join('%.2g' % v for v in x))
1, 0.0013, 7.6e-12, 0.099, 0.0013
Section 178.5: Ionic strength
from chempy.electrolytes import ionic_strength
ionic_strength({'Fe+3': 0.050, 'ClO4-': 0.150}) == .3
True
Section 178.6: Chemical kinetics (system of ordinary
dierential equations)
from chempy import ReactionSystem # The rate constants below are arbitrary
rsys = ReactionSystem.from_string("""2 Fe+2 + H2O2 -> 2 Fe+3 + 2 OH-; 42
2 Fe+3 + H2O2 -> 2 Fe+2 + O2 + 2 H+; 17
H+ + OH- -> H2O; 1e10
H2O -> H+ + OH-; 1e-4
Fe+3 + 2 H2O -> FeOOH(s) + 3 H+; 1
FeOOH(s) + 3 H+ -> Fe+3 + 2 H2O; 2.5""") # "[H2O]" = 1.0 (actually 55.4 at RT)
from chempy.kinetics.ode import get_odesys
odesys, extra = get_odesys(rsys)
from collections import defaultdict
import numpy as np
tout = sorted(np.concatenate((np.linspace(0, 23), np.logspace(-8, 1))))
c0 = defaultdict(float, {'Fe+2': 0.05, 'H2O2': 0.1, 'H2O': 1.0, 'H+': 1e-7, 'OH-': 1e-7})
result = odesys.integrate(tout, c0, atol=1e-12, rtol=1e-14)
import matplotlib.pyplot as plt
_ = plt.subplot(1, 2, 1)
_ = result.plot(names=[k for k in rsys.substances if k != 'H2O'])
_ = plt.legend(loc='best', prop={'size': 9}); _ = plt.xlabel('Time'); _ =
plt.ylabel('Concentration')
_ = plt.subplot(1, 2, 2)
_ = result.plot(names=[k for k in rsys.substances if k != 'H2O'], xscale='log', yscale='log')
_ = plt.legend(loc='best', prop={'size': 9}); _ = plt.xlabel('Time'); _ =
plt.ylabel('Concentration')
_ = plt.tight_layout()
plt.show()
GoalKicker.com – Python® Notes for Professionals
729GoalKicker.com – Python® Notes for Professionals
730Chapter 179: pygame
Parameter
Details
count
A positive integer that represents something like the number of channels needed to be reserved.
force
A boolean value (False or True) that determines whether find_channel() has to return a channel
(inactive or not) with True or not (if there are no inactive channels) with False
Pygame is the go-to library for making multimedia applications, especially games, in Python. The oﬃcial website is
http://www.pygame.org/.
Section 179.1: Pygame's mixer module
The pygame.mixer module helps control the music used in pygame programs. As of now, there are 15 diﬀerent
functions for the mixer module.
Initializing
Similar to how you have to initialize pygame with pygame.init(), you must initialize pygame.mixer as well.
By using the ﬁrst option, we initialize the module using the default values. You can though, override these default
options. By using the second option, we can initialize the module using the values we manually put in ourselves.
Standard values:
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
To check whether we have initialized it or not, we can use pygame.mixer.get_init(), which returns True if it is and
False if it is not. To quit/undo the initializing, simply use pygame.mixer.quit(). If you want to continue playing
sounds with the module, you might have to reinitialize the module.
Possible Actions
As your sound is playing, you can pause it temporarily with pygame.mixer.pause(). To resume playing your sounds,
simply use pygame.mixer.unpause(). You can also fadeout the end of the sound by using
pygame.mixer.fadeout(). It takes an argument, which is the number of milliseconds it takes to ﬁnish fading out the
music.
Channels
You can play as many songs as needed as long there are enough open channels to support them. By default, there
are 8 channels. To change the number of channels there are, use pygame.mixer.set_num_channels(). The
argument is a non-negative integer. If the number of channels are decreased, any sounds playing on the removed
channels will immediately stop.
To ﬁnd how many channels are currently being used, call pygame.mixer.get_channels(count). The output is the
number of channels that are not currently open. You can also reserve channels for sounds that must be played by
using pygame.mixer.set_reserved(count). The argument is also a non-negative integer. Any sounds playing on the
newly reserved channels will not be stopped.
You can also ﬁnd out which channel isn't being used by using pygame.mixer.find_channel(force). Its argument is
a bool: either True or False. If there are no channels that are idle and force is False, it will return None. If force is
true, it will return the channel that has been playing for the longest time.
GoalKicker.com – Python® Notes for Professionals
731Section 179.2: Installing pygame
With pip:
pip install pygame
With conda:
conda install -c tlatorre pygame=1.9.2
Direct download from website : http://www.pygame.org/download.shtml
You can ﬁnd the suitable installers for Windows and other operating systems.
Projects can also be found at http://www.pygame.org/
GoalKicker.com – Python® Notes for Professionals
732VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 180: Pyglet
Pyglet is a Python module used for visuals and sound. It has no dependencies on other modules. See [pyglet.org][1]
for the oﬃcial information. [1]: http://pyglet.org
Section 180.1: Installation of Pyglet
Install Python, go into the command line and type:
Python 2:
pip install pyglet
Python 3:
pip3 install pyglet
Section 180.2: Hello World in Pyglet
import pyglet
window = pyglet.window.Window()
label = pyglet.text.Label('Hello, world',
font_name='Times New Roman',
font_size=36,
x=window.width//2, y=window.height//2,
anchor_x='center', anchor_y='center')
@window.event
def on_draw():
window.clear()
label.draw()
pyglet.app.run()
Section 180.3: Playing Sound in Pyglet
sound = pyglet.media.load(sound.wav)
sound.play()
Section 180.4: Using Pyglet for OpenGL
import pyglet
from pyglet.gl import *
win = pyglet.window.Window()
@win.event()
def on_draw():
#OpenGL goes here. Use OpenGL as normal.
pyglet.app.run()
Section 180.5: Drawing Points Using Pyglet and OpenGL
import pyglet
from pyglet.gl import *
GoalKicker.com – Python® Notes for Professionals
734win = pyglet.window.Window()
glClear(GL_COLOR_BUFFER_BIT)
@win.event
def on_draw():
glBegin(GL_POINTS)
glVertex2f(x, y) #x is desired distance from left side of window, y is desired distance from
bottom of window
#make as many vertexes as you want
glEnd
To connect the points, replace GL_POINTS with GL_LINE_LOOP.
GoalKicker.com – Python® Notes for Professionals
735Chapter 181: Audio
Section 181.1: Working with WAV ﬁles
winsound
Windows environment
import winsound
winsound.PlaySound("path_to_wav_file.wav", winsound.SND_FILENAME)
wave
Support mono/stereo
Doesn't support compression/decompression
import wave
with wave.open("path_to_wav_file.wav", "rb") as wav_file:
# Open WAV file in read-only mode.
# Get basic information.
n_channels = wav_file.getnchannels()
# Number of channels. (1=Mono, 2=Stereo).
sample_width = wav_file.getsampwidth()
# Sample width in bytes.
framerate = wav_file.getframerate()
# Frame rate.
n_frames = wav_file.getnframes()
# Number of frames.
comp_type = wav_file.getcomptype()
# Compression type (only supports "NONE").
comp_name = wav_file.getcompname()
# Compression name.
# Read audio data.
frames = wav_file.readframes(n_frames)
# Read n_frames new frames.
assert len(frames) == sample_width * n_frames
# Duplicate to a new WAV file.
with wave.open("path_to_new_wav_file.wav", "wb") as wav_file:
# Open WAV file in write-only
mode.
# Write audio data.
params = (n_channels, sample_width, framerate, n_frames, comp_type, comp_name)
wav_file.setparams(params)
wav_file.writeframes(frames)
Section 181.2: Convert any soundﬁle with python and mpeg
from subprocess import check_call
ok = check_call(['ffmpeg','-i','input.mp3','output.wav'])
if ok:
with open('output.wav', 'rb') as f:
wav_file = f.read()
note:
http://superuser.com/questions/507386/why-would-i-choose-libav-over-ﬀmpeg-or-is-there-even-a-diﬀerence
What are the diﬀerences and similarities between ﬀmpeg, libav, and avconv?
Section 181.3: Playing Windows' beeps
Windows provides an explicit interface through which the winsound module allows you to play raw beeps at a given
frequency and duration.
import winsound
GoalKicker.com – Python® Notes for Professionals
736freq = 2500 # Set frequency To 2500 Hertz
dur = 1000 # Set duration To 1000 ms == 1 second
winsound.Beep(freq, dur)
Section 181.4: Audio With Pyglet
import pyglet
audio = pyglet.media.load("audio.wav")
audio.play()
For further information, see pyglet
GoalKicker.com – Python® Notes for Professionals
737Chapter 182: pyaudio
PyAudio provides Python bindings for PortAudio, the cross-platform audio I/O library. With PyAudio, you can easily
use Python to play and record audio on a variety of platforms. PyAudio is inspired by:
1.pyPortAudio/fastaudio: Python bindings for PortAudio v18 API.
2.tkSnack: cross-platform sound toolkit for Tcl/Tk and Python.
Section 182.1: Callback Mode Audio I/O
"""PyAudio Example: Play a wave file (callback version)."""
import pyaudio
import wave
import time
import sys
if len(sys.argv) < 2:
print("Plays a wave file.\n\nUsage: %s filename.wav" % sys.argv[0])
sys.exit(-1)
wf = wave.open(sys.argv[1], 'rb')
# instantiate PyAudio (1)
p = pyaudio.PyAudio()
# define callback (2)
def callback(in_data, frame_count, time_info, status):
data = wf.readframes(frame_count)
return (data, pyaudio.paContinue)
# open stream using callback (3)
stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
channels=wf.getnchannels(),
rate=wf.getframerate(),
output=True,
stream_callback=callback)
# start the stream (4)
stream.start_stream()
# wait for stream to finish (5)
while stream.is_active():
time.sleep(0.1)
# stop stream (6)
stream.stop_stream()
stream.close()
wf.close()
# close PyAudio (7)
p.terminate()
In callback mode, PyAudio will call a speciﬁed callback function (2) whenever it needs new audio data (to play)
and/or when there is new (recorded) audio data available. Note that PyAudio calls the callback function in a
separate thread. The function has the following signature callback(<input_data>, <frame_count>,
<time_info>, <status_flag>) and must return a tuple containing frame_count frames of audio data and a ﬂag
GoalKicker.com – Python® Notes for Professionals
738signifying whether there are more frames to play/record.
Start processing the audio stream using pyaudio.Stream.start_stream() (4), which will call the callback function
repeatedly until that function returns pyaudio.paComplete.
To keep the stream active, the main thread must not terminate, e.g., by sleeping (5).
Section 182.2: Blocking Mode Audio I/O
"""PyAudio Example: Play a wave ﬁle."""
import pyaudio
import wave
import sys
CHUNK = 1024
if len(sys.argv) < 2:
print("Plays a wave file.\n\nUsage: %s filename.wav" % sys.argv[0])
sys.exit(-1)
wf = wave.open(sys.argv[1], 'rb')
# instantiate PyAudio (1)
p = pyaudio.PyAudio()
# open stream (2)
stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
channels=wf.getnchannels(),
rate=wf.getframerate(),
output=True)
# read data
data = wf.readframes(CHUNK)
# play stream (3)
while len(data) > 0:
stream.write(data)
data = wf.readframes(CHUNK)
# stop stream (4)
stream.stop_stream()
stream.close()
# close PyAudio (5)
p.terminate()
To use PyAudio, ﬁrst instantiate PyAudio using pyaudio.PyAudio() (1), which sets up the portaudio system.
To record or play audio, open a stream on the desired device with the desired audio parameters using
pyaudio.PyAudio.open() (2). This sets up a pyaudio.Stream to play or record audio.
Play audio by writing audio data to the stream using pyaudio.Stream.write(), or read audio data from the stream
using pyaudio.Stream.read(). (3)
Note that in “blocking mode”, each pyaudio.Stream.write() or pyaudio.Stream.read() blocks until all the
given/requested frames have been played/recorded. Alternatively, to generate audio data on the ﬂy or immediately
process recorded audio data, use the “callback mode”(refer the example on call back mode)
GoalKicker.com – Python® Notes for Professionals
739Use pyaudio.Stream.stop_stream() to pause playing/recording, and pyaudio.Stream.close() to terminate the
stream. (4)
Finally, terminate the portaudio session using pyaudio.PyAudio.terminate() (5)
GoalKicker.com – Python® Notes for Professionals
740Chapter 183: shelve
Shelve is a python module used to store objects in a ﬁle. The shelve module implements persistent storage for
arbitrary Python objects which can be pickled, using a dictionary-like API. The shelve module can be used as a
simple persistent storage option for Python objects when a relational database is overkill. The shelf is accessed by
keys, just as with a dictionary. The values are pickled and written to a database created and managed by anydbm.
Section 183.1: Creating a new Shelf
The simplest way to use shelve is via the DbﬁlenameShelf class. It uses anydbm to store the data. You can use the
class directly, or simply call shelve.open():
import shelve
s = shelve.open('test_shelf.db')
try:
s['key1'] = { 'int': 10, 'float':9.5, 'string':'Sample data' }
finally:
s.close()
To access the data again, open the shelf and use it like a dictionary:
import shelve
s = shelve.open('test_shelf.db')
try:
existing = s['key1']
finally:
s.close()
print existing
If you run both sample scripts, you should see:
$ python shelve_create.py
$ python shelve_existing.py
{'int': 10, 'float': 9.5, 'string': 'Sample data'}
The dbm module does not support multiple applications writing to the same database at the same time. If you
know your client will not be modifying the shelf, you can tell shelve to open the database read-only.
import shelve
s = shelve.open('test_shelf.db', flag='r')
try:
existing = s['key1']
finally:
s.close()
print existing
If your program tries to modify the database while it is opened read-only, an access error exception is generated.
The exception type depends on the database module selected by anydbm when the database was created.
GoalKicker.com – Python® Notes for Professionals
741Section 183.2: Sample code for shelve
To shelve an object, ﬁrst import the module and then assign the object value as follows:
import shelve
database = shelve.open(filename.suffix)
object = Object()
database['key'] = object
Section 183.3: To summarize the interface (key is a string,
data is an arbitrary object):
import shelve
d = shelve.open(filename)# open -- file may get suffix added by low-level
# library
d[key] = data# store data at key (overwrites old data if
# using an existing key)
# retrieve a COPY of data at key (raise KeyError
# if no such key)
# delete data stored at key (raises KeyError
# if no such key)
data = d[key]
del d[key]
flag = key in d
klist = list(d.keys())
# true if the key exists
# a list of all existing keys (slow!)
# as d was opened WITHOUT writeback=True, beware:
d['xx'] = [0, 1, 2]
# this works as expected, but...
d['xx'].append(3)
# *this doesn't!* -- d['xx'] is STILL [0, 1, 2]!
# having opened d without writeback=True, you need to code carefully:
temp = d['xx']
# extracts the copy
temp.append(5)
# mutates the copy
d['xx'] = temp
# stores the copy right back, to persist it
# or, d=shelve.open(filename,writeback=True) would let you just code
# d['xx'].append(5) and have it work as expected, BUT it would also
# consume more memory and make the d.close() operation slower.
d.close()
# close it
Section 183.4: Write-back
Shelves do not track modiﬁcations to volatile objects, by default. That means if you change the contents of an item
stored in the shelf, you must update the shelf explicitly by storing the item again.
import shelve
s = shelve.open('test_shelf.db')
try:
print s['key1']
s['key1']['new_value'] = 'this was not here before'
finally:
s.close()
s = shelve.open('test_shelf.db', writeback=True)
try:
GoalKicker.com – Python® Notes for Professionals
742print s['key1']
finally:
s.close()
In this example, the dictionary at ‘key1’ is not stored again, so when the shelf is re-opened, the changes have not
been preserved.
$ python shelve_create.py
$ python shelve_withoutwriteback.py
{'int': 10, 'float': 9.5, 'string': 'Sample data'}
{'int': 10, 'float': 9.5, 'string': 'Sample data'}
To automatically catch changes to volatile objects stored in the shelf, open the shelf with writeback enabled. The
writeback ﬂag causes the shelf to remember all of the objects retrieved from the database using an in-memory
cache. Each cache object is also written back to the database when the shelf is closed.
import shelve
s = shelve.open('test_shelf.db', writeback=True)
try:
print s['key1']
s['key1']['new_value'] = 'this was not here before'
print s['key1']
finally:
s.close()
s = shelve.open('test_shelf.db', writeback=True)
try:
print s['key1']
finally:
s.close()
Although it reduces the chance of programmer error, and can make object persistence more transparent, using
writeback mode may not be desirable in every situation. The cache consumes extra memory while the shelf is open,
and pausing to write every cached object back to the database when it is closed can take extra time. Since there is
no way to tell if the cached objects have been modiﬁed, they are all written back. If your application reads data
more than it writes, writeback will add more overhead than you might want.
$ python shelve_create.py
$ python shelve_writeback.py
{'int': 10, 'float': 9.5, 'string': 'Sample data'}
{'int': 10, 'new_value': 'this was not here before', 'float': 9.5, 'string': 'Sample data'}
{'int': 10, 'new_value': 'this was not here before', 'float': 9.5, 'string': 'Sample data'}
GoalKicker.com – Python® Notes for Professionals
743Chapter 184: IoT Programming with
Python and Raspberry PI
Section 184.1: Example - Temperature sensor
Interfacing of DS18B20 with Raspberry pi
Connection of DS18B20 with Raspberry pi
You can see there are three terminal
1. Vcc
2. Gnd
3. Data (One wire protocol)
R1 is 4.7k ohm resistance for pulling up the voltage level
1. Vcc should be connected to any of the 5v or 3.3v pins of Raspberry pi (PIN : 01, 02, 04, 17).
2. Gnd should be connected to any of the Gnd pins of Raspberry pi (PIN : 06, 09, 14, 20, 25).
GoalKicker.com – Python® Notes for Professionals
7443. DATA should be connected to (PIN : 07)
Enabling the one-wire interface from the RPi side
4. Login to Raspberry pi using putty or any other linux/unix terminal.
5. After login, open the /boot/conﬁg.txt ﬁle in your favourite browser.
nano /boot/conﬁg.txt
6. Now add the this line dtoverlay=w1–gpio to the end of the ﬁle.
7. Now reboot the Raspberry pi sudo reboot.
8. Log in to Raspberry pi, and run sudo modprobe g1-gpio
9. Then run sudo modprobe w1-therm
10. Now go to the directory /sys/bus/w1/devices cd /sys/bus/w1/devices
11. Now you will found out a virtual directory created of your temperature sensor starting from 28-********.
12. Go to this directory cd 28-********
13. Now there is a ﬁle name w1-slave, This ﬁle contains the temperature and other information like CRC. cat
w1-slave.
Now write a module in python to read the temperature
import glob
import time
RATE = 30
sensor_dirs = glob.glob("/sys/bus/w1/devices/28*")
if len(sensor_dirs) != 0:
while True:
time.sleep(RATE)
for directories in sensor_dirs:
temperature_file = open(directories + "/w1_slave")
# Reading the files
text = temperature_file.read()
temperature_file.close()
# Split the text with new lines (\n) and select the second line.
second_line = text.split("\n")[1]
# Split the line into words, and select the 10th word
temperature_data = second_line.split(" ")[9]
# We will read after ignoring first two character.
temperature = float(temperature_data[2:])
# Now normalise the temperature by dividing 1000.
temperature = temperature / 1000
print 'Address : '+str(directories.split('/')[-1])+', Temperature : '+str(temperature)
Above python module will print the temperature vs address for inﬁnite time. RATE parameter is deﬁned to change
or adjust the frequency of temperature query from the sensor.
GPIO pin diagram
1. [https://www.element14.com/community/servlet/JiveServlet/previewBody/73950-102-11-339300/pi3_gpio.pn
GoalKicker.com – Python® Notes for Professionals
745g][3]
GoalKicker.com – Python® Notes for Professionals
746VIDEO: Complete Python
Bootcamp: Go from zero
to hero in Python 3
Learn Python like a Professional! Start from the
basics and go all the way to creating your own
applications and games!
✔ Learn to use Python professionally, learning both Python 2 and Python 3!
✔ Create games with Python, like Tic Tac Toe and Blackjack!
✔ Learn advanced Python features, like the collections module and how to work with timestamps!
✔ Learn to use Object Oriented Programming with classes!
✔ Understand complex topics, like decorators.
✔ Understand how to use both the Jupyter Notebook and create .py ﬁles
✔ Get an understanding of how to create GUIs in the Jupyter Notebook system!
✔ Build a complete understanding of Python from the ground up!
Watch Today →Chapter 185: kivy - Cross-platform Python
Framework for NUI Development
NUI : A natural user interface (NUI) is a system for human-computer interaction that the user operates through
intuitive actions related to natural, everyday human behavior.
Kivy is a Python library for development of multi-touch enabled media rich applications which can be installed on
diﬀerent devices. Multi-touch refers to the ability of a touch-sensing surface (usually a touch screen or a trackpad)
to detect or sense input from two or more points of contact simultaneously.
Section 185.1: First App
To create an kivy application
1. sub class the app class
2. Implement the build method, which will return the widget.
3. Instantiate the class an invoke the run.
from kivy.app import App
from kivy.uix.label import Label
class Test(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
Test().run()
Explanation
from kivy.app import App
The above statement will import the parent class app. This will be present in your installation directory
your_installtion_directory/kivy/app.py
from kivy.uix.label import Label
The above statement will import the ux element Label. All the ux element are present in your installation directory
your_installation_directory/kivy/uix/.
class Test(App):
The above statement is for to create your app and class name will be your app name. This class is inherited the
parent app class.
def build(self):
The above statement override the build method of app class. Which will return the widget that needs to be shown
when you will start the app.
return Label(text='Hello world')
The above statement is the body of the build method. It is returning the Label with its text Hello world.
GoalKicker.com – Python® Notes for Professionals
748if __name__ == '__main__':
The above statement is the entry point from where python interpreter start executing your app.
Test().run()
The above statement Initialise your Test class by creating its instance. And invoke the app class function run().
Your app will look like the below picture.
GoalKicker.com – Python® Notes for Professionals
749Chapter 186: Pandas Transform: Preform
operations on groups and concatenate the
results
Section 186.1: Simple transform
First, Let's create a dummy dataframe
We assume that a customer can have n orders, an order can have m items, and items can be ordered more
multiple times
orders_df = pd.DataFrame()
orders_df['customer_id'] = [1,1,1,1,1,2,2,3,3,3,3,3]
orders_df['order_id'] = [1,1,1,2,2,3,3,4,5,6,6,6]
orders_df['item'] = ['apples', 'chocolate', 'chocolate', 'coffee', 'coffee', 'apples',
'bananas', 'coffee', 'milkshake', 'chocolate', 'strawberry', 'strawberry']
# And this is how the dataframe looks like:
print(orders_df)
#
customer_id order_id
item
# 0
1
1
apples
# 1
1
1
chocolate
# 2
1
1
chocolate
# 3
1
2
coffee
# 4
1
2
coffee
# 5
2
3
apples
# 6
2
3
bananas
# 7
3
4
coffee
# 8
3
5
milkshake
# 9
3
6
chocolate
# 10
3
6 strawberry
# 11
3
6 strawberry
.
.
Now, we will use pandas transform function to count the number of orders per customer
# First, we define the function that will be applied per customer_id
count_number_of_orders = lambda x: len(x.unique())
# And now, we can transform each group using the logic defined above
orders_df['number_of_orders_per_cient'] = (
# Put the results into a new column that
is called 'number_of_orders_per_cient'
orders_df
# Take the original dataframe
.groupby(['customer_id'])['order_id'] # Create a separate group for each
customer_id & select the order_id
.transform(count_number_of_orders))
# Apply the function to each group
separately
# Inspecting the results ...
print(orders_df)
#
customer_id order_id
# 0
1
1
# 1
1
1
# 2
1
1
# 3
1
2
# 4
1
2
item
apples
chocolate
chocolate
coffee
coffee
number_of_orders_per_cient
2
2
2
2
2
GoalKicker.com – Python® Notes for Professionals
750# 5
# 6
# 7
# 8
# 9
# 10
# 11
2
2
3
3
3
3
3
3
3
4
5
6
6
6
apples
bananas
coffee
milkshake
chocolate
strawberry
strawberry
1
1
3
3
3
3
3
Section 186.2: Multiple results per group
Using transform functions that return sub-calculations per group
In the previous example, we had one result per client. However, functions returning diﬀerent values for the group
can also be applied.
# Create a dummy dataframe
orders_df = pd.DataFrame()
orders_df['customer_id'] = [1,1,1,1,1,2,2,3,3,3,3,3]
orders_df['order_id'] = [1,1,1,2,2,3,3,4,5,6,6,6]
orders_df['item'] = ['apples', 'chocolate', 'chocolate', 'coffee', 'coffee', 'apples',
'bananas', 'coffee', 'milkshake', 'chocolate', 'strawberry', 'strawberry']
# Let's try to see if the items were ordered more than once in each orders
# First, we define a function that will be applied per group
def multiple_items_per_order(_items):
# Apply .duplicated, which will return True is the item occurs more than once.
multiple_item_bool = _items.duplicated(keep=False)
return(multiple_item_bool)
# Then, we transform each group according to the defined function
orders_df['item_duplicated_per_order'] = (
# Put the results into a new column
orders_df
# Take the orders dataframe
.groupby(['order_id'])['item']
# Create a separate group for each
order_id & select the item
.transform(multiple_items_per_order)) # Apply the defined function to each
group separately
# Inspecting the results ...
print(orders_df)
#
customer_id order_id
item
# 0
1
1
apples
# 1
1
1
chocolate
# 2
1
1
chocolate
# 3
1
2
coffee
# 4
1
2
coffee
# 5
2
3
apples
# 6
2
3
bananas
# 7
3
4
coffee
# 8
3
5
milkshake
# 9
3
6
chocolate
# 10
3
6 strawberry
# 11
3
6 strawberry
item_duplicated_per_order
False
True
True
True
True
False
False
False
False
False
True
True
GoalKicker.com – Python® Notes for Professionals
751Chapter 187: Similarities in syntax,
Dierences in meaning: Python vs.
JavaScript
It sometimes happens that two languages put diﬀerent meanings on the same or similar syntax expression. When
the both languages are of interest for a programmer, clarifying these bifurcation points helps to better understand
the both languages in their basics and subtleties.
Section 187.1: `in` with lists
2 in [2, 3]
In Python this evaluates to True, but in JavaScript to false. This is because in Python in checks if a value is contained
in a list, so 2 is in [2, 3] as its ﬁrst element. In JavaScript in is used with objects and checks if an object contains the
property with the name expressed by the value. So JavaScript considers [2, 3] as an object or a key-value map like
this:
{'0': 2, '1': 3}
and checks if it has a property or a key '2' in it. Integer 2 is silently converted to string '2'.
GoalKicker.com – Python® Notes for Professionals
752Chapter 188: Call Python from C#
The documentation provides a sample implementation of the inter-process communication between C# and
Python scripts.
Section 188.1: Python script to be called by C# application
import sys
import json
# load input arguments from the text file
filename = sys.argv[ 1 ]
with open( filename ) as data_file:
input_args = json.loads( data_file.read() )
# cast strings to floats
x, y = [ float(input_args.get( key )) for key in [ 'x', 'y' ] ]
print json.dumps( { 'sum' : x + y , 'subtract' : x - y } )
Section 188.2: C# code calling Python script
using MongoDB.Bson;
using System;
using System.Diagnostics;
using System.IO;
namespace python_csharp
{
class Program
{
static void Main(string[] args)
{
// full path to .py file
string pyScriptPath = "...../sum.py";
// convert input arguments to JSON string
BsonDocument argsBson = BsonDocument.Parse("{ 'x' : '1', 'y' : '2' }");
bool saveInputFile = false;
string argsFile = string.Format("{0}\\{1}.txt", Path.GetDirectoryName(pyScriptPath),
Guid.NewGuid());
string outputString = null;
// create new process start info
ProcessStartInfo prcStartInfo = new ProcessStartInfo
{
// full path of the Python interpreter 'python.exe'
FileName = "python.exe", // string.Format(@"""{0}""", "python.exe"),
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = false
};
try
{
// write input arguments to .txt file
using (StreamWriter sw = new StreamWriter(argsFile))
GoalKicker.com – Python® Notes for Professionals
753{
sw.WriteLine(argsBson);
prcStartInfo.Arguments = string.Format("{0} {1}", string.Format(@"""{0}""",
pyScriptPath), string.Format(@"""{0}""", argsFile));
}
// start process
using (Process process = Process.Start(prcStartInfo))
{
// read standard output JSON string
using (StreamReader myStreamReader = process.StandardOutput)
{
outputString = myStreamReader.ReadLine();
process.WaitForExit();
}
}
}
finally
{
// delete/save temporary .txt file
if (!saveInputFile)
{
File.Delete(argsFile);
}
}
Console.WriteLine(outputString);
}
}
}
GoalKicker.com – Python® Notes for Professionals
754Chapter 189: ctypes
ctypes is a python built-in library that invokes exported functions from native compiled libraries.
Note: Since this library handles compiled code, it is relatively OS dependent.
Section 189.1: ctypes arrays
As any good C programmer knows, a single value won't get you that far. What will really get us going are arrays!
>>> c_int * 16
<class '__main__.c_long_Array_16'>
This is not an actual array, but it's pretty darn close! We created a class that denotes an array of 16 ints.
Now all we need to do is to initialize it:
>>> arr = (c_int * 16)(*range(16))
>>> arr
<__main__.c_long_Array_16 object at 0xbaddcafe>
Now arr is an actual array that contains the numbers from 0 to 15.
They can be accessed just like any list:
>>> arr[5]
5
>>> arr[5] = 20
>>> arr[5]
20
And just like any other ctypes object, it also has a size and a location:
>>> sizeof(arr)
64 # sizeof(c_int) * 16
>>> hex(addressof(arr))
'0xc000l0ff'
Section 189.2: Wrapping functions for ctypes
In some cases, a C function accepts a function pointer. As avid ctypes users, we would like to use those functions,
and even pass python function as arguments.
Let's deﬁne a function:
>>> def max(x, y):
return x if x >= y else y
Now, that function takes two arguments and returns a result of the same type. For the sake of the example, let's
assume that type is an int.
Like we did on the array example, we can deﬁne an object that denotes that prototype:
>>> CFUNCTYPE(c_int, c_int, c_int)
GoalKicker.com – Python® Notes for Professionals
755<CFunctionType object at 0xdeadbeef>
That prototype denotes a function that returns an c_int (the ﬁrst argument), and accepts two c_int arguments
(the other arguments).
Now let's wrap the function:
>>> CFUNCTYPE(c_int, c_int, c_int)(max)
<CFunctionType object at 0xdeadbeef>
Function prototypes have on more usage: They can wrap ctypes function (like libc.ntohl) and verify that the
correct arguments are used when invoking the function.
>>> libc.ntohl() # garbage in - garbage out
>>> CFUNCTYPE(c_int, c_int)(libc.ntohl)()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: this function takes at least 1 argument (0 given)
Section 189.3: Basic usage
Let's say we want to use libc's ntohl function.
First, we must load libc.so:
>>> from ctypes import *
>>> libc = cdll.LoadLibrary('libc.so.6')
>>> libc
<CDLL 'libc.so.6', handle baadf00d at 0xdeadbeef>
Then, we get the function object:
>>> ntohl = libc.ntohl
>>> ntohl
<_FuncPtr object at 0xbaadf00d>
And now, we can simply invoke the function:
>>> ntohl(0x6C)
1811939328
>>> hex(_)
'0x6c000000'
Which does exactly what we expect it to do.
Section 189.4: Common pitfalls
Failing to load a ﬁle
The ﬁrst possible error is failing to load the library. In that case an OSError is usually raised.
This is either because the ﬁle doesn't exists (or can't be found by the OS):
>>> cdll.LoadLibrary("foobar.so")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
GoalKicker.com – Python® Notes for Professionals
756File "/usr/lib/python3.5/ctypes/__init__.py", line 425, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: foobar.so: cannot open shared object file: No such file or directory
As you can see, the error is clear and pretty indicative.
The second reason is that the ﬁle is found, but is not of the correct format.
>>> cdll.LoadLibrary("libc.so")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/ctypes/__init__.py", line 425, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/i386-linux-gnu/libc.so: invalid ELF header
In this case, the ﬁle is a script ﬁle and not a .so ﬁle. This might also happen when trying to open a .dll ﬁle on a
Linux machine or a 64bit ﬁle on a 32bit python interpreter. As you can see, in this case the error is a bit more vague,
and requires some digging around.
Failing to access a function
Assuming we successfully loaded the .so ﬁle, we then need to access our function like we've done on the ﬁrst
example.
When a non-existing function is used, an AttributeError is raised:
>>> libc.foo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/ctypes/__init__.py", line 360, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python3.5/ctypes/__init__.py", line 365, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /lib/i386-linux-gnu/libc.so.6: undefined symbol: foo
Section 189.5: Basic ctypes object
The most basic object is an int:
>>> obj = ctypes.c_int(12)
>>> obj
c_long(12)
Now, obj refers to a chunk of memory containing the value 12.
That value can be accessed directly, and even modiﬁed:
>>> obj.value
12
>>> obj.value = 13
>>> obj
c_long(13)
GoalKicker.com – Python® Notes for Professionals
757Since obj refers to a chunk of memory, we can also ﬁnd out its size and location:
>>> sizeof(obj)
4
>>> hex(addressof(obj))
'0xdeadbeef'
Section 189.6: Complex usage
Let's combine all of the examples above into one complex scenario: using libc's lfind function.
For more details about the function, read the man page. I urge you to read it before going on.
First, we'll deﬁne the proper prototypes:
>>> compar_proto = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
>>> lfind_proto = CFUNCTYPE(c_void_p, c_void_p, c_void_p, POINTER(c_uint), c_uint, compar_proto)
Then, let's create the variables:
>>> key = c_int(12)
>>> arr = (c_int * 16)(*range(16))
>>> nmemb = c_uint(16)
And now we deﬁne the comparison function:
>>> def compar(x, y):
return x.contents.value - y.contents.value
Notice that x, and y are POINTER(c_int), so we need to dereference them and take their values in order to actually
compare the value stored in the memory.
Now we can combine everything together:
>>> lfind = lfind_proto(libc.lfind)
>>> ptr = lfind(byref(key), byref(arr), byref(nmemb), sizeof(c_int), compar_proto(compar))
ptr is the returned void pointer. If key wasn't found in arr, the value would be None, but in this case we got a valid
value.
Now we can convert it and access the value:
>>> cast(ptr, POINTER(c_int)).contents
c_long(12)
Also, we can see that ptr points to the correct value inside arr:
>>> addressof(arr) + 12 * sizeof(c_int) == ptr
True
GoalKicker.com – Python® Notes for Professionals
758VIDEO: Python for Data
Science and Machine
Learning Bootcamp
Learn how to use NumPy, Pandas, Seaborn,
Matplotlib , Plotly, Scikit-Learn , Machine Learning,
Tensorﬂow, and more!
✔ Use Python for Data Science and Machine Learning
✔ Use Spark for Big Data Analysis
✔ Implement Machine Learning Algorithms
✔ Learn to use NumPy for Numerical Data
✔ Learn to use Pandas for Data Analysis
✔ Learn to use Matplotlib for Python Plotting
✔ Learn to use Seaborn for statistical plots
✔ Use Plotly for interactive dynamic visualizations
✔ Use SciKit-Learn for Machine Learning Tasks
✔ K-Means Clustering
✔ Logistic Regression
✔ Linear Regression
✔ Random Forest and Decision Trees
✔ Neural Networks
✔ Support Vector Machines
Watch Today →Chapter 190: Writing extensions
Section 190.1: Hello World with C Extension
The following C source ﬁle (which we will call hello.c for demonstration purposes) produces an extension module
named hello that contains a single function greet():
#include <Python.h>
#include <stdio.h>
#if PY_MAJOR_VERSION >= 3
#define IS_PY3K
#endif
static PyObject *hello_greet(PyObject *self, PyObject *args)
{
const char *input;
if (!PyArg_ParseTuple(args, "s", &input)) {
return NULL;
}
printf("%s", input);
Py_RETURN_NONE;
}
static PyMethodDef HelloMethods[] = {
{ "greet", hello_greet, METH_VARARGS, "Greet the user" },
{ NULL, NULL, 0, NULL }
};
#ifdef IS_PY3K
static struct PyModuleDef hellomodule = {
PyModuleDef_HEAD_INIT, "hello", NULL, -1, HelloMethods
};
PyMODINIT_FUNC PyInit_hello(void)
{
return PyModule_Create(&hellomodule);
}
#else
PyMODINIT_FUNC inithello(void)
{
(void) Py_InitModule("hello", HelloMethods);
}
#endif
To compile the ﬁle with the gcc compiler, run the following command in your favourite terminal:
gcc /path/to/your/file/hello.c -o /path/to/your/file/hello
To execute the greet() function that we wrote earlier, create a ﬁle in the same directory, and call it hello.py
import hello
# imports the compiled library
hello.greet("Hello!") # runs the greet() function with "Hello!" as an argument
Section 190.2: C Extension Using c++ and Boost
This is a basic example of a C Extension using C++ and Boost.
GoalKicker.com – Python® Notes for Professionals
760C++ Code
C++ code put in hello.cpp:
#include <boost/python/module.hpp>
#include <boost/python/list.hpp>
#include <boost/python/class.hpp>
#include <boost/python/def.hpp>
// Return a hello world string.
std::string get_hello_function()
{
return "Hello world!";
}
// hello class that can return a list of count hello world strings.
class hello_class
{
public:
// Taking the greeting message in the constructor.
hello_class(std::string message) : _message(message) {}
// Returns the message count times in a python list.
boost::python::list as_list(int count)
{
boost::python::list res;
for (int i = 0; i < count; ++i) {
res.append(_message);
}
return res;
}
private:
std::string _message;
};
// Defining a python module naming it to "hello".
BOOST_PYTHON_MODULE(hello)
{
// Here you declare what functions and classes that should be exposed on the module.
// The get_hello_function exposed to python as a function.
boost::python::def("get_hello", get_hello_function);
// The hello_class exposed to python as a class.
boost::python::class_<hello_class>("Hello", boost::python::init<std::string>())
.def("as_list", &hello_class::as_list)
;
}
To compile this into a python module you will need the python headers and the boost libraries. This example was
made on Ubuntu 12.04 using python 3.4 and gcc. Boost is supported on many platforms. In case of Ubuntu the
needed packages was installed using:
sudo apt-get install gcc libboost-dev libpython3.4-dev
Compiling the source ﬁle into a .so-ﬁle that can later be imported as a module provided it is on the python path:
GoalKicker.com – Python® Notes for Professionals
761gcc -shared -o hello.so -fPIC -I/usr/include/python3.4 hello.cpp -lboost_python-py34 -lboost_system
-l:libpython3.4m.so
The python code in the ﬁle example.py:
import hello
print(hello.get_hello())
h = hello.Hello("World hello!")
print(h.as_list(3))
Then python3 example.py will give the following output:
Hello world!
['World hello!', 'World hello!', 'World hello!']
Section 190.3: Passing an open ﬁle to C Extensions
Pass an open ﬁle object from Python to C extension code.
You can convert the ﬁle to an integer ﬁle descriptor using PyObject_AsFileDescriptor function:
PyObject *fobj;
int fd = PyObject_AsFileDescriptor(fobj);
if (fd < 0){
return NULL;
}
To convert an integer ﬁle descriptor back into a python object, use PyFile_FromFd.
int fd; /* Existing file descriptor */
PyObject *fobj = PyFile_FromFd(fd, "filename","r",-1,NULL,NULL,NULL,1);
GoalKicker.com – Python® Notes for Professionals
762Chapter 191: Python Lex-Yacc
PLY is a pure-Python implementation of the popular compiler construction tools lex and yacc.
Section 191.1: Getting Started with PLY
To install PLY on your machine for python2/3, follow the steps outlined below:
1. Download the source code from here.
2. Unzip the downloaded zip ﬁle
3. Navigate into the unzipped ply-3.10 folder
4. Run the following command in your terminal: python setup.py install
If you completed all the above, you should now be able to use the PLY module. You can test it out by opening a
python interpreter and typing import ply.lex.
Note: Do not use pip to install PLY, it will install a broken distribution on your machine.
Section 191.2: The "Hello, World!" of PLY - A Simple Calculator
Let's demonstrate the power of PLY with a simple example: this program will take an arithmetic expression as a
string input, and attempt to solve it.
Open up your favourite editor and copy the following code:
from ply import lex
import ply.yacc as yacc
tokens = (
'PLUS',
'MINUS',
'TIMES',
'DIV',
'LPAREN',
'RPAREN',
'NUMBER',
)
t_ignore = ' \t'
t_PLUS
t_MINUS
t_TIMES
t_DIV
t_LPAREN
t_RPAREN
= r'\+'
= r'-'
= r'\*'
= r'/'
= r'\('
= r'\)'
def t_NUMBER( t ) :
r'[0-9]+'
t.value = int( t.value )
return t
def t_newline( t ):
r'\n+'
t.lexer.lineno += len( t.value )
def t_error( t ):
GoalKicker.com – Python® Notes for Professionals
763print("Invalid Token:",t.value[0])
t.lexer.skip( 1 )
lexer = lex.lex()
precedence = (
( 'left', 'PLUS', 'MINUS' ),
( 'left', 'TIMES', 'DIV' ),
( 'nonassoc', 'UMINUS' )
)
def p_add( p ) :
'expr : expr PLUS expr'
p[0] = p[1] + p[3]
def p_sub( p ) :
'expr : expr MINUS expr'
p[0] = p[1] - p[3]
def p_expr2uminus( p ) :
'expr : MINUS expr %prec UMINUS'
p[0] = - p[2]
def p_mult_div( p ) :
'''expr : expr TIMES expr
| expr DIV expr'''
if p[2] == '*' :
p[0] = p[1] * p[3]
else :
if p[3] == 0 :
print("Can't divide by 0")
raise ZeroDivisionError('integer division by 0')
p[0] = p[1] / p[3]
def p_expr2NUM( p ) :
'expr : NUMBER'
p[0] = p[1]
def p_parens( p ) :
'expr : LPAREN expr RPAREN'
p[0] = p[2]
def p_error( p ):
print("Syntax error in input!")
parser = yacc.yacc()
res = parser.parse("-4*-(3-5)") # the input
print(res)
Save this ﬁle as calc.py and run it.
Output:
-8
Which is the right answer for -4 * - (3 - 5).
GoalKicker.com – Python® Notes for Professionals
764Section 191.3: Part 1: Tokenizing Input with Lex
There are two steps that the code from example 1 carried out: one was tokenizing the input, which means it looked
for symbols that constitute the arithmetic expression, and the second step was parsing, which involves analysing
the extracted tokens and evaluating the result.
This section provides a simple example of how to tokenize user input, and then breaks it down line by line.
import ply.lex as lex
# List of token names. This is always required
tokens = [
'NUMBER',
'PLUS',
'MINUS',
'TIMES',
'DIVIDE',
'LPAREN',
'RPAREN',
]
# Regular expression rules for simple tokens
t_PLUS
= r'\+'
t_MINUS
= r'-'
t_TIMES
= r'\*'
t_DIVIDE = r'/'
t_LPAREN = r'\('
t_RPAREN = r'\)'
# A regular expression rule with some action code
def t_NUMBER(t):
r'\d+'
t.value = int(t.value)
return t
# Define a rule so we can track line numbers
def t_newline(t):
r'\n+'
t.lexer.lineno += len(t.value)
# A string containing ignored characters (spaces and tabs)
t_ignore = ' \t'
# Error handling rule
def t_error(t):
print("Illegal character '%s'" % t.value[0])
t.lexer.skip(1)
# Build the lexer
lexer = lex.lex()
# Give the lexer some input
lexer.input(data)
# Tokenize
while True:
tok = lexer.token()
if not tok:
break
# No more input
print(tok)
GoalKicker.com – Python® Notes for Professionals
765Save this ﬁle as calclex.py. We'll be using this when building our Yacc parser.
Breakdown
1. Import the module using import ply.lex
2. All lexers must provide a list called tokens that deﬁnes all of the possible token names that can be produced
by the lexer. This list is always required.
tokens = [
'NUMBER',
'PLUS',
'MINUS',
'TIMES',
'DIVIDE',
'LPAREN',
'RPAREN',
]
tokens could also be a tuple of strings (rather than a string), where each string denotes a token as before.
3. The regex rule for each string may be deﬁned either as a string or as a function. In either case, the variable
name should be preﬁxed by t_ to denote it is a rule for matching tokens.
For simple tokens, the regular expression can be speciﬁed as strings: t_PLUS = r'\+'
If some kind of action needs to be performed, a token rule can be speciﬁed as a function.
def t_NUMBER(t):
r'\d+'
t.value = int(t.value)
return t
Note, the rule is speciﬁed as a doc string within the function. The function accepts one argument which
is an instance of LexToken, performs some action and then returns back the argument.
If you want to use an external string as the regex rule for the function instead of specifying a doc
string, consider the following example:
@TOKEN(identifier)
def t_ID(t):
...
# actions
# identifier is a string holding the regex
An instance of LexToken object (let's call this object t) has the following attributes:
1. t.type which is the token type (as a string) (eg: 'NUMBER', 'PLUS', etc). By default, t.type is set
to the name following the t_ preﬁx.
2. t.value which is the lexeme (the actual text matched)
3. t.lineno which is the current line number (this is not automatically updated, as the lexer knows
nothing of line numbers). Update lineno using a function called t_newline.
def t_newline(t):
r'\n+'
t.lexer.lineno += len(t.value)
GoalKicker.com – Python® Notes for Professionals
7664. t.lexpos which is the position of the token relative to the beginning of the input text.
If nothing is returned from a regex rule function, the token is discarded. If you want to discard a token,
you can alternatively add t_ignore_ preﬁx to a regex rule variable instead of deﬁning a function for the
same rule.
def t_COMMENT(t):
r'\#.*'
pass
# No return value. Token discarded
...Is the same as:
t_ignore_COMMENT = r'\#.*'
This is of course invalid if you're carrying out some action when you see a comment. In which case, use
a function to deﬁne the regex rule.
If you haven't deﬁned a token for some characters but still want to ignore it, use t_ignore =
"<characters to ignore>" (these preﬁxes are necessary):
t_ignore_COMMENT = r'\#.*'
t_ignore = ' \t'
# ignores spaces and tabs
When building the master regex, lex will add the regexes speciﬁed in the ﬁle as follows:
1. Tokens deﬁned by functions are added in the same order as they appear in the ﬁle.
2. Tokens deﬁned by strings are added in decreasing order of the string length of the string
deﬁning the regex for that token.
If you are matching == and = in the same ﬁle, take advantage of these rules.
Literals are tokens that are returned as they are. Both t.type and t.value will be set to the character
itself. Deﬁne a list of literals as such:
literals = [ '+', '-', '*', '/' ]
or,
literals = "+-*/"
It is possible to write token functions that perform additional actions when literals are matched.
However, you'll need to set the token type appropriately. For example:
literals = [ '{', '}' ]
def t_lbrace(t):
r'\{'
t.type = '{'
literal)
return t
# Set token type to the expected literal (ABSOLUTE MUST if this is a
GoalKicker.com – Python® Notes for Professionals
767Handle errors with t_error function.
# Error handling rule
def t_error(t):
print("Illegal character '%s'" % t.value[0])
t.lexer.skip(1) # skip the illegal token (don't process it)
In general, t.lexer.skip(n) skips n characters in the input string.
4. Final preparations:
Build the lexer using lexer = lex.lex().
You can also put everything inside a class and call use instance of the class to deﬁne the lexer. Eg:
import ply.lex as lex
class MyLexer(object):
...
# everything relating to token rules and error handling comes here as usual
# Build the lexer
def build(self, **kwargs):
self.lexer = lex.lex(module=self, **kwargs)
def test(self, data):
self.lexer.input(data)
for token in self.lexer.token():
print(token)
# Build the lexer and try it out
m = MyLexer()
m.build()
m.test("3 + 4")
# Build the lexer
#
Provide input using lexer.input(data) where data is a string
To get the tokens, use lexer.token() which returns tokens matched. You can iterate over lexer in a loop as
in:
for i in lexer:
print(i)
Section 191.4: Part 2: Parsing Tokenized Input with Yacc
This section explains how the tokenized input from Part 1 is processed - it is done using Context Free Grammars
(CFGs). The grammar must be speciﬁed, and the tokens are processed according to the grammar. Under the hood,
the parser uses an LALR parser.
# Yacc example
import ply.yacc as yacc
# Get the token map from the lexer. This is required.
from calclex import tokens
GoalKicker.com – Python® Notes for Professionals
768def p_expression_plus(p):
'expression : expression PLUS term'
p[0] = p[1] + p[3]
def p_expression_minus(p):
'expression : expression MINUS term'
p[0] = p[1] - p[3]
def p_expression_term(p):
'expression : term'
p[0] = p[1]
def p_term_times(p):
'term : term TIMES factor'
p[0] = p[1] * p[3]
def p_term_div(p):
'term : term DIVIDE factor'
p[0] = p[1] / p[3]
def p_term_factor(p):
'term : factor'
p[0] = p[1]
def p_factor_num(p):
'factor : NUMBER'
p[0] = p[1]
def p_factor_expr(p):
'factor : LPAREN expression RPAREN'
p[0] = p[2]
# Error rule for syntax errors
def p_error(p):
print("Syntax error in input!")
# Build the parser
parser = yacc.yacc()
while True:
try:
s = raw_input('calc > ')
except EOFError:
break
if not s: continue
result = parser.parse(s)
print(result)
Breakdown
Each grammar rule is deﬁned by a function where the docstring to that function contains the appropriate
context-free grammar speciﬁcation. The statements that make up the function body implement the semantic
actions of the rule. Each function accepts a single argument p that is a sequence containing the values of
each grammar symbol in the corresponding rule. The values of p[i] are mapped to grammar symbols as
shown here:
def p_expression_plus(p):
'expression : expression PLUS term'
#
^
^
^
^
# p[0]
p[1]
p[2] p[3]
GoalKicker.com – Python® Notes for Professionals
769p[0] = p[1] + p[3]
For tokens, the "value" of the corresponding p[i] is the same as the p.value attribute assigned in the lexer
module. So, PLUS will have the value +.
For non-terminals, the value is determined by whatever is placed in p[0]. If nothing is placed, the value is
None. Also, p[-1] is not the same as p[3], since p is not a simple list (p[-1] can specify embedded actions
(not discussed here)).
Note that the function can have any name, as long as it is preceded by p_.
The p_error(p) rule is deﬁned to catch syntax errors (same as yyerror in yacc/bison).
Multiple grammar rules can be combined into a single function, which is a good idea if productions have a
similar structure.
def p_binary_operators(p):
'''expression : expression PLUS term
| expression MINUS term
term
: term TIMES factor
| term DIVIDE factor'''
if p[2] == '+':
p[0] = p[1] + p[3]
elif p[2] == '-':
p[0] = p[1] - p[3]
elif p[2] == '*':
p[0] = p[1] * p[3]
elif p[2] == '/':
p[0] = p[1] / p[3]
Character literals can be used instead of tokens.
def p_binary_operators(p):
'''expression : expression '+' term
| expression '-' term
term
: term '*' factor
| term '/' factor'''
if p[2] == '+':
p[0] = p[1] + p[3]
elif p[2] == '-':
p[0] = p[1] - p[3]
elif p[2] == '*':
p[0] = p[1] * p[3]
elif p[2] == '/':
p[0] = p[1] / p[3]
Of course, the literals must be speciﬁed in the lexer module.
Empty productions have the form '''symbol : '''
To explicitly set the start symbol, use start = 'foo', where foo is some non-terminal.
Setting precedence and associativity can be done using the precedence variable.
precedence = (
('nonassoc', 'LESSTHAN', 'GREATERTHAN'),
GoalKicker.com – Python® Notes for Professionals
# Nonassociative operators
770('left', 'PLUS', 'MINUS'),
('left', 'TIMES', 'DIVIDE'),
('right', 'UMINUS'),
# Unary minus operator
)
Tokens are ordered from lowest to highest precedence. nonassoc means that those tokens do not associate.
This means that something like a < b < c is illegal whereas a < b is still legal.
parser.out is a debugging ﬁle that is created when the yacc program is executed for the ﬁrst time. Whenever
a shift/reduce conﬂict occurs, the parser always shifts.
GoalKicker.com – Python® Notes for Professionals
771Chapter 192: Unit Testing
Section 192.1: Test Setup and Teardown within a
unittest.TestCase
Sometimes we want to prepare a context for each test to be run under. The setUp method is run prior to each test
in the class. tearDown is run at the end of every test. These methods are optional. Remember that TestCases are
often used in cooperative multiple inheritance so you should be careful to always call super in these methods so
that base class's setUp and tearDown methods also get called. The base implementation of TestCase provides
empty setUp and tearDown methods so that they can be called without raising exceptions:
import unittest
class SomeTest(unittest.TestCase):
def setUp(self):
super(SomeTest, self).setUp()
self.mock_data = [1,2,3,4,5]
def test(self):
self.assertEqual(len(self.mock_data), 5)
def tearDown(self):
super(SomeTest, self).tearDown()
self.mock_data = []
if __name__ == '__main__':
unittest.main()
Note that in python2.7+, there is also the addCleanup method that registers functions to be called after the test is
run. In contrast to tearDown which only gets called if setUp succeeds, functions registered via addCleanup will be
called even in the event of an unhandled exception in setUp. As a concrete example, this method can frequently be
seen removing various mocks that were registered while the test was running:
import unittest
import some_module
class SomeOtherTest(unittest.TestCase):
def setUp(self):
super(SomeOtherTest, self).setUp()
# Replace `some_module.method` with a `mock.Mock`
my_patch = mock.patch.object(some_module, 'method')
my_patch.start()
# When the test finishes running, put the original method back.
self.addCleanup(my_patch.stop)
Another beneﬁt of registering cleanups this way is that it allows the programmer to put the cleanup code next to
the setup code and it protects you in the event that a subclasser forgets to call super in tearDown.
Section 192.2: Asserting on Exceptions
You can test that a function throws an exception with the built-in unittest through two diﬀerent methods.
GoalKicker.com – Python® Notes for Professionals
772Using a context manager
def division_function(dividend, divisor):
return dividend / divisor
class MyTestCase(unittest.TestCase):
def test_using_context_manager(self):
with self.assertRaises(ZeroDivisionError):
x = division_function(1, 0)
This will run the code inside of the context manager and, if it succeeds, it will fail the test because the exception was
not raised. If the code raises an exception of the correct type, the test will continue.
You can also get the content of the raised exception if you want to execute additional assertions against it.
class MyTestCase(unittest.TestCase):
def test_using_context_manager(self):
with self.assertRaises(ZeroDivisionError) as ex:
x = division_function(1, 0)
self.assertEqual(ex.message, 'integer division or modulo by zero')
By providing a callable function
def division_function(dividend, divisor):
"""
Dividing two numbers.
:type dividend: int
:type divisor: int
:raises: ZeroDivisionError if divisor is zero (0).
:rtype: int
"""
return dividend / divisor
class MyTestCase(unittest.TestCase):
def test_passing_function(self):
self.assertRaises(ZeroDivisionError, division_function, 1, 0)
The exception to check for must be the ﬁrst parameter, and a callable function must be passed as the second
parameter. Any other parameters speciﬁed will be passed directly to the function that is being called, allowing you
to specify the parameters that trigger the exception.
Section 192.3: Testing Exceptions
Programs throw errors when for instance wrong input is given. Because of this, one needs to make sure that an
error is thrown when actual wrong input is given. Because of that we need to check for an exact exception, for this
example we will use the following exception:
class WrongInputException(Exception):
pass
This exception is raised when wrong input is given, in the following context where we always expect a number as
text input.
GoalKicker.com – Python® Notes for Professionals
773def convert2number(random_input):
try:
my_input = int(random_input)
except ValueError:
raise WrongInputException("Expected an integer!")
return my_input
To check whether an exception has been raised, we use assertRaises to check for that exception. assertRaises
can be used in two ways:
1. Using the regular function call. The ﬁrst argument takes the exception type, second a callable (usually a
function) and the rest of arguments are passed to this callable.
2. Using a with clause, giving only the exception type to the function. This has as advantage that more code can
be executed, but should be used with care since multiple functions can use the same exception which can be
problematic. An example: with self.assertRaises(WrongInputException): convert2number("not a number")
This ﬁrst has been implemented in the following test case:
import unittest
class ExceptionTestCase(unittest.TestCase):
def test_wrong_input_string(self):
self.assertRaises(WrongInputException, convert2number, "not a number")
def test_correct_input(self):
try:
result = convert2number("56")
self.assertIsInstance(result, int)
except WrongInputException:
self.fail()
There also may be a need to check for an exception which should not have been thrown. However, a test will
automatically fail when an exception is thrown and thus may not be necessary at all. Just to show the options, the
second test method shows a case on how one can check for an exception not to be thrown. Basically, this is
catching the exception and then failing the test using the fail method.
Section 192.4: Choosing Assertions Within Unittests
While Python has an assert statement, the Python unit testing framework has better assertions specialized for
tests: they are more informative on failures, and do not depend on the execution's debug mode.
Perhaps the simplest assertion is assertTrue, which can be used like this:
import unittest
class SimplisticTest(unittest.TestCase):
def test_basic(self):
self.assertTrue(1 + 1 == 2)
This will run ﬁne, but replacing the line above with
self.assertTrue(1 + 1 == 3)
will fail.
GoalKicker.com – Python® Notes for Professionals
774The assertTrue assertion is quite likely the most general assertion, as anything tested can be cast as some boolean
condition, but often there are better alternatives. When testing for equality, as above, it is better to write
self.assertEqual(1 + 1, 3)
When the former fails, the message is
======================================================================
FAIL: test (__main__.TruthTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "stuff.py", line 6, in test
self.assertTrue(1 + 1 == 3)
AssertionError: False is not true
but when the latter fails, the message is
======================================================================
FAIL: test (__main__.TruthTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "stuff.py", line 6, in test
self.assertEqual(1 + 1, 3)
AssertionError: 2 != 3
which is more informative (it actually evaluated the result of the left hand side).
You can ﬁnd the list of assertions in the standard documentation. In general, it is a good idea to choose the
assertion that is the most speciﬁcally ﬁtting the condition. Thus, as shown above, for asserting that 1 + 1 == 2 it is
better to use assertEqual than assertTrue. Similarly, for asserting that a is None, it is better to use assertIsNone
than assertEqual.
Note also that the assertions have negative forms. Thus assertEqual has its negative counterpart assertNotEqual,
and assertIsNone has its negative counterpart assertIsNotNone. Once again, using the negative counterparts
when appropriate, will lead to clearer error messages.
Section 192.5: Unit tests with pytest
installing pytest:
pip install pytest
getting the tests ready:
GoalKicker.com – Python® Notes for Professionals
775mkdir tests
touch tests/test_docker.py
Functions to test in docker_something/helpers.py:
from subprocess import Popen, PIPE
# this Popen is monkeypatched with the fixture `all_popens`
def copy_file_to_docker(src, dest):
try:
result = Popen(['docker','cp', src, 'something_cont:{}'.format(dest)], stdout=PIPE,
stderr=PIPE)
err = result.stderr.read()
if err:
raise Exception(err)
except Exception as e:
print(e)
return result
def docker_exec_something(something_file_string):
fl = Popen(["docker", "exec", "-i", "something_cont", "something"], stdin=PIPE, stdout=PIPE,
stderr=PIPE)
fl.stdin.write(something_file_string)
fl.stdin.close()
err = fl.stderr.read()
fl.stderr.close()
if err:
print(err)
exit()
result = fl.stdout.read()
print(result)
The test imports test_docker.py:
import os
from tempfile import NamedTemporaryFile
import pytest
from subprocess import Popen, PIPE
from docker_something import helpers
copy_file_to_docker = helpers.copy_file_to_docker
docker_exec_something = helpers.docker_exec_something
mocking a ﬁle like object in test_docker.py:
class MockBytes():
'''Used to collect bytes
'''
all_read = []
all_write = []
all_close = []
def read(self, *args, **kwargs):
# print('read', args, kwargs, dir(self))
self.all_read.append((self, args, kwargs))
def write(self, *args, **kwargs):
# print('wrote', args, kwargs)
self.all_write.append((self, args, kwargs))
GoalKicker.com – Python® Notes for Professionals
776def close(self, *args, **kwargs):
# print('closed', self, args, kwargs)
self.all_close.append((self, args, kwargs))
def get_all_mock_bytes(self):
return self.all_read, self.all_write, self.all_close
Monkey patching with pytest in test_docker.py:
@pytest.fixture
def all_popens(monkeypatch):
'''This fixture overrides / mocks the builtin Popen
and replaces stdin, stdout, stderr with a MockBytes object
note: monkeypatch is magically imported
'''
all_popens = []
class MockPopen(object):
def __init__(self, args, stdout=None, stdin=None, stderr=None):
all_popens.append(self)
self.args = args
self.byte_collection = MockBytes()
self.stdin = self.byte_collection
self.stdout = self.byte_collection
self.stderr = self.byte_collection
pass
monkeypatch.setattr(helpers, 'Popen', MockPopen)
return all_popens
Example tests, must start with the preﬁx test_ in the test_docker.py ﬁle:
def test_docker_install():
p = Popen(['which', 'docker'], stdout=PIPE, stderr=PIPE)
result = p.stdout.read()
assert 'bin/docker' in result
def test_copy_file_to_docker(all_popens):
result = copy_file_to_docker('asdf', 'asdf')
collected_popen = all_popens.pop()
mock_read, mock_write, mock_close = collected_popen.byte_collection.get_all_mock_bytes()
assert mock_read
assert result.args == ['docker', 'cp', 'asdf', 'something_cont:asdf']
def test_docker_exec_something(all_popens):
docker_exec_something(something_file_string)
collected_popen = all_popens.pop()
mock_read, mock_write, mock_close = collected_popen.byte_collection.get_all_mock_bytes()
assert len(mock_read) == 3
something_template_stdin = mock_write[0][1][0]
these = [os.environ['USER'], os.environ['password_prod'], 'table_name_here', 'test_vdm',
'col_a', 'col_b', '/tmp/test.tsv']
assert all([x in something_template_stdin for x in these])
running the tests one at a time:
GoalKicker.com – Python® Notes for Professionals
777py.test -k test_docker_install tests
py.test -k test_copy_file_to_docker tests
py.test -k test_docker_exec_something tests
running all the tests in the tests folder:
py.test -k test_ tests
Section 192.6: Mocking functions with
unittest.mock.create_autospec
One way to mock a function is to use the create_autospec function, which will mock out an object according to its
specs. With functions, we can use this to ensure that they are called appropriately.
With a function multiply in custom_math.py:
def multiply(a, b):
return a * b
And a function multiples_of in process_math.py:
from custom_math import multiply
def multiples_of(integer, *args, num_multiples=0, **kwargs):
"""
:rtype: list
"""
multiples = []
for x in range(1, num_multiples + 1):
"""
Passing in args and kwargs here will only raise TypeError if values were
passed to multiples_of function, otherwise they are ignored. This way we can
test that multiples_of is used correctly. This is here for an illustration
of how create_autospec works. Not recommended for production code.
"""
multiple = multiply(integer,x, *args, **kwargs)
multiples.append(multiple)
return multiples
We can test multiples_of alone by mocking out multiply. The below example uses the Python standard library
unittest, but this can be used with other testing frameworks as well, like pytest or nose:
from unittest.mock import create_autospec
import unittest
# we import the entire module so we can mock out multiply
import custom_math
custom_math.multiply = create_autospec(custom_math.multiply)
from process_math import multiples_of
class TestCustomMath(unittest.TestCase):
def test_multiples_of(self):
multiples = multiples_of(3, num_multiples=1)
custom_math.multiply.assert_called_with(3, 1)
GoalKicker.com – Python® Notes for Professionals
778def test_multiples_of_with_bad_inputs(self):
with self.assertRaises(TypeError) as e:
multiples_of(1, "extra arg", num_multiples=1) # this should raise a TypeError
GoalKicker.com – Python® Notes for Professionals
779Chapter 193: py.test
Section 193.1: Setting up py.test
py.test is one of several third party testing libraries that are available for Python. It can be installed using pip with
pip install pytest
The Code to Test
Say we are testing an addition function in projectroot/module/code.py:
# projectroot/module/code.py
def add(a, b):
return a + b
The Testing Code
We create a test ﬁle in projectroot/tests/test_code.py. The ﬁle must begin with test_ to be recognized as a
testing ﬁle.
# projectroot/tests/test_code.py
from module import code
def test_add():
assert code.add(1, 2) == 3
Running The Test
From projectroot we simply run py.test:
# ensure we have the modules
$ touch tests/__init__.py
$ touch module/__init__.py
$ py.test
================================================== test session starts
===================================================
platform darwin -- Python 2.7.10, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /projectroot, inifile:
collected 1 items
tests/test_code.py .
================================================ 1 passed in 0.01 seconds
================================================
Section 193.2: Intro to Test Fixtures
More complicated tests sometimes need to have things set up before you run the code you want to test. It is
possible to do this in the test function itself, but then you end up with large test functions doing so much that it is
diﬃcult to tell where the setup stops and the test begins. You can also get a lot of duplicate setup code between
your various test functions.
GoalKicker.com – Python® Notes for Professionals
780Our code ﬁle:
# projectroot/module/stuff.py
class Stuff(object):
def prep(self):
self.foo = 1
self.bar = 2
Our test ﬁle:
# projectroot/tests/test_stuff.py
import pytest
from module import stuff
def test_foo_updates():
my_stuff = stuff.Stuff()
my_stuff.prep()
assert 1 == my_stuff.foo
my_stuff.foo = 30000
assert my_stuff.foo == 30000
def test_bar_updates():
my_stuff = stuff.Stuff()
my_stuff.prep()
assert 2 == my_stuff.bar
my_stuff.bar = 42
assert 42 == my_stuff.bar
These are pretty simple examples, but if our Stuff object needed a lot more setup, it would get unwieldy. We see
that there is some duplicated code between our test cases, so let's refactor that into a separate function ﬁrst.
# projectroot/tests/test_stuff.py
import pytest
from module import stuff
def get_prepped_stuff():
my_stuff = stuff.Stuff()
my_stuff.prep()
return my_stuff
def test_foo_updates():
my_stuff = get_prepped_stuff()
assert 1 == my_stuff.foo
my_stuff.foo = 30000
assert my_stuff.foo == 30000
def test_bar_updates():
my_stuff = get_prepped_stuff()
assert 2 == my_stuff.bar
my_stuff.bar = 42
assert 42 == my_stuff.bar
This looks better but we still have the my_stuff = get_prepped_stuff() call cluttering up our test functions.
py.test ﬁxtures to the rescue!
GoalKicker.com – Python® Notes for Professionals
781Fixtures are much more powerful and ﬂexible versions of test setup functions. They can do a lot more than we're
leveraging here, but we'll take it one step at a time.
First we change get_prepped_stuff to a ﬁxture called prepped_stuff. You want to name your ﬁxtures with nouns
rather than verbs because of how the ﬁxtures will end up being used in the test functions themselves later. The
@pytest.fixture indicates that this speciﬁc function should be handled as a ﬁxture rather than a regular function.
@pytest.fixture
def prepped_stuff():
my_stuff = stuff.Stuff()
my_stuff.prep()
return my_stuff
Now we should update the test functions so that they use the ﬁxture. This is done by adding a parameter to their
deﬁnition that exactly matches the ﬁxture name. When py.test executes, it will run the ﬁxture before running the
test, then pass the return value of the ﬁxture into the test function through that parameter. (Note that ﬁxtures
don't need to return a value; they can do other setup things instead, like calling an external resource, arranging
things on the ﬁlesystem, putting values in a database, whatever the tests need for setup)
def test_foo_updates(prepped_stuff):
my_stuff = prepped_stuff
assert 1 == my_stuff.foo
my_stuff.foo = 30000
assert my_stuff.foo == 30000
def test_bar_updates(prepped_stuff):
my_stuff = prepped_stuff
assert 2 == my_stuff.bar
my_stuff.bar = 42
assert 42 == my_stuff.bar
Now you can see why we named it with a noun. but the my_stuff = prepped_stuff line is pretty much useless, so
let's just use prepped_stuff directly instead.
def test_foo_updates(prepped_stuff):
assert 1 == prepped_stuff.foo
prepped_stuff.foo = 30000
assert prepped_stuff.foo == 30000
def test_bar_updates(prepped_stuff):
assert 2 == prepped_stuff.bar
prepped_stuff.bar = 42
assert 42 == prepped_stuff.bar
Now we're using ﬁxtures! We can go further by changing the scope of the ﬁxture (so it only runs once per test
module or test suite execution session instead of once per test function), building ﬁxtures that use other ﬁxtures,
parametrizing the ﬁxture (so that the ﬁxture and all tests using that ﬁxture are run multiple times, once for each
parameter given to the ﬁxture), ﬁxtures that read values from the module that calls them... as mentioned earlier,
ﬁxtures have a lot more power and ﬂexibility than a normal setup function.
Cleaning up after the tests are done.
Let's say our code has grown and our Stuﬀ object now needs special clean up.
# projectroot/module/stuff.py
GoalKicker.com – Python® Notes for Professionals
782class Stuff(object):
def prep(self):
self.foo = 1
self.bar = 2
def finish(self):
self.foo = 0
self.bar = 0
We could add some code to call the clean up at the bottom of every test function, but ﬁxtures provide a better way
to do this. If you add a function to the ﬁxture and register it as a ﬁnalizer, the code in the ﬁnalizer function will get
called after the test using the ﬁxture is done. If the scope of the ﬁxture is larger than a single function (like module
or session), the ﬁnalizer will be executed after all the tests in scope are completed, so after the module is done
running or at the end of the entire test running session.
@pytest.fixture
def prepped_stuff(request): # we need to pass in the request to use finalizers
my_stuff = stuff.Stuff()
my_stuff.prep()
def fin(): # finalizer function
# do all the cleanup here
my_stuff.finish()
request.addfinalizer(fin) # register fin() as a finalizer
# you can do more setup here if you really want to
return my_stuff
Using the ﬁnalizer function inside a function can be a bit hard to understand at ﬁrst glance, especially when you
have more complicated ﬁxtures. You can instead use a yield ﬁxture to do the same thing with a more human
readable execution ﬂow. The only real diﬀerence is that instead of using return we use a yield at the part of the
ﬁxture where the setup is done and control should go to a test function, then add all the cleanup code after the
yield. We also decorate it as a yield_fixture so that py.test knows how to handle it.
@pytest.yield_fixture
def prepped_stuff(): # it doesn't need request now!
# do setup
my_stuff = stuff.Stuff()
my_stuff.prep()
# setup is done, pass control to the test functions
yield my_stuff
# do cleanup
my_stuff.finish()
And that concludes the Intro to Test Fixtures!
For more information, see the oﬃcial py.test ﬁxture documentation and the oﬃcial yield ﬁxture documentation
Section 193.3: Failing Tests
A failing test will provide helpful output as to what went wrong:
# projectroot/tests/test_code.py
from module import code
def test_add__failing():
assert code.add(10, 11) == 33
GoalKicker.com – Python® Notes for Professionals
783Results:
$ py.test
================================================== test session starts
===================================================
platform darwin -- Python 2.7.10, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /projectroot, inifile:
collected 1 items
tests/test_code.py F
======================================================== FAILURES
========================================================
___________________________________________________ test_add__failing
____________________________________________________
>
E
E
E
def test_add__failing():
assert code.add(10, 11) == 33
assert 21 == 33
+ where 21 = <function add at 0x105d4d6e0>(10, 11)
+
where <function add at 0x105d4d6e0> = code.add
tests/test_code.py:5: AssertionError
================================================ 1 failed in 0.01 seconds
================================================
GoalKicker.com – Python® Notes for Professionals
784Chapter 194: Proﬁling
Section 194.1: %%timeit and %timeit in IPython
Proﬁling string concatenation:
In [1]: import string
In [2]: %%timeit s=""; long_list=list(string.ascii_letters)*50
....: for substring in long_list:
....:
s+=substring
....:
1000 loops, best of 3: 570 us per loop
In [3]: %%timeit long_list=list(string.ascii_letters)*50
....: s="".join(long_list)
....:
100000 loops, best of 3: 16.1 us per loop
Proﬁling loops over iterables and lists:
In [4]: %timeit for i in range(100000):pass
100 loops, best of 3: 2.82 ms per loop
In [5]: %timeit for i in list(range(100000)):pass
100 loops, best of 3: 3.95 ms per loop
Section 194.2: Using cProﬁle (Preferred Proﬁler)
Python includes a proﬁler called cProﬁle. This is generally preferred over using timeit.
It breaks down your entire script and for each method in your script it tells you:
ncalls: The number of times a method was called
tottime: Total time spent in the given function (excluding time made in calls to sub-functions)
percall: Time spent per call. Or the quotient of tottime divided by ncalls
cumtime: The cumulative time spent in this and all subfunctions (from invocation till exit). This ﬁgure is
accurate even for recursive functions.
percall: is the quotient of cumtime divided by primitive calls
filename:lineno(function): provides the respective data of each function
The cProﬁler can be easily called on Command Line using:
$ python -m cProfile main.py
To sort the returned list of proﬁled methods by the time taken in the method:
$ python -m cProfile -s time main.py
Section 194.3: timeit() function
Proﬁling repetition of elements in an array
>>> import timeit
GoalKicker.com – Python® Notes for Professionals
785>>> timeit.timeit('list(itertools.repeat("a", 100))', 'import itertools', number = 10000000)
10.997665435877963
>>> timeit.timeit('["a"]*100', number = 10000000)
7.118789926862576
Section 194.4: timeit command line
Proﬁling concatenation of numbers
python -m timeit "'-'.join(str(n) for n in range(100))"
10000 loops, best of 3: 29.2 usec per loop
python -m timeit "'-'.join(map(str,range(100)))"
100000 loops, best of 3: 19.4 usec per loop
Section 194.5: line_proﬁler in command line
The source code with @proﬁle directive before the function we want to proﬁle:
import requests
@profile
def slow_func():
s = requests.session()
html=s.get("https://en.wikipedia.org/").text
sum([pow(ord(x),3.1) for x in list(html)])
for i in range(50):
slow_func()
Using kernprof command to calculate proﬁling line by line
$ kernprof -lv so6.py
Wrote profile results to so6.py.lprof
Timer unit: 4.27654e-07 s
Total time: 22.6427 s
File: so6.py
Function: slow_func at line 4
Line # Hits Time Per Hit % Time Line Contents
==============================================================
4 @profile
5 def slow_func():
6 50 20729 414.6 0.0 s = requests.session()
7 50 47618627 952372.5 89.9 html=s.get("https://en.wikipedia.org/").text
8 50 5306958 106139.2 10.0 sum([pow(ord(x),3.1) for x in list(html)])
Page request is almost always slower than any calculation based on the information on the page.
GoalKicker.com – Python® Notes for Professionals
786VIDEO: Machine
Learning A-Z: Hands-On
Python In Data Science
Learn to create Machine Learning Algorithms in
Python from two Data Science experts. Code
templates included.
✔ Master Machine Learning on Python
✔ Have a great intuition of many Machine Learning models
✔ Make accurate predictions
✔ Make powerful analysis
✔ Make robust Machine Learning models
✔ Create strong added value to your business
✔ Use Machine Learning for personal purpose
✔ Handle speciﬁc topics like Reinforcement Learning, NLP and Deep Learning
✔ Handle advanced techniques like Dimensionality Reduction
✔ Know which Machine Learning model to choose for each type of problem
✔ Build an army of powerful Machine Learning models and know how to combine them to solve any
problem
Watch Today →Chapter 195: Python speed of program
Section 195.1: Deque operations
A deque is a double-ended queue.
class Deque:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def addFront(self, item):
self.items.append(item)
def addRear(self, item):
self.items.insert(0,item)
def removeFront(self):
return self.items.pop()
def removeRear(self):
return self.items.pop(0)
def size(self):
return len(self.items)
Operations : Average Case (assumes parameters are randomly generated)
Append : O(1)
Appendleft : O(1)
Copy : O(n)
Extend : O(k)
Extendleft : O(k)
Pop : O(1)
Popleft : O(1)
Remove : O(n)
Rotate : O(k)
Section 195.2: Algorithmic Notations
There are certain principles that apply to optimization in any computer language, and Python is no exception. Don't
optimize as you go: Write your program without regard to possible optimizations, concentrating instead on
making sure that the code is clean, correct, and understandable. If it's too big or too slow when you've ﬁnished,
then you can consider optimizing it.
Remember the 80/20 rule: In many ﬁelds you can get 80% of the result with 20% of the eﬀort (also called the
GoalKicker.com – Python® Notes for Professionals
78890/10 rule - it depends on who you talk to). Whenever you're about to optimize code, use proﬁling to ﬁnd out where
that 80% of execution time is going, so you know where to concentrate your eﬀort.
Always run "before" and "after" benchmarks: How else will you know that your optimizations actually made a
diﬀerence? If your optimized code turns out to be only slightly faster or smaller than the original version, undo your
changes and go back to the original, clear code.
Use the right algorithms and data structures: Don't use an O(n2) bubble sort algorithm to sort a thousand elements
when there's an O(n log n) quicksort available. Similarly, don't store a thousand items in an array that requires an
O(n) search when you could use an O(log n) binary tree, or an O(1) Python hash table.
For more visit the link below... Python Speed Up
The following 3 asymptotic notations are mostly used to represent time complexity of algorithms.
1. Θ Notation: The theta notation bounds a functions from above and below, so it deﬁnes exact asymptotic
behavior. A simple way to get Theta notation of an expression is to drop low order terms and ignore leading
constants. For example, consider the following expression. 3n3 + 6n2 + 6000 = Θ(n3) Dropping lower order
terms is always ﬁne because there will always be a n0 after which Θ(n3) has higher values than Θn2)
irrespective of the constants involved. For a given function g(n), we denote Θ(g(n)) is following set of
functions. Θ(g(n)) = {f(n): there exist positive constants c1, c2 and n0 such that 0 <= c1g(n) <= f(n) <= c2g(n) for
all n >= n0} The above deﬁnition means, if f(n) is theta of g(n), then the value f(n) is always between c1g(n) and
c2g(n) for large values of n (n >= n0). The deﬁnition of theta also requires that f(n) must be non-negative for
values of n greater than n0.
2. Big O Notation: The Big O notation deﬁnes an upper bound of an algorithm, it bounds a function only from
above. For example, consider the case of Insertion Sort. It takes linear time in best case and quadratic time in
worst case. We can safely say that the time complexity of Insertion sort is O(n^2). Note that O(n^2) also
covers linear time. If we use Θ notation to represent time complexity of Insertion sort, we have to use two
statements for best and worst cases:
1. The worst case time complexity of Insertion Sort is Θ(n^2).
2. The best case time complexity of Insertion Sort is Θ(n).
The Big O notation is useful when we only have upper bound on time complexity of an algorithm. Many times we
easily ﬁnd an upper bound by simply looking at the algorithm. O(g(n)) = { f(n): there exist positive constants c and n0
such that 0 <= f(n) <= cg(n) for all n >= n0}
0. Ω Notation: Just as Big O notation provides an asymptotic upper bound on a function, Ω notation provides
an asymptotic lower bound. Ω Notation< can be useful when we have lower bound on time complexity of an
algorithm. As discussed in the previous post, the best case performance of an algorithm is generally not
useful, the Omega notation is the least used notation among all three. For a given function g(n), we denote by
Ω(g(n)) the set of functions. Ω (g(n)) = {f(n): there exist positive constants c and n0 such that 0 <= cg(n) <= f(n)
for all n >= n0}. Let us consider the same Insertion sort example here. The time complexity of Insertion Sort
can be written as Ω(n), but it is not a very useful information about insertion sort, as we are generally
interested in worst case and sometimes in average case.
Section 195.3: Notation
Basic Idea
The notation used when describing the speed of your Python program is called Big-O notation. Let's say you have a
function:
GoalKicker.com – Python® Notes for Professionals
789def list_check(to_check, the_list):
for item in the_list:
if to_check == item:
return True
return False
This is a simple function to check if an item is in a list. To describe the complexity of this function, you will say O(n).
This means "Order of n" as the O function is known as the Order function.
O(n) - generally n is the number of items in container
O(k) - generally k is the value of the parameter or the number of elements in the parameter
Section 195.4: List operations
Operations : Average Case (assumes parameters are randomly generated)
Append : O(1)
Copy : O(n)
Del slice : O(n)
Delete item : O(n)
Insert : O(n)
Get item : O(1)
Set item : O(1)
Iteration : O(n)
Get slice : O(k)
Set slice : O(n + k)
Extend : O(k)
Sort : O(n log n)
Multiply : O(nk)
x in s : O(n)
min(s), max(s) :O(n)
Get length : O(1)
Section 195.5: Set operations
Operation : Average Case (assumes parameters generated randomly) : Worst case
x in s : O(1)
Diﬀerence s - t : O(len(s))
GoalKicker.com – Python® Notes for Professionals
790Intersection s&t : O(min(len(s), len(t))) : O(len(s) * len(t)
Multiple intersection s1&s2&s3&...&sn : : (n-1) * O(l) where l is max(len(s1),...,len(sn))
s.diﬀerence_update(t) : O(len(t)) : O(len(t) * len(s))
s.symetric_diﬀerence_update(t) : O(len(t))
Symetric diﬀerence s^t : O(len(s)) : O(len(s) * len(t))
Union s|t : O(len(s) + len(t))
GoalKicker.com – Python® Notes for Professionals
791Chapter 196: Performance optimization
Section 196.1: Code proﬁling
First and foremost you should be able to ﬁnd the bottleneck of your script and note that no optimization can
compensate for a poor choice in data structure or a ﬂaw in your algorithm design. Secondly do not try to optimize
too early in your coding process at the expense of readability/design/quality. Donald Knuth made the following
statement on optimization:
"We should forget about small eﬃciencies, say about 97% of the time: premature optimization is the root
of all evil. Yet we should not pass up our opportunities in that critical 3%"
To proﬁle your code you have several tools: cProfile (or the slower profile) from the standard library,
line_profiler and timeit. Each of them serve a diﬀerent purpose.
cProfile is a deterministic proﬁler: function call, function return, and exception events are monitored, and precise
timings are made for the intervals between these events (up to 0.001s). The library documentation
([https://docs.python.org/2/library/proﬁle.html][1]) provides us with a simple use case
import cProfile
def f(x):
return "42!"
cProfile.run('f(12)')
Or if you prefer to wrap parts of your existing code:
import cProfile, pstats, StringIO
pr = cProfile.Profile()
pr.enable()
# ... do something ...
# ... long ...
pr.disable()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print s.getvalue()
This will create outputs looking like the table below, where you can quickly see where your program spends most of
its time and identify the functions to optimize.
3 function calls in 0.000 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 :1(f)
1 0.000 0.000 0.000 0.000 :1()
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
The module line_profiler ([https://github.com/rkern/line_proﬁler][1]) is useful to have a line by line analysis of
your code. This is obviously not manageable for long scripts but is aimed at snippets. See the documentation for
more details. The easiest way to get started is to use the kernprof script as explained one the package page, note
that you will need to specify manually the function(s) to proﬁle.
GoalKicker.com – Python® Notes for Professionals
792$ kernprof -l script_to_profile.py
kernprof will create an instance of LineProﬁler and insert it into the __builtins__ namespace with the name
proﬁle. It has been written to be used as a decorator, so in your script, you decorate the functions you want to
proﬁle with @profile.
@profile
def slow_function(a, b, c):
...
The default behavior of kernprof is to put the results into a binary ﬁle script_to_profile.py.lprof . You can tell
kernprof to immediately view the formatted results at the terminal with the [-v/--view] option. Otherwise, you can
view the results later like so:
$ python -m line_profiler script_to_profile.py.lprof
Finally timeit provides a simple way to test one liners or small expression both from the command line and the
python shell. This module will answer question such as, is it faster to do a list comprehension or use the built-in
list() when transforming a set into a list. Look for the setup keyword or -s option to add setup code.
>>> import timeit
>>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
0.8187260627746582
from a terminal
$ python -m timeit '"-".join(str(n) for n in range(100))'
10000 loops, best of 3: 40.3 usec per loop
GoalKicker.com – Python® Notes for Professionals
793Chapter 197: Security and Cryptography
Python, being one of the most popular languages in computer and network security, has great potential in security
and cryptography. This topic deals with the cryptographic features and implementations in Python from its uses in
computer and network security to hashing and encryption/decryption algorithms.
Section 197.1: Secure Password Hashing
The PBKDF2 algorithm exposed by hashlib module can be used to perform secure password hashing. While this
algorithm cannot prevent brute-force attacks in order to recover the original password from the stored hash, it
makes such attacks very expensive.
import hashlib
import os
salt = os.urandom(16)
hash = hashlib.pbkdf2_hmac('sha256', b'password', salt, 100000)
PBKDF2 can work with any digest algorithm, the above example uses SHA256 which is usually recommended. The
random salt should be stored along with the hashed password, you will need it again in order to compare an
entered password to the stored hash. It is essential that each password is hashed with a diﬀerent salt. As to the
number of rounds, it is recommended to set it as high as possible for your application.
If you want the result in hexadecimal, you can use the binascii module:
import binascii
hexhash = binascii.hexlify(hash)
Note: While PBKDF2 isn't bad, bcrypt and especially scrypt are considered stronger against brute-force attacks.
Neither is part of the Python standard library at the moment.
Section 197.2: Calculating a Message Digest
The hashlib module allows creating message digest generators via the new method. These generators will turn an
arbitrary string into a ﬁxed-length digest:
import hashlib
h = hashlib.new('sha256')
h.update(b'Nobody expects the Spanish Inquisition.')
h.digest()
# ==> b'.\xdf\xda\xdaVR[\x12\x90\xff\x16\xfb\x17D\xcf\xb4\x82\xdd)\x14\xff\xbc\xb6Iy\x0c\x0eX\x9eF-='
Note that you can call update an arbitrary number of times before calling digest which is useful to hash a large ﬁle
chunk by chunk. You can also get the digest in hexadecimal format by using hexdigest:
h.hexdigest()
# ==> '2edfdada56525b1290ff16fb1744cfb482dd2914ffbcb649790c0e589e462d3d'
Section 197.3: Available Hashing Algorithms
hashlib.new requires the name of an algorithm when you call it to produce a generator. To ﬁnd out what
algorithms are available in the current Python interpreter, use hashlib.algorithms_available:
GoalKicker.com – Python® Notes for Professionals
794import hashlib
hashlib.algorithms_available
# ==> {'sha256', 'DSA-SHA', 'SHA512', 'SHA224', 'dsaWithSHA', 'SHA', 'RIPEMD160', 'ecdsa-with-SHA1',
'sha1', 'SHA384', 'md5', 'SHA1', 'MD5', 'MD4', 'SHA256', 'sha384', 'md4', 'ripemd160', 'sha224',
'sha512', 'DSA', 'dsaEncryption', 'sha', 'whirlpool'}
The returned list will vary according to platform and interpreter; make sure you check your algorithm is available.
There are also some algorithms that are guaranteed to be available on all platforms and interpreters, which are
available using hashlib.algorithms_guaranteed:
hashlib.algorithms_guaranteed
# ==> {'sha256', 'sha384', 'sha1', 'sha224', 'md5', 'sha512'}
Section 197.4: File Hashing
A hash is a function that converts a variable length sequence of bytes to a ﬁxed length sequence. Hashing ﬁles can
be advantageous for many reasons. Hashes can be used to check if two ﬁles are identical or verify that the contents
of a ﬁle haven't been corrupted or changed.
You can use hashlib to generate a hash for a ﬁle:
import hashlib
hasher = hashlib.new('sha256')
with open('myfile', 'r') as f:
contents = f.read()
hasher.update(contents)
print hasher.hexdigest()
For larger ﬁles, a buﬀer of ﬁxed length can be used:
import hashlib
SIZE = 65536
hasher = hashlib.new('sha256')
with open('myfile', 'r') as f:
buffer = f.read(SIZE)
while len(buffer) > 0:
hasher.update(buffer)
buffer = f.read(SIZE)
print(hasher.hexdigest())
Section 197.5: Generating RSA signatures using pycrypto
RSA can be used to create a message signature. A valid signature can only be generated with access to the private
RSA key, validating on the other hand is possible with merely the corresponding public key. So as long as the other
side knows your public key they can verify the message to be signed by you and unchanged - an approach used for
email for example. Currently, a third-party module like pycrypto is required for this functionality.
import errno
from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
GoalKicker.com – Python® Notes for Professionals
795message = b'This message is from me, I promise.'
try:
with open('privkey.pem', 'r') as f:
key = RSA.importKey(f.read())
except IOError as e:
if e.errno != errno.ENOENT:
raise
# No private key, generate a new one. This can take a few seconds.
key = RSA.generate(4096)
with open('privkey.pem', 'wb') as f:
f.write(key.exportKey('PEM'))
with open('pubkey.pem', 'wb') as f:
f.write(key.publickey().exportKey('PEM'))
hasher = SHA256.new(message)
signer = PKCS1_v1_5.new(key)
signature = signer.sign(hasher)
Verifying the signature works similarly but uses the public key rather than the private key:
with open('pubkey.pem', 'rb') as f:
key = RSA.importKey(f.read())
hasher = SHA256.new(message)
verifier = PKCS1_v1_5.new(key)
if verifier.verify(hasher, signature):
print('Nice, the signature is valid!')
else:
print('No, the message was signed with the wrong private key or modified')
Note: The above examples use PKCS#1 v1.5 signing algorithm which is very common. pycrypto also implements the
newer PKCS#1 PSS algorithm, replacing PKCS1_v1_5 by PKCS1_PSS in the examples should work if you want to use
that one. Currently there seems to be little reason to use it however.
Section 197.6: Asymmetric RSA encryption using pycrypto
Asymmetric encryption has the advantage that a message can be encrypted without exchanging a secret key with
the recipient of the message. The sender merely needs to know the recipients public key, this allows encrypting the
message in such a way that only the designated recipient (who has the corresponding private key) can decrypt it.
Currently, a third-party module like pycrypto is required for this functionality.
from Crypto.Cipher import PKCS1_OAEP
from Crypto.PublicKey import RSA
message = b'This is a very secret message.'
with open('pubkey.pem', 'rb') as f:
key = RSA.importKey(f.read())
cipher = PKCS1_OAEP.new(key)
encrypted = cipher.encrypt(message)
The recipient can decrypt the message then if they have the right private key:
with open('privkey.pem', 'rb') as f:
key = RSA.importKey(f.read())
cipher = PKCS1_OAEP.new(key)
decrypted = cipher.decrypt(encrypted)
GoalKicker.com – Python® Notes for Professionals
796Note: The above examples use PKCS#1 OAEP encryption scheme. pycrypto also implements PKCS#1 v1.5 encryption
scheme, this one is not recommended for new protocols however due to known caveats.
Section 197.7: Symmetric encryption using pycrypto
Python's built-in crypto functionality is currently limited to hashing. Encryption requires a third-party module like
pycrypto. For example, it provides the AES algorithm which is considered state of the art for symmetric encryption.
The following code will encrypt a given message using a passphrase:
import hashlib
import math
import os
from Crypto.Cipher import AES
IV_SIZE = 16
KEY_SIZE = 32
SALT_SIZE = 16
# 128 bit, fixed for the AES algorithm
# 256 bit meaning AES-256, can also be 128 or 192 bits
# This size is arbitrary
cleartext = b'Lorem ipsum'
password = b'highly secure encryption password'
salt = os.urandom(SALT_SIZE)
derived = hashlib.pbkdf2_hmac('sha256', password, salt, 100000,
dklen=IV_SIZE + KEY_SIZE)
iv = derived[0:IV_SIZE]
key = derived[IV_SIZE:]
encrypted = salt + AES.new(key, AES.MODE_CFB, iv).encrypt(cleartext)
The AES algorithm takes three parameters: encryption key, initialization vector (IV) and the actual message to be
encrypted. If you have a randomly generated AES key then you can use that one directly and merely generate a
random initialization vector. A passphrase doesn't have the right size however, nor would it be recommendable to
use it directly given that it isn't truly random and thus has comparably little entropy. Instead, we use the built-in
implementation of the PBKDF2 algorithm to generate a 128 bit initialization vector and 256 bit encryption key from
the password.
Note the random salt which is important to have a diﬀerent initialization vector and key for each message
encrypted. This ensures in particular that two equal messages won't result in identical encrypted text, but it also
prevents attackers from reusing work spent guessing one passphrase on messages encrypted with another
passphrase. This salt has to be stored along with the encrypted message in order to derive the same initialization
vector and key for decrypting.
The following code will decrypt our message again:
salt = encrypted[0:SALT_SIZE]
derived = hashlib.pbkdf2_hmac('sha256', password, salt, 100000,
dklen=IV_SIZE + KEY_SIZE)
iv = derived[0:IV_SIZE]
key = derived[IV_SIZE:]
cleartext = AES.new(key, AES.MODE_CFB, iv).decrypt(encrypted[SALT_SIZE:])
GoalKicker.com – Python® Notes for Professionals
797Chapter 198: Secure Shell Connection in
Python
Parameter
Usage
hostname This parameter tells the host to which the connection needs to be established
username username required to access the host
porthost port
passwordpassword for the account
Section 198.1: ssh connection
from paramiko import client
ssh = client.SSHClient() # create a new SSHClient object
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) #auto-accept unknown host keys
ssh.connect(hostname, username=username, port=port, password=password) #connect with a host
stdin, stdout, stderr = ssh.exec_command(command) # submit a command to ssh
print stdout.channel.recv_exit_status() #tells the status 1 - job failed
GoalKicker.com – Python® Notes for Professionals
798Chapter 199: Python Anti-Patterns
Section 199.1: Overzealous except clause
Exceptions are powerful, but a single overzealous except clause can take it all away in a single line.
try: res = get_result() res = res[0] log('got result: %r' % res) except: if not res: res = '' print('got exception')
This example demonstrates 3 symptoms of the antipattern:
1. The except with no exception type (line 5) will catch even healthy exceptions, including KeyboardInterrupt.
That will prevent the program from exiting in some cases.
2. The except block does not reraise the error, meaning that we won't be able to tell if the exception came from
within get_result or because res was an empty list.
3. Worst of all, if we were worried about result being empty, we've caused something much worse. If
get_result fails, res will stay completely unset, and the reference to res in the except block, will raise
NameError, completely masking the original error.
Always think about the type of exception you're trying to handle. Give the exceptions page a read and get a feel for
what basic exceptions exist.
Here is a ﬁxed version of the example above:
import traceback try: res = get_result() except Exception: log_exception(traceback.format_exc()) raise try: res = res[0]
except IndexError: res = '' log('got result: %r' % res)
We catch more speciﬁc exceptions, reraising where necessary. A few more lines, but inﬁnitely more correct.
Section 199.2: Looking before you leap with processor-
intensive function
A program can easily waste time by calling a processor-intensive function multiple times.
For example, take a function which looks like this: it returns an integer if the input value can produce one, else
None:
def intensive_f(value): # int -> Optional[int]
# complex, and time-consuming code
if process_has_failed:
return None
return integer_output
And it could be used in the following way:
x = 5
if intensive_f(x) is not None:
print(intensive_f(x) / 2)
else:
print(x, "could not be processed")
print(x)
Whilst this will work, it has the problem of calling intensive_f, which doubles the length of time for the code to
run. A better solution would be to get the return value of the function beforehand.
GoalKicker.com – Python® Notes for Professionals
799x = 5
result = intensive_f(x)
if result is not None:
print(result / 2)
else:
print(x, "could not be processed")
However, a clearer and possibly more pythonic way is to use exceptions, for example:
x = 5
try:
print(intensive_f(x) / 2)
except TypeError: # The exception raised if None + 1 is attempted
print(x, "could not be processed")
Here no temporary variable is needed. It may often be preferable to use a assert statement, and to catch the
AssertionError instead.
Dictionary keys
A common example of where this may be found is accessing dictionary keys. For example compare:
bird_speeds = get_very_long_dictionary()
if "european swallow" in bird_speeds:
speed = bird_speeds["european swallow"]
else:
speed = input("What is the air-speed velocity of an unladen swallow?")
print(speed)
with:
bird_speeds = get_very_long_dictionary()
try:
speed = bird_speeds["european swallow"]
except KeyError:
speed = input("What is the air-speed velocity of an unladen swallow?")
print(speed)
The ﬁrst example has to look through the dictionary twice, and as this is a long dictionary, it may take a long time to
do so each time. The second only requires one search through the dictionary, and thus saves a lot of processor
time.
An alternative to this is to use dict.get(key, default), however many circumstances may require more complex
operations to be done in the case that the key is not present
GoalKicker.com – Python® Notes for Professionals
800VIDEO: Machine
Learning, Data Science
and Deep Learning with
Python
Complete hands-on machine learning tutorial with
data science, Tensorﬂow, artiﬁcial intelligence,
and neural networks
✔ Build artiﬁcial neural networks with Tensorﬂow and Keras
✔ Classify images, data, and sentiments using deep learning
✔ Make predictions using linear regression, polynomial regression, and multivariate regression
✔ Data Visualization with MatPlotLib and Seaborn
✔ Implement machine learning at massive scale with Apache Spark's MLLib
✔ Understand reinforcement learning - and how to build a Pac-Man bot
✔ Classify data using K-Means clustering, Support Vector Machines (SVM), KNN, Decision Trees,
Naive Bayes, and PCA
✔ Use train/test and K-Fold cross validation to choose and tune your models
✔ Build a movie recommender system using item-based and user-based collaborative ﬁltering
Watch Today →Chapter 200: Common Pitfalls
Python is a language meant to be clear and readable without any ambiguities and unexpected behaviors.
Unfortunately, these goals are not achievable in all cases, and that is why Python does have a few corner cases
where it might do something diﬀerent than what you were expecting.
This section will show you some issues that you might encounter when writing Python code.
Section 200.1: List multiplication and common references
Consider the case of creating a nested list structure by multiplying:
li = [[]] * 3
print(li)
# Out: [[], [], []]
At ﬁrst glance we would think we have a list of containing 3 diﬀerent nested lists. Let's try to append 1 to the ﬁrst
one:
li[0].append(1)
print(li)
# Out: [[1], [1], [1]]
1 got appended to all of the lists in li.
The reason is that [[]] * 3 doesn't create a list of 3 diﬀerent lists. Rather, it creates a list holding 3 references
to the same list object. As such, when we append to li[0] the change is visible in all sub-elements of li. This is
equivalent of:
li = []
element = [[]]
li = element + element + element
print(li)
# Out: [[], [], []]
element.append(1)
print(li)
# Out: [[1], [1], [1]]
This can be further corroborated if we print the memory addresses of the contained list by using id:
li = [[]] * 3
print([id(inner_list) for inner_list in li])
# Out: [6830760, 6830760, 6830760]
The solution is to create the inner lists with a loop:
li = [[] for _ in range(3)]
Instead of creating a single list and then making 3 references to it, we now create 3 diﬀerent distinct lists. This,
again, can be veriﬁed by using the id function:
print([id(inner_list) for inner_list in li])
# Out: [6331048, 6331528, 6331488]
GoalKicker.com – Python® Notes for Professionals
802You can also do this. It causes a new empty list to be created in each append call.
>>> li = []
>>> li.append([])
>>> li.append([])
>>> li.append([])
>>> for k in li: print(id(k))
...
4315469256
4315564552
4315564808
Don't use index to loop over a sequence.
Don't:
for i in range(len(tab)):
print(tab[i])
Do:
for elem in tab:
print(elem)
for will automate most iteration operations for you.
Use enumerate if you really need both the index and the element.
for i, elem in enumerate(tab):
print((i, elem))
Be careful when using "==" to check against True or False
if (var == True):
# this will execute if var is True or 1, 1.0, 1L
if (var != True):
# this will execute if var is neither True nor 1
if (var == False):
# this will execute if var is False or 0 (or 0.0, 0L, 0j)
if (var == None):
# only execute if var is None
if var:
# execute if var is a non-empty string/list/dictionary/tuple, non-0, etc
if not var:
# execute if var is "", {}, [], (), 0, None, etc.
if var is True:
# only execute if var is boolean True, not 1
if var is False:
# only execute if var is boolean False, not 0
if var is None:
GoalKicker.com – Python® Notes for Professionals
803# same as var == None
Do not check if you can, just do it and handle the error
Pythonistas usually say "It's easier to ask for forgiveness than permission".
Don't:
if os.path.isfile(file_path):
file = open(file_path)
else:
# do something
Do:
try:
file = open(file_path)
except OSError as e:
# do something
Or even better with Python 2.6+:
with open(file_path) as file:
It is much better because it is much more generic. You can apply try/except to almost anything. You don't need to
care about what to do to prevent it, just care about the error you are risking.
Do not check against type
Python is dynamically typed, therefore checking for type makes you lose ﬂexibility. Instead, use duck typing by
checking behavior. If you expect a string in a function, then use str() to convert any object to a string. If you expect
a list, use list() to convert any iterable to a list.
Don't:
def foo(name):
if isinstance(name, str):
print(name.lower())
def bar(listing):
if isinstance(listing, list):
listing.extend((1, 2, 3))
return ", ".join(listing)
Do:
def foo(name) :
print(str(name).lower())
def bar(listing) :
l = list(listing)
l.extend((1, 2, 3))
return ", ".join(l)
Using the last way, foo will accept any object. bar will accept strings, tuples, sets, lists and much more. Cheap DRY.
Don't mix spaces and tabs
GoalKicker.com – Python® Notes for Professionals
804Use object as ﬁrst parent
This is tricky, but it will bite you as your program grows. There are old and new classes in Python 2.x. The old ones
are, well, old. They lack some features, and can have awkward behavior with inheritance. To be usable, any of your
class must be of the "new style". To do so, make it inherit from object.
Don't:
class Father:
pass
class Child(Father):
pass
Do:
class Father(object):
pass
class Child(Father):
pass
In Python 3.x all classes are new style so you don't need to do that.
Don't initialize class attributes outside the init method
People coming from other languages ﬁnd it tempting because that is what you do in Java or PHP. You write the class
name, then list your attributes and give them a default value. It seems to work in Python, however, this doesn't
work the way you think. Doing that will setup class attributes (static attributes), then when you will try to get the
object attribute, it will gives you its value unless it's empty. In that case it will return the class attributes. It implies
two big hazards:
If the class attribute is changed, then the initial value is changed.
If you set a mutable object as a default value, you'll get the same object shared across instances.
Don't (unless you want static):
class Car(object):
color = "red"
wheels = [Wheel(), Wheel(), Wheel(), Wheel()]
Do:
class Car(object):
def __init__(self):
self.color = "red"
self.wheels = [Wheel(), Wheel(), Wheel(), Wheel()]
Section 200.2: Mutable default argument
def foo(li=[]):
li.append(1)
print(li)
GoalKicker.com – Python® Notes for Professionals
805foo([2])
# Out: [2, 1]
foo([3])
# Out: [3, 1]
This code behaves as expected, but what if we don't pass an argument?
foo()
# Out: [1] As expected...
foo()
# Out: [1, 1]
Not as expected...
This is because default arguments of functions and methods are evaluated at deﬁnition time rather than run time.
So we only ever have a single instance of the li list.
The way to get around it is to use only immutable types for default arguments:
def foo(li=None):
if not li:
li = []
li.append(1)
print(li)
foo()
# Out: [1]
foo()
# Out: [1]
While an improvement and although if not li correctly evaluates to False, many other objects do as well, such as
zero-length sequences. The following example arguments can cause unintended results:
x = []
foo(li=x)
# Out: [1]
foo(li="")
# Out: [1]
foo(li=0)
# Out: [1]
The idiomatic approach is to directly check the argument against the None object:
def foo(li=None):
if li is None:
li = []
li.append(1)
print(li)
foo()
# Out: [1]
Section 200.3: Changing the sequence you are iterating over
A for loop iterates over a sequence, so altering this sequence inside the loop could lead to unexpected results
(especially when adding or removing elements):
GoalKicker.com – Python® Notes for Professionals
806alist = [0, 1, 2]
for index, value in enumerate(alist):
alist.pop(index)
print(alist)
# Out: [1]
Note: list.pop() is being used to remove elements from the list.
The second element was not deleted because the iteration goes through the indices in order. The above loop
iterates twice, with the following results:
# Iteration #1
index = 0
alist = [0, 1, 2]
alist.pop(0) # removes '0'
# Iteration #2
index = 1
alist = [1, 2]
alist.pop(1) # removes '2'
# loop terminates, but alist is not empty:
alist = [1]
This problem arises because the indices are changing while iterating in the direction of increasing index. To avoid
this problem, you can iterate through the loop backwards:
alist = [1,2,3,4,5,6,7]
for index, item in reversed(list(enumerate(alist))):
# delete all even items
if item % 2 == 0:
alist.pop(index)
print(alist)
# Out: [1, 3, 5, 7]
By iterating through the loop starting at the end, as items are removed (or added), it does not aﬀect the indices of
items earlier in the list. So this example will properly remove all items that are even from alist.
A similar problem arises when inserting or appending elements to a list that you are iterating over, which can
result in an inﬁnite loop:
alist = [0, 1, 2]
for index, value in enumerate(alist):
# break to avoid infinite loop:
if index == 20:
break
alist.insert(index, 'a')
print(alist)
# Out (abbreviated): ['a', 'a', ..., 'a', 'a',
0,
1,
2]
Without the break condition the loop would insert 'a' as long as the computer does not run out of memory and
the program is allowed to continue. In a situation like this, it is usually preferred to create a new list, and add items
to the new list as you loop through the original list.
When using a for loop, you cannot modify the list elements with the placeholder variable:
alist = [1,2,3,4]
GoalKicker.com – Python® Notes for Professionals
807for item in alist:
if item % 2 == 0:
item = 'even'
print(alist)
# Out: [1,2,3,4]
In the above example, changing item doesn't actually change anything in the original list. You need to use the
list index (alist[2]), and enumerate() works well for this:
alist = [1,2,3,4]
for index, item in enumerate(alist):
if item % 2 == 0:
alist[index] = 'even'
print(alist)
# Out: [1, 'even', 3, 'even']
A while loop might be a better choice in some cases:
If you are going to delete all the items in the list:
zlist = [0, 1, 2]
while zlist:
print(zlist[0])
zlist.pop(0)
print('After: zlist =', zlist)
# Out: 0
#
1
#
2
# After: zlist = []
Although simply resetting zlist will accomplish the same result;
zlist = []
The above example can also be combined with len() to stop after a certain point, or to delete all but x items in the
list:
zlist = [0, 1, 2]
x = 1
while len(zlist) > x:
print(zlist[0])
zlist.pop(0)
print('After: zlist =', zlist)
# Out: 0
#
1
# After: zlist = [2]
Or to loop through a list while deleting elements that meet a certain condition (in this case deleting all even
elements):
zlist = [1,2,3,4,5]
i = 0
while i < len(zlist):
if zlist[i] % 2 == 0:
zlist.pop(i)
else:
GoalKicker.com – Python® Notes for Professionals
808i += 1
print(zlist)
# Out: [1, 3, 5]
Notice that you don't increment i after deleting an element. By deleting the element at zlist[i], the index of the
next item has decreased by one, so by checking zlist[i] with the same value for i on the next iteration, you will
be correctly checking the next item in the list.
A contrary way to think about removing unwanted items from a list, is to add wanted items to a new list. The
following example is an alternative to the latter while loop example:
zlist = [1,2,3,4,5]
z_temp = []
for item in zlist:
if item % 2 != 0:
z_temp.append(item)
zlist = z_temp
print(zlist)
# Out: [1, 3, 5]
Here we are funneling desired results into a new list. We can then optionally reassign the temporary list to the
original variable.
With this trend of thinking, you can invoke one of Python's most elegant and powerful features, list
comprehensions, which eliminates temporary lists and diverges from the previously discussed in-place list/index
mutation ideology.
zlist = [1,2,3,4,5]
[item for item in zlist if item % 2 != 0]
# Out: [1, 3, 5]
Section 200.4: Integer and String identity
Python uses internal caching for a range of integers to reduce unnecessary overhead from their repeated creation.
In eﬀect, this can lead to confusing behavior when comparing integer identities:
>>> -8 is (-7 - 1)
False
>>> -3 is (-2 - 1)
True
and, using another example:
>>> (255 + 1) is (255 + 1)
True
>>> (256 + 1) is (256 + 1)
False
Wait what?
We can see that the identity operation is yields True for some integers (-3, 256) but no for others (-8, 257).
To be more speciﬁc, integers in the range [-5, 256] are internally cached during interpreter startup and are only
created once. As such, they are identical and comparing their identities with is yields True; integers outside this
GoalKicker.com – Python® Notes for Professionals
809range are (usually) created on-the-ﬂy and their identities compare to False.
This is a common pitfall since this is a common range for testing, but often enough, the code fails in the later
staging process (or worse - production) with no apparent reason after working perfectly in development.
The solution is to always compare values using the equality (==) operator and not the identity (is) operator.
Python also keeps references to commonly used strings and can result in similarly confusing behavior when
comparing identities (i.e. using is) of strings.
>>> 'python' is 'py' + 'thon'
True
The string 'python' is commonly used, so Python has one object that all references to the string 'python' use.
For uncommon strings, comparing identity fails even when the strings are equal.
>>> 'this is not a common string' is 'this is not' + ' a common string'
False
>>> 'this is not a common string' == 'this is not' + ' a common string'
True
So, just like the rule for Integers, always compare string values using the equality (==) operator and not the
identity (is) operator.
Section 200.5: Dictionaries are unordered
You might expect a Python dictionary to be sorted by keys like, for example, a C++ std::map, but this is not the
case:
myDict = {'first': 1, 'second': 2, 'third': 3}
print(myDict)
# Out: {'first': 1, 'second': 2, 'third': 3}
print([k for k in myDict])
# Out: ['second', 'third', 'first']
Python doesn't have any built-in class that automatically sorts its elements by key.
However, if sorting is not a must, and you just want your dictionary to remember the order of insertion of its
key/value pairs, you can use collections.OrderedDict:
from collections import OrderedDict
oDict = OrderedDict([('first', 1), ('second', 2), ('third', 3)])
print([k for k in oDict])
# Out: ['first', 'second', 'third']
Keep in mind that initializing an OrderedDict with a standard dictionary won't sort in any way the dictionary for
you. All that this structure does is to preserve the order of key insertion.
The implementation of dictionaries was changed in Python 3.6 to improve their memory consumption. A side eﬀect
of this new implementation is that it also preserves the order of keyword arguments passed to a function:
Python 3.x Version ≥ 3.6
GoalKicker.com – Python® Notes for Professionals
810def func(**kw): print(kw.keys())
func(a=1, b=2, c=3, d=4, e=5)
dict_keys(['a', 'b', 'c', 'd', 'e']) # expected order
Caveat: beware that “the order-preserving aspect of this new implementation is considered an implementation
detail and should not be relied upon”, as it may change in the future.
Section 200.6: Variable leaking in list comprehensions and for
loops
Consider the following list comprehension
Python 2.x Version ≤ 2.7
i = 0
a = [i for i in range(3)]
print(i) # Outputs 2
This occurs only in Python 2 due to the fact that the list comprehension “leaks” the loop control variable into the
surrounding scope (source). This behavior can lead to hard-to-ﬁnd bugs and it has been ﬁxed in Python 3.
Python 3.x Version ≥ 3.0
i = 0
a = [i for i in range(3)]
print(i) # Outputs 0
Similarly, for loops have no private scope for their iteration variable
i = 0
for i in range(3):
pass
print(i) # Outputs 2
This type of behavior occurs both in Python 2 and Python 3.
To avoid issues with leaking variables, use new variables in list comprehensions and for loops as appropriate.
Section 200.7: Chaining of or operator
When testing for any of several equality comparisons:
if a == 3 or b == 3 or c == 3:
it is tempting to abbreviate this to
if a or b or c == 3: # Wrong
This is wrong; the or operator has lower precedence than ==, so the expression will be evaluated as if (a) or (b)
or (c == 3):. The correct way is explicitly checking all the conditions:
if a == 3 or b == 3 or c == 3:
# Right Way
Alternately, the built-in any() function may be used in place of chained or operators:
GoalKicker.com – Python® Notes for Professionals
811if any([a == 3, b == 3, c == 3]): # Right
Or, to make it more eﬃcient:
if any(x == 3 for x in (a, b, c)): # Right
Or, to make it shorter:
if 3 in (a, b, c): # Right
Here, we use the in operator to test if the value is present in a tuple containing the values we want to compare
against.
Similarly, it is incorrect to write
if a == 1 or 2 or 3:
which should be written as
if a in (1, 2, 3):
Section 200.8: sys.argv[0] is the name of the ﬁle being
executed
The ﬁrst element of sys.argv[0] is the name of the python ﬁle being executed. The remaining elements are the
script arguments.
# script.py
import sys
print(sys.argv[0])
print(sys.argv)
$ python script.py
=> script.py
=> ['script.py']
$ python script.py fizz
=> script.py
=> ['script.py', 'fizz']
$ python script.py fizz buzz
=> script.py
=> ['script.py', 'fizz', 'buzz']
Section 200.9: Accessing int literals' attributes
You might have heard that everything in Python is an object, even literals. This means, for example, 7 is an object as
well, which means it has attributes. For example, one of these attributes is the bit_length. It returns the amount of
bits needed to represent the value it is called upon.
x = 7
x.bit_length()
# Out: 3
GoalKicker.com – Python® Notes for Professionals
812Seeing the above code works, you might intuitively think that 7.bit_length() would work as well, only to ﬁnd out it
raises a SyntaxError. Why? because the interpreter needs to diﬀerentiate between an attribute access and a
ﬂoating number (for example 7.2 or 7.bit_length()). It can't, and that's why an exception is raised.
There are a few ways to access an int literals' attributes:
# parenthesis
(7).bit_length()
# a space
7 .bit_length()
Using two dots (like this 7..bit_length()) doesn't work in this case, because that creates a float literal and ﬂoats
don't have the bit_length() method.
This problem doesn't exist when accessing float literals' attributes since the interpreter is "smart" enough to know
that a float literal can't contain two ., for example:
7.2.as_integer_ratio()
# Out: (8106479329266893, 1125899906842624)
Section 200.10: Global Interpreter Lock (GIL) and blocking
threads
Plenty has been written about Python's GIL. It can sometimes cause confusion when dealing with multi-threaded
(not to be confused with multiprocess) applications.
Here's an example:
import math
from threading import Thread
def calc_fact(num):
math.factorial(num)
num = 600000
t = Thread(target=calc_fact, daemon=True, args=[num])
print("About to calculate: {}!".format(num))
t.start()
print("Calculating...")
t.join()
print("Calculated")
You would expect to see Calculating... printed out immediately after the thread is started, we wanted the
calculation to happen in a new thread after all! But in actuality, you see it get printed after the calculation is
complete. That is because the new thread relies on a C function (math.factorial) which will lock the GIL while it
executes.
There are a couple ways around this. The ﬁrst is to implement your factorial function in native Python. This will
allow the main thread to grab control while you are inside your loop. The downside is that this solution will be a lot
slower, since we're not using the C function anymore.
def calc_fact(num):
""" A slow version of factorial in native Python """
res = 1
while num >= 1:
res = res * num
GoalKicker.com – Python® Notes for Professionals
813num -= 1
return res
You can also sleep for a period of time before starting your execution. Note: this won't actually allow your program
to interrupt the computation happening inside the C function, but it will allow your main thread to continue after
the spawn, which is what you may expect.
def calc_fact(num):
sleep(0.001)
math.factorial(num)
Section 200.11: Multiple return
Function xyz returns two values a and b:
def xyz():
return a, b
Code calling xyz stores result into one variable assuming xyz returns only one value:
t = xyz()
Value of t is actually a tuple (a, b) so any action on t assuming it is not a tuple may fail deep in the code with a an
unexpected error about tuples.
TypeError: type tuple doesn't deﬁne ... method
The ﬁx would be to do:
a, b = xyz()
Beginners will have trouble ﬁnding the reason of this message by only reading the tuple error message !
Section 200.12: Pythonic JSON keys
my_var = 'bla';
api_key = 'key';
...lots of code here...
params = {"language": "en", my_var: api_key}
If you are used to JavaScript, variable evaluation in Python dictionaries won't be what you expect it to be. This
statement in JavaScript would result in the params object as follows:
{
"language": "en",
"my_var": "key"
}
In Python, however, it would result in the following dictionary:
{
"language": "en",
"bla": "key"
GoalKicker.com – Python® Notes for Professionals
814}
my_var is evaluated and its value is used as the key.
GoalKicker.com – Python® Notes for Professionals
815Chapter 201: Hidden Features
Section 201.1: Operator Overloading
Everything in Python is an object. Each object has some special internal methods which it uses to interact with other
objects. Generally, these methods follow the __action__ naming convention. Collectively, this is termed as the
Python Data Model.
You can overload any of these methods. This is commonly used in operator overloading in Python. Below is an
example of operator overloading using Python's data model. The Vector class creates a simple vector of two
variables. We'll add appropriate support for mathematical operations of two vectors using operator overloading.
class Vector(object):
def __init__(self, x, y):
self.x = x
self.y = y
def __add__(self, v):
# Addition with another vector.
return Vector(self.x + v.x, self.y + v.y)
def __sub__(self, v):
# Subtraction with another vector.
return Vector(self.x - v.x, self.y - v.y)
def __mul__(self, s):
# Multiplication with a scalar.
return Vector(self.x * s, self.y * s)
def __div__(self, s):
# Division with a scalar.
float_s = float(s)
return Vector(self.x / float_s, self.y / float_s)
def __floordiv__(self, s):
# Division with a scalar (value floored).
return Vector(self.x // s, self.y // s)
def __repr__(self):
# Print friendly representation of Vector class. Else, it would
# show up like, <__main__.Vector instance at 0x01DDDDC8>.
return '<Vector (%f, %f)>' % (self.x, self.y, )
a = Vector(3, 5)
b = Vector(2, 7)
print a + b # Output: <Vector (5.000000, 12.000000)>
print b - a # Output: <Vector (-1.000000, 2.000000)>
print b * 1.3 # Output: <Vector (2.600000, 9.100000)>
print a // 17 # Output: <Vector (0.000000, 0.000000)>
print a / 17 # Output: <Vector (0.176471, 0.294118)>
The above example demonstrates overloading of basic numeric operators. A comprehensive list can be found here.
GoalKicker.com – Python® Notes for Professionals
816Credits
Thank you greatly to all the people from Stack Overﬂow Documentation who helped provide this content,
more changes can be sent to web@petercv.com for new content to be published or updated
Çağatay Uslu
2Cubed
4444
A. Ciclet
A. Raza
Aaron Christiansen
Aaron Critchley
Aaron Hall
Abhishek Kumar
abukaj
acdr
Adam Brenecki
Adam Matan
Adam_92
adeora
Aditya
Adrian Antunez
Adriano
afeique
Aidan
Ajean
Akshat Mahajan
aldanor
Aldo
Alec
alecxe
alejosocorro
Alex Gaynor
Alex L
Alex Logan
AlexV
Alfe
alfonso.kim
ALinuxLover
Alireza Savand
Alleo
Alon Alexander
amblina
Ami Tavory
amin
Amir Rachum
Amitay Stern
Anaphory
anatoly techtonik
Andrea
andrew
Andrew Schade
Chapter 20
Chapters 39, 122 and 147
Chapter 21
Chapter 196
Chapter 1
Chapters 40 and 109
Chapter 1
Chapter 38
Chapter 149
Chapter 200
Chapter 21
Chapter 85
Chapters 84 and 104
Chapter 40
Chapter 197
Chapters 40, 53, 134, 195 and 200
Chapter 88
Chapter 33
Chapter 1
Chapter 75
Chapter 5
Chapters 33, 67, 120 and 146
Chapter 40
Chapter 103
Chapter 200
Chapters 5, 40, 87, 92 and 93
Chapters 1 and 75
Chapter 55
Chapter 16
Chapter 1
Chapter 33
Chapter 88
Chapter 16
Chapter 1
Chapter 192
Chapters 21 and 149
Chapter 116
Chapters 83, 85 and 129
Chapter 192
Chapter 9
Chapters 19 and 39
Chapters 41 and 91
Chapter 159
Chapter 160
Chapter 1
Chapter 131
Chapter 84
GoalKicker.com – Python® Notes for Professionals
817Andrii Abramov
Andrzej Pronobis
Andy
Andy Hayden
angussidney
Ani Menon
Annonymous
Anthony Pham
Antoine Bolvy
Antoine Pinsard
Antti Haapala
Antwan
APerson
Aquib Javed Khan
Ares
Arkady
Arpit Solanki
Artem Kolontay
ArtOfCode
Arun
Aryaman Arora
ashes999
asmeurer
atayenel
Athari
Avantol13
avb
Axe
B8vrede
Baaing Cow
Bahrom
Bakuriu
balki
Barry
Bastian
bbayles
Beall619
bee
Benedict Bunting
Bharel
Bhargav
Bhargav Rao
bignose
Billy
Biswa_9937
bitchaser
bixel
blubberdiblub
blueberryﬁelds
blueenvelope
Bluethon
boboquack
bogdanciobanu
Chapter 1
Chapters 8, 38 and 55
Chapters 1, 5, 7, 17, 33, 51, 82 and 88
Chapters 8, 33, 67, 73, 75, 77, 98 and 149
Chapter 1
Chapters 1, 4, 40, 149 and 154
Chapters 78, 87 and 199
Chapters 13, 15, 16, 19, 20, 30, 33, 43, 45, 55, 60, 70 and 179
Chapters 1 and 149
Chapter 39
Chapters 5, 16, 72, 87 and 106
Chapter 149
Chapters 21, 69 and 72
Chapter 1
Chapters 1, 15, 20 and 41
Chapter 33
Chapters 1, 82 and 125
Chapter 173
Chapters 67, 173 and 197
Chapters 65 and 108
Chapter 179
Chapter 75
Chapters 45 and 47
Chapter 124
Chapter 151
Chapter 38
Chapter 30
Chapters 21 and 149
Chapters 1, 40, 75 and 103
Chapters 1 and 200
Chapter 8
Chapter 149
Chapter 53
Chapter 20
Chapter 86
Chapter 128
Chapters 74 and 101
Chapters 161 and 164
Chapter 99
Chapters 30 and 149
Chapter 40
Chapters 41, 149 and 200
Chapter 149
Chapter 200
Chapters 178, 182 and 183
Chapter 149
Chapter 200
Chapter 177
Chapter 181
Chapters 9 and 20
Chapter 149
Chapters 10, 11 and 18
Chapter 111
GoalKicker.com – Python® Notes for Professionals
818Bonifacio2
BoppreH
Bosoneando
Božo Stojković
bpachev
Brendan Abel
brennan
Brett Cannon
Brian C
Brien
Bryan P
BSL
Burhan Khalid
BusyAnt
Buzz
Cache Staheli
CamelBackNotation
Cameron Gagnon
Camsbury
caped114
carrdelling
Cbeb24404
ceruleus
cﬁ
Chandan Purohit
ChaoticTwist
Charles
Charul
Chinmay Hegde
Chong Tang
Chris Hunt
Chris Larson
Chris Midgley
Chris Mueller
Christian Ternus
Christofer Ohlsson
Christophe Roussy
Chromium
Cilyan
Cimbali
cizixs
cjds
Clíodhna
Claudiu
Clayton Wahlstrom
cledoux
CodenameLambda
Cody Piersall
Colin Yang
Comrade SparklePony
Conrad.Dean
crhodes
c ʟ s
Chapter 64
Chapter 19
Chapter 46
Chapters 1, 14, 21, 33 and 149
Chapter 53
Chapter 84
Chapter 173
Chapters 11 and 43
Chapter 1
Chapter 41
Chapter 1
Chapters 1 and 197
Chapter 19
Chapters 1, 20, 43, 60, 78 and 88
Chapter 18
Chapter 41
Chapter 33
Chapter 149
Chapters 9 and 33
Chapter 41
Chapter 77
Chapter 1
Chapter 1
Chapters 21, 26 and 69
Chapters 20 and 33
Chapters 21, 33, 41 and 107
Chapters 10, 21, 30, 41, 149 and 200
Chapter 167
Chapters 50, 94, 132, 164 and 171
Chapter 21
Chapter 16
Chapter 33
Chapter 1
Chapter 19
Chapters 1, 16, 43, 51 and 78
Chapter 45
Chapter 200
Chapter 134
Chapter 170
Chapter 8
Chapters 19, 20 and 128
Chapters 110 and 134
Chapter 1
Chapters 1, 31, 67, 75, 80, 83, 88, 111, 118, 153, 192 and 193
Chapter 149
Chapter 108
Chapters 1 and 67
Chapter 8
Chapter 149
Chapters 180 and 181
Chapters 1, 5, 21, 38 and 43
Chapter 30
Chapters 1, 149, 161 and 191
GoalKicker.com – Python® Notes for Professionals
819Dair
Daksh Gupta
Dania
danidee
Daniel
Daniil Ryzhkov
Darkade
Darth Kotik
Darth Shadow
Dartmouth
Dave J
David
David Cullen
David Heyman
davidism
DawnPaladin
Dee
deeenes
deepakkt
DeepSpace
Delgan
denvaar
depperm
DevD
Devesh Saini
DhiaTN
dhimanta
Dilettant
Dima Tisnek
djaszczurowski
Doc
dodell
Doraemon
Doug Henderson
Douglas Starnes
Dov
dreftymac
driax
Duh
Dunatotatos
dwanderson
eandersson
edwinksl
eenblam
Elazar
Eleftheria
elegent
Ellis
Elodin
Emma
Enamul Hassan
engineercoding
Enrico Maria De Angelis
Chapters 11, 120 and 173
Chapters 1 and 38
Chapter 1
Chapter 33
Chapter 43
Chapter 173
Chapter 173
Chapter 16
Chapters 1, 40, 75, 97, 149 and 173
Chapters 1, 62, 149 and 150
Chapters 40 and 149
Chapters 9, 33, 124 and 161
Chapters 30 and 121
Chapters 41 and 149
Chapter 13
Chapter 33
Chapter 186
Chapters 1, 20 and 67
Chapter 14
Chapters 9, 16, 77, 100, 149 and 200
Chapters 1, 16, 20 and 40
Chapter 167
Chapters 1, 3, 38, 41 and 99
Chapter 1
Chapter 115
Chapter 16
Chapters 184 and 185
Chapter 200
Chapter 21
Chapter 167
Chapter 143
Chapter 1
Chapter 29
Chapter 41
Chapter 1
Chapter 30
Chapter 40
Chapters 39, 75 and 88
Chapter 149
Chapter 171
Chapter 149
Chapter 127
Chapter 173
Chapter 21
Chapters 1, 7, 8, 13, 15, 16, 20, 21, 28, 38, 41, 67, 87, 111, 144 and 149
Chapter 113
Chapter 33
Chapters 20 and 45
Chapters 33 and 195
Chapters 20 and 21
Chapter 16
Chapter 192
Chapter 1
GoalKicker.com – Python® Notes for Professionals
820enrico.bacis
erewok
Eric
Eric Finn
Eric Zhang
Erica
ericdwang
ericmarkmartin
Erik Godard
EsmaeelE
Esteis
ettanany
Everyone_Else
evuez
exhuma
Fábio Perez
Faiz Halde
FazeL
Felix D.
Felk
Fermi paradox
Fernando
Fﬁsegydd
Filip Haglund
Firix
ﬂamenco
Flickerlight
Florian Bender
FMc
Francisco Guimaraes
Franck Dernoncourt
FrankBr
frankyjuang
Fred Barclay
Freddy
fredley
freidrichen
Frustrated
Gal Dreiman
ganesh gadila
Ganesh K
Gareth Latty
garg10may
Gavin
Geeklhem
Generic Snake
geoﬀspear
Gerard Roche
gerrit
ghostarbeiter
Giannis Spiliopoulos
GiantsLoveDeathMetal
girish946
Chapters 21, 56 and 149
Chapter 149
Chapter 107
Chapter 16
Chapter 110
Chapter 1
Chapter 149
Chapters 67, 98, 110 and 149
Chapter 1
Chapter 1
Chapters 13 and 21
Chapters 27 and 149
Chapter 149
Chapters 7, 8, 14, 20, 40, 113 and 149
Chapter 20
Chapter 31
Chapters 21, 114 and 119
Chapters 111 and 148
Chapter 16
Chapter 21
Chapter 21
Chapter 173
Chapters 14, 38, 98, 108 and 193
Chapter 1
Chapters 1 and 150
Chapter 56
Chapter 20
Chapter 21
Chapter 43
Chapter 94
Chapter 1
Chapter 36
Chapter 181
Chapters 1 and 157
Chapter 1
Chapter 45
Chapter 21
Chapter 74
Chapters 16, 20, 21, 33, 40, 136 and 137
Chapters 20 and 41
Chapter 148
Chapter 19
Chapters 21 and 149
Chapter 149
Chapters 14, 110 and 124
Chapter 16
Chapter 149
Chapter 1
Chapter 40
Chapters 16, 21, 33, 41, 45, 88, 132 and 149
Chapter 40
Chapters 40 and 164
Chapters 31 and 154
GoalKicker.com – Python® Notes for Professionals
821giucal
GoatsWearHats
goodmami
Greg
greut
Guy
H. Pauwelyn
hackvan
Hannele
Hannes Karppila
Harrison
hashcode55
ha_1694
heyhey2k
hiro protagonist
HoverHell
Hriddhi Dey
Hurkyl
hxysayhi
Ian
IanAuld
iankit
iBelieve
idjaw
ifma
Igor Raush
Ilia Barahovski
ilse2005
Inbar Rose
Indradhanush Gupta
Inﬁnity
InitializeSahib
intboolstring
iScrE4m
JF
Jörn Hees
J0HN
j3485
jackskis
Jacques de Hooge
JakeD
James
James Elderﬁeld
James Taylor
JamesS
Jan
jani
japborst
Jean
jedwards
Jeﬀ Hutchins
Jeﬀrey Lin
JelmerS
Chapter 55
Chapters 1, 16, 29, 41 and 72
Chapter 75
Chapter 22
Chapter 37
Chapters 16, 19 and 156
Chapter 1
Chapter 164
Chapter 21
Chapters 14 and 134
Chapter 40
Chapter 76
Chapter 173
Chapter 94
Chapters 54 and 200
Chapter 12
Chapter 105
Chapters 21 and 33
Chapters 66 and 168
Chapter 1
Chapters 1 and 21
Chapters 21 and 37
Chapter 19
Chapter 41
Chapter 108
Chapters 1, 19, 20, 38, 39, 45, 67 and 98
Chapters 32, 41 and 88
Chapter 30
Chapter 16
Chapter 49
Chapters 19 and 115
Chapters 38, 39 and 82
Chapters 10, 21 and 45
Chapter 149
Chapters 1, 9, 15, 20, 29, 33, 38, 88, 97, 111, 119, 125 and 149
Chapter 137
Chapters 21 and 67
Chapter 20
Chapters 53 and 67
Chapters 97 and 151
Chapter 22
Chapters 8, 14, 19, 20, 33 and 100
Chapters 20, 40, 45 and 149
Chapter 1
Chapter 21
Chapter 75
Chapter 20
Chapter 86
Chapters 1 and 40
Chapters 1, 102 and 149
Chapter 110
Chapters 1, 16, 75, 132 and 200
Chapter 102
GoalKicker.com – Python® Notes for Professionals
822JGreenwell
JHS
Jim Fasarakis Hilliard
jim opleydulven
Jimmy Song
jimsug
jkdev
jkitchen
JL Peyret
jlarsch
jmunsch
JNat
joel3000
Johan Lundberg
John Slegers
John Zwinck
Jonatan
jonrsharpe
Joseph True
Josh
Jossie Calderon
jrast
JRodDynamite
jtbandes
Juan T
JuanPablo
Julien Spronck
Julij Jegorov
Justin
Justin Chadwell
Justin M. Ucar
j__
Kabie
Kallz
Kamran Mackey
Karl Knechtel
KartikKannapur
kdopen
keiv.ﬂy
Kevin Brown
KeyWeeUsr
KIDJourney
Kinifwyne
Kiran Vemuri
kisanme
knight
kollery
kon psych
krato
Kunal Marwaha
Kwarrtz
L3viathan
Lafexlos
Chapters 3, 9, 33 and 37
Chapter 21
Chapters 1, 16, 33, 41, 55, 87, 110, 149 and 200
Chapter 1
Chapter 149
Chapters 1 and 20
Chapters 20 and 38
Chapter 33
Chapters 40 and 51
Chapter 38
Chapters 1, 47, 92, 125, 181 and 192
Chapters 10, 20 and 29
Chapters 21, 103 and 192
Chapter 1
Chapters 1 and 149
Chapter 11
Chapters 40, 64 and 87
Chapters 1, 75, 78 and 98
Chapter 1
Chapter 149
Chapter 86
Chapter 16
Chapters 1, 21 and 40
Chapter 70
Chapters 1, 67, 90 and 149
Chapter 110
Chapters 53 and 75
Chapter 188
Chapters 30, 33, 40, 74 and 149
Chapter 125
Chapter 149
Chapter 41
Chapter 149
Chapter 38
Chapter 1
Chapters 67, 69 and 149
Chapters 20 and 38
Chapters 19, 21 and 110
Chapter 194
Chapters 1, 5, 14, 30, 53, 75, 146, 149 and 192
Chapters 80 and 153
Chapter 21
Chapters 43 and 193
Chapter 1
Chapter 1
Chapter 40
Chapter 156
Chapter 47
Chapter 83
Chapter 149
Chapter 21
Chapters 33 and 98
Chapters 1, 9 and 20
GoalKicker.com – Python® Notes for Professionals
823LDP
Lee Netherton
Leo
Leo Thumma
Leon
Leon Z.
Liteye
loading...
Locane
lorenzofeliz
LostAvatar
Luca Van Oort
Luke Taylor
lukewrites
Lyndsy Simon
machine yearning
magu_
Mahdi
Mahmoud Hashemi
Majid
Malt
manu
MANU
Marco Pashkov
Mario Corchero
Mark
Mark Miller
Mark Omo
Markus Meskanen
MarkyPython
Marlon Abeykoon
Martijn Pieters
Martin Valgur
Math
Mathias711
matsjoyce
Matt Dodge
Matt Giltaji
Matt Rowland
MattCorr
Mattew Whitt
mattgathu
Matthew
max
Max Feng
mbrig
mbsingh
Md Sifatul Islam
mdegis
Mechanic
mertyildiran
MervS
metmirr
Chapter 20
Chapters 21, 33 and 114
Chapters 49 and 97
Chapter 20
Chapter 1
Chapter 74
Chapters 21 and 38
Chapters 83 and 114
Chapter 21
Chapter 2
Chapters 1 and 161
Chapter 165
Chapter 70
Chapter 20
Chapter 21
Chapters 19, 53 and 67
Chapter 77
Chapters 21, 82 and 120
Chapter 199
Chapters 19, 28, 77, 82, 98, 112 and 173
Chapter 200
Chapter 1
Chapter 1
Chapters 29, 39, 40, 83 and 173
Chapter 192
Chapter 125
Chapter 130
Chapter 168
Chapter 21
Chapter 41
Chapter 79
Chapters 1, 67, 77 and 97
Chapter 104
Chapter 16
Chapter 1
Chapters 1 and 9
Chapters 149 and 200
Chapters 33, 40, 173 and 193
Chapter 149
Chapters 4 and 121
Chapters 21, 37, 39, 110, 146, 173 and 192
Chapters 19, 117, 124 and 190
Chapter 77
Chapter 67
Chapter 14
Chapter 21
Chapter 161
Chapters 28 and 75
Chapter 1
Chapters 1, 9, 19 and 28
Chapter 1
Chapter 125
Chapter 162
GoalKicker.com – Python® Notes for Professionals
824mezzode
mgilson
Michael Recachinas
Michel Touw
Mike Driscoll
Miljen Mikic
Mimouni
Mirec Miskuf
mnoronha
Mohammad Julﬁkar
moshemeirelles
MrP01
mrtuovinen
MSD
MSeifert
muddyﬁsh
Mukunda Modell
Muntasir Alam
Murphy4
MYGz
Naga2Raja
Nander Speerstra
naren
Nathan Osman
Nathaniel Ford
ncmathsadist
nd.
nehemiah
nemesisﬁxx
Ni.
Nick Humrich
Nicolás
Nicole White
niemmi
niyasc
nlsdfnbch
Nour Chawich
noɥʇʎ ʎzɐɹƆ
Nuhil Mehdy
numbermaniac
obust
Ohad Eytan
ojas mohril
omgimanerd
Or East
OrangeTux
Ortomala Lokni
orvi
Oz Bar
Ozair Kafray
Panda
Parousia
Chapter 28
Chapter 192
Chapter 149
Chapter 161
Chapters 1 and 13
Chapter 1
Chapter 1
Chapter 21
Chapters 1 and 149
Chapter 123
Chapter 1
Chapter 20
Chapter 92
Chapter 1
Chapters 9, 16, 19, 21, 26, 33, 37, 41, 43, 45, 48, 55, 64, 67, 68, 69, 70, 71, 72,
73 and 200
Chapters 1, 20, 21, 33, 37, 57, 111 and 149
Chapter 37
Chapter 1
Chapter 33
Chapter 40
Chapter 150
Chapters 40, 75 and 116
Chapters 42 and 89
Chapter 190
Chapters 1, 29 and 41
Chapter 200
Chapter 33
Chapter 173
Chapter 10
Chapters 1 and 92
Chapter 139
Chapter 29
Chapter 5
Chapter 149
Chapters 1, 43, 45 and 149
Chapters 5, 19, 28, 30, 53, 67, 117, 120 and 121
Chapter 40
Chapters 1, 19, 21, 28, 88 and 149
Chapter 173
Chapters 1 and 9
Chapter 54
Chapter 5
Chapter 38
Chapter 200
Chapters 8, 21, 75, 112 and 189
Chapter 149
Chapter 173
Chapters 1, 25, 41, 125, 133 and 134
Chapter 20
Chapter 30
Chapter 21
Chapters 23 and 69
GoalKicker.com – Python® Notes for Professionals
825Pasha
Patrick Haugh
Paul
Paul Weaver
paulmorriss
Paulo Freitas
Paulo Scardine
Pavan Nath
pcurry
Peter Brittain
Peter Mølgaard Pallesen
Peter Shinners
petrs
philngo
Pigman168
pistache
pktangyue
poke
PolyGeo
poppie
ppperry
Prem Narain
Preston
proprefenetre
proprius
PSN
pylang
PYPL
Pythonista
pzp
Quill
qwertyuip9
R Colmenares
R Nar
Rápli András
Régis B.
Raghav
Rahul Nair
RahulHP
rajah9
Ram Grandhi
RandomHash
rassar
ravigadila
Razik
Rednivrug
regnarg
Reut Sharabani
rfkortekaas
Ricardo
Riccardo Petraglia
Richard Fitzhugh
rlee827
Chapters 3, 20, 21, 33, 37, 38, 67, 70, 77, 83 and 149
Chapters 1 and 200
Chapter 5
Chapter 88
Chapter 5
Chapter 149
Chapter 39
Chapters 1, 20 and 179
Chapters 29, 110 and 149
Chapter 77
Chapter 73
Chapter 109
Chapter 77
Chapter 16
Chapter 96
Chapter 38
Chapter 149
Chapter 20
Chapter 145
Chapter 149
Chapter 55
Chapter 59
Chapters 138 and 173
Chapter 147
Chapter 5
Chapter 1
Chapters 1, 8, 21, 33, 38, 43, 53, 54, 73, 80, 128, 147, 173, 192 and 200
Chapter 79
Chapters 32 and 149
Chapters 1, 29, 30, 33, 41, 49, 64 and 67
Chapter 1
Chapters 161, 173 and 181
Chapter 10
Chapter 21
Chapter 82
Chapter 173
Chapter 125
Chapters 1, 21, 43, 88 and 143
Chapters 5, 8, 45, 53, 64 and 112
Chapters 14, 16 and 45
Chapter 1
Chapter 95
Chapter 172
Chapters 20, 60, 85, 91 and 104
Chapter 158
Chapters 2, 35 and 63
Chapter 75
Chapters 64 and 200
Chapters 1 and 115
Chapter 157
Chapters 21, 84 and 117
Chapter 38
Chapter 62
GoalKicker.com – Python® Notes for Professionals
826rll
Rob H
Rob Murray
Ronen Ness
ronrest
Roy Iacob
rrao
rrawat
Ryan Smith
ryanyuyu
Ry
Sachin Kalkur
sagism
Saiful Azad
Sam Krygsheld
Sam Whited
Sangeeth Sudheer
Saqib Shamsi
Sardathrion
Sardorbek Imomaliev
sarvajeetsuman
SashaZd
satsumas
sayan
Scott Mermelstein
Sebastian Schrader
Selcuk
Sempoo
Serenity
SerialDev
serv
Seth M. Larson
Seven
sevenforce
ShadowRanger
Shantanu Alshi
Shawn Mehan
Shihab Shahriar
Shijo
Shoe
Shrey Gupta
Shreyash S Sarnayak
Shuo
SiggyF
Simon Fraser
Simon Hibbs
Simplans
Sirajus Salayhin
sisanared
skrrgwasme
SN Ravichandran KR
solarc
Chapter 21
Chapter 121
Chapter 94
Chapter 30
Chapters 19 and 41
Chapter 19
Chapter 1
Chapter 161
Chapters 21 and 120
Chapter 21
Chapter 149
Chapter 125
Chapter 5
Chapter 43
Chapter 1
Chapter 111
Chapter 1
Chapter 92
Chapter 103
Chapter 103
Chapters 9 and 16
Chapters 12, 14, 29, 64, 86, 134, 143, 144, 146 and 194
Chapter 67
Chapters 1 and 96
Chapters 110, 135 and 149
Chapter 173
Chapters 1, 28, 149 and 201
Chapter 38
Chapters 20, 30, 40, 43, 149 and 173
Chapter 82
Chapter 40
Chapters 54 and 87
Chapters 1, 11, 20 and 33
Chapters 16 and 67
Chapter 149
Chapter 173
Chapters 10, 15, 19, 20 and 47
Chapter 200
Chapter 198
Chapter 21
Chapters 41, 56 and 173
Chapter 12
Chapter 77
Chapters 16 and 111
Chapter 173
Chapter 169
Chapters 1, 9, 10, 14, 16, 19, 21, 28, 33, 37, 38, 41, 43, 44, 45, 50, 69, 75, 77,
82, 88, 99, 147, 149 and 173
Chapters 5, 175 and 176
Chapter 39
Chapters 16 and 99
Chapter 75
Chapters 20 and 149
GoalKicker.com – Python® Notes for Professionals
827Soumendra Kumar Sahoo
SouvikMaji
sricharan
StardustGogeta
stark
Stephen Nyamweya
Steve Barnes
Steven Maude
sth
strpeter
StuxCrystal
Sudip Bhandari
Sun Qingyao
Sunny Patel
SuperBiasedMan
supersam654
surfthecity
Symmitchry
sytech
Sнаđошƒа
Tadhg McDonald
talhasch
Tasdik Rahman
taylor swift
techydesigner
Teepeemm
Tejas Jadhav
Tejus Prasad
TemporalWolf
textshell
TheGenie OfTruth
theheadofabroom
the_cat_lady
The_Curry_Man
Thomas Ahle
Thomas Crowley
Thomas Gerot
Thomas Moreau
Thtu
Tim
Tim D
tjohnson
tlo
tobias_k
Tom
Tom Barron
Tom de Geus
Tony Meyer
Tony Suﬀolk 66
tox123
TuringTux
Tyler Crompton
Chapters 14 and 38
Chapter 1
Chapter 149
Chapter 43
Chapter 1
Chapter 161
Chapters 33 and 82
Chapters 11, 33, 47 and 92
Chapters 91, 92 and 141
Chapters 85 and 192
Chapters 21, 37, 43, 56, 76, 82, 121 and 142
Chapter 88
Chapter 101
Chapter 21
Chapters 1, 4, 15, 16, 20, 21, 26, 29, 30, 33, 41, 43, 64, 69, 77, 80, 88, 132, 149
and 200
Chapter 70
Chapter 6
Chapters 47 and 53
Chapter 92
Chapters 1 and 134
Chapter 149
Chapters 92, 93 and 164
Chapter 30
Chapter 1
Chapters 1, 38, 43 and 190
Chapter 152
Chapter 201
Chapter 1
Chapter 90
Chapters 16, 28, 33 and 121
Chapter 1
Chapters 41, 49 and 64
Chapter 43
Chapter 16
Chapters 60 and 134
Chapter 105
Chapters 30, 43, 58, 61, 126 and 181
Chapter 119
Chapter 80
Chapter 149
Chapter 200
Chapter 44
Chapter 82
Chapters 28 and 40
Chapter 16
Chapters 1 and 21
Chapter 1
Chapter 43
Chapters 9, 10, 38 and 40
Chapter 38
Chapter 4
Chapter 86
GoalKicker.com – Python® Notes for Professionals
828Tyler Gubala
Udi
UltraBob
Umibozu
Underyx
Undo
unutbu
user2027202827
user2314737
user2683246
user2728397
user2853437
user312016
user3333708
user405
user6457549
Utsav T
vaichidrewar
valeas
Valentin Lorentz
Valor Naram
vaultah
Veedrac
Vikash Kumar Jain
Vin
Vinayak
vinzee
viveksyngh
VJ Magar
Vlad Bezden
weewooquestionaire
WeizhongTu
Wickramaranga
Will
Wingston Sharon
Wladimir Palant
wnnmaw
Wolf
WombatPM
Wombatz
wrwrwr
wwii
wythagoras
Xavier Combelle
XCoder Real
xgord
XonAether
xtreak
Y0da
ygram
Yogendra Sharma
yurib
Chapters 119 and 122
Chapter 54
Chapter 38
Chapter 30
Chapter 49
Chapter 9
Chapter 116
Chapter 163
Chapters 8, 9, 13, 16, 20, 28, 30, 33, 38, 40, 41, 57, 60, 64, 69, 75, 88, 110, 134,
142, 149, 154, 161, 196 and 200
Chapters 43 and 187
Chapter 166
Chapter 1
Chapters 1, 40 and 77
Chapter 33
Chapter 33
Chapter 20
Chapter 20
Chapter 1
Chapter 161
Chapters 20, 21, 43, 110 and 149
Chapter 43
Chapters 20, 33, 43 and 77
Chapters 21, 33, 41 and 110
Chapter 174
Chapters 1 and 17
Chapter 149
Chapters 99, 116 and 120
Chapters 10 and 19
Chapter 31
Chapter 103
Chapter 1
Chapters 41 and 149
Chapter 53
Chapters 5, 15, 16, 21, 30, 33, 91, 116, 117, 121 and 164
Chapter 155
Chapters 21, 37 and 197
Chapters 41, 43 and 53
Chapter 149
Chapter 30
Chapter 200
Chapter 173
Chapter 14
Chapter 9
Chapters 15, 19, 111 and 120
Chapter 47
Chapters 14 and 30
Chapter 52
Chapters 67 and 149
Chapter 85
Chapter 190
Chapters 1 and 117
Chapter 64
GoalKicker.com – Python® Notes for Professionals
829Zach Janicki
Zags
Zaid Ajaj
zarak
Zaz
zenlc2000
Zhanping Shi
zmo
zondo
zopieux
zvone
zxxz
Zydnar
Ƙ ỈSƬƠƑ
λuser
Некто
Chapter 1
Chapter 1
Chapter 67
Chapter 149
Chapter 21
Chapter 34
Chapter 145
Chapters 83, 140 and 141
Chapters 75 and 83
Chapter 173
Chapters 13, 37, 39 and 112
Chapter 33
Chapter 81
Chapter 117
Chapters 67 and 77
Chapters 24, 37 and 128
GoalKicker.com – Python® Notes for Professionals
830You may also like




### context Bash


Bash
Bash
Notes for Professionals
Notes for Professionals
100+ pages
of professional hints and tricks
GoalKicker.com
Free Programming Books
Disclaimer
This is an unocial free book created for educational purposes and is
not aliated with ocial Bash group(s) or company(s).
All trademarks and registered trademarks are
the property of their respective ownersContents
About ................................................................................................................................................................................... 1
Chapter 1: Getting started with Bash ................................................................................................................. 2
Section 1.1: Hello World ................................................................................................................................................. 2
Section 1.2: Hello World Using Variables ..................................................................................................................... 4
Section 1.3: Hello World with User Input ...................................................................................................................... 4
Section 1.4: Importance of Quoting in Strings ............................................................................................................ 5
Section 1.5: Viewing information for Bash built-ins .................................................................................................... 6
Section 1.6: Hello World in "Debug" mode .................................................................................................................. 6
Section 1.7: Handling Named Arguments .................................................................................................................... 7
Chapter 2: Script shebang ........................................................................................................................................ 8
Section 2.1: Env shebang .............................................................................................................................................. 8
Section 2.2: Direct shebang .......................................................................................................................................... 8
Section 2.3: Other shebangs ........................................................................................................................................ 8
Chapter 3: Navigating directories ...................................................................................................................... 10
Section 3.1: Absolute vs relative directories .............................................................................................................. 10
Section 3.2: Change to the last directory .................................................................................................................. 10
Section 3.3: Change to the home directory .............................................................................................................. 10
Section 3.4: Change to the Directory of the Script .................................................................................................. 10
Chapter 4: Listing Files ............................................................................................................................................ 12
Section 4.1: List Files in a Long Listing Format ......................................................................................................... 12
Section 4.2: List the Ten Most Recently Modiﬁed Files ............................................................................................ 13
Section 4.3: List All Files Including Dotﬁles ................................................................................................................ 13
Section 4.4: List Files Without Using `ls` ..................................................................................................................... 13
Section 4.5: List Files ................................................................................................................................................... 14
Section 4.6: List Files in a Tree-Like Format ............................................................................................................. 14
Section 4.7: List Files Sorted by Size .......................................................................................................................... 14
Chapter 5: Using cat .................................................................................................................................................. 16
Section 5.1: Concatenate ﬁles ..................................................................................................................................... 16
Section 5.2: Printing the Contents of a File ............................................................................................................... 16
Section 5.3: Write to a ﬁle ........................................................................................................................................... 17
Section 5.4: Show non printable characters ............................................................................................................. 17
Section 5.5: Read from standard input ..................................................................................................................... 18
Section 5.6: Display line numbers with output ......................................................................................................... 18
Section 5.7: Concatenate gzipped ﬁles ..................................................................................................................... 18
Chapter 6: Grep ........................................................................................................................................................... 20
Section 6.1: How to search a ﬁle for a pattern ......................................................................................................... 20
Chapter 7: Aliasing ..................................................................................................................................................... 21
Section 7.1: Bypass an alias ........................................................................................................................................ 21
Section 7.2: Create an Alias ........................................................................................................................................ 21
Section 7.3: Remove an alias ..................................................................................................................................... 21
Section 7.4: The BASH_ALIASES is an internal bash assoc array .......................................................................... 22
Section 7.5: Expand alias ............................................................................................................................................ 22
Section 7.6: List all Aliases .......................................................................................................................................... 22
Chapter 8: Jobs and Processes ........................................................................................................................... 23
Section 8.1: Job handling ............................................................................................................................................ 23
Section 8.2: Check which process running on speciﬁc port .................................................................................... 25Section 8.3: Disowning background job .................................................................................................................... 25
Section 8.4: List Current Jobs ..................................................................................................................................... 25
Section 8.5: Finding information about a running process ..................................................................................... 25
Section 8.6: List all processes ..................................................................................................................................... 26
Chapter 9: Redirection ............................................................................................................................................. 27
Section 9.1: Redirecting standard output .................................................................................................................. 27
Section 9.2: Append vs Truncate ............................................................................................................................... 27
Section 9.3: Redirecting both STDOUT and STDERR .............................................................................................. 28
Section 9.4: Using named pipes ................................................................................................................................. 28
Section 9.5: Redirection to network addresses ........................................................................................................ 30
Section 9.6: Print error messages to stderr .............................................................................................................. 30
Section 9.7: Redirecting multiple commands to the same ﬁle ............................................................................... 31
Section 9.8: Redirecting STDIN .................................................................................................................................. 31
Section 9.9: Redirecting STDERR ............................................................................................................................... 32
Section 9.10: STDIN, STDOUT and STDERR explained ............................................................................................ 32
Chapter 10: Control Structures ............................................................................................................................ 34
Section 10.1: Conditional execution of command lists ............................................................................................. 34
Section 10.2: If statement ............................................................................................................................................ 35
Section 10.3: Looping over an array .......................................................................................................................... 36
Section 10.4: Using For Loop to List Iterate Over Numbers .................................................................................... 37
Section 10.5: continue and break ............................................................................................................................... 37
Section 10.6: Loop break ............................................................................................................................................. 37
Section 10.7: While Loop ............................................................................................................................................. 38
Section 10.8: For Loop with C-style syntax ............................................................................................................... 39
Section 10.9: Until Loop ............................................................................................................................................... 39
Section 10.10: Switch statement with case ................................................................................................................ 39
Section 10.11: For Loop without a list-of-words parameter ..................................................................................... 40
Chapter 11: true, false and : commands .......................................................................................................... 41
Section 11.1: Inﬁnite Loop ............................................................................................................................................. 41
Section 11.2: Function Return ...................................................................................................................................... 41
Section 11.3: Code that will always/never be executed ........................................................................................... 41
Chapter 12: Arrays ...................................................................................................................................................... 42
Section 12.1: Array Assignments ................................................................................................................................. 42
Section 12.2: Accessing Array Elements .................................................................................................................... 43
Section 12.3: Array Modiﬁcation ................................................................................................................................. 43
Section 12.4: Array Iteration ....................................................................................................................................... 44
Section 12.5: Array Length .......................................................................................................................................... 45
Section 12.6: Associative Arrays ................................................................................................................................. 45
Section 12.7: Looping through an array .................................................................................................................... 46
Section 12.8: Destroy, Delete, or Unset an Array ..................................................................................................... 47
Section 12.9: Array from string ................................................................................................................................... 47
Section 12.10: List of initialized indexes ...................................................................................................................... 47
Section 12.11: Reading an entire ﬁle into an array .................................................................................................... 48
Section 12.12: Array insert function ............................................................................................................................ 48
Chapter 13: Associative arrays ............................................................................................................................ 50
Section 13.1: Examining assoc arrays ........................................................................................................................ 50
Chapter 14: Functions ............................................................................................................................................... 52
Section 14.1: Functions with arguments ..................................................................................................................... 52
Section 14.2: Simple Function ..................................................................................................................................... 53
Section 14.3: Handling ﬂags and optional parameters ........................................................................................... 53Section 14.4: Print the function deﬁnition .................................................................................................................. 54
Section 14.5: A function that accepts named parameters ...................................................................................... 54
Section 14.6: Return value from a function ............................................................................................................... 55
Section 14.7: The exit code of a function is the exit code of its last command ..................................................... 55
Chapter 15: Bash Parameter Expansion .......................................................................................................... 57
Section 15.1: Modifying the case of alphabetic characters ..................................................................................... 57
Section 15.2: Length of parameter ............................................................................................................................ 57
Section 15.3: Replace pattern in string ...................................................................................................................... 58
Section 15.4: Substrings and subarrays .................................................................................................................... 59
Section 15.5: Delete a pattern from the beginning of a string ................................................................................ 60
Section 15.6: Parameter indirection ........................................................................................................................... 61
Section 15.7: Parameter expansion and ﬁlenames .................................................................................................. 61
Section 15.8: Default value substitution ..................................................................................................................... 62
Section 15.9: Delete a pattern from the end of a string .......................................................................................... 62
Section 15.10: Munging during expansion ................................................................................................................. 63
Section 15.11: Error if variable is empty or unset ...................................................................................................... 64
Chapter 16: Copying (cp) ......................................................................................................................................... 65
Section 16.1: Copy a single ﬁle .................................................................................................................................... 65
Section 16.2: Copy folders ........................................................................................................................................... 65
Chapter 17: Find ........................................................................................................................................................... 66
Section 17.1: Searching for a ﬁle by name or extension .......................................................................................... 66
Section 17.2: Executing commands against a found ﬁle ......................................................................................... 66
Section 17.3: Finding ﬁle by access / modiﬁcation time .......................................................................................... 67
Section 17.4: Finding ﬁles according to size .............................................................................................................. 68
Section 17.5: Filter the path ......................................................................................................................................... 69
Section 17.6: Finding ﬁles by type .............................................................................................................................. 70
Section 17.7: Finding ﬁles by speciﬁc extension ........................................................................................................ 70
Chapter 18: Using sort .............................................................................................................................................. 71
Section 18.1: Sort command output ........................................................................................................................... 71
Section 18.2: Make output unique .............................................................................................................................. 71
Section 18.3: Numeric sort .......................................................................................................................................... 71
Section 18.4: Sort by keys ........................................................................................................................................... 72
Chapter 19: Sourcing ................................................................................................................................................. 74
Section 19.1: Sourcing a ﬁle ......................................................................................................................................... 74
Section 19.2: Sourcing a virtual environment ........................................................................................................... 74
Chapter 20: Here documents and here strings ........................................................................................... 76
Section 20.1: Execute command with here document ............................................................................................. 76
Section 20.2: Indenting here documents .................................................................................................................. 76
Section 20.3: Create a ﬁle ........................................................................................................................................... 77
Section 20.4: Here strings ........................................................................................................................................... 77
Section 20.5: Run several commands with sudo ..................................................................................................... 78
Section 20.6: Limit Strings .......................................................................................................................................... 78
Chapter 21: Quoting ................................................................................................................................................... 80
Section 21.1: Double quotes for variable and command substitution .................................................................... 80
Section 21.2: Dierence between double quote and single quote ......................................................................... 80
Section 21.3: Newlines and control characters ......................................................................................................... 81
Section 21.4: Quoting literal text ................................................................................................................................. 81
Chapter 22: Conditional Expressions ................................................................................................................ 83
Section 22.1: File type tests ......................................................................................................................................... 83Section 22.2: String comparison and matching ....................................................................................................... 83
Section 22.3: Test on exit status of a command ...................................................................................................... 85
Section 22.4: One liner test ......................................................................................................................................... 85
Section 22.5: File comparison .................................................................................................................................... 85
Section 22.6: File access tests .................................................................................................................................... 86
Section 22.7: Numerical comparisons ....................................................................................................................... 86
Chapter 23: Scripting with Parameters ........................................................................................................... 88
Section 23.1: Multiple Parameter Parsing .................................................................................................................. 88
Section 23.2: Argument parsing using a for loop .................................................................................................... 89
Section 23.3: Wrapper script ...................................................................................................................................... 89
Section 23.4: Accessing Parameters ......................................................................................................................... 90
Section 23.5: Split string into an array in Bash ......................................................................................................... 91
Chapter 24: Bash history substitutions ........................................................................................................... 92
Section 24.1: Quick Reference .................................................................................................................................... 92
Section 24.2: Repeat previous command with sudo ............................................................................................... 93
Section 24.3: Search in the command history by pattern ....................................................................................... 93
Section 24.4: Switch to newly created directory with !#:N ...................................................................................... 93
Section 24.5: Using !$ .................................................................................................................................................. 94
Section 24.6: Repeat the previous command with a substitution .......................................................................... 94
Chapter 25: Math ........................................................................................................................................................ 95
Section 25.1: Math using dc ........................................................................................................................................ 95
Section 25.2: Math using bash capabilities ............................................................................................................... 96
Section 25.3: Math using bc ........................................................................................................................................ 96
Section 25.4: Math using expr .................................................................................................................................... 97
Chapter 26: Bash Arithmetic ................................................................................................................................. 98
Section 26.1: Simple arithmetic with (( )) ................................................................................................................... 98
Section 26.2: Arithmetic command ........................................................................................................................... 98
Section 26.3: Simple arithmetic with expr ................................................................................................................. 99
Chapter 27: Scoping ................................................................................................................................................ 100
Section 27.1: Dynamic scoping in action ................................................................................................................. 100
Chapter 28: Process substitution ...................................................................................................................... 101
Section 28.1: Compare two ﬁles from the web ....................................................................................................... 101
Section 28.2: Feed a while loop with the output of a command .......................................................................... 101
Section 28.3: Concatenating ﬁles ............................................................................................................................ 101
Section 28.4: Stream a ﬁle through multiple programs at once .......................................................................... 101
Section 28.5: With paste command ........................................................................................................................ 102
Section 28.6: To avoid usage of a sub-shell ........................................................................................................... 102
Chapter 29: Programmable completion ....................................................................................................... 103
Section 29.1: Simple completion using function ..................................................................................................... 103
Section 29.2: Simple completion for options and ﬁlenames ................................................................................ 103
Chapter 30: Customizing PS1 .............................................................................................................................. 104
Section 30.1: Colorize and customize terminal prompt ......................................................................................... 104
Section 30.2: Show git branch name in terminal prompt ..................................................................................... 105
Section 30.3: Show time in terminal prompt ........................................................................................................... 105
Section 30.4: Show a git branch using PROMPT_COMMAND .............................................................................. 106
Section 30.5: Change PS1 prompt ............................................................................................................................ 106
Section 30.6: Show previous command return status and time .......................................................................... 107
Chapter 31: Brace Expansion ............................................................................................................................... 109
Section 31.1: Modifying ﬁlename extension ............................................................................................................. 109Section 31.2: Create directories to group ﬁles by month and year ...................................................................... 109
Section 31.3: Create a backup of dotﬁles ................................................................................................................ 109
Section 31.4: Use increments .................................................................................................................................... 109
Section 31.5: Using brace expansion to create lists ............................................................................................... 109
Section 31.6: Make Multiple Directories with Sub-Directories ............................................................................... 110
Chapter 32: getopts : smart positional-parameter parsing .............................................................. 111
Section 32.1: pingnmap ............................................................................................................................................. 111
Chapter 33: Debugging .......................................................................................................................................... 113
Section 33.1: Checking the syntax of a script with "-n" .......................................................................................... 113
Section 33.2: Debugging using bashdb .................................................................................................................. 113
Section 33.3: Debugging a bash script with "-x" .................................................................................................... 113
Chapter 34: Pattern matching and regular expressions ..................................................................... 115
Section 34.1: Get captured groups from a regex match against a string ........................................................... 115
Section 34.2: Behaviour when a glob does not match anything ......................................................................... 115
Section 34.3: Check if a string matches a regular expression .............................................................................. 116
Section 34.4: Regex matching .................................................................................................................................. 116
Section 34.5: The * glob ............................................................................................................................................ 116
Section 34.6: The ** glob ........................................................................................................................................... 117
Section 34.7: The ? glob ............................................................................................................................................ 117
Section 34.8: The [ ] glob ......................................................................................................................................... 118
Section 34.9: Matching hidden ﬁles ......................................................................................................................... 119
Section 34.10: Case insensitive matching ................................................................................................................ 119
Section 34.11: Extended globbing ............................................................................................................................. 119
Chapter 35: Change shell ...................................................................................................................................... 121
Section 35.1: Find the current shell .......................................................................................................................... 121
Section 35.2: List available shells ............................................................................................................................. 121
Section 35.3: Change the shell ................................................................................................................................. 121
Chapter 36: Internal variables ........................................................................................................................... 122
Section 36.1: Bash internal variables at a glance ................................................................................................... 122
Section 36.2: $@ ........................................................................................................................................................ 123
Section 36.3: $# ......................................................................................................................................................... 124
Section 36.4: $HISTSIZE ............................................................................................................................................ 124
Section 36.5: $FUNCNAME ....................................................................................................................................... 124
Section 36.6: $HOME ................................................................................................................................................. 124
Section 36.7: $IFS ....................................................................................................................................................... 124
Section 36.8: $OLDPWD ............................................................................................................................................ 125
Section 36.9: $PWD ................................................................................................................................................... 125
Section 36.10: $1 $2 $3 etc.. ....................................................................................................................................... 125
Section 36.11: $* .......................................................................................................................................................... 126
Section 36.12: $! .......................................................................................................................................................... 126
Section 36.13: $? ......................................................................................................................................................... 126
Section 36.14: $$ ........................................................................................................................................................ 126
Section 36.15: $RANDOM .......................................................................................................................................... 126
Section 36.16: $BASHPID ........................................................................................................................................... 127
Section 36.17: $BASH_ENV ....................................................................................................................................... 127
Section 36.18: $BASH_VERSINFO ............................................................................................................................ 127
Section 36.19: $BASH_VERSION .............................................................................................................................. 127
Section 36.20: $EDITOR ............................................................................................................................................ 127
Section 36.21: $HOSTNAME ...................................................................................................................................... 127
Section 36.22: $HOSTTYPE ....................................................................................................................................... 128Section 36.23: $MACHTYPE ...................................................................................................................................... 128
Section 36.24: $OSTYPE ............................................................................................................................................ 128
Section 36.25: $PATH ................................................................................................................................................ 128
Section 36.26: $PPID .................................................................................................................................................. 128
Section 36.27: $SECONDS ......................................................................................................................................... 128
Section 36.28: $SHELLOPTS ..................................................................................................................................... 129
Section 36.29: $_ ....................................................................................................................................................... 129
Section 36.30: $GROUPS ........................................................................................................................................... 129
Section 36.31: $LINENO ............................................................................................................................................. 129
Section 36.32: $SHLVL .............................................................................................................................................. 129
Section 36.33: $UID .................................................................................................................................................... 131
Chapter 37: Job Control ........................................................................................................................................ 132
Section 37.1: List background processes ................................................................................................................ 132
Section 37.2: Bring a background process to the foreground ............................................................................. 132
Section 37.3: Restart stopped background process .............................................................................................. 132
Section 37.4: Run command in background .......................................................................................................... 132
Section 37.5: Stop a foreground process ................................................................................................................ 132
Chapter 38: Case statement ............................................................................................................................... 133
Section 38.1: Simple case statement ....................................................................................................................... 133
Section 38.2: Case statement with fall through ..................................................................................................... 133
Section 38.3: Fall through only if subsequent pattern(s) match .......................................................................... 133
Chapter 39: Read a ﬁle (data stream, variable) line-by-line (and/or ﬁeld-by-ﬁeld)? ......... 135
Section 39.1: Looping through a ﬁle line by line ..................................................................................................... 135
Section 39.2: Looping through the output of a command ﬁeld by ﬁeld ............................................................. 135
Section 39.3: Read lines of a ﬁle into an array ....................................................................................................... 135
Section 39.4: Read lines of a string into an array .................................................................................................. 136
Section 39.5: Looping through a string line by line ................................................................................................ 136
Section 39.6: Looping through the output of a command line by line ................................................................ 136
Section 39.7: Read a ﬁle ﬁeld by ﬁeld ..................................................................................................................... 136
Section 39.8: Read a string ﬁeld by ﬁeld ................................................................................................................ 137
Section 39.9: Read ﬁelds of a ﬁle into an array ..................................................................................................... 137
Section 39.10: Read ﬁelds of a string into an array ............................................................................................... 137
Section 39.11: Reads ﬁle (/etc/passwd) line by line and ﬁeld by ﬁeld ................................................................. 138
Chapter 40: File execution sequence ............................................................................................................. 140
Section 40.1: .proﬁle vs .bash_proﬁle (and .bash_login) ....................................................................................... 140
Chapter 41: Splitting Files .................................................................................................................................... 141
Section 41.1: Split a ﬁle ............................................................................................................................................... 141
Chapter 42: File Transfer using scp ................................................................................................................ 142
Section 42.1: scp transferring ﬁle ............................................................................................................................. 142
Section 42.2: scp transferring multiple ﬁles ........................................................................................................... 142
Section 42.3: Downloading ﬁle using scp ................................................................................................................ 142
Chapter 43: Pipelines .............................................................................................................................................. 143
Section 43.1: Using |& ................................................................................................................................................. 143
Section 43.2: Show all processes paginated .......................................................................................................... 144
Section 43.3: Modify continuous output of a command ....................................................................................... 144
Chapter 44: Managing PATH environment variable ............................................................................. 145
Section 44.1: Add a path to the PATH environment variable ................................................................................ 145
Section 44.2: Remove a path from the PATH environment variable .................................................................. 145
Chapter 45: Word splitting .................................................................................................................................. 147Section 45.1: What, when and Why? ........................................................................................................................ 147
Section 45.2: Bad eects of word splitting ............................................................................................................. 147
Section 45.3: Usefulness of word splitting .............................................................................................................. 148
Section 45.4: Splitting by separator changes ......................................................................................................... 149
Section 45.5: Splitting with IFS .................................................................................................................................. 149
Section 45.6: IFS & word splitting ............................................................................................................................. 149
Chapter 46: Avoiding date using printf ........................................................................................................ 151
Section 46.1: Get the current date ............................................................................................................................ 151
Section 46.2: Set variable to current time .............................................................................................................. 151
Chapter 47: Using "trap" to react to signals and system events ................................................... 152
Section 47.1: Introduction: clean up temporary ﬁles .............................................................................................. 152
Section 47.2: Catching SIGINT or Ctl+C ................................................................................................................... 152
Section 47.3: Accumulate a list of trap work to run at exit ................................................................................... 153
Section 47.4: Killing Child Processes on Exit ........................................................................................................... 153
Section 47.5: react on change of terminals window size ...................................................................................... 153
Chapter 48: Chain of commands and operations ................................................................................... 155
Section 48.1: Counting a text pattern ocurrence .................................................................................................... 155
Section 48.2: transfer root cmd output to user ﬁle ............................................................................................... 155
Section 48.3: logical chaining of commands with && and || ................................................................................. 155
Section 48.4: serial chaining of commands with semicolon ................................................................................. 155
Section 48.5: chaining commands with | ................................................................................................................. 156
Chapter 49: Type of Shells .................................................................................................................................. 157
Section 49.1: Start an interactive shell ..................................................................................................................... 157
Section 49.2: Detect type of shell ............................................................................................................................ 157
Section 49.3: Introduction to dot ﬁles ...................................................................................................................... 157
Chapter 50: Color script output (cross-platform) ................................................................................... 159
Section 50.1: color-output.sh .................................................................................................................................... 159
Chapter 51: co-processes ..................................................................................................................................... 160
Section 51.1: Hello World ........................................................................................................................................... 160
Chapter 52: Typing variables ............................................................................................................................. 161
Section 52.1: declare weakly typed variables ........................................................................................................ 161
Chapter 53: Jobs at speciﬁc times .................................................................................................................. 162
Section 53.1: Execute job once at speciﬁc time ...................................................................................................... 162
Section 53.2: Doing jobs at speciﬁed times repeatedly using systemd.timer .................................................... 162
Chapter 54: Handling the system prompt .................................................................................................. 164
Section 54.1: Using the PROMPT_COMMAND envrionment variable .................................................................. 164
Section 54.2: Using PS2 ............................................................................................................................................ 165
Section 54.3: Using PS3 ............................................................................................................................................. 165
Section 54.4: Using PS4 ............................................................................................................................................ 165
Section 54.5: Using PS1 ............................................................................................................................................. 166
Chapter 55: The cut command .......................................................................................................................... 167
Section 55.1: Only one delimiter character ............................................................................................................. 167
Section 55.2: Repeated delimiters are interpreted as empty ﬁelds .................................................................... 167
Section 55.3: No quoting ........................................................................................................................................... 167
Section 55.4: Extracting, not manipulating ............................................................................................................. 167
Chapter 56: Bash on Windows 10 ...................................................................................................................... 169
Section 56.1: Readme ................................................................................................................................................ 169
Chapter 57: Cut Command .................................................................................................................................. 170Section 57.1: Show the ﬁrst column of a ﬁle ........................................................................................................... 170
Section 57.2: Show columns x to y of a ﬁle ............................................................................................................ 170
Chapter 58: global and local variables ......................................................................................................... 171
Section 58.1: Global variables ................................................................................................................................... 171
Section 58.2: Local variables .................................................................................................................................... 171
Section 58.3: Mixing the two together ..................................................................................................................... 171
Chapter 59: CGI Scripts .......................................................................................................................................... 173
Section 59.1: Request Method: GET ......................................................................................................................... 173
Section 59.2: Request Method: POST /w JSON ..................................................................................................... 175
Chapter 60: Select keyword ................................................................................................................................ 177
Section 60.1: Select keyword can be used for getting input argument in a menu format ................................ 177
Chapter 61: When to use eval ............................................................................................................................. 178
Section 61.1: Using Eval ............................................................................................................................................. 178
Section 61.2: Using Eval with Getopt ........................................................................................................................ 179
Chapter 62: Networking With Bash ................................................................................................................. 180
Section 62.1: Networking commands ...................................................................................................................... 180
Chapter 63: Parallel ................................................................................................................................................. 182
Section 63.1: Parallelize repetitive tasks on list of ﬁles .......................................................................................... 182
Section 63.2: Parallelize STDIN ................................................................................................................................ 183
Chapter 64: Decoding URL .................................................................................................................................. 184
Section 64.1: Simple example ................................................................................................................................... 184
Section 64.2: Using printf to decode a string ......................................................................................................... 184
Chapter 65: Design Patterns ............................................................................................................................... 185
Section 65.1: The Publish/Subscribe (Pub/Sub) Pattern ....................................................................................... 185
Chapter 66: Pitfalls .................................................................................................................................................. 187
Section 66.1: Whitespace When Assigning Variables ............................................................................................ 187
Section 66.2: Failed commands do not stop script execution .............................................................................. 187
Section 66.3: Missing The Last Line in a File ........................................................................................................... 187
Appendix A: Keyboard shortcuts ...................................................................................................................... 189
Section A.1: Editing Shortcuts ................................................................................................................................... 189
Section A.2: Recall Shortcuts ................................................................................................................................... 189
Section A.3: Macros ................................................................................................................................................... 189
Section A.4: Custome Key Bindings ........................................................................................................................ 189
Section A.5: Job Control ........................................................................................................................................... 190
Credits ............................................................................................................................................................................ 191
You may also like ...................................................................................................................................................... 195About
Please feel free to share this PDF with anyone for free,
latest version of this book can be downloaded from:
https://goalkicker.com/BashBook
This Bash Notes for Professionals book is compiled from Stack Overﬂow
Documentation, the content is written by the beautiful people at Stack Overﬂow.
Text content is released under Creative Commons BY-SA, see credits at the end
of this book whom contributed to the various chapters. Images may be copyright
of their respective owners unless otherwise speciﬁed
This is an unoﬃcial free book created for educational purposes and is not
aﬃliated with oﬃcial Bash group(s) or company(s) nor Stack Overﬂow. All
trademarks and registered trademarks are the property of their respective
company owners
The information presented in this book is not guaranteed to be correct nor
accurate, use at your own risk
Please send feedback and corrections to web@petercv.com
GoalKicker.com – Bash Notes for Professionals
1Chapter 1: Getting started with Bash
Version Release Date
0.99
1989-06-08
1.011989-06-23
2.01996-12-31
2.021998-04-20
2.031999-02-19
2.042001-03-21
2.05b2002-07-17
3.02004-08-03
3.12005-12-08
3.22006-10-11
4.02009-02-20
4.12009-12-31
4.22011-02-13
4.32014-02-26
4.42016-09-15
Section 1.1: Hello World
Interactive Shell
The Bash shell is commonly used interactively: It lets you enter and edit commands, then executes them when
you press the Return key. Many Unix-based and Unix-like operating systems use Bash as their default shell
(notably Linux and macOS). The terminal automatically enters an interactive Bash shell process on startup.
Output Hello World by typing the following:
echo "Hello World"
#> Hello World # Output Example
Notes
You can change the shell by just typing the name of the shell in terminal. For example: sh, bash, etc.
echo is a Bash builtin command that writes the arguments it receives to the standard output. It appends a
newline to the output, by default.
Non-Interactive Shell
The Bash shell can also be run non-interactively from a script, making the shell require no human interaction.
Interactive behavior and scripted behavior should be identical – an important design consideration of Unix V7
Bourne shell and transitively Bash. Therefore anything that can be done at the command line can be put in a script
ﬁle for reuse.
Follow these steps to create a Hello World script:
1. Create a new ﬁle called hello-world.sh
GoalKicker.com – Bash Notes for Professionals
2touch hello-world.sh
2. Make the script executable by running chmod +x hello-world.sh
3. Add this code:
#!/bin/bash
echo "Hello World"
Line 1: The ﬁrst line of the script must start with the character sequence #!, referred to as shebang1. The
shebang instructs the operating system to run /bin/bash, the Bash shell, passing it the script's path as an
argument.
E.g. /bin/bash hello-world.sh
Line 2: Uses the echo command to write Hello World to the standard output.
4. Execute the hello-world.sh script from the command line using one of the following:
./hello-world.sh – most commonly used, and recommended
/bin/bash hello-world.sh
bash hello-world.sh – assuming /bin is in your $PATH
sh hello-world.sh
For real production use, you would omit the .sh extension (which is misleading anyway, since this is a Bash script,
not a sh script) and perhaps move the ﬁle to a directory within your PATH so that it is available to you regardless of
your current working directory, just like a system command such as cat or ls.
Common mistakes include:
1. Forgetting to apply execute permission on the ﬁle, i.e., chmod +x hello-world.sh, resulting in the output of
./hello-world.sh: Permission denied.
2. Editing the script on Windows, which produces incorrect line ending characters that Bash cannot handle.
A common symptom is : command not found where the carriage return has forced the cursor to the
beginning of line, overwriting the text before the colon in the error message.
The script can be ﬁxed using the dos2unix program.
An example use: dos2unix hello-world.sh
dos2unix edits the ﬁle inline.
3. Using sh ./hello-world.sh, not realizing that bash and sh are distinct shells with distinct features (though
since Bash is backwards-compatible, the opposite mistake is harmless).
Anyway, simply relying on the script's shebang line is vastly preferable to explicitly writing bash or sh (or
python or perl or awk or ruby or...) before each script's ﬁle name.
A common shebang line to use in order to make your script more portable is to use #!/usr/bin/env bash
instead of hard-coding a path to Bash. That way, /usr/bin/env has to exist, but beyond that point, bash just
GoalKicker.com – Bash Notes for Professionals
3needs to be on your PATH. On many systems, /bin/bash doesn't exist, and you should use
/usr/local/bin/bash or some other absolute path; this change avoids having to ﬁgure out the details of
that.
1 Also referred to as sha-bang, hashbang, pound-bang, hash-pling.
Section 1.2: Hello World Using Variables
Create a new ﬁle called hello.sh with the following content and give it executable permissions with chmod +x
hello.sh.
Execute/Run via: ./hello.sh
#!/usr/bin/env bash
# Note that spaces cannot be used around the `=` assignment operator
whom_variable="World"
# Use printf to safely output the data
printf "Hello, %s\n" "$whom_variable"
#> Hello, World
This will print Hello, World to standard output when executed.
To tell bash where the script is you need to be very speciﬁc, by pointing it to the containing directory, normally with
./ if it is your working directory, where . is an alias to the current directory. If you do not specify the directory, bash
tries to locate the script in one of the directories contained in the $PATH environment variable.
The following code accepts an argument $1, which is the ﬁrst command line argument, and outputs it in a
formatted string, following Hello,.
Execute/Run via: ./hello.sh World
#!/usr/bin/env bash
printf "Hello, %s\n" "$1"
#> Hello, World
It is important to note that $1 has to be quoted in double quote, not single quote. "$1" expands to the ﬁrst
command line argument, as desired, while '$1' evaluates to literal string $1.
Security Note:
Read Security implications of forgetting to quote a variable in bash shells to understand the
importance of placing the variable text within double quotes.
Section 1.3: Hello World with User Input
The following will prompt a user for input, and then store that input as a string (text) in a variable. The variable is
then used to give a message to the user.
GoalKicker.com – Bash Notes for Professionals
4#!/usr/bin/env bash
echo "Who are you?"
read name
echo "Hello, $name."
The command read here reads one line of data from standard input into the variable name. This is then referenced
using $name and printed to standard out using echo.
Example output:
$ ./hello_world.sh
Who are you?
Matt
Hello, Matt.
Here the user entered the name "Matt", and this code was used to say Hello, Matt..
And if you want to append something to the variable value while printing it, use curly brackets around the variable
name as shown in the following example:
#!/usr/bin/env bash
echo "What are you doing?"
read action
echo "You are ${action}ing."
Example output:
$ ./hello_world.sh
What are you doing?
Sleep
You are Sleeping.
Here when user enters an action, "ing" is appended to that action while printing.
Section 1.4: Importance of Quoting in Strings
Quoting is important for string expansion in bash. With these, you can control how the bash parses and expands
your strings.
There are two types of quoting:
Weak: uses double quotes: "
Strong: uses single quotes: '
If you want to bash to expand your argument, you can use Weak Quoting:
#!/usr/bin/env bash
world="World"
echo "Hello $world"
#> Hello World
If you don't want to bash to expand your argument, you can use Strong Quoting:
#!/usr/bin/env bash
world="World"
echo 'Hello $world'
GoalKicker.com – Bash Notes for Professionals
5#> Hello $world
You can also use escape to prevent expansion:
#!/usr/bin/env bash
world="World"
echo "Hello \$world"
#> Hello $world
For more detailed information other than beginner details, you can continue to read it here.
Section 1.5: Viewing information for Bash built-ins
help <command>
This will display the Bash help (manual) page for the speciﬁed built-in.
For example, help unset will show:
unset: unset [-f] [-v] [-n] [name ...]
Unset values and attributes of shell variables and functions.
For each NAME, remove the corresponding variable or function.
Options:
-f
treat each NAME as a shell function
-v
treat each NAME as a shell variable
-n
treat each NAME as a name reference and unset the variable itself
rather than the variable it references
Without options, unset first tries to unset a variable, and if that fails,
tries to unset a function.
Some variables cannot be unset; also see `readonly'.
Exit Status:
Returns success unless an invalid option is given or a NAME is read-only.
To see a list of all built-ins with a short description, use
help -d
Section 1.6: Hello World in "Debug" mode
$ cat hello.sh
#!/bin/bash
echo "Hello World"
$ bash -x hello.sh
+ echo Hello World
Hello World
The -x argument enables you to walk through each line in the script. One good example is here:
$ cat hello.sh
#!/bin/bash
echo "Hello World\n"
GoalKicker.com – Bash Notes for Professionals
6adding_string_to_number="s"
v=$(expr 5 + $adding_string_to_number)
$ ./hello.sh
Hello World
expr: non-integer argument
The above prompted error is not enough to trace the script; however, using the following way gives you a better
sense where to look for the error in the script.
$ bash -x hello.sh
+ echo Hello World\n
Hello World
+ adding_string_to_number=s
+ expr 5 + s
expr: non-integer argument
+ v=
Section 1.7: Handling Named Arguments
#!/bin/bash
deploy=false
uglify=false
while (( $# > 1 )); do case $1 in
--deploy) deploy="$2";;
--uglify) uglify="$2";;
*) break;
esac; shift 2
done
$deploy && echo "will deploy... deploy = $deploy"
$uglify && echo "will uglify... uglify = $uglify"
# how to run
# chmod +x script.sh
# ./script.sh --deploy true --uglify false
GoalKicker.com – Bash Notes for Professionals
7Chapter 2: Script shebang
Section 2.1: Env shebang
To execute a script ﬁle with the bash executable found in the PATH environment variable by using the executable
env, the ﬁrst line of a script ﬁle must indicate the absolute path to the env executable with the argument bash:
#!/usr/bin/env bash
The env path in the shebang is resolved and used only if a script is directly launch like this:
script.sh
The script must have execution permission.
The shebang is ignored when a bash interpreter is explicitly indicated to execute a script:
bash script.sh
Section 2.2: Direct shebang
To execute a script ﬁle with the bash interpreter, the ﬁrst line of a script ﬁle must indicate the absolute path to the
bash executable to use:
#!/bin/bash
The bash path in the shebang is resolved and used only if a script is directly launch like this:
./script.sh
The script must have execution permission.
The shebang is ignored when a bash interpreter is explicitly indicated to execute a script:
bash script.sh
Section 2.3: Other shebangs
There are two kinds of programs the kernel knows of. A binary program is identiﬁed by it's ELF
(ExtenableLoadableFormat) header, which is usually produced by a compiler. The second one are scripts of any
kind.
If a ﬁle starts in the very ﬁrst line with the sequence #! then the next string has to be a pathname of an interpreter.
If the kernel reads this line, it calls the interpreter named by this pathname and gives all of the following words in
this line as arguments to the interpreter. If there is no ﬁle named "something" or "wrong":
#!/bin/bash something wrong
echo "This line never gets printed"
bash tries to execute its argument "something wrong" which doesn't exist. The name of the script ﬁle is added too.
To see this clearly use an echo shebang:
GoalKicker.com – Bash Notes for Professionals
8#"/bin/echo something wrong
# and now call this script named "thisscript" like so:
# thisscript one two
# the output will be:
something wrong ./thisscript one two
Some programs like awk use this technique to run longer scripts residing in a disk ﬁle.
GoalKicker.com – Bash Notes for Professionals
9Chapter 3: Navigating directories
Section 3.1: Absolute vs relative directories
To change to an absolutely speciﬁed directory, use the entire name, starting with a slash /, thus:
cd /home/username/project/abc
If you want to change to a directory near your current on, you can specify a relative location. For example, if you are
already in /home/username/project, you can enter the subdirectory abc thus:
cd abc
If you want to go to the directory above the current directory, you can use the alias ... For example, if you were in
/home/username/project/abc and wanted to go to /home/username/project, then you would do the following:
cd ..
This may also be called going "up" a directory.
Section 3.2: Change to the last directory
For the current shell, this takes you to the previous directory that you were in, no matter where it was.
cd -
Doing it multiple times eﬀectively "toggles" you being in the current directory or the previous one.
Section 3.3: Change to the home directory
The default directory is the home directory ($HOME, typically /home/username), so cd without any directory takes you
there
cd
Or you could be more explicit:
cd $HOME
A shortcut for the home directory is ~, so that could be used as well.
cd ~
Section 3.4: Change to the Directory of the Script
In general, there are two types of Bash scripts:
1. System tools which operate from the current working directory
2. Project tools which modify ﬁles relative to their own place in the ﬁles system
For the second type of scripts, it is useful to change to the directory where the script is stored. This can be done
with the following command:
GoalKicker.com – Bash Notes for Professionals
10cd "$(dirname "$(readlink -f "$0")")"
This command runs 3 commands:
1. readlink -f "$0" determines the path to the current script ($0)
2. dirname converts the path to script to the path to its directory
3. cd changes the current work directory to the directory it receives from dirname
GoalKicker.com – Bash Notes for Professionals
11Chapter 4: Listing Files
-a, --all
Option
Description
List all entries including ones that start with a dot
-A, --almost-allList all entries excluding . and ..
-cSort ﬁles by change time
-d, --directoryList directory entries
-h, --human-readable Show sizes in human readable format (i.e. K, M)
-HSame as above only with powers of 1000 instead of 1024
-lShow contents in long-listing format
-oLong -listing format without group info
-r, --reverseShow contents in reverse order
-s, --sizePrint size of each ﬁle in blocks
-SSort by ﬁle size
--sort=WORDSort contents by a word. (i.e size, version, status)
-tSort by modiﬁcation time
-uSort by last access time
-vSort by version
-1List one ﬁle per line
Section 4.1: List Files in a Long Listing Format
The ls command's -l option prints a speciﬁed directory's contents in a long listing format. If no directory is
speciﬁed then, by default, the contents of the current directory are listed.
ls -l /etc
Example Output:
total 1204
drwxr-xr-x
-rw-r--r--
drwxr-xr-x
...
3 root root
1 root root
2 root root
4096 Apr 21 03:44 acpi
3028 Apr 21 03:38 adduser.conf
4096 Jun 11 20:42 alternatives
The output ﬁrst displays total, which indicates the total size in blocks of all the ﬁles in the listed directory. It then
displays eight columns of information for each ﬁle in the listed directory. Below are the details for each column in
the output:
Column No. Example
d
1.1Description
File type (see table below)
1.2rwxr-xr-xPermission string
23Number of hard links
3rootOwner name
4rootOwner group
54096File size in bytes
6Apr 21 03:44 Modiﬁcation time
7acpi
File name
GoalKicker.com – Bash Notes for Professionals
12File Type
The ﬁle type can be one of any of the following characters.
Character
File Type
-Regular ﬁle
bBlock special ﬁle
cCharacter special ﬁle
CHigh performance ("contiguous data") ﬁle
dDirectory
DDoor (special IPC ﬁle in Solaris 2.5+ only)
lSymbolic link
MOﬀ-line ("migrated") ﬁle (Cray DMF)
nNetwork special ﬁle (HP-UX)
pFIFO (named pipe)
PPort (special system ﬁle in Solaris 10+ only)
sSocket
?Some other ﬁle type
Section 4.2: List the Ten Most Recently Modiﬁed Files
The following will list up to ten of the most recently modiﬁed ﬁles in the current directory, using a long listing
format (-l) and sorted by time (-t).
ls -lt | head
Section 4.3: List All Files Including Dotﬁles
A dotﬁle is a ﬁle whose names begin with a .. These are normally hidden by ls and not listed unless requested.
For example the following output of ls:
$ ls
bin pki
The -a or --all option will list all ﬁles, including dotﬁles.
$ ls -a
.
.ansible
.. .bash_history
.bash_logout
.bash_profile
.bashrc
bin
.lesshst
pki
.puppetlabs
.ssh
.viminfo
The -A or --almost-all option will list all ﬁles, including dotﬁles, but does not list implied . and ... Note that . is
the current directory and .. is the parent directory.
$ ls -A
.ansible
.bash_history
.bash_logout
.bash_profile
.bashrc
bin
.lesshst
pki
.puppetlabs
.ssh
.viminfo
Section 4.4: List Files Without Using `ls`
Use the Bash shell's ﬁlename expansion and brace expansion capabilities to obtain the ﬁlenames:
GoalKicker.com – Bash Notes for Professionals
13# display the files and directories that are in the current directory
printf "%s\n" *
# display only the directories in the current directory
printf "%s\n" */
# display only (some) image files
printf "%s\n" *.{gif,jpg,png}
To capture a list of ﬁles into a variable for processing, it is typically good practice to use a bash array:
files=( * )
# iterate over them
for file in "${files[@]}"; do
echo "$file"
done
Section 4.5: List Files
The ls command lists the contents of a speciﬁed directory, excluding dotﬁles. If no directory is speciﬁed then, by
default, the contents of the current directory are listed.
Listed ﬁles are sorted alphabetically, by default, and aligned in columns if they don’t ﬁt on one line.
$ ls
apt configs
bin Desktop
Documents
eclipse
Fonts
git
Music
Pictures
Programming
Public
Templates
Videos
workspace
Section 4.6: List Files in a Tree-Like Format
The tree command lists the contents of a speciﬁed directory in a tree-like format. If no directory is speciﬁed then,
by default, the contents of the current directory are listed.
Example Output:
$ tree /tmp
/tmp
├── 5037
├── adb.log
└── evince-20965
└── image.FPWTJY.png
Use the tree command's -L option to limit the display depth and the -d option to only list directories.
Example Output:
$ tree -L 1 -d /tmp
/tmp
└── evince-20965
Section 4.7: List Files Sorted by Size
The ls command's -S option sorts the ﬁles in descending order of ﬁle size.
GoalKicker.com – Bash Notes for Professionals
14$ ls -l -S ./Fruits
total 444
-rw-rw-rw- 1 root root 295303 Jul 28 19:19 apples.jpg
-rw-rw-rw- 1 root root 102283 Jul 28 19:19 kiwis.jpg
-rw-rw-rw- 1 root root 50197 Jul 28 19:19 bananas.jpg
When used with the -r option the sort order is reversed.
$ ls -l -S -r /Fruits
total 444
-rw-rw-rw- 1 root root 50197 Jul 28 19:19 bananas.jpg
-rw-rw-rw- 1 root root 102283 Jul 28 19:19 kiwis.jpg
-rw-rw-rw- 1 root root 295303 Jul 28 19:19 apples.jpg
GoalKicker.com – Bash Notes for Professionals
15Chapter 5: Using cat
Option
-n
Print line numbers
Details
-vShow non-printing characters using ^ and M- notation except LFD and TAB
-TShow TAB characters as ^I
-EShow linefeed(LF) characters as $
-eSame as -vE
-bNumber nonempty output lines, overrides -n
-Aequivalent to -vET
-ssuppress repeated empty output lines, s refers to squeeze
Section 5.1: Concatenate ﬁles
This is the primary purpose of cat.
cat file1 file2 file3 > file_all
cat can also be used similarly to concatenate ﬁles as part of a pipeline, e.g.
cat file1 file2 file3 | grep foo
Section 5.2: Printing the Contents of a File
cat file.txt
will print the contents of a ﬁle.
If the ﬁle contains non-ASCII characters, you can display those characters symbolically with cat -v. This can be
quite useful for situations where control characters would otherwise be invisible.
cat -v unicode.txt
Very often, for interactive use, you are better oﬀ using an interactive pager like less or more, though. (less is far
more powerful than more and it is advised to use less more often than more.)
less file.txt
To pass the contents of a ﬁle as input to a command. An approach usually seen as better (UUOC) is to use
redirection.
tr A-Z a-z <file.txt
# as an alternative to cat file.txt | tr A-Z a-z
In case the content needs to be listed backwards from its end the command tac can be used:
tac file.txt
If you want to print the contents with line numbers, then use -n with cat:
cat -n file.txt
GoalKicker.com – Bash Notes for Professionals
16To display the contents of a ﬁle in a completely unambiguous byte-by-byte form, a hex dump is the standard
solution. This is good for very brief snippets of a ﬁle, such as when you don't know the precise encoding. The
standard hex dump utility is od -cH, though the representation is slightly cumbersome; common replacements
include xxd and hexdump.
$ printf 'Hëllö wörld' | xxd
0000000: 48c3 ab6c 6cc3 b620 77c3 b672 6c64
H..ll.. w..rld
Section 5.3: Write to a ﬁle
cat >file
It will let you write the text on terminal which will be saved in a ﬁle named ﬁle.
cat >>file
will do the same, except it will append the text to the end of the ﬁle.
N.B: Ctrl+D to end writing text on terminal (Linux)
A here document can be used to inline the contents of a ﬁle into a command line or a script:
cat <<END >file
Hello, World.
END
The token after the << redirection symbol is an arbitrary string which needs to occur alone on a line (with no leading
or trailing whitespace) to indicate the end of the here document. You can add quoting to prevent the shell from
performing command substitution and variable interpolation:
cat <<'fnord'
Nothing in `here` will be $changed
fnord
(Without the quotes, here would be executed as a command, and $changed would be substituted with the value of
the variable changed -- or nothing, if it was undeﬁned.)
Section 5.4: Show non printable characters
This is useful to see if there are any non-printable characters, or non-ASCII characters.
e.g. If you have copy-pasted the code from web, you may have quotes like ” instead of standard ".
$ cat -v file.txt
$ cat -vE file.txt # Useful in detecting trailing spaces.
e.g.
$ echo '”
M-bM-^@M-^]
' | cat -vE # echo | will be replaced by actual file.
$
You may also want to use cat -A (A for All) that is equivalent to cat -vET. It will display TAB characters (displayed
GoalKicker.com – Bash Notes for Professionals
17as ^I), non printable characters and end of each line:
$ echo '” `' | cat -A
M-bM-^@M-^]^I`$
Section 5.5: Read from standard input
cat < file.txt
Output is same as cat file.txt, but it reads the contents of the ﬁle from standard input instead of directly from
the ﬁle.
printf "first line\nSecond line\n" | cat -n
The echo command before | outputs two lines. The cat command acts on the output to add line numbers.
Section 5.6: Display line numbers with output
Use the --number ﬂag to print line numbers before each line. Alternatively, -n does the same thing.
$ cat --number file
1
2
3
4
5
line 1
line 2
line 4
line 5
To skip empty lines when counting lines, use the --number-nonblank, or simply -b.
$ cat -b file
1
2line 1
line 2
3
4line 4
line 5
Section 5.7: Concatenate gzipped ﬁles
Files compressed by gzip can be directly concatenated into larger gzipped ﬁles.
cat file1.gz file2.gz file3.gz > combined.gz
This is a property of gzip that is less eﬃcient than concatenating the input ﬁles and gzipping the result:
cat file1 file2 file3 | gzip > combined.gz
A complete demonstration:
echo 'Hello world!' > hello.txt
echo 'Howdy world!' > howdy.txt
gzip hello.txt
gzip howdy.txt
GoalKicker.com – Bash Notes for Professionals
18cat hello.txt.gz howdy.txt.gz > greetings.txt.gz
gunzip greetings.txt.gz
cat greetings.txt
Which results in
Hello world!
Howdy world!
Notice that greetings.txt.gz is a single ﬁle and is decompressed as the single ﬁle greeting.txt. Contrast this
with tar -czf hello.txt howdy.txt > greetings.tar.gz, which keeps the ﬁles separate inside the tarball.
GoalKicker.com – Bash Notes for Professionals
19Chapter 6: Grep
Section 6.1: How to search a ﬁle for a pattern
To ﬁnd the word foo in the ﬁle bar :
grep foo ~/Desktop/bar
To ﬁnd all lines that do not contain foo in the ﬁle bar :
grep –v foo ~/Desktop/bar
To use ﬁnd all words containing foo in the end (WIldcard Expansion):
grep "*foo" ~/Desktop/bar
GoalKicker.com – Bash Notes for Professionals
20Chapter 7: Aliasing
Shell aliases are a simple way to create new commands or to wrap existing commands with code of your own. They
somewhat overlap with shell functions, which are however more versatile and should therefore often be preferred.
Section 7.1: Bypass an alias
Sometimes you may want to bypass an alias temporarily, without disabling it. To work with a concrete example,
consider this alias:
alias ls='ls --color=auto'
And let's say you want to use the ls command without disabling the alias. You have several options:
Use the command builtin: command ls
Use the full path of the command: /bin/ls
Add a \ anywhere in the command name, for example: \ls, or l\s
Quote the command: "ls" or 'ls'
Section 7.2: Create an Alias
alias word='command'
Invoking word will run command. Any arguments supplied to the alias are simply appended to the target of the alias:
alias myAlias='some command --with --options'
myAlias foo bar baz
The shell will then execute:
some command --with --options foo bar baz
To include multiple commands in the same alias, you can string them together with &&. For example:
alias print_things='echo "foo" && echo "bar" && echo "baz"'
Section 7.3: Remove an alias
To remove an existing alias, use:
unalias {alias_name}
Example:
# create an alias
$ alias now='date'
# preview the alias
$ now
Thu Jul 21 17:11:25 CEST 2016
# remove the alias
$ unalias now
GoalKicker.com – Bash Notes for Professionals
21# test if removed
$ now
-bash: now: command not found
Section 7.4: The BASH_ALIASES is an internal bash assoc
array
Aliases are named shortcuts of commands, one can deﬁne and use in interactive bash instances. They are held in
an associative array named BASH_ALIASES. To use this var in a script, it must be run within an interactive shell
#!/bin/bash -li
# note the -li above! -l makes this behave like a login shell
# -i makes it behave like an interactive shell
#
# shopt -s expand_aliases will not work in most cases
echo There are ${#BASH_ALIASES[*]} aliases defined.
for ali in "${!BASH_ALIASES[@]}"; do
printf "alias: %-10s triggers: %s\n" "$ali" "${BASH_ALIASES[$ali]}"
done
Section 7.5: Expand alias
Assuming that bar is an alias for someCommand -flag1.
Type bar on the command line and then press Ctrl + alt + e
you'll get someCommand -flag1 where bar was standing.
Section 7.6: List all Aliases
alias -p
will list all the current aliases.
GoalKicker.com – Bash Notes for Professionals
22Chapter 8: Jobs and Processes
Section 8.1: Job handling
Creating jobs
To create an job, just append a single & after the command:
$ sleep 10 &
[1] 20024
You can also make a running process a job by pressing Ctrl + z :
$ sleep 10
^Z
[1]+ Stopped
sleep 10
Background and foreground a process
To bring the Process to the foreground, the command fg is used together with %
$ sleep 10 &
[1] 20024
$ fg %1
sleep 10
Now you can interact with the process. To bring it back to the background you can use the bg command. Due to the
occupied terminal session, you need to stop the process ﬁrst by pressing Ctrl + z .
$ sleep 10
^Z
[1]+ Stopped
sleep 10
$ bg %1
[1]+ sleep 10 &
Due to the laziness of some Programmers, all these commands also work with a single % if there is only one
process, or for the ﬁrst process in the list. For Example:
$ sleep 10 &
[1] 20024
$ fg %
sleep 10
# to bring a process to foreground 'fg %' is also working.
or just
$ %
sleep 10
# laziness knows no boundaries, '%' is also working.
Additionally, just typing fg or bg without any argument handles the last job:
$ sleep 20 &
$ sleep 10 &
$ fg
GoalKicker.com – Bash Notes for Professionals
23sleep 10
^C
$ fg
sleep 20
Killing running jobs
$ sleep 10 &
[1] 20024
$ kill %1
[1]+ Terminated
sleep 10
The sleep process runs in the background with process id (pid) 20024 and job number 1. In order to reference the
process, you can use either the pid or the job number. If you use the job number, you must preﬁx it with %. The
default kill signal sent by kill is SIGTERM, which allows the target process to exit gracefully.
Some common kill signals are shown below. To see a full list, run kill -l.
Signal name Signal value
Eﬀect
SIGHUP1Hangup
SIGINT2Interrupt from keyboard
SIGKILL9Kill signal
SIGTERM15Termination signal
Start and kill speciﬁc processes
Probably the easiest way of killing a running process is by selecting it through the process name as in the following
example using pkill command as
pkill -f test.py
(or) a more fool-proof way using pgrep to search for the actual process-id
kill $(pgrep -f 'python test.py')
The same result can be obtained using grep over ps -ef | grep name_of_process then killing the process
associated with the resulting pid (process id). Selecting a process using its name is convinient in a testing
environment but can be really dangerous when the script is used in production: it is virtually impossible to be sure
that the name will match the process you actually want to kill. In those cases, the following approach is actually
much safe.
Start the script that will eventually killed with the following approach. Let's assume that the command you want to
execute and eventually kill is python test.py.
#!/bin/bash
if [[ ! -e /tmp/test.py.pid ]]; then
# Check if the file already exists
python test.py &
#+and if so do not run another process.
echo $! > /tmp/test.py.pid
else
echo -n "ERROR: The process is already running with pid "
cat /tmp/test.py.pid
echo
fi
This will create a ﬁle in the /tmp directory containing the pid of the python test.py process. If the ﬁle already
exists, we assume that the command is already running and the script return an error.
GoalKicker.com – Bash Notes for Professionals
24Then, when you want to kill it use the following script:
#!/bin/bash
if [[ -e /tmp/test.py.pid ]]; then
kill `cat /tmp/test.py.pid`
rm /tmp/test.py.pid
else
echo "test.py is not running"
fi
# If the file do not exists, then the
#+the process is not running. Useless
#+trying to kill it.
that will kill exactly the process associated with your command, without relying on any volatile information (like the
string used to run the command). Even in this case if the ﬁle does not exist, the script assume that you want to kill a
non-running process.
This last example can be easily improved for running the same command multiple times (appending to the pid ﬁle
instead of overwriting it, for example) and to manage cases where the process dies before being killed.
Section 8.2: Check which process running on speciﬁc port
To check which process running on port 8080
lsof -i :8080
Section 8.3: Disowning background job
$ gzip extremelylargefile.txt &
$ bg
$ disown %1
This allows a long running process to continue once your shell (terminal, ssh, etc) is closed.
Section 8.4: List Current Jobs
$ tail -f /var/log/syslog > log.txt
[1]+ Stopped
tail -f /var/log/syslog > log.txt
$ sleep 10 &
$ jobs
[1]+ Stopped
[2]- Running
tail -f /var/log/syslog > log.txt
sleep 10 &
Section 8.5: Finding information about a running process
ps aux | grep <search-term> shows processes matching search-term
Example:
root@server7:~# ps aux | grep nginx
root
315 0.0 0.3 144392 1020 ?
/usr/sbin/nginx
www-data 5647 0.0 1.1 145124 3048 ?
www-data 5648 0.0 0.1 144392
376 ?
root
13134 0.0 0.3
4960
920 pts/0
root@server7:~#
GoalKicker.com – Bash Notes for Professionals
SsMay280:00 nginx: master process
S
S
S+Jul18
Jul18
14:332:53 nginx: worker process
0:00 nginx: cache manager process
0:00 grep --color=auto nginx
25Here, second column is the process id. For example, if you want to kill the nginx process, you can use the command
kill 5647. It is always adviced to use the kill command with SIGTERM rather than SIGKILL.
Section 8.6: List all processes
There are two common ways to list all processes on a system. Both list all processes running by all users, though
they diﬀer in the format they output (the reason for the diﬀerences are historical).
ps -ef
ps aux
# lists all processes
# lists all processes in alternative format (BSD)
This can be used to check if a given application is running. For example, to check if the SSH server (sshd) is running:
ps -ef | grep sshd
GoalKicker.com – Bash Notes for Professionals
26Chapter 9: Redirection
Parameter
internal ﬁle descriptorAn integer.
Details
directionOne of >, < or <>
external ﬁle descriptor or path & followed by an integer for ﬁle descriptor or a path.
Section 9.1: Redirecting standard output
> redirect the standard output (aka STDOUT) of the current command into a ﬁle or another descriptor.
These examples write the output of the ls command into the ﬁle file.txt
ls >file.txt
> file.txt ls
The target ﬁle is created if it doesn't exists, otherwise this ﬁle is truncated.
The default redirection descriptor is the standard output or 1 when none is speciﬁed. This command is equivalent
to the previous examples with the standard output explicitly indicated:
ls 1>file.txt
Note: the redirection is initialized by the executed shell and not by the executed command, therefore it is done
before the command execution.
Section 9.2: Append vs Truncate
Truncate >
1. Create speciﬁed ﬁle if it does not exist.
2. Truncate (remove ﬁle's content)
3. Write to ﬁle
$ echo "first line" > /tmp/lines
$ echo "second line" > /tmp/lines
$ cat /tmp/lines
second line
Append >>
1. Create speciﬁed ﬁle if it does not exist.
2. Append ﬁle (writing at end of ﬁle).
# Overwrite existing file
$ echo "first line" > /tmp/lines
# Append a second line
$ echo "second line" >> /tmp/lines
$ cat /tmp/lines
first line
second line
GoalKicker.com – Bash Notes for Professionals
27Section 9.3: Redirecting both STDOUT and STDERR
File descriptors like 0 and 1 are pointers. We change what ﬁle descriptors point to with redirection. >/dev/null
means 1 points to /dev/null.
First we point 1 (STDOUT) to /dev/null then point 2 (STDERR) to whatever 1 points to.
# STDERR is redirect to STDOUT: redirected to /dev/null,
# effectually redirecting both STDERR and STDOUT to /dev/null
echo 'hello' > /dev/null 2>&1
Version ≥ 4.0
This can be further shortened to the following:
echo 'hello' &> /dev/null
However, this form may be undesirable in production if shell compatibility is a concern as it conﬂicts with POSIX,
introduces parsing ambiguity, and shells without this feature will misinterpret it:
# Actual code
echo 'hello' &> /dev/null
echo 'hello' &> /dev/null 'goodbye'
# Desired behavior
echo 'hello' > /dev/null 2>&1
echo 'hello' 'goodbye' > /dev/null 2>&1
# Actual behavior
echo 'hello' &
echo 'hello' & goodbye > /dev/null
NOTE: &> is known to work as desired in both Bash and Zsh.
Section 9.4: Using named pipes
Sometimes you may want to output something by one program and input it into another program, but can't use a
standard pipe.
ls -l | grep ".log"
You could simply write to a temporary ﬁle:
touch tempFile.txt
ls -l > tempFile.txt
grep ".log" < tempFile.txt
This works ﬁne for most applications, however, nobody will know what tempFile does and someone might remove
it if it contains the output of ls -l in that directory. This is where a named pipe comes into play:
mkfifo myPipe
ls -l > myPipe
grep ".log" < myPipe
myPipe is technically a ﬁle (everything is in Linux), so let's do ls -l in an empty directory that we just created a pipe
in:
GoalKicker.com – Bash Notes for Professionals
28mkdir pipeFolder
cd pipeFolder
mkfifo myPipe
ls -l
The output is:
prw-r--r-- 1 root root 0 Jul 25 11:20 myPipe
Notice the ﬁrst character in the permissions, it's listed as a pipe, not a ﬁle.
Now let's do something cool.
Open one terminal, and make note of the directory (or create one so that cleanup is easy), and make a pipe.
mkfifo myPipe
Now let's put something in the pipe.
echo "Hello from the other side" > myPipe
You'll notice this hangs, the other side of the pipe is still closed. Let's open up the other side of the pipe and let that
stuﬀ through.
Open another terminal and go to the directory that the pipe is in (or if you know it, prepend it to the pipe):
cat < myPipe
You'll notice that after hello from the other side is output, the program in the ﬁrst terminal ﬁnishes, as does
that in the second terminal.
Now run the commands in reverse. Start with cat < myPipe and then echo something into it. It still works, because
a program will wait until something is put into the pipe before terminating, because it knows it has to get
something.
Named pipes can be useful for moving information between terminals or between programs.
Pipes are small. Once full, the writer blocks until some reader reads the contents, so you need to either run the
reader and writer in diﬀerent terminals or run one or the other in the background:
ls -l /tmp > myPipe &
cat < myPipe
More examples using named pipes:
Example 1 - all commands on the same terminal / same shell
$ { ls -l && cat file3; } >mypipe &
$ cat <mypipe
# Output: Prints ls -l data and then prints file3 contents on screen
Example 2 - all commands on the same terminal / same shell
$ ls -l >mypipe &
$ cat file3 >mypipe &
GoalKicker.com – Bash Notes for Professionals
29$ cat <mypipe
#Output: This prints on screen the contents of mypipe.
Mind that ﬁrst contents of file3 are displayed and then the ls -l data is displayed (LIFO conﬁguration).
Example 3 - all commands on the same terminal / same shell
$ { pipedata=$(<mypipe) && echo "$pipedata"; } &
$ ls >mypipe
# Output: Prints the output of ls directly on screen
Mind that the variable $pipedata is not available for usage in the main terminal / main shell since the use of
& invokes a subshell and $pipedata was only available in this subshell.
Example 4 - all commands on the same terminal / same shell
$ export pipedata
$ pipedata=$(<mypipe) &
$ ls -l *.sh >mypipe
$ echo "$pipedata"
#Output : Prints correctly the contents of mypipe
This prints correctly the value of $pipedata variable in the main shell due to the export declaration of the
variable. The main terminal/main shell is not hanging due to the invocation of a background shell (&).
Section 9.5: Redirection to network addresses
Version ≥ 2.04
Bash treats some paths as special and can do some network communication by writing to
/dev/{udp|tcp}/host/port. Bash cannot setup a listening server, but can initiate a connection, and for TCP can
read the results at least.
For example, to send a simple web request one could do:
exec 3</dev/tcp/www.google.com/80
printf 'GET / HTTP/1.0\r\n\r\n' >&3
cat <&3
and the results of www.google.com's default web page will be printed to stdout.
Similarly
printf 'HI\n' >/dev/udp/192.168.1.1/6666
would send a UDP message containing HI\n to a listener on 192.168.1.1:6666
Section 9.6: Print error messages to stderr
Error messages are generally included in a script for debugging purposes or for providing rich user experience.
Simply writing error message like this:
GoalKicker.com – Bash Notes for Professionals
30cmd || echo 'cmd failed'
may work for simple cases but it's not the usual way. In this example, the error message will pollute the actual
output of the script by mixing both errors and successful output in stdout.
In short, error message should go to stderr not stdout. It's pretty simple:
cmd || echo 'cmd failed' >/dev/stderr
Another example:
if cmd; then
echo 'success'
else
echo 'cmd failed' >/dev/stderr
fi
In the above example, the success message will be printed on stdout while the error message will be printed on
stderr.
A better way to print error message is to deﬁne a function:
err(){
echo "E: $*" >>/dev/stderr
}
Now, when you have to print an error:
err "My error message"
Section 9.7: Redirecting multiple commands to the same ﬁle
{
echo "contents of home directory"
ls ~
} > output.txt
Section 9.8: Redirecting STDIN
< reads from its right argument and writes to its left argument.
To write a ﬁle into STDIN we should read /tmp/a_file and write into STDIN i.e 0</tmp/a_file
Note: Internal ﬁle descriptor defaults to 0 (STDIN) for <
$ echo "b" > /tmp/list.txt
$ echo "a" >> /tmp/list.txt
$ echo "c" >> /tmp/list.txt
$ sort < /tmp/list.txt
a
b
c
GoalKicker.com – Bash Notes for Professionals
31Section 9.9: Redirecting STDERR
2 is STDERR.
$ echo_to_stderr 2>/dev/null # echos nothing
Deﬁnitions:
echo_to_stderr is a command that writes "stderr" to STDERR
echo_to_stderr () {
echo stderr >&2
}
$ echo_to_stderr
stderr
Section 9.10: STDIN, STDOUT and STDERR explained
Commands have one input (STDIN) and two kinds of outputs, standard output (STDOUT) and standard error
(STDERR).
For example:
STDIN
root@server~# read
Type some text here
Standard input is used to provide input to a program. (Here we're using the read builtin to read a line from STDIN.)
STDOUT
root@server~# ls file
file
Standard output is generally used for "normal" output from a command. For example, ls lists ﬁles, so the ﬁles are
sent to STDOUT.
STDERR
root@server~# ls anotherfile
ls: cannot access 'anotherfile': No such file or directory
Standard error is (as the name implies) used for error messages. Because this message is not a list of ﬁles, it is sent
to STDERR.
STDIN, STDOUT and STDERR are the three standard streams. They are identiﬁed to the shell by a number rather
than a name:
0 = Standard in
1 = Standard out
2 = Standard error
By default, STDIN is attached to the keyboard, and both STDOUT and STDERR appear in the terminal. However, we
GoalKicker.com – Bash Notes for Professionals
32can redirect either STDOUT or STDERR to whatever we need. For example, let's say that you only need the standard
out and all error messages printed on standard error should be suppressed. That's when we use the descriptors 1
and 2.
Redirecting STDERR to /dev/null
Taking the previous example,
root@server~# ls anotherfile 2>/dev/null
root@server~#
In this case, if there is any STDERR, it will be redirected to /dev/null (a special ﬁle which ignores anything put into it),
so you won't get any error output on the shell.
GoalKicker.com – Bash Notes for Professionals
33Chapter 10: Control Structures
Parameter to [ or test
File Operators
Details
Details
-e "$file"Returns true if the ﬁle exists.
-d "$file"Returns true if the ﬁle exists and is a directory
-f "$file"Returns true if the ﬁle exists and is a regular ﬁle
-h "$file"Returns true if the ﬁle exists and is a symbolic link
String ComparatorsDetails
-z "$str"True if length of string is zero
-n "$strTrue if length of string is non-zero
"$str" = "$str2"True if string $str is equal to string $str2. Not best for integers. It may work but will be
inconsitent
"$str" != "$str2"True if the strings are not equal
Integer ComparatorsDetails
"$int1" -eq "$int2"True if the integers are equal
"$int1" -ne "$int2"True if the integers are not equals
"$int1" -gt "$int2"True if int1 is greater than int 2
"$int1" -ge "$int2"True if int1 is greater than or equal to int2
"$int1" -lt "$int2"True if int1 is less than int 2
"$int1" -le "$int2"True if int1 is less than or equal to int2
Section 10.1: Conditional execution of command lists
How to use conditional execution of command lists
Any builtin command, expression, or function, as well as any external command or script can be executed
conditionally using the &&(and) and ||(or) operators.
For example, this will only print the current directory if the cd command was successful.
cd my_directory && pwd
Likewise, this will exit if the cd command fails, preventing catastrophe:
cd my_directory || exit
rm -rf *
When combining multiple statements in this manner, it's important to remember that (unlike many C-style
languages) these operators have no precedence and are left-associative.
Thus, this statement will work as expected...
cd my_directory && pwd || echo "No such directory"
If the cd succeeds, the && pwd executes and the current working directory name is printed. Unless pwd fails (a
rarity) the || echo ... will not be executed.
If the cd fails, the && pwd will be skipped and the || echo ... will run.
But this will not (if you're thinking if...then...else)...
GoalKicker.com – Bash Notes for Professionals
34cd my_directory && ls || echo "No such directory"
If the cd fails, the && ls is skipped and the || echo ... is executed.
If the cd succeeds, the && ls is executed.
If the ls succeeds, the || echo ... is ignored. (so far so good)
BUT... if the ls fails, the || echo ... will also be executed.
It is the ls, not the cd, that is the previous command.
Why use conditional execution of command lists
Conditional execution is a hair faster than if...then but its main advantage is allowing functions and scripts to exit
early, or "short circuit".
Unlike many languages like C where memory is explicitly allocated for structs and variables and such (and thus
must be deallocated), bash handles this under the covers. In most cases, we don't have to clean up anything before
leaving the function. A return statement will deallocate everything local to the function and pickup execution at the
return address on the stack.
Returning from functions or exiting scripts as soon as possible can thus signiﬁcantly improve performance and
reduce system load by avoiding the unnecessary execution of code. For example...
my_function () {
### ALWAYS CHECK THE RETURN CODE
# one argument required. "" evaluates to false(1)
[[ "$1" ]]
|| return 1
# work with the argument. exit on failure
do_something_with "$1" || return 1
do_something_else
|| return 1
# Success! no failures detected, or we wouldn't be here
return 0
}
Section 10.2: If statement
if [[ $1 -eq 1 ]]; then
echo "1 was passed in the first parameter"
elif [[ $1 -gt 2 ]]; then
echo "2 was not passed in the first parameter"
else
echo "The first parameter was not 1 and is not more than 2."
fi
The closing fi is necessary, but the elif and/or the else clauses can be omitted.
The semicolons before then are standard syntax for combining two commands on a single line; they can be omitted
only if then is moved to the next line.
It's important to understand that the brackets [[ are not part of the syntax, but are treated as a command; it is the
exit code from this command that is being tested. Therefore, you must always include spaces around the brackets.
GoalKicker.com – Bash Notes for Professionals
35This also means that the result of any command can be tested. If the exit code from the command is a zero, the
statement is considered true.
if grep "foo" bar.txt; then
echo "foo was found"
else
echo "foo was not found"
fi
Mathematical expressions, when placed inside double parentheses, also return 0 or 1 in the same way, and can
also be tested:
if (( $1 + 5 > 91 )); then
echo "$1 is greater than 86"
fi
You may also come across if statements with single brackets. These are deﬁned in the POSIX standard and are
guaranteed to work in all POSIX-compliant shells including Bash. The syntax is very similar to that in Bash:
if [ "$1" -eq 1 ]; then
echo "1 was passed in the first parameter"
elif [ "$1" -gt 2 ]; then
echo "2 was not passed in the first parameter"
else
echo "The first parameter was not 1 and is not more than 2."
fi
Section 10.3: Looping over an array
for loop:
arr=(a b c d e f)
for i in "${arr[@]}";do
echo "$i"
done
Or
for ((i=0;i<${#arr[@]};i++));do
echo "${arr[$i]}"
done
while loop:
i=0
while [ $i -lt ${#arr[@]} ];do
echo "${arr[$i]}"
i=$(expr $i + 1)
done
Or
i=0
while (( $i < ${#arr[@]} ));do
echo "${arr[$i]}"
((i++))
GoalKicker.com – Bash Notes for Professionals
36done
Section 10.4: Using For Loop to List Iterate Over Numbers
#! /bin/bash
for i in {1..10}; do # {1..10} expands to "1 2 3 4 5 6 7 8 9 10"
echo $i
done
This outputs the following:
1
2
3
4
5
6
7
8
8
10
Section 10.5: continue and break
Example for continue
for i in [series]
do
command 1
command 2
if (condition) # Condition to jump over command 3
continue # skip to the next value in "series"
fi
command 3
done
Example for break
for i in [series]
do
command 4
if (condition) # Condition to break the loop
then
command 5 # Command if the loop needs to be broken
break
fi
command 6 # Command to run if the "condition" is never true
done
Section 10.6: Loop break
Break multiple loop:
arr=(a b c d e f)
for i in "${arr[@]}";do
echo "$i"
GoalKicker.com – Bash Notes for Professionals
37for j in "${arr[@]}";do
echo "$j"
break 2
done
done
Output:
a
a
Break single loop:
arr=(a b c d e f)
for i in "${arr[@]}";do
echo "$i"
for j in "${arr[@]}";do
echo "$j"
break
done
done
Output:
a
a
b
a
c
a
d
a
e
a
f
a
Section 10.7: While Loop
#! /bin/bash
i=0
while [ $i -lt 5 ] #While i is less than 5
do
echo "i is currently $i"
i=$[$i+1] #Not the lack of spaces around the brackets. This makes it a not a test expression
done #ends the loop
Watch that there are spaces around the brackets during the test (after the while statement). These spaces are
necessary.
This loop outputs:
i is currently 0
i is currently 1
i is currently 2
i is currently 3
GoalKicker.com – Bash Notes for Professionals
38i is currently 4
Section 10.8: For Loop with C-style syntax
The basic format of C-style for loop is:
for (( variable assignment; condition; iteration process ))
Notes:
The assignment of the variable inside C-style for loop can contain spaces unlike the usual assignment
Variables inside C-style for loop aren't preceded with $.
Example:
for (( i = 0; i < 10; i++ ))
do
echo "The iteration number is $i"
done
Also we can process multiple variables inside C-style for loop:
for (( i = 0, j = 0; i < 10; i++, j = i * i ))
do
echo "The square of $i is equal to $j"
done
Section 10.9: Until Loop
Until loop executes until condition is true
i=5
until [[ i -eq 10 ]]; do #Checks if i=10
echo "i=$i" #Print the value of i
i=$((i+1)) #Increment i by 1
done
Output:
i=5
i=6
i=7
i=8
i=9
When i reaches 10 the condition in until loop becomes true and the loop ends.
Section 10.10: Switch statement with case
With the case statement you can match values against one variable.
The argument passed to case is expanded and try to match against each patterns.
If a match is found, the commands upto ;; are executed.
GoalKicker.com – Bash Notes for Professionals
39case "$BASH_VERSION" in
[34]*)
echo {1..4}
;;
*)
seq -s" " 1 4
esac
Pattern are not regular expressions but shell pattern matching (aka globs).
Section 10.11: For Loop without a list-of-words parameter
for arg; do
echo arg=$arg
done
A for loop without a list of words parameter will iterate over the positional parameters instead. In other words, the
above example is equivalent to this code:
for arg in "$@"; do
echo arg=$arg
done
In other words, if you catch yourself writing for i in "$@"; do ...; done, just drop the in part, and write simply
for i; do ...; done.
GoalKicker.com – Bash Notes for Professionals
40Chapter 11: true, false and : commands
Section 11.1: Inﬁnite Loop
while true; do
echo ok
done
or
while :; do
echo ok
done
or
until false; do
echo ok
done
Section 11.2: Function Return
function positive() {
return 0
}
function negative() {
return 1
}
Section 11.3: Code that will always/never be executed
if true; then
echo Always executed
fi
if false; then
echo Never executed
fi
GoalKicker.com – Bash Notes for Professionals
41Chapter 12: Arrays
Section 12.1: Array Assignments
List Assignment
If you are familiar with Perl, C, or Java, you might think that Bash would use commas to separate array elements,
however this is not the case; instead, Bash uses spaces:
# Array in Perl
my @array = (1, 2, 3, 4);
# Array in Bash
array=(1 2 3 4)
Create an array with new elements:
array=('first element' 'second element' 'third element')
Subscript Assignment
Create an array with explicit element indices:
array=([3]='fourth element' [4]='fifth element')
Assignment by index
array[0]='first element'
array[1]='second element'
Assignment by name (associative array)
Version ≥ 4.0
declare -A array
array[first]='First element'
array[second]='Second element'
Dynamic Assignment
Create an array from the output of other command, for example use seq to get a range from 1 to 10:
array=(`seq 1 10`)
Assignment from script's input arguments:
array=("$@")
Assignment within loops:
while read -r; do
#array+=("$REPLY")
# Array append
array[$i]="$REPLY"
# Assignment by index
let i++
# Increment index
done < <(seq 1 10) # command substitution
GoalKicker.com – Bash Notes for Professionals
42echo ${array[@]}
# output: 1 2 3 4 5 6 7 8 9 10
where $REPLY is always the current input
Section 12.2: Accessing Array Elements
Print element at index 0
echo "${array[0]}"
Version < 4.3
Print last element using substring expansion syntax
echo "${arr[@]: -1 }"
Version ≥ 4.3
Print last element using subscript syntax
echo "${array[-1]}"
Print all elements, each quoted separately
echo "${array[@]}"
Print all elements as a single quoted string
echo "${array[*]}"
Print all elements from index 1, each quoted separately
echo "${array[@]:1}"
Print 3 elements from index 1, each quoted separately
echo "${array[@]:1:3}"
String Operations
If referring to a single element, string operations are permitted:
array=(zero one two)
echo "${array[0]:0:3}" # gives out zer (chars at position 0, 1 and 2 in the string zero)
echo "${array[0]:1:3}" # gives out ero (chars at position 1, 2 and 3 in the string zero)
so ${array[$i]:N:M} gives out a string from the Nth position (starting from 0) in the string ${array[$i]} with M
following chars.
Section 12.3: Array Modiﬁcation
Change Index
Initialize or update a particular element in the array
array[10]="elevenths element"
# because it's starting with 0
GoalKicker.com – Bash Notes for Professionals
43Version ≥ 3.1
Append
Modify array, adding elements to the end if no subscript is speciﬁed.
array+=('fourth element' 'fifth element')
Replace the entire array with a new parameter list.
array=("${array[@]}" "fourth element" "fifth element")
Add an element at the beginning:
array=("new element" "${array[@]}")
Insert
Insert an element at a given index:
arr=(a b c d)
# insert an element at index 2
i=2
arr=("${arr[@]:0:$i}" 'new' "${arr[@]:$i}")
echo "${arr[2]}" #output: new
Delete
Delete array indexes using the unset builtin:
arr=(a b c)
echo "${arr[@]}"
echo "${!arr[@]}"
unset -v 'arr[1]'
echo "${arr[@]}"
echo "${!arr[@]}"
# outputs: a b c
# outputs: 0 1 2
# outputs: a c
# outputs: 0 2
Merge
array3=("${array1[@]}" "${array2[@]}")
This works for sparse arrays as well.
Re-indexing an array
This can be useful if elements have been removed from an array, or if you're unsure whether there are gaps in the
array. To recreate the indices without gaps:
array=("${array[@]}")
Section 12.4: Array Iteration
Array iteration comes in two ﬂavors, foreach and the classic for-loop:
a=(1 2 3 4)
# foreach loop
GoalKicker.com – Bash Notes for Professionals
44for y in "${a[@]}"; do
# act on $y
echo "$y"
done
# classic for-loop
for ((idx=0; idx < ${#a[@]}; ++idx)); do
# act on ${a[$idx]}
echo "${a[$idx]}"
done
You can also iterate over the output of a command:
a=($(tr ',' ' ' <<<"a,b,c,d")) # tr can transform one character to another
for y in "${a[@]}"; do
echo "$y"
done
Section 12.5: Array Length
${#array[@]} gives the length of the array ${array[@]}:
array=('first element' 'second element' 'third element')
echo "${#array[@]}" # gives out a length of 3
This works also with Strings in single elements:
echo "${#array[0]}"
# gives out the lenght of the string at element 0: 13
Section 12.6: Associative Arrays
Version ≥ 4.0
Declare an associative array
declare -A aa
Declaring an associative array before initialization or use is mandatory.
Initialize elements
You can initialize elements one at a time as follows:
aa[hello]=world
aa[ab]=cd
aa["key with space"]="hello world"
You can also initialize an entire associative array in a single statement:
aa=([hello]=world [ab]=cd ["key with space"]="hello world")
Access an associative array element
echo ${aa[hello]}
# Out: world
Listing associative array keys
GoalKicker.com – Bash Notes for Professionals
45echo "${!aa[@]}"
#Out: hello ab key with space
Listing associative array values
echo "${aa[@]}"
#Out: world cd hello world
Iterate over associative array keys and values
for key in "${!aa[@]}"; do
echo "Key:
${key}"
echo "Value: ${array[$key]}"
done
# Out:
# Key:
hello
# Value: world
# Key:
ab
# Value: cd
# Key:
key with space
# Value: hello world
Count associative array elements
echo "${#aa[@]}"
# Out: 3
Section 12.7: Looping through an array
Our example array:
arr=(a b c d e f)
Using a for..in loop:
for i in "${arr[@]}"; do
echo "$i"
done
Version ≥ 2.04
Using C-style for loop:
for ((i=0;i<${#arr[@]};i++)); do
echo "${arr[$i]}"
done
Using while loop:
i=0
while [ $i -lt ${#arr[@]} ]; do
echo "${arr[$i]}"
i=$((i + 1))
done
Version ≥ 2.04
GoalKicker.com – Bash Notes for Professionals
46Using while loop with numerical conditional:
i=0
while (( $i < ${#arr[@]} )); do
echo "${arr[$i]}"
((i++))
done
Using an until loop:
i=0
until [ $i -ge ${#arr[@]} ]; do
echo "${arr[$i]}"
i=$((i + 1))
done
Version ≥ 2.04
Using an until loop with numerical conditional:
i=0
until (( $i >= ${#arr[@]} )); do
echo "${arr[$i]}"
((i++))
done
Section 12.8: Destroy, Delete, or Unset an Array
To destroy, delete, or unset an array:
unset array
To destroy, delete, or unset a single array element:
unset array[10]
Section 12.9: Array from string
stringVar="Apple Orange Banana Mango"
arrayVar=(${stringVar// / })
Each space in the string denotes a new item in the resulting array.
echo ${arrayVar[0]} # will print Apple
echo ${arrayVar[3]} # will print Mango
Similarly, other characters can be used for the delimiter.
stringVar="Apple+Orange+Banana+Mango"
arrayVar=(${stringVar//+/ })
echo ${arrayVar[0]} # will print Apple
echo ${arrayVar[2]} # will print Banana
Section 12.10: List of initialized indexes
Get the list of inialized indexes in an array
GoalKicker.com – Bash Notes for Professionals
47$ arr[2]='second'
$ arr[10]='tenth'
$ arr[25]='twenty five'
$ echo ${!arr[@]}
2 10 25
Section 12.11: Reading an entire ﬁle into an array
Reading in a single step:
IFS=$'\n' read -r -a arr < file
Reading in a loop:
arr=()
while IFS= read -r line; do
arr+=("$line")
done
Version ≥ 4.0
Using mapfile or readarray (which are synonymous):
mapfile -t arr < file
readarray -t arr < file
Section 12.12: Array insert function
This function will insert an element into an array at a given index:
insert(){
h='
################## insert ########################
# Usage:
#
insert arr_name index element
#
#
Parameters:
#
arr_name
: Name of the array variable
#
index
: Index to insert at
#
element
: Element to insert
##################################################
'
[[ $1 = -h ]] && { echo "$h" >/dev/stderr; return 1; }
declare -n __arr__=$1
# reference to the array variable
i=$2
# index to insert at
el="$3"
# element to insert
# handle errors
[[ ! "$i" =~ ^[0-9]+$ ]] && { echo "E: insert: index must be a valid integer" >/dev/stderr;
return 1; }
(( $1 < 0 )) && { echo "E: insert: index can not be negative" >/dev/stderr; return 1; }
# Now insert $el at $i
__arr__=("${__arr__[@]:0:$i}" "$el" "${__arr__[@]:$i}")
}
Usage:
insert array_variable_name index element
GoalKicker.com – Bash Notes for Professionals
48Example:
arr=(a b c d)
echo "${arr[2]}" # output: c
# Now call the insert function and pass the array variable name,
# index to insert at
# and the element to insert
insert arr 2 'New Element'
# 'New Element' was inserted at index 2 in arr, now print them
echo "${arr[2]}" # output: New Element
echo "${arr[3]}" # output: c
GoalKicker.com – Bash Notes for Professionals
49Chapter 13: Associative arrays
Section 13.1: Examining assoc arrays
All needed usage shown with this snippet:
#!/usr/bin/env bash
declare -A assoc_array=([key_string]=value
\
[one]="something"
\
[two]="another thing"
\
[ three ]='mind the blanks!'
\
[ " four" ]='count the blanks of this key later!'
\
[IMPORTANT]='SPACES DO ADD UP!!!'
\
[1]='there are no integers!'
\
[info]="to avoid history expansion "
\
[info2]="quote exclamation mark with single quotes" \
)
echo # just a blank line
echo now here are the values of assoc_array:
echo ${assoc_array[@]}
echo not that useful,
echo # just a blank line
echo this is better:
declare -p assoc_array
# -p == print
echo have a close look at the spaces above\!\!\!
echo # just a blank line
echo accessing the keys
echo the keys in assoc_array are ${!assoc_array[*]}
echo mind the use of indirection operator \!
echo # just a blank line
echo now we loop over the assoc_array line by line
echo note the \! indirection operator which works differently,
echo if used with assoc_array.
echo # just a blank line
for key in "${!assoc_array[@]}"; do # accessing keys using ! indirection!!!!
printf "key: \"%s\"\nvalue: \"%s\"\n\n" "$key" "${assoc_array[$key]}"
done
echo have a close look at the spaces in entries with keys two, three and four above\!\!\!
echo # just a blank line
echo # just another blank line
echo there is a difference using integers as keys\!\!\!
i=1
echo declaring an integer var i=1
echo # just a blank line
echo Within an integer_array bash recognizes artithmetic context.
echo Within an assoc_array bash DOES NOT recognize artithmetic context.
echo # just a blank line
echo this works: \${assoc_array[\$i]}: ${assoc_array[$i]}
echo this NOT!!: \${assoc_array[i]}: ${assoc_array[i]}
GoalKicker.com – Bash Notes for Professionals
50echo # just a blank line
echo # just a blank line
echo an \${assoc_array[i]} has a string context within braces in contrast to an integer_array
declare -i integer_array=( one two three )
echo "doing a: declare -i integer_array=( one two three )"
echo # just a blank line
echo both forms do work: \${integer_array[i]} : ${integer_array[i]}
echo and this too: \${integer_array[\$i]} : ${integer_array[$i]}
GoalKicker.com – Bash Notes for Professionals
51Chapter 14: Functions
Section 14.1: Functions with arguments
In helloJohn.sh:
#!/bin/bash
greet() {
local name="$1"
echo "Hello, $name"
}
greet "John Doe"
# running above script
$ bash helloJohn.sh
Hello, John Doe
1. If you don't modify the argument in any way, there is no need to copy it to a local variable - simply echo
"Hello, $1".
2. You can use $1, $2, $3 and so on to access the arguments inside the function.
Note: for arguments more than 9 $10 won't work (bash will read it as $10), you need to do ${10},
${11} and so on.
3. $@ refers to all arguments of a function:
#!/bin/bash
foo() {
echo "$@"
}
foo 1 2 3 # output => 1 2 3
Note: You should practically always use double quotes around "$@", like here.
Omitting the quotes will cause the shell to expand wildcards (even when the user speciﬁcally quoted them in
order to avoid that) and generally introduce unwelcome behavior and potentially even security problems.
foo "string with spaces;" '$HOME' "*"
# output => string with spaces; $HOME *
4. for default arguments use ${1:-default_val}. Eg:
#!/bin/bash
foo() {
local val=${1:-25}
echo "$val"
}
GoalKicker.com – Bash Notes for Professionals
52foo
foo 30
# output => 25
# output => 30
5. to require an argument use ${var:?error message}
foo() {
local val=${1:?Must provide an argument}
echo "$val"
}
Section 14.2: Simple Function
In helloWorld.sh
#!/bin/bash
# Define a function greet
greet ()
{
echo "Hello World!"
}
# Call the function greet
greet
In running the script, we see our message
$ bash helloWorld.sh
Hello World!
Note that sourcing a ﬁle with functions makes them available in your current bash session.
$ source helloWorld.sh
$ greet
Hello World!
# or, more portably, ". helloWorld.sh"
You can export a function in some shells, so that it is exposed to child processes.
bash -c 'greet'
export -f greet
bash -c 'greet'
# fails
# export function; note -f
# success
Section 14.3: Handling ﬂags and optional parameters
The getopts builtin can be used inside functions to write functions that accommodate ﬂags and optional
parameters. This presents no special diﬃculty but one has to handle appropriately the values touched by getopts.
As an example, we deﬁne a failwith function that writes a message on stderr and exits with code 1 or an arbitrary
code supplied as parameter to the -x option:
# failwith [-x STATUS] PRINTF-LIKE-ARGV
# Fail with the given diagnostic message
#
# The -x flag can be used to convey a custom exit status, instead of
# the value 1. A newline is automatically added to the output.
failwith()
GoalKicker.com – Bash Notes for Professionals
53{
local OPTIND OPTION OPTARG status
status=1
OPTIND=1
while getopts 'x:' OPTION; do
case ${OPTION} in
x)
status="${OPTARG}";;
*)
1>&2 printf 'failwith: %s: Unsupported option.\n' "${OPTION}";;
esac
done
shift $(( OPTIND - 1 ))
{
printf 'Failure: '
printf "$@"
printf '\n'
} 1>&2
exit "${status}"
}
This function can be used as follows:
failwith '%s: File not found.' "${filename}"
failwith -x 70 'General internal error.'
and so on.
Note that as for printf, variables should not be used as ﬁrst argument. If the message to print consists of the
content of a variable, one should use the %s speciﬁer to print it, like in
failwith '%s' "${message}"
Section 14.4: Print the function deﬁnition
getfunc() {
declare -f "$@"
}
function func(){
echo "I am a sample function"
}
funcd="$(getfunc func)"
getfunc func # or echo "$funcd"
Output:
func ()
{
echo "I am a sample function"
}
Section 14.5: A function that accepts named parameters
foo() {
while [[ "$#" -gt 0 ]]
GoalKicker.com – Bash Notes for Professionals
54do
case $1 in
-f|--follow)
local FOLLOW="following"
;;
-t|--tail)
local TAIL="tail=$2"
;;
esac
shift
done
echo "FOLLOW: $FOLLOW"
echo "TAIL: $TAIL"
}
Example usage:
foo -f
foo -t 10
foo -f --tail 10
foo --follow --tail 10
Section 14.6: Return value from a function
The return statement in Bash doesn't return a value like C-functions, instead it exits the function with a return
status. You can think of it as the exit status of that function.
If you want to return a value from the function then send the value to stdout like this:
fun() {
local var="Sample value to be returned"
echo "$var"
#printf "%s\n" "$var"
}
Now, if you do:
var="$(fun)"
the output of fun will be stored in $var.
Section 14.7: The exit code of a function is the exit code of its
last command
Consider this example function to check if a host is up:
is_alive() {
ping -c1 "$1" &> /dev/null
}
This function sends a single ping to the host speciﬁed by the ﬁrst function parameter. The output and error output
of ping are both redirected to /dev/null, so the function will never output anything. But the ping command will
have exit code 0 on success, and non-zero on failure. As this is the last (and in this example, the only) command of
the function, the exit code of ping will be reused for the exit code of the function itself.
GoalKicker.com – Bash Notes for Professionals
55This fact is very useful in conditional statements.
For example, if host graucho is up, then connect to it with ssh:
if is_alive graucho; then
ssh graucho
fi
Another example: repeatedly check until host graucho is up, and then connect to it with ssh:
while ! is_alive graucho; do
sleep 5
done
ssh graucho
GoalKicker.com – Bash Notes for Professionals
56Chapter 15: Bash Parameter Expansion
The $ character introduces parameter expansion, command substitution, or arithmetic expansion. The parameter
name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to
be expanded from characters immediately following it which could be interpreted as part of the name.
Read more in the Bash User Manual.
Section 15.1: Modifying the case of alphabetic characters
Version ≥ 4.0
To uppercase
$ v="hello"
# Just the first character
$ printf '%s\n' "${v^}"
Hello
# All characters
$ printf '%s\n' "${v^^}"
HELLO
# Alternative
$ v="hello world"
$ declare -u string="$v"
$ echo "$string"
HELLO WORLD
To lowercase
$ v="BYE"
# Just the first character
$ printf '%s\n' "${v,}"
bYE
# All characters
$ printf '%s\n' "${v,,}"
bye
# Alternative
$ v="HELLO WORLD"
$ declare -l string="$v"
$ echo "$string"
hello world
Toggle Case
$ v="Hello World"
# All chars
$ echo "${v~~}"
hELLO wORLD
$ echo "${v~}"
# Just the first char
hello World
Section 15.2: Length of parameter
# Length of a string
$ var='12345'
$ echo "${#var}"
GoalKicker.com – Bash Notes for Professionals
575
Note that it's the length in number of characters which is not necessarily the same as the number of bytes (like in
UTF-8 where most characters are encoded in more than one byte), nor the number of glyphs/graphemes (some of
which are combinations of characters), nor is it necessarily the same as the display width.
# Number of array elements
$ myarr=(1 2 3)
$ echo "${#myarr[@]}"
3
# Works for positional parameters as well
$ set -- 1 2 3 4
$ echo "${#@}"
4
# But more commonly (and portably to other shells), one would use
$ echo "$#"
4
Section 15.3: Replace pattern in string
First match:
$ a='I am a string'
$ echo "${a/a/A}"
I Am a string
All matches:
$ echo "${a//a/A}"
I Am A string
Match at the beginning:
$ echo "${a/#I/y}"
y am a string
Match at the end:
$ echo "${a/%g/N}"
I am a strinN
Replace a pattern with nothing:
$ echo "${a/g/}"
I am a strin
Add preﬁx to array items:
$ A=(hello world)
$ echo "${A[@]/#/R}"
Rhello Rworld
GoalKicker.com – Bash Notes for Professionals
58Section 15.4: Substrings and subarrays
var='0123456789abcdef'
# Define a zero-based offset
$ printf '%s\n' "${var:3}"
3456789abcdef
# Offset and length of substring
$ printf '%s\n' "${var:3:4}"
3456
Version ≥ 4.2
# Negative length counts from the end of the string
$ printf '%s\n' "${var:3:-5}"
3456789a
# Negative offset counts from the end
# Needs a space to avoid confusion with ${var:-6}
$ printf '%s\n' "${var: -6}"
abcdef
# Alternative: parentheses
$ printf '%s\n' "${var:(-6)}"
abcdef
# Negative offset and negative length
$ printf '%s\n' "${var: -6:-5}"
a
The same expansions apply if the parameter is a positional parameter or the element of a subscripted array:
# Set positional parameter $1
set -- 0123456789abcdef
# Define offset
$ printf '%s\n' "${1:5}"
56789abcdef
# Assign to array element
myarr[0]='0123456789abcdef'
# Define offset and length
$ printf '%s\n' "${myarr[0]:7:3}"
789
Analogous expansions apply to positional parameters, where oﬀsets are one-based:
# Set positional parameters $1, $2, ...
$ set -- 1 2 3 4 5 6 7 8 9 0 a b c d e f
# Define an offset (beware $0 (not a positional parameter)
# is being considered here as well)
$ printf '%s\n' "${@:10}"
0
a
b
c
d
e
f
GoalKicker.com – Bash Notes for Professionals
59# Define an offset and a length
$ printf '%s\n' "${@:10:3}"
0
a
b
# No negative lengths allowed for positional parameters
$ printf '%s\n' "${@:10:-2}"
bash: -2: substring expression < 0
# Negative offset counts from the end
# Needs a space to avoid confusion with ${@:-10:2}
$ printf '%s\n' "${@: -10:2}"
7
8
# ${@:0} is $0 which is not otherwise a positional parameters or part
# of $@
$ printf '%s\n' "${@:0:2}"
/usr/bin/bash
1
Substring expansion can be used with indexed arrays:
# Create array (zero-based indices)
$ myarr=(0 1 2 3 4 5 6 7 8 9 a b c d e f)
# Elements with index 5 and higher
$ printf '%s\n' "${myarr[@]:12}"
c
d
e
f
# 3 elements, starting with index 5
$ printf '%s\n' "${myarr[@]:5:3}"
5
6
7
# The last element of the array
$ printf '%s\n' "${myarr[@]: -1}"
f
Section 15.5: Delete a pattern from the beginning of a string
Shortest match:
$ a='I am a string'
$ echo "${a#*a}"
m a string
Longest match:
$ echo "${a##*a}"
string
GoalKicker.com – Bash Notes for Professionals
60Section 15.6: Parameter indirection
Bash indirection permits to get the value of a variable whose name is contained in another variable. Variables
example:
$ red="the color red"
$ green="the color green"
$ color=red
$ echo "${!color}"
the color red
$ color=green
$ echo "${!color}"
the color green
Some more examples that demonstrate the indirect expansion usage:
$ foo=10
$ x=foo
$ echo ${x}
foo
$ foo=10
$ x=foo
$ echo ${!x}
10
#Classic variable print
#Indirect expansion
One more example:
$ argtester () { for (( i=1; i<="$#"; i++ )); do echo "${i}";done; }; argtester -ab -cd -ef
1
#i expanded to 1
2
#i expanded to 2
3
#i expanded to 3
$ argtester () { for (( i=1; i<="$#"; i++ )); do echo "${!i}";done; }; argtester -ab -cd -ef
-ab
# i=1 --> expanded to $1 ---> expanded to first argument sent to function
-cd
# i=2 --> expanded to $2 ---> expanded to second argument sent to function
-ef
# i=3 --> expanded to $3 ---> expanded to third argument sent to function
Section 15.7: Parameter expansion and ﬁlenames
You can use Bash Parameter Expansion to emulate common ﬁlename-processing operations like basename and
dirname.
We will use this as our example path:
FILENAME="/tmp/example/myfile.txt"
To emulate dirname and return the directory name of a ﬁle path:
echo "${FILENAME%/*}"
#Out: /tmp/example
To emulate basename $FILENAME and return the ﬁlename of a ﬁle path:
echo "${FILENAME##*/}"
GoalKicker.com – Bash Notes for Professionals
61#Out: myfile.txt
To emulate basename $FILENAME .txt and return the ﬁlename without the .txt. extension:
BASENAME="${FILENAME##*/}"
echo "${BASENAME%%.txt}"
#Out: myfile
Section 15.8: Default value substitution
${parameter:-word}
If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is
substituted.
$ unset var
$ echo "${var:-XX}"
XX
$ var=""
$ echo "${var:-XX}"
XX
$ var=23
$ echo "${var:-XX}"
23
# Parameter is unset -> expansion XX occurs
# Parameter is null -> expansion XX occurs
# Parameter is not null -> original expansion occurs
${parameter:=word}
If parameter is unset or null, the expansion of word is assigned to parameter. The value of parameter is
then substituted. Positional parameters and special parameters may not be assigned to in this way.
$ unset var
$ echo "${var:=XX}"
XX
$ echo "$var"
XX
$ var=""
$ echo "${var:=XX}"
XX
$ echo "$var"
XX
$ var=23
$ echo "${var:=XX}"
23
$ echo "$var"
23
# Parameter is unset -> word is assigned to XX
# Parameter is null -> word is assigned to XX
# Parameter is not null -> no assignment occurs
Section 15.9: Delete a pattern from the end of a string
Shortest match:
$ a='I am a string'
$ echo "${a%a*}"
I am
Longest match:
GoalKicker.com – Bash Notes for Professionals
62$ echo "${a%%a*}"
I
Section 15.10: Munging during expansion
Variables don't necessarily have to expand to their values - substrings can be extracted during expansion, which
can be useful for extracting ﬁle extensions or parts of paths. Globbing characters keep their usual meanings, so .*
refers to a literal dot, followed by any sequence of characters; it's not a regular expression.
$ v=foo-bar-baz
$ echo ${v%%-*}
foo
$ echo ${v%-*}
foo-bar
$ echo ${v##*-}
baz
$ echo ${v#*-}
bar-baz
It's also possible to expand a variable using a default value - say I want to invoke the user's editor, but if they've not
set one I'd like to give them vim.
$ EDITOR=nano
$ ${EDITOR:-vim} /tmp/some_file
# opens nano
$ unset EDITOR
$ $ ${EDITOR:-vim} /tmp/some_file
# opens vim
There are two diﬀerent ways of performing this expansion, which diﬀer in whether the relevant variable is empty or
unset. Using :- will use the default if the variable is either unset or empty, whilst - only uses the default if the
variable is unset, but will use the variable if it is set to the empty string:
$ a="set"
$ b=""
$ unset c
$ echo ${a:-default_a} ${b:-default_b} ${c:-default_c}
set default_b default_c
$ echo ${a-default_a} ${b-default_b} ${c-default_c}
set default_c
Similar to defaults, alternatives can be given; where a default is used if a particular variable isn't available, an
alternative is used if the variable is available.
$ a="set"
$ b=""
$ echo ${a:+alternative_a} ${b:+alternative_b}
alternative_a
Noting that these expansions can be nested, using alternatives becomes particularly useful when supplying
arguments to command line ﬂags;
$ output_file=/tmp/foo
$ wget ${output_file:+"-o ${output_file}"} www.stackexchange.com
# expands to wget -o /tmp/foo www.stackexchange.com
$ unset output_file
GoalKicker.com – Bash Notes for Professionals
63$ wget ${output_file:+"-o ${output_file}"} www.stackexchange.com
# expands to wget www.stackexchange.com
Section 15.11: Error if variable is empty or unset
The semantics for this are similar to that of default value substitution, but instead of substituting a default value, it
errors out with the provided error message. The forms are ${VARNAME?ERRMSG} and ${VARNAME:?ERRMSG}. The form
with : will error our if the variable is unset or empty, whereas the form without will only error out if the variable is
unset. If an error is thrown, the ERRMSG is output and the exit code is set to 1.
#!/bin/bash
FOO=
# ./script.sh: line 4: FOO: EMPTY
echo "FOO is ${FOO:?EMPTY}"
# FOO is
echo "FOO is ${FOO?UNSET}"
# ./script.sh: line 8: BAR: EMPTY
echo "BAR is ${BAR:?EMPTY}"
# ./script.sh: line 10: BAR: UNSET
echo "BAR is ${BAR?UNSET}"
The run the full example above each of the erroring echo statements needs to be commented out to proceed.
GoalKicker.com – Bash Notes for Professionals
64Chapter 16: Copying (cp)
-a,-archive
Option
Description
Combines the d, p and r options
-b, -backupBefore removal, makes a backup
-d, --no-deference Preserves links
-f, --force
Remove existing destinations without prompting user
-i, --interactive Show prompt before overwriting
-l, --linkInstead of copying, link ﬁles instead
-p, --preservePreserve ﬁle attributes when possible
-R, --recursiveRecursively copy directories
Section 16.1: Copy a single ﬁle
Copy foo.txt from /path/to/source/ to /path/to/target/folder/
cp /path/to/source/foo.txt /path/to/target/folder/
Copy foo.txt from /path/to/source/ to /path/to/target/folder/ into a ﬁle called bar.txt
cp /path/to/source/foo.txt /path/to/target/folder/bar.txt
Section 16.2: Copy folders
copy folder foo into folder bar
cp -r /path/to/foo /path/to/bar
if folder bar exists before issuing the command, then foo and its content will be copied into the folder bar.
However, if bar does not exist before issuing the command, then the folder bar will be created and the content of
foo will be placed into bar
GoalKicker.com – Bash Notes for Professionals
65Chapter 17: Find
ﬁnd is a command to recursively search a directory for ﬁles(or directories) that match a criteria, and then perform
some action on the selected ﬁles.
ﬁnd search_path selection_criteria action
Section 17.1: Searching for a ﬁle by name or extension
To ﬁnd ﬁles/directories with a speciﬁc name, relative to pwd:
$ find . -name "myFile.txt"
./myFile.txt
To ﬁnd ﬁles/directories with a speciﬁc extension, use a wildcard:
$ find . -name "*.txt"
./myFile.txt
./myFile2.txt
To ﬁnd ﬁles/directories matching one of many extensions, use the or ﬂag:
$ find . -name "*.txt" -o -name "*.sh"
To ﬁnd ﬁles/directories which name begin with abc and end with one alpha character following a one digit:
$ find . -name "abc[a-z][0-9]"
To ﬁnd all ﬁles/directories located in a speciﬁc directory
$ find /opt
To search for ﬁles only (not directories), use -type f:
find /opt -type f
To search for directories only (not regular ﬁles), use -type d:
find /opt -type d
Section 17.2: Executing commands against a found ﬁle
Sometimes we will need to run commands against a lot of ﬁles. This can be done using xargs.
find . -type d -print | xargs -r chmod 770
The above command will recursively ﬁnd all directories (-type d) relative to . (which is your current working
directory), and execute chmod 770 on them. The -r option speciﬁes to xargs to not run chmod if find did not ﬁnd
any ﬁles.
If your ﬁles names or directories have a space character in them, this command may choke; a solution is to use the
following
GoalKicker.com – Bash Notes for Professionals
66find . -type d -print0 | xargs -r -0 chmod 770
In the above example, the -print0 and -0 ﬂags specify that the ﬁle names will be separated using a null byte, and
allows the use of special characters, like spaces, in the ﬁle names. This is a GNU extension, and may not work in
other versions of find and xargs.
The preferred way to do this is to skip the xargs command and let find call the subprocess itself:
find . -type d -exec chmod 770 {} \;
Here, the {} is a placeholder indicating that you want to use the ﬁle name at that point. find will execute chmod on
each ﬁle individually.
You can alternatively pass all ﬁle names to a single call of chmod, by using
find . -type d -exec chmod 770 {} +
This is also the behaviour of the above xargs snippets. (To call on each ﬁle individually, you can use xargs -n1).
A third option is to let bash loop over the list of ﬁlenames find outputs:
find . -type d | while read -r d; do chmod 770 "$d"; done
This is syntactically the most clunky, but convenient when you want to run multiple commands on each found ﬁle.
However, this is unsafe in the face of ﬁle names with odd names.
find . -type f | while read -r d; do mv "$d" "${d// /_}"; done
which will replace all spaces in ﬁle names with underscores.(This example also won't work if there are spaces in
leading directory names.)
The problem with the above is that while read -r expects one entry per line, but ﬁle names can contain newlines
(and also, read -r will lose any trailing whitespace). You can ﬁx this by turning things around:
find . -type d -exec bash -c 'for f; do mv "$f" "${f// /_}"; done' _ {} +
This way, the -exec receives the ﬁle names in a form which is completely correct and portable; the bash -c receives
them as a number of arguments, which will be found in $@, correctly quoted etc. (The script will need to handle
these names correctly, of course; every variable which contains a ﬁle name needs to be in double quotes.)
The mysterious _ is necessary because the ﬁrst argument to bash -c 'script' is used to populate $0.
Section 17.3: Finding ﬁle by access / modiﬁcation time
On an ext ﬁlesystem, each ﬁle has a stored Access, Modiﬁcation, and (Status) Change time associated with it - to
view this information you can use stat myFile.txt; using ﬂags within ﬁnd, we can search for ﬁles that were
modiﬁed within a certain time range.
To ﬁnd ﬁles that have been modiﬁed within the last 2 hours:
$ find . -mmin -120
GoalKicker.com – Bash Notes for Professionals
67To ﬁnd ﬁles that have not been modiﬁed within the last 2 hours:
$ find . -mmin +120
The above example are searching only on the modiﬁed time - to search on access times, or changed times, use a, or
c accordingly.
$ find . -amin -120
$ find . -cmin +120
General format:
-mmin n : File was modiﬁed n minutes ago
-mmin -n : File was modiﬁed less than n minutes ago
-mmin +n : File was modiﬁed more than n minutes ago
Find ﬁles that have been modiﬁed within the last 2 days:
find . -mtime -2
Find ﬁles that have not been modiﬁed within the last 2 days
find . -mtime +2
Use -atime and -ctime for access time and status change time respectively.
General format:
-mtime n : File was modiﬁed nx24 hours ago
-mtime -n : File was modiﬁed less than nx24 hours ago
-mtime +n : File was modiﬁed more than nx24 hours ago
Find ﬁles modiﬁed in a range of dates, from 2007-06-07 to 2007-06-08:
find . -type f -newermt 2007-06-07 ! -newermt 2007-06-08
Find ﬁles accessed in a range of timestamps (using ﬁles as timestamp), from 1 hour ago to 10 minutes ago:
touch -t $(date -d '1 HOUR AGO' +%Y%m%d%H%M.%S) start_date
touch -t $(date -d '10 MINUTE AGO' +%Y%m%d%H%M.%S) end_date
timeout 10 find "$LOCAL_FOLDER" -newerat "start_date" ! -newerat "end_date" -print
General format:
-newerXY reference : Compares the timestamp of the current ﬁle with reference. XY could have one of the
following values: at (access time), mt (modiﬁcation time), ct (change time) and more. reference is the name of a ﬁle
whe want to compare the timestamp speciﬁed (access, modiﬁcation, change) or a string describing an absolute
time.
Section 17.4: Finding ﬁles according to size
Find ﬁles larger than 15MB:
GoalKicker.com – Bash Notes for Professionals
68find -type f -size +15M
Find ﬁles less than 12KB:
find -type f -size -12k
Find ﬁles exactly of 12KB size:
find -type f -size 12k
Or
find -type f -size 12288c
Or
find -type f -size 24b
Or
find -type f -size 24
General format:
find [options] -size n[cwbkMG]
Find ﬁles of n-block size, where +n means more than n-block, -n means less than n-block and n (without
any sign) means exactly n-block
Block size:
1. c: bytes
2. w: 2 bytes
3. b: 512 bytes (default)
4. k: 1 KB
5. M: 1 MB
6. G: 1 GB
Section 17.5: Filter the path
The -path parameter allows to specify a pattern to match the path of the result. The pattern can match also the
name itself.
To ﬁnd only ﬁles containing log anywhere in their path (folder or name):
find . -type f -path '*log*'
To ﬁnd only ﬁles within a folder called log (on any level):
find . -type f -path '*/log/*'
To ﬁnd only ﬁles within a folder called log or data:
GoalKicker.com – Bash Notes for Professionals
69find . -type f -path '*/log/*' -o -path '*/data/*'
To ﬁnd all ﬁles except the ones contained in a folder called bin:
find . -type f -not -path '*/bin/*'
To ﬁnd all ﬁle all ﬁles except the ones contained in a folder called bin or log ﬁles:
find . -type f -not -path '*log' -not -path '*/bin/*'
Section 17.6: Finding ﬁles by type
To ﬁnd ﬁles, use the -type f ﬂag
$ find . -type f
To ﬁnd directories, use the -type d ﬂag
$ find . -type d
To ﬁnd block devices, use the -type b ﬂag
$ find /dev -type b
To ﬁnd symlinks, use the -type l ﬂag
$ find . -type l
Section 17.7: Finding ﬁles by speciﬁc extension
To ﬁnd all the ﬁles of a certain extension within the current path you can use the following find syntax. It works by
making use of bash's built-in glob construct to match all the names having the .extension.
find /directory/to/search -maxdepth 1 -type f -name "*.extension"
To ﬁnd all ﬁles of type .txt from the current directory alone, do
find . -maxdepth 1 -type f -name "*.txt"
GoalKicker.com – Bash Notes for Professionals
70Chapter 18: Using sort
Option
Meaning
-u
Make each lines of output unique
sort is a Unix command to order data in ﬁle(s) in a sequence.
Section 18.1: Sort command output
sort command is used to sort a list of lines.
Input from a ﬁle
sort file.txt
Input from a command
You can sort any output command. In the example a list of ﬁle following a pattern.
find * -name pattern | sort
Section 18.2: Make output unique
If each lines of the output need to be unique, add -u option.
To display owner of ﬁles in folder
ls -l | awk '{print $3}' | sort -u
Section 18.3: Numeric sort
Suppose we have this ﬁle:
test>>cat file
10.Gryffindor
4.Hogwarts
2.Harry
3.Dumbledore
1.The sorting hat
To sort this ﬁle numerically, use sort with -n option:
test>>sort -n file
This should sort the ﬁle as below:
1.The sorting hat
2.Harry
3.Dumbledore
4.Hogwarts
10.Gryffindor
Reversing sort order: To reverse the order of the sort use the -r option
GoalKicker.com – Bash Notes for Professionals
71To reverse the sort order of the above ﬁle use:
sort -rn file
This should sort the ﬁle as below:
10.Gryffindor
4.Hogwarts
3.Dumbledore
2.Harry
1.The sorting hat
Section 18.4: Sort by keys
Suppose we have this ﬁle:
test>>cat Hogwarts
Harry
Malfoy
Gryffindor
Slytherin
Hermione
Goyle
Ron
Snape
Ron
Goyle
Rowena
Ravenclaw
Lockhart
Olivander
Flitwick
Helga
Hufflepuff
Tonks
Newt
Sprout
To sort this ﬁle using a column as key use the k option:
test>>sort -k 2 Hogwarts
This will sort the ﬁle with column 2 as the key:
Ron
Goyle
Hermione
Goyle
Harry
Malfoy
Gryffindor Slytherin
Ron
Snape
Flitwick
Lockhart
Rowena
Ravenclaw
Olivander
Sprout
Tonks
Helga
Hufflepuff
Newt
Now if we have to sort the ﬁle with a secondary key along with the primary key use:
sort -k 2,2 -k 1,1 Hogwarts
This will ﬁrst sort the ﬁle with column 2 as primary key, and then sort the ﬁle with column 1 as secondary key:
Hermione
Ron
Harry
Gryffindor
Ron
Goyle
Goyle
Malfoy
Slytherin
Snape
Lockhart
Flitwick
Rowena
Ravenclaw
Olivander
Tonks
Sprout
Helga
Hufflepuff
Newt
If we need to sort a ﬁle with more than 1 key , then for every -k option we need to specify where the sort ends. So -
k1,1 means start the sort at the ﬁrst column and end sort at ﬁrst column.
-t option
In the previous example the ﬁle had the default delimeter - tab. In case of sorting a ﬁle that has non-default
delimeter we need the -t option to specify the delimeter. Suppose we have the ﬁle as below:
test>>cat file
GoalKicker.com – Bash Notes for Professionals
725.|Gryffindor
4.|Hogwarts
2.|Harry
3.|Dumbledore
1.|The sorting hat
To sort this ﬁle as per the second column, use:
test>>sort -t "|" -k 2 file
This will sort the ﬁle as below:
3.|Dumbledore
5.|Gryffindor
2.|Harry
4.|Hogwarts
1.|The sorting hat
GoalKicker.com – Bash Notes for Professionals
73Chapter 19: Sourcing
Section 19.1: Sourcing a ﬁle
Sourcing a ﬁle is diﬀerent from execution, in that all commands are evaluated within the context of the current
bash session - this means that any variables, function, or aliases deﬁned will persist throughout your session.
Create the ﬁle you wish to source sourceme.sh
#!/bin/bash
export A="hello_world"
alias sayHi="echo Hi"
sayHello() {
echo Hello
}
From your session, source the ﬁle
$ source sourceme.sh
From hencefourth, you have all the resources of the sourced ﬁle available
$ echo $A
hello_world
$ sayHi
Hi
$ sayHello
Hello
Note that the command . is synonymous to source, such that you can simply use
$ . sourceme.sh
Section 19.2: Sourcing a virtual environment
When developing several applications on one machine, it becomes useful to separate out dependencies into virtual
environments.
With the use of virtualenv, these environments are sourced into your shell so that when you run a command, it
comes from that virtual environment.
This is most commonly installed using pip.
pip install https://github.com/pypa/virtualenv/tarball/15.0.2
Create a new environment
virtualenv --python=python3.5 my_env
Activate the environment
GoalKicker.com – Bash Notes for Professionals
74source my_env/bin/activate
GoalKicker.com – Bash Notes for Professionals
75Chapter 20: Here documents and here
strings
Section 20.1: Execute command with here document
ssh -p 21 example@example.com <<EOF
echo 'printing pwd'
echo "\$(pwd)"
ls -a
find '*.txt'
EOF
$ is escaped because we do not want it to be expanded by the current shell i.e $(pwd) is to be executed on the
remote shell.
Another way:
ssh -p 21 example@example.com <<'EOF'
echo 'printing pwd'
echo "$(pwd)"
ls -a
find '*.txt'
EOF
Note: The closing EOF should be at the beginning of the line (No whitespaces before). If indentation is required,
tabs may be used if you start your heredoc with <<-. See the Indenting here documents and Limit Strings examples
for more information.
Section 20.2: Indenting here documents
You can indent the text inside here documents with tabs, you need to use the <<- redirection operator instead of
<<:
$ cat <<- EOF
This is some content indented with tabs `\t`.
You cannot indent with spaces you __have__ to use tabs.
Bash will remove empty space before these lines.
__Note__: Be sure to replace spaces with tabs when copying this example.
EOF
This is some content indented with tabs _\t_.
You cannot indent with spaces you __have__ to use tabs.
Bash will remove empty space before these lines.
__Note__: Be sure to replace spaces with tabs when copying this example.
One practical use case of this (as mentioned in man bash) is in shell scripts, for example:
if cond; then
cat <<- EOF
hello
there
EOF
fi
It is customary to indent the lines within code blocks as in this if statement, for better readability. Without the <<-
GoalKicker.com – Bash Notes for Professionals
76operator syntax, we would be forced to write the above code like this:
if cond; then
cat << EOF
hello
there
EOF
fi
That's very unpleasant to read, and it gets much worse in a more complex realistic script.
Section 20.3: Create a ﬁle
A classic use of here documents is to create a ﬁle by typing its content:
cat > fruits.txt << EOF
apple
orange
lemon
EOF
The here-document is the lines between the << EOF and EOF.
This here document becomes the input of the cat command. The cat command simply outputs its input, and using
the output redirection operator > we redirect to a ﬁle fruits.txt.
As a result, the fruits.txt ﬁle will contain the lines:
apple
orange
lemon
The usual rules of output redirection apply: if fruits.txt did not exist before, it will be created. If it existed before,
it will be truncated.
Section 20.4: Here strings
Version ≥ 2.05b
You can feed a command using here strings like this:
$ awk '{print $2}' <<< "hello world - how are you?"
world
$ awk '{print $1}' <<< "hello how are you
> she is fine"
hello
she
You can also feed a while loop with a here string:
$ while IFS=" " read -r word1 word2 rest
> do
> echo "$word1"
> done <<< "hello how are you - i am fine"
hello
GoalKicker.com – Bash Notes for Professionals
77Section 20.5: Run several commands with sudo
sudo -s <<EOF
a='var'
echo 'Running serveral commands with sudo'
mktemp -d
echo "\$a"
EOF
$a needs to be escaped to prevent it to be expanded by the current shell
Or
sudo -s <<'EOF'
a='var'
echo 'Running serveral commands with sudo'
mktemp -d
echo "$a"
EOF
Section 20.6: Limit Strings
A heredoc uses the limitstring to determine when to stop consuming input. The terminating limitstring must
Be at the start of a line.
Be the only text on the line Note: If you use <<- the limitstring can be preﬁxed with tabs \t
Correct:
cat <<limitstring
line 1
line 2
limitstring
This will output:
line 1
line 2
Incorrect use:
cat <<limitstring
line 1
line 2
limitstring
Since limitstring on the last line is not exactly at the start of the line, the shell will continue to wait for further
input, until it sees a line that starts with limitstring and doesn't contain anything else. Only then it will stop
waiting for input, and proceed to pass the here-document to the cat command.
Note that when you preﬁx the initial limitstring with a hyphen, any tabs at the start of the line are removed before
parsing, so the data and the limit string can be indented with tabs (for ease of reading in shell scripts).
cat <<-limitstring
line 1
has a tab each before the words line and has
line 2 has two leading tabs
GoalKicker.com – Bash Notes for Professionals
78limitstring
will produce
line 1
has a tab each before the words line and has
line 2 has two leading tabs
with the leading tabs (but not the internal tabs) removed.
GoalKicker.com – Bash Notes for Professionals
79Chapter 21: Quoting
Section 21.1: Double quotes for variable and command
substitution
Variable substitutions should only be used inside double quotes.
calculation='2 * 3'
echo "$calculation"
echo $calculation
echo "$(($calculation))"
# prints 2 * 3
# prints 2, the list of files in the current directory, and 3
# prints 6
Outside of double quotes, $var takes the value of var, splits it into whitespace-delimited parts, and interprets each
part as a glob (wildcard) pattern. Unless you want this behavior, always put $var inside double quotes: "$var".
The same applies to command substitutions: "$(mycommand)" is the output of mycommand, $(mycommand) is the
result of split+glob on the output.
echo "$var"
echo "$(mycommand)"
another=$var
make -D THING=$var
make -D THING="$var"
make -D "THING=$var"
# good
# good
# also works, assignment is implicitly double-quoted
# BAD! This is not a bash assignment.
# good
# also good
Command substitutions get their own quoting contexts. Writing arbitrarily nested substitutions is easy because the
parser will keep track of nesting depth instead of greedily searching for the ﬁrst " character. The StackOverﬂow
syntax highlighter parses this wrong, however. For example:
echo "formatted text: $(printf "a + b = %04d" "${c}")" # “formatted text: a + b = 0000”
Variable arguments to a command substitution should be double-quoted inside the expansions as well:
echo "$(mycommand "$arg1" "$arg2")"
Section 21.2: Dierence between double quote and single
quote
Double quote
Allows variable expansionSingle quote
Prevents variable expansion
Allows history expansion if enabledPrevents history expansion
Allows command substitutionPrevents command substitution
* and @ can have special meaning* and @ are always literals
Can contain both single quote or double quoteSingle quote is not allowed inside single quote
$, `, ", \ can be escaped with \ to prevent their special meaning All of them are literals
Properties that are common to both:
Prevents globbing
Prevents word splitting
Examples:
GoalKicker.com – Bash Notes for Professionals
80$ echo "!cat"
echo "cat file"
cat file
$ echo '!cat'
!cat
echo "\"'\""
"'"
$ a='var'
$ echo '$a'
$a
$ echo "$a"
var
Section 21.3: Newlines and control characters
A newline can be included in a single-quoted string or double-quoted string. Note that backslash-newline does not
result in a newline, the line break is ignored.
newline1='
'
newline2="
"
newline3=$'\n'
empty=\
echo "Line${newline1}break"
echo "Line${newline2}break"
echo "Line${newline3}break"
echo "No line break${empty} here"
Inside dollar-quote strings, backslash-letter or backslash-octal can be used to insert control characters, like in many
other programming languages.
echo $'Tab: [\t]'
echo $'Tab again: [\009]'
echo $'Form feed: [\f]'
echo $'Line\nbreak'
Section 21.4: Quoting literal text
All the examples in this paragraph print the line
!"#$&'()*;<=>?
@[\]^`{|}~
A backslash quotes the next character, i.e. the next character is interpreted literally. The one exception is a newline:
backslash-newline expands to the empty string.
echo \!\"\#\$\&\'\(\)\*\;\<\=\>\?\ \ \@\[\\\]\^\`\{\|\}\~
All text between single quotes (forward quotes ', also known as apostrophe) is printed literally. Even backslash
stands for itself, and it's impossible to include a single quote; instead, you can stop the literal string, include a literal
single quote with a backslash, and start the literal string again. Thus the 4-character sequence '\'' eﬀectively allow
to include a single quote in a literal string.
echo '!"#$&'\''()*;<=>?
@[\]^`{|}~'
GoalKicker.com – Bash Notes for Professionals
81#
^^^^
Dollar-single-quote starts a string literal $'…' like many other programming languages, where backslash quotes
the next character.
echo $'!"#$&\'()*;<=>?
#
^^
@[\\]^`{|}~'
^^
Double quotes " delimit semi-literal strings where only the characters " \ $ and ` retain their special meaning.
These characters need a backslash before them (note that if backslash is followed by some other character, the
backslash remains). Double quotes are mostly useful when including a variable or a command substitution.
echo "!\"#\$&'()*;<=>?
#
^^
echo "!\"#\$&'()*;<=>?
#
^^
@[\\]^\`{|}~"
^^ ^^
@[\]^\`{|}~"
^ ^^
\[ prints \[
Interactively, beware that ! triggers history expansion inside double quotes: "!oops" looks for an older command
containing oops; "\!oops" doesn't do history expansion but keeps the backslash. This does not happen in scripts.
GoalKicker.com – Bash Notes for Professionals
82Chapter 22: Conditional Expressions
Section 22.1: File type tests
The -e conditional operator tests whether a ﬁle exists (including all ﬁle types: directories, etc.).
if [[ -e $filename ]]; then
echo "$filename exists"
fi
There are tests for speciﬁc ﬁle types as well.
if [[ -f $filename ]]; then
echo "$filename is a regular file"
elif [[ -d $filename ]]; then
echo "$filename is a directory"
elif [[ -p $filename ]]; then
echo "$filename is a named pipe"
elif [[ -S $filename ]]; then
echo "$filename is a named socket"
elif [[ -b $filename ]]; then
echo "$filename is a block device"
elif [[ -c $filename ]]; then
echo "$filename is a character device"
fi
if [[ -L $filename ]]; then
echo "$filename is a symbolic link (to any file type)"
fi
For a symbolic link, apart from -L, these tests apply to the target, and return false for a broken link.
if [[ -L $filename || -e $filename ]]; then
echo "$filename exists (but may be a broken symbolic link)"
fi
if [[ -L $filename && ! -e $filename ]]; then
echo "$filename is a broken symbolic link"
fi
Section 22.2: String comparison and matching
String comparison uses the == operator between quoted strings. The != operator negates the comparison.
if [[ "$string1" == "$string2" ]]; then
echo "\$string1 and \$string2 are identical"
fi
if [[ "$string1" != "$string2" ]]; then
echo "\$string1 and \$string2 are not identical"
fi
If the right-hand side is not quoted then it is a wildcard pattern that $string1 is matched against.
string='abc'
pattern1='a*'
pattern2='x*'
if [[ "$string" == $pattern1 ]]; then
# the test is true
GoalKicker.com – Bash Notes for Professionals
83echo "The string $string matches the pattern $pattern"
fi
if [[ "$string" != $pattern2 ]]; then
# the test is false
echo "The string $string does not match the pattern $pattern"
fi
The < and > operators compare the strings in lexicographic order (there are no less-or-equal or greater-or-equal
operators for strings).
There are unary tests for the empty string.
if [[ -n "$string" ]]; then
echo "$string is non-empty"
fi
if [[ -z "${string// }" ]]; then
echo "$string is empty or contains only spaces"
fi
if [[ -z "$string" ]]; then
echo "$string is empty"
fi
Above, the -z check may mean $string is unset, or it is set to an empty string. To distinguish between empty and
unset, use:
if [[ -n "${string+x}" ]]; then
echo "$string is set, possibly to the empty string"
fi
if [[ -n "${string-x}" ]]; then
echo "$string is either unset or set to a non-empty string"
fi
if [[ -z "${string+x}" ]]; then
echo "$string is unset"
fi
if [[ -z "${string-x}" ]]; then
echo "$string is set to an empty string"
fi
where x is arbitrary. Or in table form:
+-------+-------+-----------+
$string is: | unset | empty | non-empty |
+-----------------------+-------+-------+-----------+
| [[ -z ${string} ]]
| true | true | false
|
| [[ -z ${string+x} ]] | true | false | false
|
| [[ -z ${string-x} ]] | false | true | false
|
| [[ -n ${string} ]]
| false | false | true
|
| [[ -n ${string+x} ]] | false | true | true
|
| [[ -n ${string-x} ]] | true | false | true
|
+-----------------------+-------+-------+-----------+
Alternatively, the state can be checked in a case statement:
case ${var+x$var} in
(x) echo empty;;
("") echo unset;;
(x*[![:blank:]]*) echo non-blank;;
(*) echo blank
GoalKicker.com – Bash Notes for Professionals
84esac
Where [:blank:] is locale speciﬁc horizontal spacing characters (tab, space, etc).
Section 22.3: Test on exit status of a command
Exit status 0: success
Exit status other than 0: failure
To test on the exit status of a command:
if command;then
echo 'success'
else
echo 'failure'
fi
Section 22.4: One liner test
You can do things like this:
[[ $s = 'something' ]] && echo 'matched' || echo "didn't match"
[[ $s == 'something' ]] && echo 'matched' || echo "didn't match"
[[ $s != 'something' ]] && echo "didn't match" || echo "matched"
[[ $s -eq 10 ]] && echo 'equal' || echo "not equal"
(( $s == 10 )) && echo 'equal' || echo 'not equal'
One liner test for exit status:
command && echo 'exited with 0' || echo 'non 0 exit'
cmd && cmd1 && echo 'previous cmds were successful' || echo 'one of them failed'
cmd || cmd1 #If cmd fails try cmd1
Section 22.5: File comparison
if [[ $file1 -ef $file2 ]]; then
echo "$file1 and $file2 are the same file"
fi
“Same ﬁle” means that modifying one of the ﬁles in place aﬀects the other. Two ﬁles can be the same even if they
have diﬀerent names, for example if they are hard links, or if they are symbolic links with the same target, or if one
is a symbolic link pointing to the other.
If two ﬁles have the same content, but they are distinct ﬁles (so that modifying one does not aﬀect the other), then
-ef reports them as diﬀerent. If you want to compare two ﬁles byte by byte, use the cmp utility.
if cmp -s -- "$file1" "$file2"; then
echo "$file1 and $file2 have identical contents"
else
echo "$file1 and $file2 differ"
fi
To produce a human-readable list of diﬀerences between text ﬁles, use the diff utility.
if diff -u "$file1" "$file2"; then
GoalKicker.com – Bash Notes for Professionals
85echo "$file1 and $file2 have identical contents"
else
: # the differences between the files have been listed
fi
Section 22.6: File access tests
if [[ -r $filename ]]; then
echo "$filename is a readable file"
fi
if [[ -w $filename ]]; then
echo "$filename is a writable file"
fi
if [[ -x $filename ]]; then
echo "$filename is an executable file"
fi
These tests take permissions and ownership into account to determine whether the script (or programs launched
from the script) can access the ﬁle.
Beware of race conditions (TOCTOU): just because the test succeeds now doesn't mean that it's still valid on the
next line. It's usually better to try to access a ﬁle, and handle the error, rather than test ﬁrst and then have to
handle the error anyway in case the ﬁle has changed in the meantime.
Section 22.7: Numerical comparisons
Numerical comparisons use the -eq operators and friends
if [[ $num1 -eq $num2 ]]; then
echo "$num1 == $num2"
fi
if [[ $num1 -le $num2 ]]; then
echo "$num1 <= $num2"
fi
There are six numeric operators:
-eq equal
-ne not equal
-le less or equal
-lt less than
-ge greater or equal
-gt greater than
Note that the < and > operators inside [[ … ]] compare strings, not numbers.
if [[ 9 -lt 10 ]]; then
echo "9 is before 10 in numeric order"
fi
if [[ 9 > 10 ]]; then
echo "9 is after 10 in lexicographic order"
fi
The two sides must be numbers written in decimal (or in octal with a leading zero). Alternatively, use the ((…))
arithmetic expression syntax, which performs integer calculations in a C/Java/…-like syntax.
GoalKicker.com – Bash Notes for Professionals
86x=2
if ((2*x == 4)); then
echo "2 times 2 is 4"
fi
((x += 1))
echo "2 plus 1 is $x"
GoalKicker.com – Bash Notes for Professionals
87Chapter 23: Scripting with Parameters
Section 23.1: Multiple Parameter Parsing
To parse lots of parameters, the preferred way of doing this is using a while loop, a case statement, and shift.
shift is used to pop the ﬁrst parameter in the series, making what used to be $2, now be $1. This is useful for
processing arguments one at a time.
#!/bin/bash
# Load the user defined parameters
while [[ $# > 0 ]]
do
case "$1" in
-a|--valueA)
valA="$2"
shift
;;
-b|--valueB)
valB="$2"
shift
;;
--help|*)
echo "Usage:"
echo "
--valueA \"value\""
echo "
--valueB \"value\""
echo "
--help"
exit 1
;;
esac
shift
done
echo "A: $valA"
echo "B: $valB"
Inputs and Outputs
$ ./multipleParams.sh --help
Usage:
--valueA "value"
--valueB "value"
--help
$ ./multipleParams.sh
A:
B:
$ ./multipleParams.sh --valueB 2
A:
B: 2
$ ./multipleParams.sh --valueB 2 --valueA "hello world"
A: hello world
GoalKicker.com – Bash Notes for Professionals
88B: 2
Section 23.2: Argument parsing using a for loop
A simple example which provides the options:
Opt
Alt. Opt
Details
-h--helpShow help
-v--versionShow version info
-dr path --doc-root path An option which takes a secondary parameter (a path)
-i--installA boolean option (true/false)
-*--Invalid option
#!/bin/bash
dr=''
install=false
skip=false
for op in "$@";do
if $skip;then skip=false;continue;fi
case "$op" in
-v|--version)
echo "$ver_info"
shift
exit 0
;;
-h|--help)
echo "$help"
shift
exit 0
;;
-dr|--doc-root)
shift
if [[ "$1" != "" ]]; then
dr="${1/%\//}"
shift
skip=true
else
echo "E: Arg missing for -dr option"
exit 1
fi
;;
-i|--install)
install=true
shift
;;
-*)
echo "E: Invalid option: $1"
shift
exit 1
;;
esac
done
Section 23.3: Wrapper script
Wrapper script is a script that wraps another script or command to provide extra functionalities or just to make
something less tedious.
GoalKicker.com – Bash Notes for Professionals
89For example, the actual egrep in new GNU/Linux system is being replaced by a wrapper script named egrep. This is
how it looks:
#!/bin/sh
exec grep -E "$@"
So, when you run egrep in such systems, you are actually running grep -E with all the arguments forwarded.
In general case, if you want to run an example script/command exmp with another script mexmp then the wrapper
mexmp script will look like:
#!/bin/sh
exmp "$@" # Add other options before "$@"
# or
#full/path/to/exmp "$@"
Section 23.4: Accessing Parameters
When executing a Bash script, parameters passed into the script are named in accordance to their position: $1 is
the name of the ﬁrst parameter, $2 is the name of the second parameter, and so on.
A missing parameter simply evaluates to an empty string. Checking for the existence of a parameter can be done as
follows:
if [ -z "$1" ]; then
echo "No argument supplied"
fi
Getting all the parameters
$@ and $* are ways of interacting with all the script parameters. Referencing the Bash man page, we see that:
$*: Expands to the positional parameters, starting from one. When the expansion occurs within double
quotes, it expands to a single word with the value of each parameter separated by the ﬁrst character of the
IFS special variable.
$@: Expands to the positional parameters, starting from one. When the expansion occurs within double
quotes, each parameter expands to a separate word.
Getting the number of parameters
$# gets the number of parameters passed into a script. A typical use case would be to check if the appropriate
number of arguments are passed:
if [ $# -eq 0 ]; then
echo "No arguments supplied"
fi
Example 1
Loop through all arguments and check if they are ﬁles:
for item in "$@"
do
if [[ -f $item ]]; then
echo "$item is a file"
GoalKicker.com – Bash Notes for Professionals
90fi
done
Example 2
Loop through all arguments and check if they are ﬁles:
for (( i = 1; i <= $#; ++ i ))
do
item=${@:$i:1}
if [[ -f $item ]]; then
echo "$item is a file"
fi
done
Section 23.5: Split string into an array in Bash
Let's say we have a String parameter and we want to split it by comma
my_param="foo,bar,bash"
To split this string by comma we can use;
IFS=',' read -r -a array <<< "$my_param"
Here, IFS is a special variable called Internal ﬁeld separator which deﬁnes the character or characters used to
separate a pattern into tokens for some operations.
To access an individual element:
echo "${array[0]}"
To iterate over the elements:
for element in "${array[@]}"
do
echo "$element"
done
To get both the index and the value:
for index in "${!array[@]}"
do
echo "$index ${array[index]}"
done
GoalKicker.com – Bash Notes for Professionals
91Chapter 24: Bash history substitutions
Section 24.1: Quick Reference
Interaction with the history
# List all previous commands
history
# Clear the history, useful if you entered a password by accident
history -c
Event designators
# Expands to line n of bash history
!n
# Expands to last command
!!
# Expands to last command starting with "text"
!text
# Expands to last command containing "text"
!?text
# Expands to command n lines ago
!-n
# Expands to last command with first occurrence of "foo" replaced by "bar"
^foo^bar^
# Expands to the current command
!#
Word designators
These are separated by : from the event designator they refer to. The colon can be omitted if the word designator
doesn't start with a number: !^ is the same as !:^.
# Expands to the first argument of the most recent command
!^
# Expands to the last argument of the most recent command (short for !!:$)
!$
# Expands to the third argument of the most recent command
!:3
# Expands to arguments x through y (inclusive) of the last command
# x and y can be numbers or the anchor characters ^ $
!:x-y
# Expands to all words of the last command except the 0th
# Equivalent to :^-$
!*
Modiﬁers
These modify the preceding event or word designator.
# Replacement in the expansion using sed syntax
GoalKicker.com – Bash Notes for Professionals
92# Allows flags before the s and alternate separators
:s/foo/bar/ #substitutes bar for first occurrence of foo
:gs|foo|bar| #substitutes bar for all foo
# Remove leading path from last argument ("tail")
:t
# Remove trailing path from last argument ("head")
:h
# Remove file extension from last argument
:r
If the Bash variable HISTCONTROL contains either ignorespace or ignoreboth (or, alternatively, HISTIGNORE contains
the pattern [ ]*), you can prevent your commands from being stored in Bash history by prepending them with a
space:
# This command won't be saved in the history
foo
# This command will be saved
bar
Section 24.2: Repeat previous command with sudo
$ apt-get install r-base
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
$ sudo !!
sudo apt-get install r-base
[sudo] password for <user>:
Section 24.3: Search in the command history by pattern
Press control
r and type a pattern.
For example, if you recently executed man 5 crontab, you can ﬁnd it quickly by starting to type "crontab". The
prompt will change like this:
(reverse-i-search)`cr': man 5 crontab
The `cr' there is the string I typed so far. This is an incremental search, so as you continue typing, the search result
gets updated to match the most recent command that contained the pattern.
Press the left or right arrow keys to edit the matched command before running it, or the enter key to run the
command.
By default the search ﬁnds the most recently executed command matching the pattern. To go further back in the
history press control
r again. You may press it repeatedly until you ﬁnd the desired command.
Section 24.4: Switch to newly created directory with !#:N
$ mkdir backup_download_directory && cd !#:1
mkdir backup_download_directory && cd backup_download_directory
This will substitute the Nth argument of the current command. In the example !#:1 is replaced with the ﬁrst
GoalKicker.com – Bash Notes for Professionals
93argument, i.e. backup_download_directory.
Section 24.5: Using !$
You can use the !$ to reduce repetition when using the command line:
$ echo ping
ping
$ echo !$
ping
You can also build upon the repetition
$ echo !$ pong
ping pong
$ echo !$, a great game
pong, a great game
Notice that in the last example we did not get ping pong, a great game because the last argument passed to the
previous command was pong, we can avoid issue like this by adding quotes. Continuing with the example, our last
argument was game:
$ echo "it is !$ time"
it is game time
$ echo "hooray, !$!"
hooray, it is game time!
Section 24.6: Repeat the previous command with a
substitution
$ mplayer Lecture_video_part1.mkv
$ ^1^2^
mplayer Lecture_video_part2.mkv
This command will replace 1 with 2 in the previously executed command. It will only replace the ﬁrst occurrence of
the string and is equivalent to !!:s/1/2/.
If you want to replace all occurrences, you have to use !!:gs/1/2/ or !!:as/1/2/.
GoalKicker.com – Bash Notes for Professionals
94Chapter 25: Math
Section 25.1: Math using dc
dc is one of the oldest programs on Unix.
It uses reverse polish notation, which means that you ﬁrst stack numbers, then operations. For example 1+1 is
written as 1 1+.
To print an element from the top of the stack use command p
echo '2 3 + p' | dc
5
or
dc <<< '2 3 + p'
5
You can print the top element many times
dc <<< '1 1 + p 2 + p'
2
4
For negative numbers use _ preﬁx
dc <<< '_1 p'
-1
You can also use capital letters from A to F for numbers between 10 and 15 and . as a decimal point
dc <<< 'A.4 p'
10.4
dc is using abitrary precision which means that the precision is limited only by the available memory. By default the
precision is set to 0 decimals
dc <<< '4 3 / p'
1
We can increase the precision using command k. 2k will use
dc <<< '2k 4 3 / p'
1.33
dc <<< '4k 4 3 / p'
1.3333
You can also use it over multiple lines
dc << EOF
1 1 +
3 *
p
GoalKicker.com – Bash Notes for Professionals
95EOF
6
bc is a preprocessor for dc.
Section 25.2: Math using bash capabilities
Arithmetic computation can be also done without involving any other programs like this:
Multiplication:
echo $((5 * 2))
10
Division:
echo $((5 / 2))
2
Modulo:
echo $((5 % 2))
1
Exponentiation:
echo $((5 ** 2))
25
Section 25.3: Math using bc
bc is an arbitrary precision calculator language. It could be used interactively or be executed from command line.
For example, it can print out the result of an expression:
echo '2 + 3' | bc
5
echo '12 / 5' | bc
2
For ﬂoating-post arithmetic, you can import standard library bc -l:
echo '12 / 5' | bc -l
2.40000000000000000000
It can be used for comparing expressions:
echo '8 > 5' | bc
1
echo '10 == 11' | bc
0
GoalKicker.com – Bash Notes for Professionals
96echo '10 == 10 && 8 > 3' | bc
1
Section 25.4: Math using expr
expr or Evaluate expressions evaluates an expression and writes the result on standard output
Basic arithmetics
expr 2 + 3
5
When multiplying, you need to escape the * sign
expr 2 \* 3
6
You can also use variables
a=2
expr $a + 3
5
Keep in mind that it only supports integers, so expression like this
expr 3.0 / 2
will throw an error expr: not a decimal number: '3.0'.
It supports regular expression to match patterns
expr 'Hello World' : 'Hell\(.*\)rld'
o Wo
Or ﬁnd the index of the ﬁrst char in the search string
This will throw expr: syntax error on Mac OS X, because it uses BSD expr which does not have the
index command, while expr on Linux is generally GNU expr
expr index hello l
3
expr index 'hello' 'lo'
3
GoalKicker.com – Bash Notes for Professionals
97Chapter 26: Bash Arithmetic
Parameter
Details
EXPRESSION Expression to evaluate
Section 26.1: Simple arithmetic with (( ))
#!/bin/bash
echo $(( 1 + 2 ))
Output: 3
# Using variables
#!/bin/bash
var1=4
var2=5
((output=$var1 * $var2))
printf "%d\n" "$output"
Output: 20
Section 26.2: Arithmetic command
let
let num=1+2
let num="1+2"
let 'num= 1 + 2'
let num=1 num+=2
You need quotes if there are spaces or globbing characters. So those will get error:
let num = 1 + 2
#wrong
let 'num = 1 + 2' #right
let a[1] = 1 + 1
#wrong
let 'a[1] = 1 + 1' #right
(( ))
((a=$a+1))
((a = a + 1))
((a += 1))
#add 1 to a
#like above
#like above
We can use (()) in if. Some Example:
if (( a > 1 )); then echo "a is greater than 1"; fi
The output of (()) can be assigned to a variable:
result=$((a + 1))
Or used directly in output:
echo "The result of a + 1 is $((a + 1))"
GoalKicker.com – Bash Notes for Professionals
98Section 26.3: Simple arithmetic with expr
#!/bin/bash
expr 1 + 2
Output: 3
GoalKicker.com – Bash Notes for Professionals
99Chapter 27: Scoping
Section 27.1: Dynamic scoping in action
Dynamic scoping means that variable lookups occur in the scope where a function is called, not where it is deﬁned.
$ x=3
$ func1 () { echo "in func1: $x"; }
$ func2 () { local x=9; func1; }
$ func2
in func1: 9
$ func1
in func1: 3
In a lexically scoped language, func1 would always look in the global scope for the value of x, because func1 is
deﬁned in the local scope.
In a dynamically scoped language, func1 looks in the scope where it is called. When it is called from within func2, it
ﬁrst looks in the body of func2 for a value of x. If it weren't deﬁned there, it would look in the global scope, where
func2 was called from.
GoalKicker.com – Bash Notes for Professionals
100Chapter 28: Process substitution
Section 28.1: Compare two ﬁles from the web
The following compares two ﬁles with diff using process substitution instead of creating temporary ﬁles.
diff <(curl http://www.example.com/page1) <(curl http://www.example.com/page2)
Section 28.2: Feed a while loop with the output of a command
This feeds a while loop with the output of a grep command:
while IFS=":" read -r user _
do
# "$user" holds the username in /etc/passwd
done < <(grep "hello" /etc/passwd)
Section 28.3: Concatenating ﬁles
It is well known that you cannot use the same ﬁle for input and output in the same command. For instance,
$ cat header.txt body.txt >body.txt
doesn’t do what you want. By the time cat reads body.txt, it has already been truncated by the redirection and it is
empty. The ﬁnal result will be that body.txt will hold the contents of header.txt only.
One might think to avoid this with process substitution, that is, that the command
$ cat header.txt <(cat body.txt) > body.txt
will force the original contents of body.txt to be somehow saved in some buﬀer somewhere before the ﬁle is
truncated by the redirection. It doesn’t work. The cat in parentheses begins reading the ﬁle only after all ﬁle
descriptors have been set up, just like the outer one. There is no point in trying to use process substitution in this
case.
The only way to prepend a ﬁle to another ﬁle is to create an intermediate one:
$ cat header.txt body.txt >body.txt.new
$ mv body.txt.new body.txt
which is what sed or perl or similar programs do under the carpet when called with an edit-in-place option (usually
-i).
Section 28.4: Stream a ﬁle through multiple programs at
once
This counts the number of lines in a big ﬁle with wc -l while simultaneously compressing it with gzip. Both run
concurrently.
tee >(wc -l >&2) < bigfile | gzip > bigfile.gz
Normally tee writes its input to one or more ﬁles (and stdout). We can write to commands instead of ﬁles with tee
GoalKicker.com – Bash Notes for Professionals
101>(command).
Here the command wc -l >&2 counts the lines read from tee (which in turn is reading from bigfile). (The line
count is sent to stderr (>&2) to avoid mixing with the input to gzip.) The stdout of tee is simultaneously fed into
gzip.
Section 28.5: With paste command
# Process substitution with paste command is common
# To compare the contents of two directories
paste <( ls /path/to/directory1 ) <( ls /path/to/directory2 )
Section 28.6: To avoid usage of a sub-shell
One major aspect of process substitution is that it lets us avoid usage of a sub-shell when piping commands from
the shell.
This can be demonstrated with a simple example below. I have the following ﬁles in my current folder:
$ find . -maxdepth 1 -type f -print
foo bar zoo foobar foozoo barzoo
If I pipe to a while/read loop that increments a counter as follows:
count=0
find . -maxdepth 1 -type f -print | while IFS= read -r _; do
((count++))
done
$count now does not contain 6, because it was modiﬁed in the sub-shell context. Any of the commands shown
below are run in a sub-shell context and the scope of the variables used within are lost after the sub-shell
terminates.
command &
command | command
( command )
Process substitution will solve the problem by avoiding use the of pipe | operator as in
count=0
while IFS= read -r _; do
((count++))
done < <(find . -maxdepth 1 -type f -print)
This will retain the count variable value as no sub-shells are invoked.
GoalKicker.com – Bash Notes for Professionals
102Chapter 29: Programmable completion
Section 29.1: Simple completion using function
_mycompletion() {
local command_name="$1" # not used in this example
local current_word="$2"
local previous_word="$3" # not used in this example
# COMPREPLY is an array which has to be filled with the possible completions
# compgen is used to filter matching completions
COMPREPLY=( $(compgen -W 'hello world' -- "$current_word") )
}
complete -F _mycompletion mycommand
Usage Example:
$ mycommand [TAB][TAB]
hello world
$ mycommand h[TAB][TAB]
$ mycommand hello
Section 29.2: Simple completion for options and ﬁlenames
# The following shell function will be used to generate completions for
# the "nuance_tune" command.
_nuance_tune_opts ()
{
local curr_arg prev_arg
curr_arg=${COMP_WORDS[COMP_CWORD]}
prev_arg=${COMP_WORDS[COMP_CWORD-1]}
# The "config" option takes a file arg, so get a list of the files in the
# current dir. A case statement is probably unnecessary here, but leaves
# room to customize the parameters for other flags.
case "$prev_arg" in
-config)
COMPREPLY=( $( /bin/ls -1 ) )
return 0
;;
esac
# Use compgen to provide completions for all known options.
COMPREPLY=( $(compgen -W '-analyze -experiment -generate_groups -compute_thresh -config -output
-help -usage -force -lang -grammar_overrides -begin_date -end_date -group -dataset -multiparses -
dump_records -no_index -confidencelevel -nrecs -dry_run -rec_scripts_only -save_temp -full_trc -
single_session -verbose -ep -unsupervised -write_manifest -remap -noreparse -upload -reference -
target -use_only_matching -histogram -stepsize' -- $curr_arg ) );
}
# The -o parameter tells Bash to process completions as filenames, where applicable.
complete -o filenames -F _nuance_tune_opts nuance_tune
GoalKicker.com – Bash Notes for Professionals
103Chapter 30: Customizing PS1
Section 30.1: Colorize and customize terminal prompt
This is how the author sets their personal PS1 variable:
gitPS1(){
gitps1=$(git branch 2>/dev/null | grep '*')
gitps1="${gitps1:+ (${gitps1/#\* /})}"
echo "$gitps1"
}
#Please use the below function if you are a mac user
gitPS1ForMac(){
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
timeNow(){
echo "$(date +%r)"
}
if [ "$color_prompt" = yes ]; then
if [ x$EUID = x0 ]; then
PS1='\[\033[1;38m\][$(timeNow)]\[\033[00m\]
\[\033[1;31m\]\u\[\033[00m\]\[\033[1;37m\]@\[\033[00m\]\[\033[1;33m\]\h\[\033[00m\]
\[\033[1;34m\]\w\[\033[00m\]\[\033[1;36m\]$(gitPS1)\[\033[00m\] \[\033[1;31m\]:/#\[\033[00m\] '
else
PS1='\[\033[1;38m\][$(timeNow)]\[\033[00m\]
\[\033[1;32m\]\u\[\033[00m\]\[\033[1;37m\]@\[\033[00m\]\[\033[1;33m\]\h\[\033[00m\]
\[\033[1;34m\]\w\[\033[00m\]\[\033[1;36m\]$(gitPS1)\[\033[00m\] \[\033[1;32m\]:/$\[\033[00m\] '
fi
else
PS1='[$(timeNow)] \u@\h \w$(gitPS1) :/$ '
fi
And this is how my prompt looks like:
Color reference:
# Colors
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
GoalKicker.com – Bash Notes for Professionals
104bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m'
# Black - Background
bakred='\e[41m'
# Red
badgrn='\e[42m'
# Green
bakylw='\e[43m'
# Yellow
bakblu='\e[44m'
# Blue
bakpur='\e[45m'
# Purple
bakcyn='\e[46m'
# Cyan
bakwht='\e[47m'
# White
txtrst='\e[0m'
# Text Reset
Notes:
Make the changes in ~/.bashrc or /etc/bashrc or ~/.bash_profile or ~./profile ﬁle (depending on the
OS) and save it.
For root you might also need to edit the /etc/bash.bashrc or /root/.bashrc ﬁle
Run source ~/.bashrc (distro speciﬁc) after saving the ﬁle.
Note: if you have saved the changes in ~/.bashrc, then remember to add source ~/.bashrc in your
~/.bash_profile so that this change in PS1 will be recorded every time the Terminal application starts.
Section 30.2: Show git branch name in terminal prompt
You can have functions in the PS1 variable, just make sure to single quote it or use escape for special chars:
gitPS1(){
gitps1=$(git branch 2>/dev/null | grep '*')
gitps1="${gitps1:+ (${gitps1/#\* /})}"
echo "$gitps1"
}
PS1='\u@\h:\w$(gitPS1)$ '
It will give you a prompt like this:
user@Host:/path (master)$
Notes:
Make the changes in ~/.bashrc or /etc/bashrc or ~/.bash_profile or ~./profile ﬁle (depending on the
OS) and save it.
Run source ~/.bashrc (distro speciﬁc) after saving the ﬁle.
Section 30.3: Show time in terminal prompt
timeNow(){
echo "$(date +%r)"
}
GoalKicker.com – Bash Notes for Professionals
105PS1='[$(timeNow)] \u@\h:\w$ '
It will give you a prompt like this:
[05:34:37 PM] user@Host:/path$
Notes:
Make the changes in ~/.bashrc or /etc/bashrc or ~/.bash_profile or ~./profile ﬁle (depending on the
OS) and save it.
Run source ~/.bashrc (distro speciﬁc) after saving the ﬁle.
Section 30.4: Show a git branch using PROMPT_COMMAND
If you are inside a folder of a git repository it might be nice to show the current branch you are on. In ~/.bashrc or
/etc/bashrc add the following (git is required for this to work):
function prompt_command {
# Check if we are inside a git repository
if git status > /dev/null 2>&1; then
# Only get the name of the branch
export GIT_STATUS=$(git status | grep 'On branch' | cut -b 10-)
else
export GIT_STATUS=""
fi
}
# This function gets called every time PS1 is shown
PROMPT_COMMAND=prompt_command
PS1="\$GIT_STATUS \u@\h:\w\$ "
If we are in a folder inside a git repository this will output:
branch user@machine:~$
And if we are inside a normal folder:
user@machine:~$
Section 30.5: Change PS1 prompt
To change PS1, you just have to change the value of PS1 shell variable. The value can be set in ~/.bashrc or
/etc/bashrc ﬁle, depending on the distro. PS1 can be changed to any plain text like:
PS1="hello "
Besides the plain text, a number of backslash-escaped special characters are supported:
Format
Action
\aan ASCII bell character (07)
\dthe date in “Weekday Month Date” format (e.g., “Tue May 26”)
GoalKicker.com – Bash Notes for Professionals
106\D{format}the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format
results in a locale-speciﬁc time representation. The braces are required
\ean ASCII escape character (033)
\hthe hostname up to the ﬁrst ‘.’
\Hthe hostname
\jthe number of jobs currently managed by the shell
\lthe basename of the shell’s terminal device name
\nnewline
\rcarriage return
\sthe name of the shell, the basename of $0 (the portion following the ﬁnal slash)
\tthe current time in 24-hour HH:MM:SS format
\Tthe current time in 12-hour HH:MM:SS format
\@the current time in 12-hour am/pm format
\Athe current time in 24-hour HH:MM format
\uthe username of the current user
\vthe version of bash (e.g., 2.00)
\Vthe release of bash, version + patch level (e.g., 2.00.0)
\wthe current working directory, with $HOME abbreviated with a tilde
\Wthe basename of the current working directory, with $HOME abbreviated with a tilde
\!the history number of this command
\#the command number of this command
\$if the eﬀective UID is 0, a #, otherwise a $
\nnn*the character corresponding to the octal number nnn
\a backslash
\[begin a sequence of non-printing characters, which could be used to embed a terminal control
sequence into the prompt
\]end a sequence of non-printing characters
So for example, we can set PS1 to:
PS1="\u@\h:\w\$ "
And it will output:
user@machine:~$
Section 30.6: Show previous command return status and time
Sometimes we need a visual hint to indicate the return status of previous command. The following snippet make
put it at the head of the PS1.
Note that the __stat() function should be called every time a new PS1 is generated, or else it would stick to the
return status of last command of your .bashrc or .bash_proﬁle.
# -ANSI-COLOR-CODES- #
Color_Off="\033[0m"
###-Regular-###
Red="\033[0;31m"
Green="\033[0;32m"
GoalKicker.com – Bash Notes for Professionals
107Yellow="\033[0;33m"
####-Bold-####
function __stat() {
if [ $? -eq 0 ]; then
echo -en "$Green ✔ $Color_Off "
else
echo -en "$Red ✘ $Color_Off "
fi
}
PS1='$(__stat)'
PS1+="[\t] "
PS1+="\e[0;33m\u@\h\e[0m:\e[1;34m\w\e[0m \n$ "
export PS1
GoalKicker.com – Bash Notes for Professionals
108Chapter 31: Brace Expansion
Section 31.1: Modifying ﬁlename extension
$ mv filename.{jar,zip}
This expands into mv filename.jar filename.zip .
Section 31.2: Create directories to group ﬁles by month and
year
$ mkdir 20{09..11}-{01..12}
Entering the ls command will show that the following directories were created:
2009-01 2009-04 2009-07 2009-10 2010-01 2010-04 2010-07 2010-10 2011-01 2011-04 2011-07 2011-10
2009-02 2009-05 2009-08 2009-11 2010-02 2010-05 2010-08 2010-11 2011-02 2011-05 2011-08 2011-11
2009-03 2009-06 2009-09 2009-12 2010-03 2010-06 2010-09 2010-12 2011-03 2011-06 2011-09 2011-12
Putting a 0 in front of 9 in the example ensures the numbers are padded with a single 0. You can also pad numbers
with multiple zeros, for example:
$ echo {001..10}
001 002 003 004 005 006 007 008 009 010
Section 31.3: Create a backup of dotﬁles
$ cp .vimrc{,.bak}
This expands into the command cp .vimrc .vimrc.bak.
Section 31.4: Use increments
$ echo {0..10..2}
0 2 4 6 8 10
A third parameter to specify an increment, i.e. {start..end..increment}
Using increments is not constrained to just numbers
$ for c in {a..z..5}; do echo -n $c; done
afkpuz
Section 31.5: Using brace expansion to create lists
Bash can easily create lists from alphanumeric characters.
# list from a to z
$ echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z
# reverse from z to a
$ echo {z..a}
GoalKicker.com – Bash Notes for Professionals
109z y x w v u t s r q p o n m l k j i h g f e d c b a
# digits
$ echo {1..20}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# with leading zeros
$ echo {01..20}
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
# reverse digit
$ echo {20..1}
20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
# reversed with leading zeros
$ echo {20..01}
20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01
# combining multiple braces
$ echo {a..d}{1..3}
a1 a2 a3 b1 b2 b3 c1 c2 c3 d1 d2 d3
Brace expansion is the very ﬁrst expansion that takes place, so it cannot be combined with any other expansions.
Only chars and digits can be used.
This won't work: echo {$(date +$H)..24}
Section 31.6: Make Multiple Directories with Sub-Directories
mkdir -p toplevel/sublevel_{01..09}/{child1,child2,child3}
This will create a top level folder called toplevel, nine folders inside of toplevel named sublevel_01, sublevel_02,
etc. Then inside of those sublevels: child1, child2, child3 folders, giving you:
toplevel/sublevel_01/child1
toplevel/sublevel_01/child2
toplevel/sublevel_01/child3
toplevel/sublevel_02/child1
and so on. I ﬁnd this very useful for creating multiple folders and sub folders for my speciﬁc purposes, with one
bash command. Substitute variables to help automate/parse information given to the script.
GoalKicker.com – Bash Notes for Professionals
110Chapter 32: getopts : smart positional-
parameter parsing
Parameter
Detail
optstring The option characters to be recognized
name
Then name where parsed option is stored
Section 32.1: pingnmap
#!/bin/bash
# Script name : pingnmap
# Scenario : The systems admin in company X is tired of the monotonous job
# of pinging and nmapping, so he decided to simplify the job using a script.
# The tasks he wish to achieve is
# 1. Ping - with a max count of 5 -the given IP address/domain. AND/OR
# 2. Check if a particular port is open with a given IP address/domain.
# And getopts is for her rescue.
# A brief overview of the options
# n : meant for nmap
# t : meant for ping
# i : The option to enter the IP address
# p : The option to enter the port
# v : The option to get the script version
while getopts ':nti:p:v' opt
#putting : in the beginnnig suppresses the errors for invalid options
do
case "$opt" in
'i')ip="${OPTARG}"
;;
'p')port="${OPTARG}"
;;
'n')nmap_yes=1;
;;
't')ping_yes=1;
;;
'v')echo "pingnmap version 1.0.0"
;;
*) echo "Invalid option $opt"
echo "Usage : "
echo "pingmap -[n|t[i|p]|v]"
;;
esac
done
if [ ! -z "$nmap_yes" ] && [ "$nmap_yes" -eq "1" ]
then
if [ ! -z "$ip" ] && [ ! -z "$port" ]
then
nmap -p "$port" "$ip"
fi
fi
if [ ! -z "$ping_yes" ] && [ "$ping_yes" -eq "1" ]
then
if [ ! -z "$ip" ]
then
ping -c 5 "$ip"
GoalKicker.com – Bash Notes for Professionals
111fi
fi
shift $(( OPTIND - 1 )) # Processing additional arguments
if [ ! -z "$@" ]
then
echo "Bogus arguments at the end : $@"
fi
Output
$ ./pingnmap -nt -i google.com -p 80
Starting Nmap 6.40 ( http://nmap.org ) at 2016-07-23 14:31 IST
Nmap scan report for google.com (216.58.197.78)
Host is up (0.034s latency).
rDNS record for 216.58.197.78: maa03s21-in-f14.1e100.net
PORT
STATE SERVICE
80/tcp open http
Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds
PING google.com (216.58.197.78) 56(84) bytes of data.
64 bytes from maa03s21-in-f14.1e100.net (216.58.197.78): icmp_seq=1 ttl=57 time=29.3 ms
64 bytes from maa03s21-in-f14.1e100.net (216.58.197.78): icmp_seq=2 ttl=57 time=30.9 ms
64 bytes from maa03s21-in-f14.1e100.net (216.58.197.78): icmp_seq=3 ttl=57 time=34.7 ms
64 bytes from maa03s21-in-f14.1e100.net (216.58.197.78): icmp_seq=4 ttl=57 time=39.6 ms
64 bytes from maa03s21-in-f14.1e100.net (216.58.197.78): icmp_seq=5 ttl=57 time=32.7 ms
--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 29.342/33.481/39.631/3.576 ms
$ ./pingnmap -v
pingnmap version 1.0.0
$ ./pingnmap -h
Invalid option ?
Usage :
pingmap -[n|t[i|p]|v]
$ ./pingnmap -v
pingnmap version 1.0.0
$ ./pingnmap -h
Invalid option ?
Usage :
pingmap -[n|t[i|p]|v]
GoalKicker.com – Bash Notes for Professionals
112Chapter 33: Debugging
Section 33.1: Checking the syntax of a script with "-n"
The -n ﬂag enables you to check the syntax of a script without having to execute it:
~> $ bash -n testscript.sh
testscript.sh: line 128: unexpected EOF while looking for matching `"'
testscript.sh: line 130: syntax error: unexpected end of file
Section 33.2: Debugging using bashdb
Bashdb is a utility that is similar to gdb, in that you can do things like set breakpoints at a line or at a function, print
content of variables, you can restart script execution and more.
You can normally install it via your package manager, for example on Fedora:
sudo dnf install bashdb
Or get it from the homepage. Then you can run it with your script as a paramater:
bashdb <YOUR SCRIPT>
Here are a few commands to get you started:
l - show local lines, press l again to scroll down
s - step to next line
print $VAR - echo out content of variable
restart - reruns bashscript, it re-loads it prior to execution.
eval - evaluate some custom command, ex: eval echo hi
b set breakpoint on some line
c - continue till some breakpoint
i b - info on break points
d - delete breakpoint at line #
shell - launch a sub-shell in the middle of execution, this is handy for manipulating variables
For more information, I recommend consulting the manual:
http://www.rodericksmith.plus.com/outlines/manuals/bashdbOutline.html
See also homepage:
http://bashdb.sourceforge.net/
Section 33.3: Debugging a bash script with "-x"
Use "-x" to enable debug output of executed lines. It can be run on an entire session or script, or enabled
programmatically within a script.
Run a script with debug output enabled:
$ bash -x myscript.sh
GoalKicker.com – Bash Notes for Professionals
113Or
$ bash --debug myscript.sh
Turn on debugging within a bash script. It may optionally be turned back on, though debug output is automatically
reset when the script exits.
#!/bin/bash
set -x
# Enable debugging
# some code here
set +x
# Disable debugging output.
GoalKicker.com – Bash Notes for Professionals
114Chapter 34: Pattern matching and regular
expressions
Section 34.1: Get captured groups from a regex match
against a string
a='I am a simple string with digits 1234'
pat='(.*) ([0-9]+)'
[[ "$a" =~ $pat ]]
echo "${BASH_REMATCH[0]}"
echo "${BASH_REMATCH[1]}"
echo "${BASH_REMATCH[2]}"
Output:
I am a simple string with digits 1234
I am a simple string with digits
1234
Section 34.2: Behaviour when a glob does not match anything
Preparation
$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file
.hiddenfile
$ shopt -u nullglob
$ shopt -u failglob
$ shopt -u dotglob
$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -u globstar
In case the glob does not match anything the result is determined by the options nullglob and failglob. If neither
of them are set, Bash will return the glob itself if nothing is matched
$ echo no*match
no*match
If nullglob is activated then nothing (null) is returned:
$ shopt -s nullglob
$ echo no*match
$
If failglob is activated then an error message is returned:
$ shopt -s failglob
$ echo no*match
bash: no match: no*match
$
GoalKicker.com – Bash Notes for Professionals
115Notice, that the failglob option supersedes the nullglob option, i.e., if nullglob and failglob are both set, then -
in case of no match - an error is returned.
Section 34.3: Check if a string matches a regular expression
Version ≥ 3.0
Check if a string consists in exactly 8 digits:
$ date=20150624
$ [[ $date =~ ^[0-9]{8}$ ]] && echo "yes" || echo "no"
yes
$ date=hello
$ [[ $date =~ ^[0-9]{8}$ ]] && echo "yes" || echo "no"
no
Section 34.4: Regex matching
pat='[^0-9]+([0-9]+)'
s='I am a string with some digits 1024'
[[ $s =~ $pat ]] # $pat must be unquoted
echo "${BASH_REMATCH[0]}"
echo "${BASH_REMATCH[1]}"
Output:
I am a string with some digits 1024
1024
Instead of assigning the regex to a variable ($pat) we could also do:
[[ $s =~ [^0-9]+([0-9]+) ]]
Explanation
The [[ $s =~ $pat ]] construct performs the regex matching
The captured groups i.e the match results are available in an array named BASH_REMATCH
The 0th index in the BASH_REMATCH array is the total match
The i'th index in the BASH_REMATCH array is the i'th captured group, where i = 1, 2, 3 ...
Section 34.5: The * glob
Preparation
$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file
.hiddenfile
$ shopt -u nullglob
$ shopt -u failglob
$ shopt -u dotglob
$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -u globstar
GoalKicker.com – Bash Notes for Professionals
116The asterisk * is probably the most commonly used glob. It simply matches any String
$ echo *acy
macy stacy tracy
A single * will not match ﬁles and folders that reside in subfolders
$ echo *
emptyfolder folder macy stacy tracy
$ echo folder/*
folder/anotherfolder folder/subfolder
Section 34.6: The ** glob
Version ≥ 4.0
Preparation
$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file
.hiddenfile
$ shopt -u nullglob
$ shopt -u failglob
$ shopt -u dotglob
$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -s globstar
Bash is able to interpret two adjacent asterisks as a single glob. With the globstar option activated this can be used
to match folders that reside deeper in the directory structure
echo **
emptyfolder folder folder/anotherfolder folder/anotherfolder/content
folder/anotherfolder/content/deepfolder folder/anotherfolder/content/deepfolder/file
folder/subfolder folder/subfolder/content folder/subfolder/content/deepfolder
folder/subfolder/content/deepfolder/file macy stacy tracy
The ** can be thought of a path expansion, no matter how deep the path is. This example matches any ﬁle or
folder that starts with deep, regardless of how deep it is nested:
$ echo **/deep*
folder/anotherfolder/content/deepfolder folder/subfolder/content/deepfolder
Section 34.7: The ? glob
Preparation
$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file
.hiddenfile
$ shopt -u nullglob
$ shopt -u failglob
$ shopt -u dotglob
GoalKicker.com – Bash Notes for Professionals
117$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -u globstar
The ? simply matches exactly one character
$ echo ?acy
macy
$ echo ??acy
stacy tracy
Section 34.8: The [ ] glob
Preparation
$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file
.hiddenfile
$ shopt -u nullglob
$ shopt -u failglob
$ shopt -u dotglob
$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -u globstar
If there is a need to match speciﬁc characters then '[]' can be used. Any character inside '[]' will be matched exactly
once.
$ echo [m]acy
macy
$ echo [st][tr]acy
stacy tracy
The [] glob, however, is more versatile than just that. It also allows for a negative match and even matching ranges
of characters and character classes. A negative match is achieved by using ! or ^ as the ﬁrst character following [.
We can match stacy by
$ echo [!t][^r]acy
stacy
Here we are telling bash the we want to match only ﬁles which do not not start with a t and the second letter is not
an r and the ﬁle ends in acy.
Ranges can be matched by seperating a pair of characters with a hyphen (-). Any character that falls between those
two enclosing characters - inclusive - will be matched. E.g., [r-t] is equivalent to [rst]
$ echo [r-t][r-t]acy
stacy tracy
Character classes can be matched by [:class:], e.g., in order to match ﬁles that contain a whitespace
$ echo *[[:blank:]]*
file with space
GoalKicker.com – Bash Notes for Professionals
118Section 34.9: Matching hidden ﬁles
Preparation
$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file
.hiddenfile
$ shopt -u nullglob
$ shopt -u failglob
$ shopt -u dotglob
$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -u globstar
The Bash built-in option dotglob allows to match hidden ﬁles and folders, i.e., ﬁles and folders that start with a .
$ shopt -s dotglob
$ echo *
file with space folder .hiddenfile macy stacy tracy
Section 34.10: Case insensitive matching
Preparation
$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file
.hiddenfile
$ shopt -u nullglob
$ shopt -u failglob
$ shopt -u dotglob
$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -u globstar
Setting the option nocaseglob will match the glob in a case insensitive manner
$ echo M*
M*
$ shopt -s nocaseglob
$ echo M*
macy
Section 34.11: Extended globbing
Version ≥ 2.02
Preparation
$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file
.hiddenfile
$ shopt -u nullglob
GoalKicker.com – Bash Notes for Professionals
119$ shopt -u failglob
$ shopt -u dotglob
$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -u globstar
Bash's built-in extglob option can extend a glob's matching capabilities
shopt -s extglob
The following sub-patterns comprise valid extended globs:
?(pattern-list) – Matches zero or one occurrence of the given patterns
*(pattern-list) – Matches zero or more occurrences of the given patterns
+(pattern-list) – Matches one or more occurrences of the given patterns
@(pattern-list) – Matches one of the given patterns
!(pattern-list) – Matches anything except one of the given patterns
The pattern-list is a list of globs separated by |.
$ echo *([r-t])acy
stacy tracy
$ echo *([r-t]|m)acy
macy stacy tracy
$ echo ?([a-z])acy
macy
The pattern-list itself can be another, nested extended glob. In the above example we have seen that we can
match tracy and stacy with *(r-t). This extended glob itself can be used inside the negated extended glob
!(pattern-list) in order to match macy
$ echo !(*([r-t]))acy
macy
It matches anything that does not start with zero or more occurrences of the letters r, s and t, which leaves only
macy as possible match.
GoalKicker.com – Bash Notes for Professionals
120Chapter 35: Change shell
Section 35.1: Find the current shell
There are a few ways to determine the current shell
echo $0
ps -p $$
echo $SHELL
Section 35.2: List available shells
To list available login shells :
cat /etc/shells
Example:
$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
Section 35.3: Change the shell
To change the current bash run these commands
export SHELL=/bin/bash
exec /bin/bash
to change the bash that opens on startup edit .profile and add those lines
GoalKicker.com – Bash Notes for Professionals
121Chapter 36: Internal variables
An overview of Bash's internal variables, where, how, and when to use them.
Section 36.1: Bash internal variables at a glance
Variable
$* / $@
Details
Function/script positional parameters (arguments). Expand as follows:
$* and $@ are the same as $1 $2 ... (note that it generally makes no sense to leave those
unquoted)
"$*" is the same as "$1 $2 ..." 1
"$@" is the same as "$1" "$2" ...
1. Arguments are separated by the ﬁrst character of $IFS, which does not have to be a space.
$#Number of positional parameters passed to the script or function
$!Process ID of the last (righ-most for pipelines) command in the most recently job put into the
background (note that it's not necessarily the same as the job's process group ID when job control
is enabled)
$$ID of the process that executed bash
$?Exit status of the last command
$nPositional parameters, where n=1, 2, 3, ..., 9
${n}Positional parameters (same as above), but n can be > 9
$0In scripts, path with which the script was invoked; with bash -c 'printf "%s\n" "$0"' name
args': name (the ﬁrst argument after the inline script), otherwise, the argv[0] that bash received.
$_Last ﬁeld of the last command
$IFSInternal ﬁeld separator
$PATHPATH environment variable used to look-up executables
$OLDPWDPrevious working directory
$PWDPresent working directory
$FUNCNAMEArray of function names in the execution call stack
$BASH_SOURCEArray containing source paths for elements in FUNCNAME array. Can be used to get the script path.
$BASH_ALIASES Associative array containing all currently deﬁned aliases
$BASH_REMATCH Array of matches from the last regex match
$BASH_VERSION Bash version string
$BASH_VERSINFO An array of 6 elements with Bash version information
$BASH
Absolute path to the currently executing Bash shell itself (heuristically determined by bash based
on argv[0] and the value of $PATH; may be wrong in corner cases)
$BASH_SUBSHELL Bash subshell level
$UIDReal (not eﬀective if diﬀerent) User ID of the process running bash
$PS1Primary command line prompt; see Using the PS* Variables
$PS2Secondary command line prompt (used for additional input)
$PS3Tertiary command line prompt (used in select loop)
$PS4Quaternary command line prompt (used to append info with verbose output)
$RANDOMA pseudo random integer between 0 and 32767
$REPLYVariable used by read by default when no variable is speciﬁed. Also used by SELECT to return the
user-supplied value
$PIPESTATUSArray variable that holds the exit status values of each command in the most recently executed
foreground pipeline.
GoalKicker.com – Bash Notes for Professionals
122Variable Assignment must have no space before and after. a=123 not a = 123. The latter (an equal sign
surrounded by spaces) in isolation means run the command a with the arguments = and 123, though it is
also seen in the string comparison operator (which syntactically is an argument to [ or [[ or whichever
test you are using).
Section 36.2: $@
"$@" expands to all of the command line arguments as separate words. It is diﬀerent from "$*", which expands to
all of the arguments as a single word.
"$@" is especially useful for looping through arguments and handling arguments with spaces.
Consider we are in a script that we invoked with two arguments, like so:
$ ./script.sh "␣1␣2␣" "␣3␣␣4␣"
The variables $* or $@ will expand into $1␣$2, which in turn expand into 1␣2␣3␣4 so the loop below:
for var in $*; do # same for var in $@; do
echo \\<"$var"\\>
done
will print for both
<1>
<2>
<3>
<4>
While "$*" will be expanded into "$1␣$2" which will in turn expand into "␣1␣2␣␣␣3␣␣4␣" and so the loop:
for var in "$*"; do
echo \\<"$var"\\>
done
will only invoke echo once and will print
<␣1␣2␣␣␣3␣␣4␣>
And ﬁnally "$@" will expand into "$1" "$2", which will expand into "␣1␣2␣" "␣3␣␣4␣" and so the loop
for var in "$@"; do
echo \\<"$var"\\>
done
will print
<␣1␣2␣>
<␣3␣␣4␣>
thereby preserving both the internal spacing in the arguments and the arguments separation. Note that the
GoalKicker.com – Bash Notes for Professionals
123construction for var in "$@"; do ... is so common and idiomatic that it is the default for a for loop and can be
shortened to for var; do ....
Section 36.3: $#
To get the number of command line arguments or positional parameters - type:
#!/bin/bash
echo "$#"
When run with three arguments the example above will result with the output:
~> $ ./testscript.sh firstarg secondarg thirdarg
3
Section 36.4: $HISTSIZE
The maximum number of remembered commands:
~> $ echo $HISTSIZE
1000
Section 36.5: $FUNCNAME
To get the name of the current function - type:
my_function()
{
echo "This function is $FUNCNAME"
}
# This will output "This function is my_function"
This instruction will return nothing if you type it outside the function:
my_function
echo "This function is $FUNCNAME"
# This will output "This function is"
Section 36.6: $HOME
The home directory of the user
~> $ echo $HOME
/home/user
Section 36.7: $IFS
Contains the Internal Field Separator string that bash uses to split strings when looping etc. The default is the white
space characters: \n (newline), \t (tab) and space. Changing this to something else allows you to split strings using
diﬀerent characters:
IFS=","
INPUTSTR="a,b,c,d"
for field in ${INPUTSTR}; do
echo $field
GoalKicker.com – Bash Notes for Professionals
124done
The output of the above is:
a
b
c
d
Notes:
This is responsible for the phenomenon known as word splitting.
Section 36.8: $OLDPWD
OLDPWD (OLDPrintWorkingDirectory) contains directory before the last cd command:
~> $ cd directory
directory> $ echo $OLDPWD
/home/user
Section 36.9: $PWD
PWD (PrintWorkingDirectory) The current working directory you are in at the moment:
~> $ echo $PWD
/home/user
~> $ cd directory
directory> $ echo $PWD
/home/user/directory
Section 36.10: $1 $2 $3 etc..
Positional parameters passed to the script from either the command line or a function:
#!/bin/bash
# $n is the n'th positional parameter
echo "$1"
echo "$2"
echo "$3"
The output of the above is:
~> $ ./testscript.sh firstarg secondarg thirdarg
firstarg
secondarg
thirdarg
If number of positional argument is greater than nine, curly braces must be used.
# "set -- " sets positional parameters
set -- 1 2 3 4 5 6 7 8 nine ten eleven twelve
# the following line will output 10 not 1 as the value of $1 the digit 1
# will be concatenated with the following 0
echo $10
# outputs 1
echo ${10} # outputs ten
GoalKicker.com – Bash Notes for Professionals
125# to show this clearly:
set -- arg{1..12}
echo $10
echo ${10}
Section 36.11: $*
Will return all of the positional parameters in a single string.
testscript.sh:
#!/bin/bash
echo "$*"
Run the script with several arguments:
./testscript.sh firstarg secondarg thirdarg
Output:
firstarg secondarg thirdarg
Section 36.12: $!
The Process ID (pid) of the last job run in the background:
~> $ ls &
testfile1 testfile2
[1]+ Done
~> $ echo $!
21715
ls
Section 36.13: $?
The exit status of the last executed function or command. Usually 0 will mean OK anything else will indicate a
failure:
~> $ ls *.blah;echo $?
ls: cannot access *.blah: No such file or directory
2
~> $ ls;echo $?
testfile1 testfile2
0
Section 36.14: $$
The Process ID (pid) of the current process:
~> $ echo $$
13246
Section 36.15: $RANDOM
Each time this parameter is referenced, a random integer between 0 and 32767 is generated. Assigning a value to
GoalKicker.com – Bash Notes for Professionals
126this variable seeds the random number generator (source).
~> $ echo $RANDOM
27119
~> $ echo $RANDOM
1349
Section 36.16: $BASHPID
Process ID (pid) of the current instance of Bash. This is not the same as the $$ variable, but it often gives the same
result. This is new in Bash 4 and doesn't work in Bash 3.
~> $ echo "\$\$ pid = $$ BASHPID = $BASHPID"
$$ pid = 9265 BASHPID = 9265
Section 36.17: $BASH_ENV
An environment variable pointing to the Bash startup ﬁle which is read when a script is invoked.
Section 36.18: $BASH_VERSINFO
An array containing the full version information split into elements, much more convenient than $BASH_VERSION if
you're just looking for the major version:
~> $ for ((i=0; i<=5; i++)); do echo "BASH_VERSINFO[$i] = ${BASH_VERSINFO[$i]}"; done
BASH_VERSINFO[0] = 3
BASH_VERSINFO[1] = 2
BASH_VERSINFO[2] = 25
BASH_VERSINFO[3] = 1
BASH_VERSINFO[4] = release
BASH_VERSINFO[5] = x86_64-redhat-linux-gnu
Section 36.19: $BASH_VERSION
Shows the version of bash that is running, this allows you to decide whether you can use any advanced features:
~> $ echo $BASH_VERSION
4.1.2(1)-release
Section 36.20: $EDITOR
The default editor that will be involked by any scripts or programs, usually vi or emacs.
~> $ echo $EDITOR
vi
Section 36.21: $HOSTNAME
The hostname assigned to the system during startup.
~> $ echo $HOSTNAME
mybox.mydomain.com
GoalKicker.com – Bash Notes for Professionals
127Section 36.22: $HOSTTYPE
This variable identiﬁes the hardware, it can be useful in determining which binaries to execute:
~> $ echo $HOSTTYPE
x86_64
Section 36.23: $MACHTYPE
Similar to $HOSTTYPE above, this also includes information about the OS as well as hardware
~> $ echo $MACHTYPE
x86_64-redhat-linux-gnu
Section 36.24: $OSTYPE
Returns information about the type of OS running on the machine, eg.
~> $ echo $OSTYPE
linux-gnu
Section 36.25: $PATH
The search path for ﬁnding binaries for commands. Common examples include /usr/bin and /usr/local/bin.
When a user or script attempts to run a command, the paths in $PATH are searched in order to ﬁnd a matching ﬁle
with execute permission.
The directories in $PATH are separated by a : character.
~> $ echo "$PATH"
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin
So, for example, given the above $PATH, if you type lss at the prompt, the shell will look for
/usr/kerberos/bin/lss, then /usr/local/bin/lss, then /bin/lss, then /usr/bin/lss, in this order, before
concluding that there is no such command.
Section 36.26: $PPID
The Process ID (pid) of the script or shell's parent, meaning the process than invoked the current script or shell.
~> $ echo $$
13016
~> $ echo $PPID
13015
Section 36.27: $SECONDS
The number of seconds a script has been running. This can get quite large if shown in the shell:
~> $ echo $SECONDS
98834
GoalKicker.com – Bash Notes for Professionals
128Section 36.28: $SHELLOPTS
A readonly list of the options bash is supplied on startup to control its behaviour:
~> $ echo $SHELLOPTS
braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
Section 36.29: $_
Outputs the last ﬁeld from the last command executed, useful to get something to pass onwards to another
command:
~> $ ls *.sh;echo $_
testscript1.sh testscript2.sh
testscript2.sh
It gives the script path if used before any other commands:
test.sh:
#!/bin/bash
echo "$_"
Output:
~> $ ./test.sh # running test.sh
./test.sh
Note: This is not a foolproof way to get the script path
Section 36.30: $GROUPS
An array containing the numbers of groups the user is in:
#!/usr/bin/env bash
echo You are assigned to the following groups:
for group in ${GROUPS[@]}; do
IFS=: read -r name dummy number members < <(getent group $group )
printf "name: %-10s number: %-15s members: %s\n" "$name" "$number" "$members"
done
Section 36.31: $LINENO
Outputs the line number in the current script. Mostly useful when debugging scripts.
#!/bin/bash
# this is line 2
echo something # this is line 3
echo $LINENO # Will output 4
Section 36.32: $SHLVL
When the bash command is executed a new shell is opened. The $SHLVL environment variable holds the number of
shell levels the current shell is running on top of.
GoalKicker.com – Bash Notes for Professionals
129In a new terminal window, executing the following command will produce diﬀerent results based on the Linux
distribution in use.
echo $SHLVL
Using Fedora 25, the output is "3". This indicates, that when opening a new shell, an initial bash command executes
and performs a task. The initial bash command executes a child process (another bash command) which, in turn,
executes a ﬁnal bash command to open the new shell. When the new shell opens, it is running as a child process of
2 other shell processes, hence the output of "3".
In the following example (given the user is running Fedora 25), the output of $SHLVL in a new shell will be set to "3".
As each bash command is executed, $SHLVL increments by one.
~> $ echo $SHLVL
3
~> $ bash
~> $ echo $SHLVL
4
~> $ bash
~> $ echo $SHLVL
5
One can see that executing the 'bash' command (or executing a bash script) opens a new shell. In comparison,
sourcing a script runs the code in the current shell.
test1.sh
#!/usr/bin/env bash
echo "Hello from test1.sh. My shell level is $SHLVL"
source "test2.sh"
test2.sh
#!/usr/bin/env bash
echo "Hello from test2.sh. My shell level is $SHLVL"
run.sh
#!/usr/bin/env bash
echo "Hello from run.sh. My shell level is $SHLVL"
./test1.sh
Execute:
chmod +x test1.sh && chmod +x run.sh
./run.sh
Output:
Hello from run.sh. My shell level is 4
Hello from test1.sh. My shell level is 5
Hello from test2.sh. My shell level is 5
GoalKicker.com – Bash Notes for Professionals
130Section 36.33: $UID
A read only variable that stores the users' ID number:
~> $ echo $UID
12345
GoalKicker.com – Bash Notes for Professionals
131Chapter 37: Job Control
Section 37.1: List background processes
$ jobs
[1]
Running
[2]- Running
[3]+ Running
sleep 500 & (wd: ~)
sleep 600 & (wd: ~)
./Fritzing &
First ﬁeld shows the job ids. The + and - sign that follows the job id for two jobs denote the default job and next
candidate default job when the current default job ends respectively. The default job is used when the fg or bg
commands are used without any argument.
Second ﬁeld gives the status of the job. Third ﬁeld is the command used to start the process.
The last ﬁeld (wd: ~) says that the sleep commands were started from the working directory ~ (Home).
Section 37.2: Bring a background process to the foreground
$ fg %2
sleep 600
%2 speciﬁes job no. 2. If fg is used without any arguments if brings the last process put in background to the
foreground.
$ fg %?sle
sleep 500
?sle refers to the baground process command containing "sle". If multiple background commands contain the
string, it will produce an error.
Section 37.3: Restart stopped background process
$ bg
[8]+ sleep 600 &
Section 37.4: Run command in background
$ sleep 500 &
[1] 7582
Puts the sleep command in background. 7582 is the process id of the background process.
Section 37.5: Stop a foreground process
Press Ctrl + Z to stop a foreground process and put it in background
$ sleep 600
^Z
[8]+ Stopped
sleep 600
GoalKicker.com – Bash Notes for Professionals
132Chapter 38: Case statement
Section 38.1: Simple case statement
In its simplest form supported by all versions of bash, case statement executes the case that matches the pattern.
;; operator breaks after the ﬁrst match, if any.
#!/bin/bash
var=1
case $var in
1)
echo "Antartica"
;;
2)
echo "Brazil"
;;
3)
echo "Cat"
;;
esac
Outputs:
Antartica
Section 38.2: Case statement with fall through
Version ≥ 4.0
Since bash 4.0, a new operator ;& was introduced which provides fall through mechanism.
#!/bin/bash
var=1
case $var in
1)
echo "Antartica"
;&
2)
echo "Brazil"
;&
3)
echo "Cat"
;&
esac
Outputs:
Antartica
Brazil
Cat
Section 38.3: Fall through only if subsequent pattern(s) match
Version ≥ 4.0
GoalKicker.com – Bash Notes for Professionals
133Since Bash 4.0, another operator ;;& was introduced which also provides fall through only if the patterns in
subsequent case statement(s), if any, match.
#!/bin/bash
var=abc
case $var in
a*)
echo "Antartica"
;;&
xyz)
echo "Brazil"
;;&
*b*)
echo "Cat"
;;&
esac
Outputs:
Antartica
Cat
In the below example, the abc matches both ﬁrst and third case but not the second case. So, second case is not
executed.
GoalKicker.com – Bash Notes for Professionals
134Chapter 39: Read a ﬁle (data stream,
variable) line-by-line (and/or ﬁeld-by-
ﬁeld)?
Parameter
IFS
Internal ﬁeld separator
Details
ﬁleA ﬁle name/path
-rPrevents backslash interpretation when used with read
-tRemoves a trailing newline from each line read by readarray
-d DELIMContinue until the ﬁrst character of DELIM is read (with read), rather than newline
Section 39.1: Looping through a ﬁle line by line
while IFS= read -r line; do
echo "$line"
done <file
If ﬁle may not include a newline at the end, then:
while IFS= read -r line || [ -n "$line" ]; do
echo "$line"
done <file
Section 39.2: Looping through the output of a command ﬁeld
by ﬁeld
Let's assume that the ﬁeld separator is :
while IFS= read -d : -r field || [ -n "$field" ];do
echo "**$field**"
done < <(ping google.com)
Or with a pipe:
ping google.com | while IFS= read -d : -r field || [ -n "$field" ];do
echo "**$field**"
done
Section 39.3: Read lines of a ﬁle into an array
readarray -t arr <file
Or with a loop:
arr=()
while IFS= read -r line; do
arr+=("$line")
done <file
GoalKicker.com – Bash Notes for Professionals
135Section 39.4: Read lines of a string into an array
var='line 1
line 2
line3'
readarray -t arr <<< "$var"
or with a loop:
arr=()
while IFS= read -r line; do
arr+=("$line")
done <<< "$var"
Section 39.5: Looping through a string line by line
var='line 1
line 2
line3'
while IFS= read -r line; do
echo "-$line-"
done <<< "$var"
or
readarray -t arr <<< "$var"
for i in "${arr[@]}";do
echo "-$i-"
done
Section 39.6: Looping through the output of a command line
by line
while IFS= read -r line;do
echo "**$line**"
done < <(ping google.com)
or with a pipe:
ping google.com |
while IFS= read -r line;do
echo "**$line**"
done
Section 39.7: Read a ﬁle ﬁeld by ﬁeld
Let's assume that the ﬁeld separator is : (colon) in the ﬁle ﬁle.
while IFS= read -d : -r field || [ -n "$field" ]; do
echo "$field"
done <file
For a content:
first : se
GoalKicker.com – Bash Notes for Professionals
136con
d:
Thi rd:
Fourth
The output is:
**first **
** se
con
d**
**
Thi rd**
**
Fourth
**
Section 39.8: Read a string ﬁeld by ﬁeld
Let's assume that the ﬁeld separator is :
var='line: 1
line: 2
line3'
while IFS= read -d : -r field || [ -n "$field" ]; do
echo "-$field-"
done <<< "$var"
Output:
-line-
- 1
line-
- 2
line3
-
Section 39.9: Read ﬁelds of a ﬁle into an array
Let's assume that the ﬁeld separator is :
arr=()
while IFS= read -d : -r field || [ -n "$field" ]; do
arr+=("$field")
done <file
Section 39.10: Read ﬁelds of a string into an array
Let's assume that the ﬁeld separator is :
var='1:2:3:4:
newline'
arr=()
while IFS= read -d : -r field || [ -n "$field" ]; do
arr+=("$field")
done <<< "$var"
GoalKicker.com – Bash Notes for Professionals
137echo "${arr[4]}"
Output:
newline
Section 39.11: Reads ﬁle (/etc/passwd) line by line and ﬁeld by
ﬁeld
#!/bin/bash
FILENAME="/etc/passwd"
while IFS=: read -r username password userid groupid comment homedir cmdshell
do
echo "$username, $userid, $comment $homedir"
done < $FILENAME
In unix password ﬁle, user information is stored line by line, each line consisting of information for a user separated
by colon (:) character. In this example while reading the ﬁle line by line, the line is also split into ﬁelds using colon
character as delimiter which is indicated by the value given for IFS.
Sample input
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
pulse:x:497:495:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tomcat:x:91:91:Apache Tomcat:/usr/share/tomcat6:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
Sample Output
mysql, 27, MySQL Server /var/lib/mysql
pulse, 497, PulseAudio System Daemon /var/run/pulse
sshd, 74, Privilege-separated SSH /var/empty/sshd
tomcat, 91, Apache Tomcat /usr/share/tomcat6
webalizer, 67, Webalizer /var/www/usage
To read line by line and have the entire line assigned to variable, following is a modiﬁed version of the example.
Note that we have only one variable by name line mentioned here.
#!/bin/bash
FILENAME="/etc/passwd"
while IFS= read -r line
do
echo "$line"
done < $FILENAME
Sample Input
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
pulse:x:497:495:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tomcat:x:91:91:Apache Tomcat:/usr/share/tomcat6:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
Sample Output
GoalKicker.com – Bash Notes for Professionals
138mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
pulse:x:497:495:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tomcat:x:91:91:Apache Tomcat:/usr/share/tomcat6:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
GoalKicker.com – Bash Notes for Professionals
139Chapter 40: File execution sequence
.bash_profile, .bash_login, .bashrc, and .profile all do pretty much the same thing: set up and deﬁne
functions, variables, and the sorts.
The main diﬀerence is that .bashrc is called at the opening of a non-login but interactive window, and
.bash_profile and the others are called for a login shell. Many people have their .bash_profile or similar call
.bashrc anyway.
Section 40.1: .proﬁle vs .bash_proﬁle (and .bash_login)
.profile is read by most shells on startup, including bash. However, .bash_profile is used for conﬁgurations
speciﬁc to bash. For general initialization code, put it in .profile. If it's speciﬁc to bash, use .bash_profile.
.profile isn't actually designed for bash speciﬁcally, .bash_profile is though instead. (.profile is for Bourne and
other similar shells, which bash is based oﬀ) Bash will fall back to .profile if .bash_profile isn't found.
.bash_login is a fallback for .bash_profile, if it isn't found. Generally best to use .bash_profile or .profile
instead.
GoalKicker.com – Bash Notes for Professionals
140Chapter 41: Splitting Files
Sometimes it's useful to split a ﬁle into multiple separate ﬁles. If you have large ﬁles, it might be a good idea to
break it into smaller chunks
Section 41.1: Split a ﬁle
Running the split command without any options will split a ﬁle into 1 or more separate ﬁles containing up to 1000
lines each.
split file
This will create ﬁles named xaa, xab, xac, etc, each containing up to 1000 lines. As you can see, all of them are
preﬁxed with the letter x by default. If the initial ﬁle was less than 1000 lines, only one such ﬁle would be created.
To change the preﬁx, add your desired preﬁx to the end of the command line
split file customprefix
Now ﬁles named customprefixaa, customprefixab, customprefixac etc. will be created
To specify the number of lines to output per ﬁle, use the -l option. The following will split a ﬁle into a maximum of
5000 lines
split -l5000 file
OR
split --lines=5000 file
Alternatively, you can specify a maximum number of bytes instead of lines. This is done by using the -b or --bytes
options. For example, to allow a maximum of 1MB
split --bytes=1MB file
GoalKicker.com – Bash Notes for Professionals
141Chapter 42: File Transfer using scp
Section 42.1: scp transferring ﬁle
To transfer a ﬁle securely to another machine - type:
scp file1.txt tom@server2:$HOME
This example presents transferring file1.txt from our host to server2's user tom's home directory.
Section 42.2: scp transferring multiple ﬁles
scp can also be used to transfer multiple ﬁles from one server to another. Below is example of transferring all ﬁles
from my_folder directory with extension .txt to server2. In Below example all ﬁles will be transferred to user tom
home directory.
scp /my_folder/*.txt tom@server2:$HOME
Section 42.3: Downloading ﬁle using scp
To download a ﬁle from remote server to the local machine - type:
scp tom@server2:$HOME/file.txt /local/machine/path/
This example shows how to download the ﬁle named file.txt from user tom's home directory to our local
machine's current directory.
GoalKicker.com – Bash Notes for Professionals
142Chapter 43: Pipelines
Section 43.1: Using |&
|& connects standard output and standard error of the ﬁrst command to the second one while | only connects
standard output of the ﬁrst command to the second command.
In this example, the page is downloaded via curl. with -v option curl writes some info on stderr including , the
downloaded page is written on stdout. Title of page can be found between <title> and </title>.
curl -vs 'http://www.google.com/' |& awk '/Host:/{print}
/<title>/{match($0,/<title>(.*)<\/title>/,a);print a[1]}'
Output is:
> Host: www.google.com
Google
But with | a lot more information will be printed, i.e. those that are sent to stderr because only stdout is piped to
the next command. In this example all lines except the last line (Google) were sent to stderr by curl:
* Hostname was NOT found in DNS cache
*
Trying 172.217.20.228...
* Connected to www.google.com (172.217.20.228) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: www.google.com
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Date: Sun, 24 Jul 2016 19:04:59 GMT
< Expires: -1
< Cache-Control: private, max-age=0
< Content-Type: text/html; charset=ISO-8859-1
< P3P: CP="This is not a P3P policy! See
https://www.google.com/support/accounts/answer/151657?hl=en for more info."
< Server: gws
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: NID=82=jX0yZLPPUE7u13kKNevUCDg8yG9Ze_C03o0IM-
EopOSKL0mMITEagIE816G55L2wrTlQwgXkhq4ApFvvYEoaWF-
oEoq2T0sBTuQVdsIFULj9b2O8X35O0sAgUnc3a3JnTRBqelMcuS9QkQA; expires=Mon, 23-Jan-2017 19:04:59 GMT;
path=/; domain=.google.com; HttpOnly
< Accept-Ranges: none
< Vary: Accept-Encoding
< X-Cache: MISS from jetsib_appliance
< X-Loop-Control: 5.202.190.157 81E4F9836653D5812995BA53992F8065
< Connection: close
<
{ [data not shown]
* Closing connection 0
Google
GoalKicker.com – Bash Notes for Professionals
143Section 43.2: Show all processes paginated
ps -e | less
ps -e shows all the processes, its output is connected to the input of more via |, less paginates the results.
Section 43.3: Modify continuous output of a command
~$ ping -c 1 google.com # unmodified output
PING google.com (16.58.209.174) 56(84) bytes of data.
64 bytes from wk-in-f100.1e100.net (16.58.209.174): icmp_seq=1 ttl=53 time=47.4 ms
~$ ping google.com | grep -o '^[0-9]\+[^()]\+' # modified output
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
64 bytes from wk-in-f100.1e100.net
...
The pipe (|) connects the stdout of ping to the stdin of grep, which processes it immediately. Some other
commands like sed default to buﬀering their stdin, which means that it has to receive enough data, before it will
print anything, potentially causing delays in further processing.
GoalKicker.com – Bash Notes for Professionals
144Chapter 44: Managing PATH environment
variable
Parameter
Details
PATH
Path environment variable
Section 44.1: Add a path to the PATH environment variable
The PATH environment variable is generally deﬁned in ~/.bashrc or ~/.bash_proﬁle or /etc/proﬁle or ~/.proﬁle or
/etc/bash.bashrc (distro speciﬁc Bash conﬁguration ﬁle)
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:
/usr/lib/jvm/jdk1.8.0_92/bin:/usr/lib/jvm/jdk1.8.0_92/db/bin:/usr/lib/jvm/jdk1.8.0_92/jre/bin
Now, if we want to add a path (e.g ~/bin) to the PATH variable:
PATH=~/bin:$PATH
# or
PATH=$PATH:~/bin
But this will modify the PATH only in the current shell (and its subshell). Once you exit the shell, this modiﬁcation
will be gone.
To make it permanent, we need to add that bit of code to the ~/.bashrc (or whatever) ﬁle and reload the ﬁle.
If you run the following code (in terminal), it will add ~/bin to the PATH permanently:
echo 'PATH=~/bin:$PATH' >> ~/.bashrc && source ~/.bashrc
Explanation:
echo 'PATH=~/bin:$PATH' >> ~/.bashrc adds the line PATH=~/bin:$PATH at the end of ~/.bashrc ﬁle (you
could do it with a text editor)
source ~/.bashrc reloads the ~/.bashrc ﬁle
This is a bit of code (run in terminal) that will check if a path is already included and add the path only if not:
path=~/bin
# path to be included
bashrc=~/.bashrc
# bash file to be written and reloaded
# run the following code unmodified
echo $PATH | grep -q "\(^\|:\)$path\(:\|/\{0,1\}$\)" || echo "PATH=\$PATH:$path" >> "$bashrc";
source "$bashrc"
Section 44.2: Remove a path from the PATH environment
variable
To remove a PATH from a PATH environment variable, you need to edit ~/.bashrc or ~/.bash_proﬁle or /etc/proﬁle
or ~/.proﬁle or /etc/bash.bashrc (distro speciﬁc) ﬁle and remove the assignment for that particular path.
Instead of ﬁnding the exact assignment, you could just do a replacement in the $PATH in its ﬁnal stage.
The following will safely remove $path from $PATH:
GoalKicker.com – Bash Notes for Professionals
145path=~/bin
PATH="$(echo "$PATH" |sed -e "s#\(^\|:\)$(echo "$path" |sed -e 's/[^^]/[&]/g' -e
's/\^/\\^/g')\(:\|/\{0,1\}$\)#\1\2#" -e 's#:\+#:#g' -e 's#^:\|:$##g')"
To make it permanent, you will need to add it at the end of your bash conﬁguration ﬁle.
You can do it in a functional way:
rpath(){
for path in "$@";do
PATH="$(echo "$PATH" |sed -e "s#\(^\|:\)$(echo "$path" |sed -e 's/[^^]/[&]/g' -e
's/\^/\\^/g')\(:\|/\{0,1\}$\)#\1\2#" -e 's#:\+#:#g' -e 's#^:\|:$##g')"
done
echo "$PATH"
}
PATH="$(rpath ~/bin /usr/local/sbin /usr/local/bin)"
PATH="$(rpath /usr/games)"
# etc ...
This will make it easier to handle multiple paths.
Notes:
You will need to add these codes in the Bash conﬁguration ﬁle (~/.bashrc or whatever).
Run source ~/.bashrc to reload the Bash conﬁguration (~/.bashrc) ﬁle.
GoalKicker.com – Bash Notes for Professionals
146Chapter 45: Word splitting
Parameter
IFS
Internal ﬁeld separator
-x
Details
Print commands and their arguments as they are executed (Shell option)
Section 45.1: What, when and Why?
When the shell performs parameter expansion, command substitution, variable or arithmetic expansion, it scans for
word boundaries in the result. If any word boundary is found, then the result is split into multiple words at that
position. The word boundary is deﬁned by a shell variable IFS (Internal Field Separator). The default value for IFS
are space, tab and newline, i.e. word splitting will occur on these three white space characters if not prevented
explicitly.
set -x
var='I am
a
multiline string'
fun() {
echo "-$1-"
echo "*$2*"
echo ".$3."
}
fun $var
In the above example this is how the fun function is being executed:
fun I am a multiline string
$var is split into 5 args, only I, am and a will be printed.
Section 45.2: Bad eects of word splitting
$ a='I am a string with spaces'
$ [ $a = $a ] || echo "didn't match"
bash: [: too many arguments
didn't match
[ $a = $a ] was interpreted as [ I am a string with spaces = I am a string with spaces ]. [ is
the test command for which I am a string with spaces is not a single argument, rather it's 6
arguments!!
$ [ $a = something ] || echo "didn't match"
bash: [: too many arguments
didn't match
[ $a = something ] was interpreted as [ I am a string with spaces = something ]
$ [ $(grep . file) = 'something' ]
GoalKicker.com – Bash Notes for Professionals
147bash: [: too many arguments
The grep command returns a multiline string with spaces, so you can just imagine how many arguments
are there...:D
See what, when and why for the basics.
Section 45.3: Usefulness of word splitting
There are some cases where word splitting can be useful:
Filling up array:
arr=($(grep -o '[0-9]\+' file))
This will ﬁll up arr with all numeric values found in ﬁle
Looping through space separated words:
words='foo bar baz'
for w in $words;do
echo "W: $w"
done
Output:
W: foo
W: bar
W: baz
Passing space separated parameters which don't contain white spaces:
packs='apache2 php php-mbstring php-mysql'
sudo apt-get install $packs
or
packs='
apache2
php
php-mbstring
php-mysql
'
sudo apt-get install $packs
This will install the packages. If you double quote the $packs then it will throw an error.
Unquoetd $packs is sending all the space separated package names as arguments to apt-get, while
quoting it will send the $packs string as a single argument and then apt-get will try to install a package
named apache2 php php-mbstring php-mysql (for the ﬁrst one) which obviously doesn't exist
GoalKicker.com – Bash Notes for Professionals
148See what, when and why for the basics.
Section 45.4: Splitting by separator changes
We can just do simple replacement of separators from space to new line, as following example.
echo $sentence | tr " " "\n"
It'll split the value of the variable sentence and show it line by line respectively.
Section 45.5: Splitting with IFS
To be more clear, let's create a script named showarg:
#!/usr/bin/env bash
printf "%d args:" $#
printf " <%s>" "$@"
echo
Now let's see the diﬀerences:
$ var="This is an example"
$ showarg $var
4 args: <This> <is> <an> <example>
$var is split into 4 args. IFS is white space characters and thus word splitting occurred in spaces
$ var="This/is/an/example"
$ showarg $var
1 args: <This/is/an/example>
In above word splitting didn't occur because the IFS characters weren't found.
Now let's set IFS=/
$ IFS=/
$ var="This/is/an/example"
$ showarg $var
4 args: <This> <is> <an> <example>
The $var is splitting into 4 arguments not a single argument.
Section 45.6: IFS & word splitting
See what, when and why if you don't know about the aﬃliation of IFS to word splitting
let's set the IFS to space character only:
set -x
var='I am
GoalKicker.com – Bash Notes for Professionals
149a
multiline string'
IFS=' '
fun() {
echo "-$1-"
echo "*$2*"
echo ".$3."
}
fun $var
This time word splitting will only work on spaces. The fun function will be executed like this:
fun I 'am
a
multiline' string
$var is split into 3 args. I, am\na\nmultiline and string will be printed
Let's set the IFS to newline only:
IFS=$'\n'
...
Now the fun will be executed like:
fun 'I am' a 'multiline string'
$var is split into 3 args. I am, a, multiline string will be printed
Let's see what happens if we set IFS to nullstring:
IFS=
...
This time the fun will be executed like this:
fun 'I am
a
multiline string'
$var is not split i.e it remained a single arg.
You can prevent word splitting by setting the IFS to nullstring
A general way of preventing word splitting is to use double quote:
fun "$var"
will prevent word splitting in all the cases discussed above i.e the fun function will be executed with only one
argument.
GoalKicker.com – Bash Notes for Professionals
150Chapter 46: Avoiding date using printf
In Bash 4.2, a shell built-in time conversion for printf was introduced: the format speciﬁcation %(datefmt)T makes
printf output the date-time string corresponding to the format string datefmt as understood by strftime.
Section 46.1: Get the current date
$ printf '%(%F)T\n'
2016-08-17
Section 46.2: Set variable to current time
$ printf -v now '%(%T)T'
$ echo "$now"
12:42:47
GoalKicker.com – Bash Notes for Professionals
151Chapter 47: Using "trap" to react to
signals and system events
Parameter
Meaning
-p
List currently installed traps
-l
List signal names and corresponding numbers
Section 47.1: Introduction: clean up temporary ﬁles
You can use the trap command to "trap" signals; this is the shell equivalent of the signal() or sigaction() call in C
and most other programming languages to catch signals.
One of the most common uses of trap is to clean up temporary ﬁles on both an expected and unexpected exit.
Unfortunately not enough shell scripts do this :-(
#!/bin/sh
# Make a cleanup function
cleanup() {
rm --force -- "${tmp}"
}
# Trap the special "EXIT" group, which is always run when the shell exits.
trap cleanup EXIT
# Create a temporary file
tmp="$(mktemp -p /tmp tmpfileXXXXXXX)"
echo "Hello, world!" >> "${tmp}"
# No rm -f "$tmp" needed. The advantage of using EXIT is that it still works
# even if there was an error or if you used exit.
Section 47.2: Catching SIGINT or Ctl+C
The trap is reset for subshells, so the sleep will still act on the SIGINT signal sent by ^C (usually by quitting), but the
parent process (i.e. the shell script) won't.
#!/bin/sh
# Run a command on signal 2 (SIGINT, which is what ^C sends)
sigint() {
echo "Killed subshell!"
}
trap sigint INT
# Or use the no-op command for no output
#trap : INT
# This will be killed on the first ^C
echo "Sleeping..."
sleep 500
echo "Sleeping..."
sleep 500
GoalKicker.com – Bash Notes for Professionals
152And a variant which still allows you to quit the main program by pressing ^C twice in a second:
last=0
allow_quit() {
[ $(date +%s) -lt $(( $last + 1 )) ] && exit
echo "Press ^C twice in a row to quit"
last=$(date +%s)
}
trap allow_quit INT
Section 47.3: Accumulate a list of trap work to run at exit
Have you ever forgotten to add a trap to clean up a temporary ﬁle or do other work at exit?
Have you ever set one trap which canceled another?
This code makes it easy to add things to be done on exit one item at a time, rather than having one large trap
statement somewhere in your code, which may be easy to forget.
# on_exit and add_on_exit
# Usage:
#
add_on_exit rm -f /tmp/foo
#
add_on_exit echo "I am exiting"
#
tempfile=$(mktemp)
#
add_on_exit rm -f "$tempfile"
# Based on http://www.linuxjournal.com/content/use-bash-trap-statement-cleanup-temporary-files
function on_exit()
{
for i in "${on_exit_items[@]}"
do
eval $i
done
}
function add_on_exit()
{
local n=${#on_exit_items[*]}
on_exit_items[$n]="$*"
if [[ $n -eq 0 ]]; then
trap on_exit EXIT
fi
}
Section 47.4: Killing Child Processes on Exit
Trap expressions don't have to be individual functions or programs, they can be more complex expressions as well.
By combining jobs -p and kill, we can kill all spawned child processes of the shell on exit:
trap 'jobs -p | xargs kill' EXIT
Section 47.5: react on change of terminals window size
There is a signal WINCH ( WINdowCHange), which is ﬁred when one resizes a terminal window.
declare -x rows cols
update_size(){
GoalKicker.com – Bash Notes for Professionals
153rows=$(tput lines) # get actual lines of term
cols=$(tput cols) # get actual columns of term
echo DEBUG terminal window has no $rows lines and is $cols characters wide
}
trap update_size WINCH
GoalKicker.com – Bash Notes for Professionals
154Chapter 48: Chain of commands and
operations
There are some means to chain commands together. Simple ones like just a ; or more complex ones like logical
chains which run depending on some conditions. The third one is piping commands, which eﬀectively hands over
the output data to the next command in the chain.
Section 48.1: Counting a text pattern ocurrence
Using a pipe makes the output of a command be the input of the next one.
ls -1 | grep -c ".conf"
In this case the output of the ls command is used as the input of the grep command. The result will be the number
of ﬁles that include ".conf" in their name.
This can be used to contruct chains of subsequent commands as long as needed:
ls -1 | grep ".conf" | grep -c .
Section 48.2: transfer root cmd output to user ﬁle
Often one want to show the result of a command executed by root to other users. The tee command allows easily
to write a ﬁle with user perms from a command running as root:
su -c ifconfig | tee ~/results-of-ifconfig.txt
Only ifconﬁg runs as root.
Section 48.3: logical chaining of commands with && and ||
&& chains two commands. The second one runs only if the ﬁrst one exits with success. || chains two commands.
But second one runs only if ﬁrst one exits with failure.
[ a = b
] && echo "yes" || echo "no"
# if you want to run more commands within a logical chain, use curly braces
# which designate a block of commands
# They do need a ; before closing bracket so bash can diffentiate from other uses
# of curly braces
[ a = b ] && { echo "let me see."
echo "hmmm, yes, i think it is true" ; } \
|| { echo "as i am in the negation i think "
echo "this is false. a is a not b." ; }
# mind the use of line continuation sign \
# only needed to chain yes block with || ....
Section 48.4: serial chaining of commands with semicolon
A semicolon separates just two commands.
echo "i am first" ; echo "i am second" ; echo " i am third"
GoalKicker.com – Bash Notes for Professionals
155Section 48.5: chaining commands with |
The | takes the output of the left command and pipes it as input the right command. Mind, that this is done in a
subshell. Hence you cannot set values of vars of the calling process within a pipe.
find . -type f -a -iname '*.mp3' | \
while read filename; do
mute --noise "$filename"
done
GoalKicker.com – Bash Notes for Professionals
156Chapter 49: Type of Shells
Section 49.1: Start an interactive shell
bash
Section 49.2: Detect type of shell
shopt -q login_shell && echo 'login' || echo 'not-login'
Section 49.3: Introduction to dot ﬁles
In Unix, ﬁles and directories beginning with a period usually contain settings for a speciﬁc program/a series of
programs. Dot ﬁles are usually hidden from the user, so you would need to run ls -a to see them.
An example of a dot ﬁle is .bash_history, which contains the latest executed commands, assuming the user is
using Bash.
There are various ﬁles that are sourced when you are dropped into the Bash shell. The image below, taken from
this site, shows the decision process behind choosing which ﬁles to source at startup.
GoalKicker.com – Bash Notes for Professionals
157GoalKicker.com – Bash Notes for Professionals
158Chapter 50: Color script output (cross-
platform)
Section 50.1: color-output.sh
In the opening section of a bash script, it's possible to deﬁne some variables that function as helpers to color or
otherwise format the terminal output during the run of the script.
Diﬀerent platforms use diﬀerent character sequences to express color. However, there's a utility called tput which
works on all *nix systems and returns platform-speciﬁc terminal coloring strings via a consistent cross-platform API.
For example, to store the character sequence which turns the terminal text red or green:
red=$(tput setaf 1)
green=$(tput setaf 2)
Or, to store the character sequence which resets the text to default appearance:
reset=$(tput sgr0)
Then, if the BASH script needed to show diﬀerent colored outputs, this can be achieved with:
cho "${green}Success!${reset}" echo "${red}Failure.${reset}"
GoalKicker.com – Bash Notes for Professionals
159Chapter 51: co-processes
Section 51.1: Hello World
# create the co-process
coproc bash
# send a command to it (echo a)
echo 'echo Hello World' >&"${COPROC[1]}"
# read a line from its output
read line <&"${COPROC[0]}"
# show the line
echo "$line"
The output is "Hello World".
GoalKicker.com – Bash Notes for Professionals
160Chapter 52: Typing variables
Section 52.1: declare weakly typed variables
declare is an internal command of bash. (internal command use help for displaying "manpage"). It is used to show
and deﬁne variables or show function bodies.
Syntax: declare [options] [name[=value]]...
# options are used to define
# an integer
declare -i myInteger
declare -i anotherInt=10
# an array with values
declare -a anArray=( one two three)
# an assoc Array
declare -A assocArray=( [element1]="something" [second]=anotherthing )
# note that bash recognizes the string context within []
# some modifiers exist
# uppercase content
declare -u big='this will be uppercase'
# same for lower case
declare -l small='THIS WILL BE LOWERCASE'
# readonly array
declare -ra constarray=( eternal true and unchangeable )
# export integer to environment
declare -xi importantInt=42
You can use also the + which takes away the given attribute. Mostly useless, just for completness.
To display variables and/or functions there are some options too
# printing definded vars and functions
declare -f
# restrict output to functions only
declare -F # if debugging prints line number and filename defined in too
GoalKicker.com – Bash Notes for Professionals
161Chapter 53: Jobs at speciﬁc times
Section 53.1: Execute job once at speciﬁc time
Note: at is not installed by default on most of modern distributions.
To execute a job once at some other time than now, in this example 5pm, you can use
echo "somecommand &" | at 5pm
If you want to catch the output, you can do that in the usual way:
echo "somecommand > out.txt 2>err.txt &" | at 5pm
at understands many time formats, so you can also say
echo "somecommand &" | at now + 2 minutes
echo "somecommand &" | at 17:00
echo "somecommand &" | at 17:00 Jul 7
echo "somecommand &" | at 4pm 12.03.17
If no year or date are given, it assumes the next time the time you speciﬁed occurs. So if you give a hour that
already passed today, it will assume tomorrow, and if you give a month that already passed this year, it will assume
next year.
This also works together with nohup like you would expect.
echo "nohup somecommand > out.txt 2>err.txt &" | at 5pm
There are some more commands to control timed jobs:
atq lists all timed jobs (atqueue)
atrm removes a timed job (atremove )
batch does basically the same like at, but runs jobs only when system load is lower than 0.8
All commands apply to jobs of the user logged in. If logged in as root, system wide jobs are handled of course.
Section 53.2: Doing jobs at speciﬁed times repeatedly using
systemd.timer
systemd provides a modern implementation of cron. To execute a script periodical a service and a timer ﬁle ist
needed. The service and timer ﬁles should be placed in /etc/systemd/{system,user}. The service ﬁle:
[Unit]
Description=my script or programm does the very best and this is the description
[Service]
# type is important!
Type=simple
# program|script to call. Always use absolute pathes
# and redirect STDIN and STDERR as there is no terminal while being executed
ExecStart=/absolute/path/to/someCommand >>/path/to/output 2>/path/to/STDERRoutput
#NO install section!!!! Is handled by the timer facitlities itself.
#[Install]
GoalKicker.com – Bash Notes for Professionals
162#WantedBy=multi-user.target
Next the timer ﬁle:
[Unit]
Description=my very first systemd timer
[Timer]
# Syntax for date/time specifications is Y-m-d H:M:S
# a * means "each", and a comma separated list of items can be given too
# *-*-* *,15,30,45:00 says every year, every month, every day, each hour,
# at minute 15,30,45 and zero seconds
OnCalendar=*-*-* *:01:00
# this one runs each hour at one minute zero second e.g. 13:01:00
GoalKicker.com – Bash Notes for Professionals
163Chapter 54: Handling the system prompt
Escape
Details
\aA bell character.
\dThe date, in "Weekday Month Date" format (e.g., "Tue May 26").
\D{FORMAT}The FORMAT is passed to `strftime'(3) and the result is inserted into the prompt string; an empty
FORMAT results in a locale-speciﬁc time representation. The braces are required.
\eAn escape character. \033 works of course too.
\hThe hostname, up to the ﬁrst `.'. (i.e. no domain part)
\HThe hostname eventually with domain part
\jThe number of jobs currently managed by the shell.
\lThe basename of the shell's terminal device name.
\nA newline.
\rA carriage return.
\sThe name of the shell, the basename of `$0' (the portion following the ﬁnal slash).
\tThe time, in 24-hour HH:MM:SS format.
\TThe time, in 12-hour HH:MM:SS format.
@The time, in 12-hour am/pm format.
\AThe time, in 24-hour HH:MM format.
\uThe username of the current user.
\vThe version of Bash (e.g., 2.00)
\VThe release of Bash, version + patchlevel (e.g., 2.00.0)
\wThe current working directory, with $HOME abbreviated with a tilde (uses the $PROMPT_DIRTRIM
variable).
\WThe basename of $PWD, with $HOME abbreviated with a tilde.
!The history number of this command.
#The command number of this command.
$If the eﬀective uid is 0, #, otherwise $.
\NNNThe character whose ASCII code is the octal value NNN.
\A backslash.
\[Begin a sequence of non-printing characters. This could be used to embed a terminal control
sequence into the prompt.
\]End a sequence of non-printing characters.
Section 54.1: Using the PROMPT_COMMAND envrionment
variable
When the last command in an interactive bash instance is done, the evaluated PS1 variable is displayes. Before
actually displaying PS1 bash looks whether the PROMPT_COMMAND is set. This value of this var must be a callable
program or script. If this var is set this program/script is called BEFORE the PS1 prompt is displayed.
# just a stupid function, we will use to demonstrate
# we check the date if Hour is 12 and Minute is lower than 59
lunchbreak(){
if (( $(date +%H) == 12 && $(date +%M) < 59 )); then
# and print colored \033[ starts the escape sequence
# 5; is blinking attribute
# 2; means bold
# 31 says red
GoalKicker.com – Bash Notes for Professionals
164printf "\033[5;1;31mmind the lunch break\033[0m\n";
else
printf "\033[33mstill working...\033[0m\n";
fi;
}
# activating it
export PROMPT_COMMAND=lunchbreak
Section 54.2: Using PS2
PS2 is displayed when a command extends to more than one line and bash awaits more keystrokes. It is displayed
too when a compound command like while...do..done and alike is entered.
export PS2="would you please complete this command?\n"
# now enter a command extending to at least two lines to see PS2
Section 54.3: Using PS3
When the select statement is executed, it displays the given items preﬁxed with a number and then displays the
PS3 prompt:
export PS3=" To choose your language type the preceding number : "
select lang in EN CA FR DE; do
# check input here until valid.
break
done
Section 54.4: Using PS4
PS4 is displayes when bash is in debugging mode.
#!/usr/bin/env bash
# switch on debugging
set -x
# define a stupid_func
stupid_func(){
echo I am line 1 of stupid_func
echo I am line 2 of stupid_func
}
# setting the PS4 "DEBUG" prompt
export PS4='\nDEBUG level:$SHLVL subshell-level: $BASH_SUBSHELL \nsource-file:${BASH_SOURCE}
line#:${LINENO} function:${FUNCNAME[0]:+${FUNCNAME[0]}(): }\nstatement: '
# a normal statement
echo something
# function call
stupid_func
# a pipeline of commands running in a subshell
( ls -l | grep 'x' )
GoalKicker.com – Bash Notes for Professionals
165Section 54.5: Using PS1
PS1 is the normal system prompt indicating that bash waits for commands being typed in. It understands some
escape sequences and can execute functions or progams. As bash has to position the cursor after the displayes
prompt, it needs to know how to calculate the eﬀective length of the prompt string. To indicate non printing
sequences of chars within the PS1 variable escaped braces are used: \[ a non printing sequence of chars \]. All being
said holds true for all PS* vars.
(The black caret indicates cursor)
#everything not being an escape sequence will be literally printed
export PS1="literal sequence " # Prompt is now:
literal sequence ▉
# \u == user \h == host \w == actual working directory
# mind the single quotes avoiding interpretation by shell
export PS1='\u@\h:\w > ' # \u == user, \h == host, \w actual working dir
looser@host:/some/path > ▉
# executing some commands within PS1
# following line will set foreground color to red, if user==root,
# else it resets attributes to default
# $( (($EUID == 0)) && tput setaf 1)
# later we do reset attributes to default with
# $( tput sgr0 )
# assuming being root:
PS1="\[$( (($EUID == 0)) && tput setaf 1 \]\u\[$(tput sgr0)\]@\w:\w \$ "
looser@host:/some/path > ▉ # if not root else <red>root<default>@host....
GoalKicker.com – Bash Notes for Professionals
166Chapter 55: The cut command
Parameter
-f, --ﬁeldsDetails
Field-based selection
-d, --delimiterDelimiter for ﬁeld-based selection
-c, --charactersCharacter-based selection, delimiter ignored or error
-s, --only-delimited Suppress lines with no delimiter characters (printed as-is otherwise)
--complement
Inverted selection (extract all except speciﬁed ﬁelds/characters
--output-delimiter Specify when it has to be diﬀerent from the input delimiter
The cut command is a fast way to extract parts of lines of text ﬁles. It belongs to the oldest Unix commands. Its
most popular implementations are the GNU version found on Linux and the FreeBSD version found on MacOS, but
each ﬂavor of Unix has its own. See below for diﬀerences. The input lines are read either from stdin or from ﬁles
listed as arguments on the command line.
Section 55.1: Only one delimiter character
You cannot have more than one delimiter: if you specify something like -d ",;:", some implementations will use
only the ﬁrst character as a delimiter (in this case, the comma.) Other implementations (e.g. GNU cut) will give you
an error message.
$ cut -d ",;:" -f2 <<<"J.Smith,1 Main Road,cell:1234567890;land:4081234567"
cut: the delimiter must be a single character
Try `cut --help' for more information.
Section 55.2: Repeated delimiters are interpreted as empty
ﬁelds
$ cut -d, -f1,3 <<<"a,,b,c,d,e"
a,b
is rather obvious, but with space-delimited strings it might be less obvious to some
$ cut -d ' ' -f1,3 <<<"a
a b
b c d e"
cut cannot be used to parse arguments as the shell and other programs do.
Section 55.3: No quoting
There is no way to protect the delimiter. Spreadsheets and similar CSV-handling software usually can recognize a
text-quoting character which makes it possible to deﬁne strings containing a delimiter. With cut you cannot.
$ cut -d, -f3 <<<'John,Smith,"1, Main Street"'
"1
Section 55.4: Extracting, not manipulating
You can only extract portions of lines, not reorder or repeat ﬁelds.
$ cut -d, -f2,1 <<<'John,Smith,USA' ## Just like -f1,2
GoalKicker.com – Bash Notes for Professionals
167John,Smith
$ cut -d, -f2,2 <<<'John,Smith,USA' ## Just like -f2
Smith
GoalKicker.com – Bash Notes for Professionals
168Chapter 56: Bash on Windows 10
Section 56.1: Readme
The simpler way to use Bash in Windows is to install Git for Windows. It's shipped with Git Bash which is a real Bash.
You can access it with shortcut in :
Start > All Programs > Git > Git Bash
Commands like grep, ls, find, sed, vi etc is working.
GoalKicker.com – Bash Notes for Professionals
169Chapter 57: Cut Command
Option
-b LIST, --bytes=LIST
Description
Print the bytes listed in the LIST parameter
-c LIST, --characters=LIST Print characters in positions speciﬁed in LIST parameter
-f LIST, --fields=LISTPrint ﬁelds or columns
-d DELIMITERUsed to separate columns or ﬁelds
In Bash, the cut command is useful for dividing a ﬁle into several smaller parts.
Section 57.1: Show the ﬁrst column of a ﬁle
Suppose you have a ﬁle that looks like this
John Smith 31
Robert Jones 27
...
This ﬁle has 3 columns separated by spaces. To select only the ﬁrst column, do the following.
cut -d ' ' -f1 filename
Here the -d ﬂag, speciﬁes the delimiter, or what separates the records. The -f ﬂag speciﬁes the ﬁeld or column
number. This will display the following output
John
Robert
...
Section 57.2: Show columns x to y of a ﬁle
Sometimes, it's useful to display a range of columns in a ﬁle. Suppose you have this ﬁle
Apple California 2017 1.00 47
Mango Oregon 2015 2.30 33
To select the ﬁrst 3 columns do
cut -d ' ' -f1-3 filename
This will display the following output
Apple California 2017
Mango Oregon 2015
GoalKicker.com – Bash Notes for Professionals
170Chapter 58: global and local variables
By default, every variable in bash is global to every function, script and even the outside shell if you are declaring
your variables inside a script.
If you want your variable to be local to a function, you can use local to have that variable a new variable that is
independent to the global scope and whose value will only be accessible inside that function.
Section 58.1: Global variables
var="hello"
function foo(){
echo $var
}
foo
Will obviously output "hello", but this works the other way around too:
function foo() {
var="hello"
}
foo
echo $var
Will also output "hello"
Section 58.2: Local variables
function foo() {
local var
var="hello"
}
foo
echo $var
Will output nothing, as var is a variable local to the function foo, and its value is not visible from outside of it.
Section 58.3: Mixing the two together
var="hello"
function foo(){
local var="sup?"
echo "inside function, var=$var"
}
foo
echo "outside function, var=$var"
Will output
GoalKicker.com – Bash Notes for Professionals
171inside function, var=sup?
outside function, var=hello
GoalKicker.com – Bash Notes for Professionals
172Chapter 59: CGI Scripts
Section 59.1: Request Method: GET
It is quite easy to call a CGI-Script via GET.
First you will need the encoded url of the script.
Then you add a question mark ? followed by variables.
Every variable should have two sections separated by =.
First section should be always a unique name for each variable,
while the second part has values in it only
Variables are separated by &
Total length of the string should not rise above 255 characters
Names and values needs to be html-encoded (replace: </ , / ? : @ & = + $ )
Hint:
When using html-forms the request method can be generated by it self.
With Ajax you can encode all via encodeURI and encodeURIComponent
Example:
http://www.example.com/cgi-bin/script.sh?var1=Hello%20World!&var2=This%20is%20a%20Test.&
The server should communicate via Cross-Origin Resource Sharing (CORS) only, to make request more secure. In
this showcase we use CORS to determine the Data-Type we want to use.
There are many Data-Types we can choose from, the most common are...
text/html
text/plain
application/json
When sending a request, the server will also create many environment variables. For now the most important
environment variables are $REQUEST_METHOD and $QUERY_STRING.
The Request Method has to be GET nothing else!
The Query String includes all the html-endoded data.
The Script
#!/bin/bash
# CORS is the way to communicate, so lets response to the server first
echo "Content-type: text/html"
# set the data-type we want to use
echo ""
# we don't need more rules, the empty line initiate this.
# CORS are set in stone and any communication from now on will be like reading a html-document.
# Therefor we need to create any stdout in html format!
# create html scructure and send it to stdout
echo "<!DOCTYPE html>"
echo "<html><head>"
# The content will be created depending on the Request Method
if [ "$REQUEST_METHOD" = "GET" ]; then
GoalKicker.com – Bash Notes for Professionals
173# Note that the environment variables $REQUEST_METHOD and $QUERY_STRING can be processed by the
shell directly.
# One must filter the input to avoid cross site scripting.
Var1=$(echo "$QUERY_STRING" | sed -n 's/^.*var1=\([^&]*\).*$/\1/p')
# read value of "var1"
Var1_Dec=$(echo -e $(echo "$Var1" | sed 's/+/ /g;s/%\(..\)/\\x\1/g;'))
# html decode
Var2=$(echo "$QUERY_STRING" | sed -n 's/^.*var2=\([^&]*\).*$/\1/p')
Var2_Dec=$(echo -e $(echo "$Var2" | sed 's/+/ /g;s/%\(..\)/\\x\1/g;'))
# create content for stdout
echo "<title>Bash-CGI Example 1</title>"
echo "</head><body>"
echo "<h1>Bash-CGI Example 1</h1>"
echo "<p>QUERY_STRING: ${QUERY_STRING}<br>var1=${Var1_Dec}<br>var2=${Var2_Dec}</p>"
the values to stdout
# print
else
echo "<title>456 Wrong Request Method</title>"
echo "</head><body>"
echo "<h1>456</h1>"
echo "<p>Requesting data went wrong.<br>The Request method has to be \"GET\" only!</p>"
fi
echo "<hr>"
echo "$SERVER_SIGNATURE"
# an other environment variable
echo "</body></html>"
# close html
exit 0
The html-document will look like this ...
<html><head>
<title>Bash-CGI Example 1</title>
</head><body>
<h1>Bash-CGI Example 1</h1>
<p>QUERY_STRING: var1=Hello%20World!&amp;var2=This%20is%20a%20Test.&amp;<br>var1=Hello
World!<br>var2=This is a Test.</p>
<hr>
<address>Apache/2.4.10 (Debian) Server at example.com Port 80</address>
</body></html>
The output of the variables will look like this ...
var1=Hello%20World!&var2=This%20is%20a%20Test.&
Hello World!
This is a Test.
Apache/2.4.10 (Debian) Server at example.com Port 80
Negative side eﬀects...
All the encoding and decoding does not look nice, but is needed
The Request will be public readable and leave a tray behind
The size of a request is limited
GoalKicker.com – Bash Notes for Professionals
174Needs protection against Cross-Side-Scripting (XSS)
Section 59.2: Request Method: POST /w JSON
Using Request Method POST in combination with SSL makes datatransfer more secure.
In addition...
Most of the encoding and decoding is not needed any more
The URL will be visible to any one and needs to be url encoded.
The data will be send separately and therefor should be secured via SSL
The size of the data is almost unlitmited
Still needs protection against Cross-Side-Scripting (XSS)
To keep this showcase simple we want to receive JSON Data
and communication should be over Cross-Origin Resource Sharing (CORS).
The following script will also demonstrate two diﬀerent Content-Types.
#!/bin/bash
exec 2>/dev/null
# We don't want any error messages be printed to stdout
trap "response_with_html && exit 0" ERR
# response with an html message when an error occurred
and close the script
function response_with_html(){
echo "Content-type: text/html"
echo ""
echo "<!DOCTYPE html>"
echo "<html><head>"
echo "<title>456</title>"
echo "</head><body>"
echo "<h1>456</h1>"
echo "<p>Attempt to communicate with the server went wrong.</p>"
echo "<hr>"
echo "$SERVER_SIGNATURE"
echo "</body></html>"
}
function response_with_json(){
echo "Content-type: application/json"
echo ""
echo "{\"message\": \"Hello World!\"}"
}
if [ "$REQUEST_METHOD" = "POST" ]; then
# The environment variabe $CONTENT_TYPE describes the data-type received
case "$CONTENT_TYPE" in
application/json)
# The environment variabe $CONTENT_LENGTH describes the size of the data
read -n "$CONTENT_LENGTH" QUERY_STRING_POST
# read datastream
# The following lines will prevent XSS and check for valide JSON-Data.
# But these Symbols need to be encoded somehow before sending to this script
QUERY_STRING_POST=$(echo "$QUERY_STRING_POST" | sed "s/'//g" | sed
's/\$//g;s/`//g;s/\*//g;s/\\//g' )
# removes some symbols (like \ * ` $ ') to prevent XSS
with Bash and SQL.
GoalKicker.com – Bash Notes for Professionals
175QUERY_STRING_POST=$(echo "$QUERY_STRING_POST" | sed -e :a -e 's/<[^>]*>//g;/</N;//ba')
removes most html declarations to prevent XSS within documents
JSON=$(echo "$QUERY_STRING_POST" | jq .)
# json encode - This is a pretty save way
to check for valide json code
;;
*)
response_with_html
exit 0
;;
esac
#
else
response_with_html
exit 0
fi
# Some Commands ...
response_with_json
exit 0
You will get {"message":"Hello World!"} as an answer when sending JSON-Data via POST to this Script. Every
thing else will receive the html document.
Important is also the varialbe $JSON. This variable is free of XSS, but still could have wrong values in it and needs to
be verify ﬁrst. Please keep that in mind.
This code works similar without JSON.
You could get any data this way.
You just need to change the Content-Type for your needs.
Example:
if [ "$REQUEST_METHOD" = "POST" ]; then
case "$CONTENT_TYPE" in
application/x-www-form-urlencoded)
read -n "$CONTENT_LENGTH" QUERY_STRING_POST
text/plain)
read -n "$CONTENT_LENGTH" QUERY_STRING_POST
;;
esac
fi
Last but not least, don't forget to response to all requests, otherwise third party programms won't know if they
succeeded
GoalKicker.com – Bash Notes for Professionals
176Chapter 60: Select keyword
Select keyword can be used for getting input argument in a menu format.
Section 60.1: Select keyword can be used for getting input
argument in a menu format
Suppose you want the user to SELECT keywords from a menu, we can create a script similar to
#!/usr/bin/env bash
select os in "linux" "windows" "mac"
do
echo "${os}"
break
done
Explanation: Here SELECT keyword is used to loop through a list of items that will be presented at the command
prompt for a user to pick from. Notice the break keyword for breaking out of the loop once the user makes a
choice. Otherwise, the loop will be endless!
Results: Upon running this script, a menu of these items will be displayed and the user will be prompted for a
selection. Upon selection, the value will be displayed, returning back to command prompt.
>bash select_menu.sh
1) linux
2) windows
3) mac
#? 3
mac
>
GoalKicker.com – Bash Notes for Professionals
177Chapter 61: When to use eval
First and foremost: know what you're doing! Secondly, while you should avoid using eval, if its use makes for
cleaner code, go ahead.
Section 61.1: Using Eval
For example, consider the following that sets the contents of $@ to the contents of a given variable:
a=(1 2 3)
eval set -- "${a[@]}"
This code is often accompanied by getopt or getopts to set $@ to the output of the aforementioned option parsers,
however, you can also use it to create a simple pop function that can operate on variables silently and directly
without having to store the result to the original variable:
isnum()
{
# is argument an integer?
local re='^[0-9]+$'
if [[ -n $1 ]]; then
[[ $1 =~ $re ]] && return 0
return 1
else
return 2
fi
}
isvar()
{
if isnum "$1"; then
return 1
fi
local arr="$(eval eval -- echo -n "\$$1")"
if [[ -n ${arr[@]} ]]; then
return 0
fi
return 1
}
pop()
{
if [[ -z $@ ]]; then
return 1
fi
local var=
local isvar=0
local arr=()
if isvar "$1"; then # let's check to see if this is a variable or just a bare array
var="$1"
isvar=1
arr=($(eval eval -- echo -n "\${$1[@]}")) # if it is a var, get its contents
else
arr=($@)
fi
GoalKicker.com – Bash Notes for Professionals
178# we need to reverse the contents of $@ so that we can shift
# the last element into nothingness
arr=($(awk <<<"${arr[@]}" '{ for (i=NF; i>1; --i) printf("%s ",$i); print $1; }'
# set $@ to ${arr[@]} so that we can run shift against it.
eval set -- "${arr[@]}"
shift # remove the last element
# put the array back to its original order
arr=($(awk <<<"$@" '{ for (i=NF; i>1; --i) printf("%s ",$i); print $1; }'
# echo the contents for the benefit of users and for bare arrays
echo "${arr[@]}"
if ((isvar)); then
# set the contents of the original var to the new modified array
eval -- "$var=(${arr[@]})"
fi
}
Section 61.2: Using Eval with Getopt
While eval may not be needed for a pop like function, it is however required whenever you use getopt:
Consider the following function that accepts -h as an option:
f()
{
local __me__="${FUNCNAME[0]}"
local argv="$(getopt -o 'h' -n $__me__ -- "$@")"
eval set -- "$argv"
while :; do
case "$1" in
-h)
echo "LOLOLOLOL"
return 0
;;
--)
shift
break
;;
done
echo "$@"
}
Without eval set -- "$argv" generates
-h --
instead of the desired (-h --) and subsequently enters an inﬁnite loop because
-h --
doesn't match -- or -h.
GoalKicker.com – Bash Notes for Professionals
179Chapter 62: Networking With Bash
Bash is often commonly used in the management and maintenance of servers and clusters. Information pertaining
to typical commands used by network operations, when to use which command for which purpose, and
examples/samples of unique and/or interesting applications of it should be included
Section 62.1: Networking commands
ifconfig
The above command will show all active interface of the machine and also give the information of
1. IP address assign to interface
2. MAC address of the interface
3. Broadcast address
4. Transmit and Receive bytes
Some example
ifconfig -a
The above command also show the disable interface
ifconfig eth0
The above command will only show the eth0 interface
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
The above command will assign the static IP to eth0 interface
ifup eth0
The above command will enable the eth0 interface
ifdown eth0
The below command will disable the eth0 interface
ping
The above command (Packet Internet Grouper) is to test the connectivity between the two nodes
ping -c2 8.8.8.8
The above command will ping or test the connectivity with google server for 2 seconds.
traceroute
The above command is to use in troubleshooting to ﬁnd out the number of hops taken to reach the destination.
netstat
GoalKicker.com – Bash Notes for Professionals
180The above command (Network statistics) give the connection info and their state
dig www.google.com
The above command (domain information grouper) query the DNS related information
nslookup www.google.com
The above command query the DNS and ﬁnd out the IP address of corresponding the website name.
route
The above command is used to check the Netwrok route information. It basically show you the routing table
router add default gw 192.168.1.1 eth0
The above command will add the default route of network of eth0 Interface to 192.168.1.1 in routing table.
route del default
The above command will delete the default route from the routing table
GoalKicker.com – Bash Notes for Professionals
181Chapter 63: Parallel
Option
Description
-j nRun n jobs in parallel
-kKeep same order
-XMultiple arguments with context replace
--colsep regexpSplit input on regexp for positional replacements
{} {.} {/} {/.} {#} Replacement strings
{3} {3.} {3/} {3/.} Positional replacement strings
-S sshloginExample: foo@server.example.com
--trc {}.barShorthand for --transfer --return {}.bar --cleanup
--onallRun the given command with argument on all sshlogins
--nonallRun the given command with no arguments on all sshlogins
--pipeSplit stdin (standard input) to multiple jobs.
--recend strRecord end separator for --pipe.
--recstart strRecord start separator for --pipe.
Jobs in GNU Linux can be parallelized using GNU parallel. A job can be a single command or a small script that has
to be run for each of the lines in the input. The typical input is a list of ﬁles, a list of hosts, a list of users, a list of
URLs, or a list of tables. A job can also be a command that reads from a pipe.
Section 63.1: Parallelize repetitive tasks on list of ﬁles
Many repetitive jobs can be performed more eﬃciently if you utilize more of your computer's resources (i.e. CPU's
and RAM). Below is an example of running multiple jobs in parallel.
Suppose you have a < list of files >, say output from ls. Also, let these ﬁles are bz2 compressed and the
following order of tasks need to be operated on them.
1. Decompress the bz2 ﬁles using bzcat to stdout
2. Grep (e.g. ﬁlter) lines with speciﬁc keyword(s) using grep <some key word>
3. Pipe the output to be concatenated into one single gzipped ﬁle using gzip
Running this using a while-loop may look like this
filenames="file_list.txt"
while read -r line
do
name="$line"
## grab lines with puppies in them
bzcat $line | grep puppies | gzip >> output.gz
done < "$filenames"
Using GNU Parallel, we can run 3 parallel jobs at once by simply doing
parallel -j 3 "bzcat {} | grep puppies" ::: $( cat filelist.txt ) | gzip > output.gz
This command is simple, concise and more eﬃcient when number of ﬁles and ﬁle size is large. The jobs gets
initiated by parallel, option -j 3 launches 3 parallel jobs and input to the parallel jobs is taken in by :::. The
output is eventually piped to gzip > output.gz
GoalKicker.com – Bash Notes for Professionals
182Section 63.2: Parallelize STDIN
Now, let's imagine we have 1 large ﬁle (e.g. 30 GB) that needs to be converted, line by line. Say we have a script,
convert.sh, that does this <task>. We can pipe contents of this ﬁle to stdin for parallel to take in and work with in
chunks such as
<stdin> | parallel --pipe --block <block size> -k <task> > output.txt
where <stdin> can originate from anything such as cat <file>.
As a reproducible example, our task will be nl -n rz. Take any ﬁle, mine will be data.bz2, and pass it to <stdin>
bzcat data.bz2 | nl | parallel --pipe --block 10M -k nl -n rz | gzip > ouptput.gz
The above example takes <stdin> from bzcat data.bz2 | nl, where I included nl just as a proof of concept that
the ﬁnal output output.gz will be saved in the order it was received. Then, parallel divides the <stdin> into
chunks of size 10 MB, and for each chunk it passes it through nl -n rz where it just appends a numbers rightly
justiﬁed (see nl --help for further details). The options --pipe tells parallel to split <stdin> into multiple jobs
and -- block speciﬁes the size of the blocks. The option -k speciﬁes that ordering must be maintained.
Your ﬁnal output should look something like
000001
000002
000003
000004
000005
...
000587
000588
000589
000590
000591
1
2
3
4
5<data>
<data>
<data>
<data>
<data>
552409
552410
552411
552412
552413<data>
<data>
<data>
<data>
<data>
My original ﬁle had 552,413 lines. The ﬁrst column represents the parallel jobs, and the second column represents
the original line numbering that was passed to parallel in chunks. You should notice that the order in the second
column (and rest of the ﬁle) is maintained.
GoalKicker.com – Bash Notes for Professionals
183Chapter 64: Decoding URL
Section 64.1: Simple example
Encoded URL
http%3A%2F%2Fwww.foo.com%2Findex.php%3Fid%3Dqwerty
Use this command to decode the URL
echo "http%3A%2F%2Fwww.foo.com%2Findex.php%3Fid%3Dqwerty" | sed -e "s/%\([0-9A-F][0-9A-
F]\)/\\\\\x\1/g" | xargs -0 echo -e
Decoded URL (result of command)
http://www.foo.com/index.php?id=qwerty
Section 64.2: Using printf to decode a string
#!bin/bash
$ string='Question%20-
%20%22how%20do%20I%20decode%20a%20percent%20encoded%20string%3F%22%0AAnswer%20%20%20-
%20Use%20printf%20%3A)'
$ printf '%b\n' "${string//%/\\x}"
# the result
Question - "how do I decode a percent encoded string?"
Answer
- Use printf :)
GoalKicker.com – Bash Notes for Professionals
184Chapter 65: Design Patterns
Accomplish some common design patterns in Bash
Section 65.1: The Publish/Subscribe (Pub/Sub) Pattern
When a Bash project turns into a library, it can become diﬃcult to add new functionality. Function names, variables
and parameters usually need to be changed in the scripts that utilize them. In scenarios like this, it is helpful to
decouple the code and use an event driven design pattern. In said pattern, an external script can subscribe to an
event. When that event is triggered (published) the script can execute the code that it registered with the event.
pubsub.sh:
#!/usr/bin/env bash
#
# Save the path to this script's directory in a global env variable
#
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#
# Array that will contain all registered events
#
EVENTS=()
function action1() {
echo "Action #1 was performed ${2}"
}
function action2() {
echo "Action #2 was performed"
}
#
# @desc
:: Registers an event
# @param :: string $1 - The name of the event. Basically an alias for a function name
# @param :: string $2 - The name of the function to be called
# @param :: string $3 - Full path to script that includes the function being called
#
function subscribe() {
EVENTS+=("${1};${2};${3}")
}
#
# @desc
:: Public an event
# @param :: string $1 - The name of the event being published
#
function publish() {
for event in ${EVENTS[@]}; do
local IFS=";"
read -r -a event <<< "$event"
if [[ "${event[0]}" == "${1}" ]]; then
${event[1]} "$@"
fi
done
}
#
# Register our events and the functions that handle them
GoalKicker.com – Bash Notes for Professionals
185#
subscribe "/do/work"
"action1" "${DIR}"
subscribe "/do/more/work"
"action2" "${DIR}"
subscribe "/do/even/more/work" "action1" "${DIR}"
#
# Execute our events
#
publish "/do/work"
publish "/do/more/work"
publish "/do/even/more/work" "again"
Run:
chmod +x pubsub.sh
./pubsub.sh
GoalKicker.com – Bash Notes for Professionals
186Chapter 66: Pitfalls
Section 66.1: Whitespace When Assigning Variables
Whitespace matters when assigning variables.
foo = 'bar' # incorrect
foo= 'bar' # incorrect
foo='bar'
# correct
The ﬁrst two will result in syntax errors (or worse, executing an incorrect command). The last example will correctly
set the variable $foo to the text "bar".
Section 66.2: Failed commands do not stop script execution
In most scripting languages, if a function call fails, it may throw an exception and stop execution of the program.
Bash commands do not have exceptions, but they do have exit codes. A non-zero exit code signals failure, however,
a non-zero exit code will not stop execution of the program.
This can lead to dangerous (although admittedly contrived) situations like so:
#!/bin/bash
cd ~/non/existent/directory
rm -rf *
If cd-ing to this directory fails, Bash will ignore the failure and move onto the next command, wiping clean the
directory from where you ran the script.
The best way to deal with this problem is to make use of the set command:
#!/bin/bash
set -e
cd ~/non/existent/directory
rm -rf *
set -e tells Bash to exit the script immediately if any command returns a non-zero status.
Section 66.3: Missing The Last Line in a File
The C standard says that ﬁles should end with a new line, so if EOF comes at the end of a line, that line may not be
missed by some commands. As an example:
$ echo 'one\ntwo\nthree\c' > file.txt
$ cat file.txt
one
two
three
$ while read line ; do echo "line $line" ; done < file.txt
one
two
To make sure this works correctly for in the above example, add a test so that it will continue the loop if the last line
is not empty.
GoalKicker.com – Bash Notes for Professionals
187$ while read line || [ -n "$line" ] ; do echo "line $line" ; done < file.txt
one
two
three
GoalKicker.com – Bash Notes for Professionals
188Appendix A: Keyboard shortcuts
Section A.1: Editing Shortcuts
Shortcut
Ctrl + amove to the beginning of the line
Description
Ctrl + emove to the end of the line
Ctrl + kKill the text from the current cursor position to the end of the line.
Ctrl + uKill the text from the current cursor position to the beginning of the line
Ctrl + wKill the word behind the current cursor position
Alt + bmove backward one word
Alt + fmove forward one word
Ctrl + Alt + eshell expand line
Ctrl + yYank the most recently killed text back into the buﬀer at the cursor.
Alt + yRotate through killed text. You can only do this if the prior command is Ctrl + y or
Alt + y .
Killing text will delete text, but save it so that the user can reinsert it by yanking. Similar to cut and paste except that
the text is placed on a kill ring which allows for storing more than one set of text to be yanked back on to the
command line.
You can ﬁnd out more in the emacs manual.
Section A.2: Recall Shortcuts
Shortcut
Ctrl + rsearch the history backwards
Description
Ctrl + pprevious command in history
Ctrl + nnext command in history
Ctrl + gquit history searching mode
Alt + .use the last word of the previous command
repeat to get the last word of the previous + 1 command
Alt + n
Alt + .
!! + Return
use the nth word of the previous command
execute the last command again (useful when you forgot sudo: sudo !!)
Section A.3: Macros
Shortcut
Ctrl + x , (Description
start recording a macro
Ctrl + x , )stop recording a macro
Ctrl + x , eexecute the last recorded macro
Section A.4: Custome Key Bindings
With the bind command it is possible to deﬁne custom key bindings.
The next example bind an Alt + w to >/dev/null 2>&1:
bind '"\ew"':"\" >/dev/null 2>&1\""
GoalKicker.com – Bash Notes for Professionals
189If you want to execute the line immediately add \C-m ( Enter ) to it:
bind '"\ew"':"\" >/dev/null 2>&1\C-m\""
Section A.5: Job Control
Shortcut
Ctrl + cDescription
Stop the current job
Ctrl + zSuspend the current job (send a SIGTSTP signal)
GoalKicker.com – Bash Notes for Professionals
190Credits
Thank you greatly to all the people from Stack Overﬂow Documentation who helped provide this content,
more changes can be sent to web@petercv.com for new content to be published or updated
Ajay Sangale
Ajinkya
Alessandro Mascolo
Alexej Magura
Amir Rachum
Anil
anishsane
Antoine Bolvy
Archemar
Arronical
Ashari
Ashkan
Batsu
Benjamin W.
binki
Blachshma
Bob Bagwill
Bostjan
BrunoLM
Brydon Gibson
Bubblepop
Burkhard
BurnsBA
Carpetsmoker
cb0
Chandrahas Aroori
chaos
charneykaye
chepner
Chris Rasys
Christopher Bottoms
codeforester
Cody
Colin Yang
Cows quack
CraftedCart
CrazyMax
criw
Daniel Käfer
Danny
Dario
David Grayson
Deepak K M
deepmax
depperm
dhimanta
dimo414
Chapter 1
Chapter 20
Chapters 11 and 26
Chapters 9, 12, 36 and 61
Chapter 8
Chapter 1
Chapter 5
Chapter 9
Chapter 9
Chapter 12
Chapter 36
Chapters 36 and 43
Chapter 17
Chapters 1, 9, 12, 15, 24, 31, 36, 46 and 47
Chapter 21
Chapter 1
Chapter 1
Chapter 7
Chapter 14
Chapter 9
Chapters 1, 5, 8, 12 and 24
Chapter 1
Chapter 22
Chapter 47
Chapter 28
Chapter 6
Chapter 9
Chapter 50
Chapters 15, 27 and 46
Chapter 34
Chapters 1, 3 and 5
Chapter 12
Chapter 66
Chapter 1
Chapter 30
Chapter 1
Chapter 64
Chapter 36
Chapter 67
Chapter 1
Chapters 28, 36 and 55
Chapter 9
Chapter 20
Chapter 25
Chapters 4 and 35
Chapter 62
Chapter 14
GoalKicker.com – Bash Notes for Professionals
191dingalapadum
divyum
DocSalvager
Doctor J
DonyorM
Dr Beco
Dunatotatos
Echoes_86
Edgar Rokjān
edi9999
Eric Renouf
fedorqui
ﬁfaltra
Flows
Gavyn
George Vasiliou
Gilles
glenn jackman
Grexis
Grisha Levit
gzh
hedgar2017
Holt Johnson
I0_ol
Iain
IamaTacos
Inanc Gumus
Inian
intboolstring
Jahid
James Taylor
Jamie Metzger
jandob
janos
Jeﬀrey Lin
JepZ
jerblack
Jesse Chen
JHS
jimsug
John Kugelman
Jon
Jon Ericson
Jonny Henly
jordi
Judd Rogers
Kelum Senanayake
ksoni
leftaroundabout
Leo Uﬁmtsev
liborm
lynxlynxlynx
m02ph3u5
Chapters 7 and 16
Chapters 1 and 14
Chapter 10
Chapter 28
Chapter 10
Chapter 36
Chapter 51
Chapter 17
Chapter 10
Chapter 14
Chapter 9
Chapters 12, 15, 17, 20, 28 and 34
Chapters 8 and 53
Chapter 18
Chapters 9, 26, 33 and 36
Chapters 9, 15 and 58
Chapters 21 and 22
Chapters 1, 4, 5 and 7
Chapter 15
Chapter 36
Chapter 10
Chapters 9, 15 and 22
Chapter 4
Chapter 64
Chapters 4 and 20
Chapter 35
Chapter 1
Chapters 17 and 28
Chapters 4, 5 and 7
Chapters 1, 5, 9, 10, 12, 14, 15, 17, 20, 21, 22, 23, 30, 34, 39, 43, 44 and 45
Chapter 23
Chapter 31
Chapter 29
Chapters 7, 10, 12, 14, 20 and 24
Chapter 49
Chapter 3
Chapter 12
Chapters 15, 26 and 45
Chapters 7, 19 and 67
Chapter 24
Chapter 12
Chapter 63
Chapter 9
Chapter 4
Chapter 48
Chapters 9 and 67
Chapter 23
Chapter 30
Chapter 17
Chapter 33
Chapter 9
Chapter 43
Chapter 67
GoalKicker.com – Bash Notes for Professionals
192markjwill
Markus V.
Mateusz Piotrowski
Matt Clark
mattmc
Michael Le Barbier
Grünewald
Mike Metzger
miken32
Misa Lazovic
Mohima Chaudhuri
nautical
NeilWang
Neui
Ocab19
ormaaj
Osaka
P.P.
Pavel Kazhevets
Peter Uhnak
phs
Pooyan Khosravi
Rafa Moyano
Reboot
Riccardo Petraglia
Richard Hamilton
Riker
Roman Piták
Root
Sameer Srivastava
Samik
Samuel
Saqib Rokadia
satyanarayan rao
Scroﬀ
Sergey
sjsam
Sk606
Skynet
SLePort
Stephane Chazelas
Stobor
suleiman
Sundeep
Sylvain Bugat
Thomas Champion
Tim Rijavec
TomOnTime
Trevor Clarke
tripleee
tversteeg
uhelp
UNagaswamy
Chapter 12
Chapter 4
Chapter 12
Chapters 1, 9, 14, 17, 19 and 23
Chapters 36 and 65
Chapter 14
Chapter 8
Chapters 9 and 10
Chapters 4 and 30
Chapters 18 and 41
Chapter 34
Chapter 12
Chapter 8
Chapter 58
Chapter 12
Chapter 4
Chapter 38
Chapter 25
Chapter 31
Chapter 47
Chapter 9
Chapter 42
Chapter 42
Chapter 8
Chapters 4, 16, 41 and 57
Chapters 1 and 40
Chapter 47
Chapters 5, 8 and 9
Chapter 8
Chapters 4, 5, 10, 12, 14 and 37
Chapter 5
Chapter 67
Chapter 1
Chapter 66
Chapter 14
Chapters 1 and 32
Chapters 8, 12 and 33
Chapter 45
Chapters 5 and 10
Chapters 15 and 36
Chapter 20
Chapter 59
Chapter 1
Chapters 2, 4, 9, 14 and 15
Chapter 56
Chapter 25
Chapter 47
Chapter 1
Chapters 1, 5, 14, 17 and 36
Chapter 30
Chapters 2, 7, 13, 20, 31, 36, 47, 48, 52, 53 and 54
Chapters 12, 13 and 60
GoalKicker.com – Bash Notes for Professionals
193user1336087
vielmetti
vmaroli
Warren Harper
Wenzhong
Will
Will Barnwell
William Pursell
Wojciech Kazior
Wolfgang
xhienne
ymbirtt
zarak
Zaz
Мона_Сах
南山竹
Chapters 1 and 26
Chapter 5
Chapter 39
Chapter 9
Chapter 30
Chapters 12, 15 and 21
Chapter 24
Chapters 1, 36 and 49
Chapter 36
Chapter 9
Chapter 5
Chapter 15
Chapters 8, 24 and 31
Chapter 1
Chapter 28
Chapters 1, 5, 9, 12 and 17
GoalKicker.com – Bash Notes for Professionals
194You may also like


