精华内容
下载资源
问答
  • R语言笔记一

    万次阅读 多人点赞 2016-06-19 21:44:10
    BUT: The one exception is a list, which is represented as a vector but can contain objects of different classes (indeed, that’s usually why we use them) Empty vectors can be created with the ...

    常用函数

    object.size() ##查询数据大小
    names() ##查询数据变量名称
    head(x, 10) ,tail(x, 10) ##查询数据前/后10行
    summary() ##对数据集的详细统计呈现
    table(x$y) ##对y值出现次数统计
    str() ##查询数据集/函数的详细结构
    nrow(),ncol() ##查询行列数
    sqrt(x) ##square root取x的平方根
    abs(x) ##absolute value取x的绝对值
    names(vect2)<-c(“foo”,”bar”,”norf”) ##给向量命名
    identical(vect,vect2) ##TRUE 检查两个向量是否一样
    vect[c(“foo”,”bar”)] ##用名字选取向量
    colnames(my_data)<-cnames ##修改数据框的列名
    t() ##互换数据框的行列
    length(“”)统计字符数,空字符时计数为1
    nchar(“”)统计字符数,空字符时计数为0
    tolower()将字符转换为小写
    toupper()将字符转换为大写
    chartr(“A”,”B”,x):字符串x中使用B替换A
    na.omit(),移除所有含有缺失值的观测(行删除,listwise deletion)
    paste()

    paste("Var",1:5,sep="")
    [1] "Var1" "Var2" "Var3" "Var4" "Var5"
    
    > x<-list(a='aaa',b='bbb',c="ccc")
    > y<-list(d="163.com",e="qq.com")
    > paste(x,y,sep="@")
    [1] "aaa@163.com" "bbb@qq.com"  "ccc@163.com"
    
    #增加collapse参数,设置分隔符
    > paste(x,y,sep="@",collapse=';')
    [1] "aaa@163.com;bbb@qq.com;ccc@163.com"
    > paste(x,collapse=';')
    [1] "aaa;bbb;ccc"
    

    strsplit()字符串拆分

    strsplit(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE)
    x为需要拆分的字串向量
    split为拆分位置的字串向量,默认为正则表达式匹配(fixed=FALSE),
    设置fixed=TRUE,表示使用普通文本匹配或正则表达式的精确匹配。普通文本的运算速度快
    perl=TRUE/FALSE的设置和perl语言版本有关,如果正则表达式很长,正确设置表达式并且使用perl=TRUE可以提高运算速度。
    useBytes设置是否逐个字节进行匹配,默认为FALSE,即按字符而不是字节进行匹配。
    strsplit得到的结果是列表,后面要怎么处理就得看情况而定了
    

    字符串替换:sub(),gsub()

    严格地说R语言没有字符串替换的函数
    R语言对参数都是传值不传址
    sub和gsub的区别是前者只做一次替换,gsub把满足条件的匹配都做替换
    > text<-c("Hello, Adam","Hi,Adam!","How are you,Ava")
    > sub(pattern="Adam",replacement="word",text)
    [1] "Hello, word"     "Hi,word!"        "How are you,Ava"
    > sub(pattern="Adam|Ava",replacement="word",text)
    [1] "Hello, word"      "Hi,word!"         "How are you,word"
    > gsub(pattern="Adam|Ava",replacement="word",text)
    [1] "Hello, word"      "Hi,word!"         "How are you,word"
    

    字符串提取substr(), substring()

    substr和substring函数通过位置进行字符串拆分或提取,它们本身并不使用正则表达式
    结合正则表达式函数regexpr、gregexpr或regexec使用可以非常方便地从大量文本中提取所需信息
    语法格式
    substr(x, start, stop) 
    substring(text, first, last = 1000000L)
    第 1个参数均为要拆分的字串向量,第2个参数为截取的起始位置向量,第3个参数为截取字串的终止位置向量
    substr返回的字串个数等于第一个参数的长度
    substring返回字串个数等于三个参数中最长向量长度,短向量循环使用
    > x <- "123456789" 
    > substr(x, c(2,4), c(4,5,8)) 
    [1] "234" 
    > substring(x, c(2,4), c(4,5,8)) 
    [1] "234"     "45"      "2345678"
    因为x的向量长度为1,substr获得的结果只有1个字串,
    即第2和第3个参数向量只用了第一个组合:起始位置2,终止位置4。
    substring的语句三个参数中最长的向量为c(4,5,8),执行时按短向量循环使用的规则第一个参数事实上就是c(x,x,x),
    第二个参数就成了c(2,4,2),最终截取的字串起始位置组合为:2-4, 4-5和2-8。
    

    Workspace and Files

    ls() ##查询工作区对象
    list.files(), dir() ##列出工作目录所有文件
    dir.create(“testdir”) ##创建testdir目录
    file.create(“mytest.R”) ##创建mytest.R文件
    file.exists(“mytest.R”) ##查询文件是否存在
    file.info(“mytest.R”) , file.info(“mytest.R”)$mode ##查询文件包含信息,或特定信息
    file.rename(“mytest.R”,”mytest2.R”) ##重命名为mytest2.R
    file.remove(“mytest.R”) ##删文件
    file.copy(“mytest2.R”,”mytest3.R”) ##复制为mytest3.R文件
    file.path(“mytest3.R”) ##在众多工作文件中,指定提供某个文件的相对路径。
    file.path(“folder1”,”folder2”) ##”folder1/folder2”也能创建独立于系统的路径供R工作。?

    Create a directory in the current working directory called “testdir2” and a subdirectory for it called “testdir3”, all in one command by using dir.create() and file.path().

     dir.create(file.path('testdir2','testdir3'),recursive = TRUE)
    
     unlink("testdir2", recursive = TRUE)    ##删除目录及所有(没有recursive=T,R会阻止)。名称源于unix命令。
    setwd('testdir')     ##设testdir目录,为工作目录
    > old.dir <- getwd()
    args()  ##查询函数参数构成
    sample(x) ##也可以对x重新排序
    > sample(1:6, 4, replace = TRUE)
    [1] 4 5 1 3
    
    >flips <- sample(c(0,1),100,replace = TRUE, prob = c(0.3,0.7)) #prob设定0和1出现的概率
    
    > flips
      [1] 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1
     [47] 1 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1
     [93] 1 1 1 1 1 0 1 1
    

    Sequence of Numbers

    > 1:10
     [1]  1  2  3  4  5  6  7  8  9 10
    
    >pi:10   ##real numbers 实数
    [1] 3.141593 4.141593 5.141593 6.141593 7.141593 8.141593 9.141593
    

    ?‘:’查询操作符号:

    > seq(1,10)
     [1]  1  2  3  4  5  6  7  8  9 10
    
    > seq(0, 10, by=0.5)
     [1]  0.0  0.5  1.0  1.5  2.0  2.5  3.0  3.5  4.0  4.5  5.0  5.5  6.0  6.5  7.0  7.5  8.0  8.5
    [19]  9.0  9.5 10.0
    
    >my_seq<- seq(5,10,length=30)  ##在区间(5, 10)等距生成30个数
    > 1:length(my_seq)
     [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
    > seq(along.with = my_seq)
     [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
    
    > seq_along(my_seq)  **
     [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
    
    >rep(c(0,1,2),times=10)
     [1] 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2
    >rep(c(0,1,2),each=10)
     [1] 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2
    

    Vector

    > paste(1:3,c("X", "Y", "Z"),sep="")
    [1] "1X" "2Y" "3Z"
    

    * Vector recycling!*

    > paste(LETTERS, 1:4, sep = "-")
     [1] "A-1" "B-2" "C-3" "D-4" "E-1" "F-2" "G-3" "H-4" "I-1" "J-2" "K-3" "L-4" "M-1" "N-2" "O-3"
    [16] "P-4" "Q-1" "R-2" "S-3" "T-4" "U-1" "V-2" "W-3" "X-4" "Y-1" "Z-2"
    

    数据类型

    对象与属性 Objects and Attributes

    Objects

    R has five basic or “atomic” classes of objects:

    • character
    • numeric (real numbers)
    • integer
    • complex
    • logical (True/False)

    The most basic object is a vector

    • A vector can only contain objects of the same class
    • BUT: The one exception is a list, which is represented as a vector but can contain objects of different classes (indeed, that’s usually why we use them)

    Empty vectors can be created with the vector() function.

    Numbers

    • Numbers in R a generally treated as numeric objects (i.e. double precision real numbers)
    • If you explicitly want an integer, you need to specify the L suffix
    • Ex: Entering *1* gives you a numeric object; entering *1L* explicitly gives you an integer **
    • There is also a special number *Inf* which represents infinity; e.g. 1 / 0; Inf can be used in ordinary calculations; e.g. 1 / Inf is 0
    • The value *NaN* represents an undefined value (“not a number”); e.g. 0 / 0; *NaN* can also be thought of as a missing value (more on that later)

    Attributes

    R objects can have attributes

    • names, dimnames
    • dimensions (e.g. matrices, arrays)
    • class
    • length
    • other user-defined attributes/metadata
      Attributes of an object can be accessed using the attributes() function

    向量与列表 Vectors and Lists

    Creating Vectors

    The c() function can be used to create vectors of objects.

    > x <- c(0.5, 0.6) ## numeric
    > x <- c(TRUE, FALSE) ## logical
    > x <- c(T, F) ## logical
    > x <- c("a", "b", "c") ## character
    > x <- 9:29 ## integer
    > x <- c(1+0i, 2+4i) ## complex
    

    Using the vector() function

    > x <- vector("numeric", length = 10)
    > x
     [1] 0 0 0 0 0 0 0 0 0 0
    

    Mixing Objects

    When different objects are mixed in a vector, coercion occurs so that every element in the vector is of the same class.

    > y <- c(1.7, "a") ## character
    > y <- c(TRUE, 2) ## numeric
    > y <- c("a", TRUE) ## character
    

    Explicit Coercion 强制明确

    Objects can be explicitly coerced from one class to another using the as.* functions, if available.

    > x <- 0:6
    > class(x)
    [1] "integer"
    > as.numeric(x)
    [1] 0 1 2 3 4 5 6
    > as.logical(x)
    [1] FALSE TRUE TRUE TRUE TRUE TRUE TRUE
    > as.character(x)
    [1] "0" "1" "2" "3" "4" "5" "6"
    

    Nonsensical coercion results in NAs

    > x <- c("a", "b", "c")
    > as.numeric(x)
    [1] NA NA NA
    Warning message:
    NAs introduced by coercion
    > as.logical(x)
    [1] NA NA NA
    > as.complex(x)
    [1] NA NA NA
    Warning message:
    NAs introduced by coercion 
    

    Lists

    Lists are a special type of vector that can contain elements of different classes. Lists are a very important data type in R and you should get to know them well.

    > x <- list(1, "a", TRUE, 1 + 4i)
    > x
    [[1]]
    [1] 1
    [[2]]
    [1] "a"
    [[3]]
    [1] TRUE
    [[4]]
    [1] 1+4i
    

    矩阵 Matrices

    Matrices

    Matrices are vectors with a dimension attribute. The dimension attribute is itself an integer vector of length 2 (nrow, ncol)

    > m <- matrix(nrow = 2, ncol = 3)
    > m
     [,1] [,2] [,3]
    [1,] NA NA NA
    [2,] NA NA NA
    > dim(m)
    [1] 2 3
    > attributes(m) **
    $dim
    [1] 2 3
    

    Matrices (cont’d)

    Matrices are constructed column-wise, so entries can be thought of starting in the “upper left” corner and running down the columns.

    > m <- matrix(1:6, nrow = 2, ncol = 3)
    > m
     [,1] [,2] [,3]
    [1,] 1 3 5
    [2,] 2 4 6
    

    Matrices can also be created directly from vectors by adding a dimension attribute.**

    > m <- 1:10
    > m
    [1] 1 2 3 4 5 6 7 8 9 10
    > dim(m) <- c(2, 5)  **
    > m
     [,1] [,2] [,3] [,4] [,5]
    [1,] 1 3 5 7 9
    [2,] 2 4 6 8 10
    

    cbind-ing and rbind-ing

    Matrices can be created by column-binding or row-binding with cbind() and rbind().

    > x <- 1:3
    > y <- 10:12
    > cbind(x, y)
     x y
    [1,] 1 10
    [2,] 2 11
    [3,] 3 12
    > rbind(x, y)
     [,1] [,2] [,3]
    x 1 2 3
    y 10 11 12
    

    因子 Factors

    Factors are used to represent categorical data. Factors can be unordered or ordered. One can think of a factor as an integer vector where each integer has a label.

    • Factors are treated specially by modelling functions like *lm()* and *glm()*
    • Using factors with labels is *better* than using integers because factors are self-describing; having a variable that has values “Male” and “Female” is better than a variable that has values 1 and 2.

       x <- factor(c("yes", "yes", "no", "yes", "no"))
       x
      [1] yes yes no yes no
      Levels: no yes
       table(x)
      x
      no yes
      2 3
       unclass(x)
      [1] 2 2 1 2 1
      attr(,"levels")
      [1] "no" "yes"
      

    The order of the levels can be set using the levels argument to factor(). This can be important in linear modelling because the first level is used as the baseline level.

    > x <- factor(c("yes", "yes", "no", "yes", "no"),
     levels = c("yes", "no")) **
    > x
    [1] yes yes no yes no
    Levels: yes no
    

    缺失值 Missing Values

    Missing values are denoted by NA or NaN for undefined mathematical operations.

    • is.na() is used to test objects if they are NA
    • is.nan() is used to test for NaN
    • NA values have a class also, so there are integer NA, character NA, etc
    • A NaN value is also NA but the converse is not true

      > x <- c(1, 2, NA, 10, 3)
      > is.na(x)
      [1] FALSE FALSE TRUE FALSE FALSE
      > is.nan(x)
      [1] FALSE FALSE FALSE FALSE FALSE
      > x <- c(1, 2, NaN, NA, 4)
      > is.na(x)
      [1] FALSE FALSE TRUE TRUE FALSE
      > is.nan(x)
      [1] FALSE FALSE TRUE FALSE FALSE
      

    数据框 Data Frames

    Data frames are used to store tabular data (表格数据)

    • They are represented as a special type of list where every element of the list has to have the same length
    • Each element of the list can be thought of as a column and the length of each element of the list is the number of rows
    • Unlike matrices, data frames can store different classes of objects in each column (just like lists); matrices must have every element be the same class
    • Data frames also have a special attribute called *row.names*
    • Data frames are usually created by calling *read.table()* or *read.csv()*
    • Can be converted to a matrix by calling *data.matrix()* *

      > x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
      > x
       foo bar
      1 1 TRUE
      2 2 TRUE
      3 3 FALSE
      4 4 FALSE
      > nrow(x)
      [1] 4
      > ncol(x)
      [1] 2
      

    Names Attribute 名字属性

    Names

    R objects can also have names, which is very useful for writing readable code and self-describing objects.

    > x <- 1:3
    > names(x)
    NULL
    > names(x) <- c("foo", "bar", "norf")
    > x
    foo bar norf
     1 2 3
    > names(x)
    [1] "foo" "bar" "norf"
    

    Lists can also have names.

    > x <- list(a = 1, b = 2, c = 3)
    > x
    $a
    [1] 1
    $b
    [1] 2
    $c
    [1] 3
    

    And matrices.

    > m <- matrix(1:4, nrow = 2, ncol = 2)
    > dimnames(m) <- list(c("a", "b"), c("c", "d")) ***
    > m
     c d
    a 1 3
    b 2 4
    

    Summary

    Data Types

    • atomic classes: numeric, logical, character, integer, complex \
    • vectors, lists
    • factors
    • missing values
    • data frames
    • names

    Reading Writing Data

    Reading Data

    There are a few principal functions reading data into R.

    • *read.table()*, *read.csv()*, for reading tabular data
    • *readLines()*, for reading lines of a text file
    • *source()*, for reading in R code files (inverse of dump)**
    • *dget()*, for reading in R code files (inverse of dput)**
    • *load()*, for reading in saved workspaces
    • *unserialize()*, for reading single R objects in binary form

    Writing Data

    There are analogous functions for writing data to files.

    • write.table()
    • writeLines()
    • dump()
    • dput()
    • save()
    • serialize()

    Reading Data Files with read.table *

    The read.table function is one of the most commonly used functions for reading data. It has a few important arguments:

    • *file*, the name of a file, or a connection
    • *header*, logical indicating if the file has a header line
    • *sep*, a string indicating how the columns are separated
    • *colClasses*, a character vector indicating the class of each column in the dataset
    • *nrows*, the number of rows in the dataset
    • *comment.char()*, a character string indicating the comment character
    • *skip*, the number of lines to skip from the beginning
    • *stringsAsFactors*, should character variables be coded as factors?

    read.table
    For small to moderately sized datasets, you can usually call read.table without specifying any other arguments.

    data <- read.table("foo.txt")

    R will automatically

    • skip lines that begin with a #
    • figure out how many rows there are (and how much memory needs to be allocated
    • figure what type of variable is in each column of the table Telling R all these things directly makes R run faster and more efficiently.
    • *read.csv* is identical to *read.table* except that the default separator is a comma.

    Reading in Larger Datasets with read.table

    With much larger datasets, doing the following things will make your life easier and will prevent R from choking.

    • Read the help page for read.table, which contains many hints
    • Make a rough calculation of the memory required to store your dataset. If the dataset is larger than the amount of RAM on your computer, you can probably stop right here.
    • Set comment.char = "" if there are no commented lines in your file. **
    • Use the *colClasses* argument. Specifying this option instead of using the default can make ’read.table’ run MUCH faster, often twice as fast. In order to use this option, you have to know the class of each column in your data frame. If all of the columns are “numeric”, for example, then you can just set *colClasses = "numeric"*. A quick an dirty way to figure out the classes of each column is the following:
    initial <- read.table("datatable.txt", nrows = 100) ***
    classes <- sapply(initial, class)
    tabAll <- read.table("datatable.txt",
                          colClasses = classes)
    • Set *nrows*. This doesn’t make R run faster but it helps with memory usage. A mild overestimate is okay. You can use the Unix tool *wc* to calculate the number of lines in a file.

    Know Thy System

    In general, when using R with larger datasets, it’s useful to know a few things about your system.

    • How much memory is available?
    • What other applications are in use?
    • Are there other users logged into the same system?
    • What operating system?
    • Is the OS 32 or 64 bit?

    Calculating Memory Requirements

    I have a data frame with 1,500,000 rows and 120 columns, all of which are numeric data. Roughly, how much memory is required to store this data frame?
    1,500,000 × 120 × 8 bytes/numeric

    = 1440000000 bytes
    = 1440000000 / bytes/MB
    = 1,373.29 MB
    = 1.34 GB

    Textual Formats

    • *dumping* and *dputing* are useful because the resulting textual format is edit-able, and in the case of corruption, potentially recoverable.
    • *Unlike* writing out a table or csv file, *dump* and *dput* preserve the *metadata* (sacrificing some readability), so that another user doesn’t have to specify it all over again.
    • *Textual* formats can work much better with version control programs like subversion or git which can only track changes meaningfully in text files
    • Textual formats can be longer-lived; if there is corruption somewhere in the file, it can be easier to fix the problem
    • Textual formats adhere to the “Unix philosophy”
    • Downside: The format is not very space-efficient

    dput-ting R Objects ?

    Another way to pass data around is by deparsing the R object with dput and reading it back in using dget.

    > y <- data.frame(a = 1, b = "a")
    > dput(y)
    structure(list(a = 1,
                     b = structure(1L, .Label = "a",
                                            class = "factor")),
                .Names = c("a", "b"), row.names = c(NA, -1L),
                class = "data.frame")
    > dput(y, file = "y.R")
    > new.y <- dget("y.R")
    > new.y
         a    b
    1   1    a
    

    Dumping R Objects ?

    Multiple objects can be deparsed(逆分析) using the dump function(转储功能) and read back in using source.

    > x <- "foo"
    > y <- data.frame(a = 1, b = "a")
    > dump(c("x", "y"), file = "data.R")
    > rm(x, y)
    > source("data.R")
    > y
        a  b
    1  1  a
    > x
    [1] "foo"
    

    Interfaces to the Outside World

    Data are read in using connection interfaces. Connections can be made to files (most common) or to other more exotic things.

    • *file*, opens a connection to a file
    • *gzfile*, opens a connection to a file compressed with gzip
    • *bzfile*, opens a connection to a file compressed with bzip2
    • *url*, opens a connection to a webpage

    File Connections **

    > str(file)
    function (description = "", open = "", blocking = TRUE,
                encoding = getOption("encoding"))
    
     1. *description* is the name of the file
     2. *open* is a code indicating
        - “r” read only
        - “w” writing (and initializing a new file)
        - “a” appending
        - “rb”, “wb”, “ab” reading, writing, or appending in binary mode (Windows)
    

    Connections

    In general, connections are powerful tools that let you navigate files or other external objects. In practice, we often don’t need to deal with the connection interface directly.

    con <- file("foo.txt", "r") **
    data <- read.csv(con)
    close(con)

    is the same as

    data <- read.csv("foo.txt")

    Reading Lines of a Text File

    > con <- gzfile("words.gz")
    > x <- readLines(con, 10)
    > x
     [1] "1080"        "10-point"   "10th"         "11-point"
     [5] "12-point"  "16-point"   "18-point"  "1st"
     [9] "2"              "20-point"
    

    writeLines takes a character vector and writes each element one line at a time to a text file.
    readLines can be useful for reading in lines of webpages

    ## This might take time
    con <- url("http://www.jhsph.edu", "r")
    x <- readLines(con)
    > head(x)
    [1] "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"
    [2] ""
    [3] "<html>"
    [4] "<head>"
    [5] "\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8

    Subsetting

    There are a number of operators that can be used to extract subsets of R objects.

    • [ always returns an object of the same class as the original; can be used to select more than one element (there is one exception)
    • [[ is used to extract elements of a list or a data frame; it can only be used to extract a single element and the class of the returned object will not necessarily be a list or data frame
    • $ is used to extract elements of a list or data frame by name; semantics are similar to that of [[.

      x <- c(“a”, “b”, “c”, “c”, “d”, “a”)
      x[1]
      [1] “a”
      x[2]
      [1] “b”
      x[1:4]
      [1] “a” “b” “c” “c”
      x[x > “a”]
      [1] “b” “c” “c” “d”
      u <- x > “a”
      u
      [1] FALSE TRUE TRUE TRUE TRUE FALSE
      x[u]
      [1] “b” “c” “c” “d”

    Subsetting Lists

    > x <- list(foo = 1:4, bar = 0.6)
    > x[1]
    $foo
    [1] 1 2 3 4
    > x[[1]]
    [1] 1 2 3 4
    > x$bar
    [1] 0.6
    > x[["bar"]]
    [1] 0.6
    > x["bar"]
    $bar
    [1] 0.6
    
    > x <- list(foo = 1:4, bar = 0.6, baz = "hello")
    > x[c(1, 3)]
    $foo
    [1] 1 2 3 4
    $baz
    [1] "hello"
    

    The [[ operator can be used with computed indices; $ can only be used with literal names.

    > x <- list(foo = 1:4, bar = 0.6, baz = "hello")
    > name <- "foo"
    > x[[name]]     ## computed index for ‘foo’ **
    [1] 1 2 3 4
    > x$name       ## element ‘name’ doesn’t exist!
    NULL
    > x$foo
    [1] 1 2 3 4       ## element ‘foo’ does exist
    

    Subsetting Nested Elements of a List
    The [[ can take an integer sequence.

    > x <- list(a = list(10, 12, 14), b = c(3.14, 2.81))
    > x[[c(1, 3)]]    **
    [1] 14
    > x[[1]][[3]]
    [1] 14
    > x[[c(2, 1)]]
    [1] 3.14
    

    Subsetting a Matrix

    Matrices can be subsetted in the usual way with (i,j) type indices.

    > x <- matrix(1:6, 2, 3)
    > x[1, 2]
    [1] 3
    > x[2, 1]
    [1] 2
    

    Indices can also be missing. **

    > x[1, ]
    [1] 1 3 5
    > x[, 2]
    [1] 3 4
    

    By default, when a single element of a matrix is retrieved, it is returned as a vector of length 1 rather than a 1 × 1 matrix. This behavior can be turned off by setting drop = FALSE.

    > x <- matrix(1:6, 2, 3)
    > x[1, 2]
    [1] 3
    > x[1, 2, drop = FALSE] **
        [,1] 
    [1,]   3
    

    Similarly, subsetting a single column or a single row will give you a vector, not a matrix (by default).

    > x <- matrix(1:6, 2, 3)
    > x[1, ]
    [1] 1 3 5
    > x[1, , drop = FALSE]
      [,1]    [,2]    [,3]
    [1,]   1       3       5
    

    Partial Matching

    Partial matching of names is allowed with [[ and $

    > x <- list(aardvark = 1:5)
    > x$a
    [1] 1 2 3 4 5
    > x[["a"]]
    NULL
    > x[["a", exact = FALSE]] ***
    [1] 1 2 3 4 5 
    

    Removing NA Values *

    A common task is to remove missing values (NAs).

    > x <- c(1, 2, NA, 4, NA, 5)
    > bad <- is.na(x)
    > x[!bad]
    [1] 1 2 4 5
    

    What if there are multiple things and you want to take the subset with no missing values?

    > x <- c(1, 2, NA, 4, NA, 5)
    > y <- c("a", "b", NA, "d", NA, "f")
    > good <- complete.cases(x, y) ***
    > good
    [1] TRUE TRUE FALSE TRUE FALSE TRUE
    > x[good]
    [1] 1 2 4 5
    > y[good]
    [1] "a" "b" "d" "f"
    
    > airquality[1:6, ]
          Ozone     Solar.R    Wind       Temp     Month   Day
    1       41       190       7.4         67       5       1
    2       36       118       8.0         72       5       2
    3       12       149       12.6       74       5       3
    4       18       313       11.5       62       5       4
    5       NA       NA       14.3       56       5       5
    6       28       NA 14.9 66 5 6
    > good <- complete.cases(airquality)
    > airquality[good, ] [1:6, ]   ***
             Ozone Solar.R   Wind      Temp       Month     Day
    1       41       190       7.4         67       5       1
    2       36       118       8.0         72       5       2
    3       12       149       12.6       74       5       3
    4       18       313       11.5       62       5       4
    7       23       299       8.6         65       5       7
    

    Vectorized Operations 向量化操作

    Many operations in R are vectorized making code more efficient, concise, and easier to read.

    > x <- 1:4; y <- 6:9
    > x + y
    [1] 7 9 11 13
    > x > 2
    [1] FALSE FALSE TRUE TRUE
    > x >= 2
    [1] FALSE TRUE TRUE TRUE
    > y == 8
    [1] FALSE FALSE TRUE FALSE
    > x * y
    [1] 6 14 24 36
    > x / y
    [1] 0.1666667 0.2857143 0.3750000 0.4444444
    

    Vectorized Matrix Operations

    > x <- matrix(1:4, 2, 2); y <- matrix(rep(10, 4), 2, 2) ?
    > x * y             ## element-wise multiplication
            [,1]    [,2]
    [1,]    10    30
    [2,]    20    40
    > x / y
         [,1]    [,2]
    [1,]    0.1    0.3
    [2,]    0.2    0.4
    > x %*% y       ## true matrix multiplication
              [,1]    [,2]
    [1,]      40    40
    [2,]      60    60
    

    Missing Value

    is.na(mydata) 与 mydata == NA 结果一样

    R uses ‘one-based indexing‘, which (you
    | guessed it!) means the first element of a vector is considered element 1.

    x[c(2, 10)] ##取x的第2个和第10个数
    x[c(-2, -10)] ##取除去第2个和第10个的所有数
    x[-c(2, 10)] ##同上

    展开全文
  • What is the BNC

    2015-09-30 17:04:10
    A summary of the compression test results d e t a i l s More detailed results, including some statistical analysis c o r p o r a Descriptions of the various corpora m e t h o d s Descriptions of the ...
  • what is big data?

    千次阅读 2015-08-26 18:51:20
    link: http://opensource.com/resources/big-dataBig data: everyone seems to be talking about it, but what is big data really? How is it changing the way researchers at companies, non-profits, ...

    link: http://opensource.com/resources/big-data

    Big data: everyone seems to be talking about it, but what is big data really? How is it changing the way researchers at companies, non-profits, governments, institutions, and other organizations are learning about the world around them? Where is this data coming from, how is it being processed, and how are the results being used? And why is open source so important to answering these questions?

    In this short primer, learn all about big data and what it means for the changing world we live in.

    What is big data?

    There is no hard and fast rule about exactly what size a database needs to be in order for the data inside of it to be considered “big.” Instead, what typically defines big data is the need for new techniques and tools in order to be able to process it. In order to use big data, you need programs which span multiple physical and/or virtual machines working together in concert in order to process all of the data in a reasonable span of time.

    Getting programs on multiple machines to work together in an efficient way, so that each program knows which components of the data to process, and then being able to put the results from all of the machines together to make sense of a large pool of data takes special programming techniques. Since it is typically much faster for programs to access data stored locally instead of over a network, the distribution of data across a cluster and how those machines are networked together are also important considerations which must be made when thinking about big data problems.

    What kind of datasets are considered big data?

    The uses of big data are almost as varied as they are large. Prominent examples you’re probably already familiar with including social media network analyzing their members’ data to learn more about them and connect them with content and advertising relevant to their interests, or search engines looking at the relationship between queries and results to give better answers to users’ questions.

    But the potential uses go much further! Two of the largest sources of data in large quantities are transactional data, including everything from stock prices to bank data to individual merchants’ purchase histories; and sensor data, much of it coming from what is commonly referred to as the Internet of Things (IoT). This sensor data might be anything from measurements taken from robots on the manufacturing line of an auto maker, to location data on a cell phone network, to instantaneous electrical usage in homes and businesses, to passenger boarding information taken on a transit system.

    By analyzing this data, organizations are able to learn trends about the data they are measuring, as well as the people generating this data. The hope for this big data analysis are to provide more customized service and increased efficiencies in whatever industry the data is collected from.

    How is big data analyzed?

    One of the best known methods for turning raw data into useful information is by what is known as MapReduce. MapReduce is a method for taking a large data set and performing computations on it across multiple computers, in parallel. It serves as a model for how program, and is often used to refer to the actual implementation of this model.

    In essence, MapReduce consists of two parts. The Map function does sorting and filtering, taking data and placing it inside of categories so that it can be analyzed. The Reduce function provides a summary of this data by combining it all together. While largely credited to research which took place at Google, MapReduce is now a generic term and refers to a general model used by many technologies.

    What tools are used to analyze big data?

    Perhaps the most influential and established tool for analyzing big data is known as Apache Hadoop. Apache Hadoop is a framework for storing and processing data in a large scale, and it is completely open source. Hadoop can run on commodity hardware, making it easy to use with an existing data center, or even to conduct analysis in the cloud. Hadoop is broken into four main parts:

    • The Hadoop Distributed File System (HDFS), which is a distributed
      file system designed for very high aggregate bandwidth;
    • YARN, a platform for managing Hadoop’s resources and scheduling
      programs which will run on the Hadoop infrastructure;
    • MapReduce, as described above, a model for doing big data processing;
    • And a common set of libraries for other modules to use.

    To learn more about Hadoop, see our Introduction to Apache Hadoop for big data.

    Other tools are out ther too. One which has been receiving a lot of attention recently is Apache Spark. The main selling point of Spark is that it stoes much of the data for processing in memory, as opposed to on disk, which for certain kinds of analysis can be much faster. Depending on the operation, analysts may see results a hundred times faster or more. Spark can use the Hadoop Distributed File System, but it is also capable of working with other data stores, like Apache Cassandra or OpenStack Swift. It’s also fairly easy to run Spark on a single local machine, making testing and development easier.

    For more on Apache Spark, see our collection of articles on the topic.

    Of course, these aren’t the only two tools out there. There are countless open source solutions for working with big data, many of them specialized to provide optimal features and performance for a specific niche or for specific hardware configurations. And as big data continues to grow in size and importance, the list of open source tools for working with it will certainly continue to grow alongside.

    展开全文
  • 流利说 Level 3 全文

    万次阅读 多人点赞 2019-05-22 10:51:17
    Here is a bus schedule at a bus stop. On most days the buses come on schedule but sometimes they don’t. Yesterday for example, several buses were late. This is because the traffic ...

    Level 3

    Unit1

    1/4

    Listening

    Lesson 1 An Unusual Day

    Lesson 2 Bus Schedule

    Vocabulary

    Lesson 3 Activities &Food

    Lesson 4 Spatial Relations

    Dialogue

    Lesson 5 Meeting at the Airport

    Lesson 6 Staying up late

    2/4

    Listening

    Lesson 1 Time Zones

    Lesson 2 Kim’s Movie Star Dream

    Vocabulary

    Lesson 3 Action & Comparisons

    Lesson 4 Seasons & Weather

    Dialogue

    Lesson 5 Missing the Flight

    Lesson 6 A Going Away Party

    3/4

    Listening

    Lesson 1 Buying a New Car 1-2

    Vocabulary

    Lesson 3 Spatial Relations & Needs

    Lesson 4 Places of Business

    Dialogue

    Lesson 5 Ordering Food from Home

    Lesson 6 Are Selfies Good or Bad?

    4/4

    Listening

    Lesson 1 Christina’s Future Plans 1-2

    Vocabulary

    Lesson 3 Jobs & Weather

    Lesson 4 Things to Read

    Dialogue

    Lesson 5 Foot Injury

    Lesson 6 Discussing Eating out

    Unit2

    1/4

    Listening

    Lesson 1 Stats of Matter

    Lesson 2 Test Results

    Vocabulary

    Lesson 3 Emotions

    Lesson 4 Hobbies

    Dialogue

    Lesson 5 Ready for the Meeting

    Lesson 6 Discussing Test Results

    2/4

    Listening

    Lesson 1 Paul’s Trip Plan 1-2

    Vocabulary

    Lesson 3 Sports

    Lesson 4 Injuries

    Dialogue

    Lesson 5 A Nightmare

    Lesson 6 Toilet Trouble

    3/4

    Listening

    Lesson 1 Paul’s Overseas Trip 1-2

    Vocabulary

    Lesson 3 Emergency Vehicles

    Lesson 4 Weather & Activities

    Dialogue

    Lesson 5 Checking up on Ada

    4/4

    Listening

    Lesson 1 Overview of Earth

    Lesson 2 Water on Earth

    Vocabulary

    Lesson 3 Things We Enjoy Doing

    Lesson 4 Continents

    Dialogue

    Lesson 5 A Driverless Car

    Lesson 6 Calling Customer Service

    Unit 3

    1/4

    Listening

    Lesson 1 Life & Conditions 1-2

    Vocabulary

    Lesson 3 Forms of Life

    Lesson 4 Instruments

    Dialogue

    Lesson 5 Dating Anniversary

    Lesson 6 Fine Dining

    2/4

    Listening

    Lesson 1 Quick Serve 1-2

    Vocabulary

    Lesson 3 Sciences

    Lesson 4 Disasters

    Dialogue

    Lesson 5 Desk Assembly

    Lesson 6 Life and the Universe

    3/4

    Listening

    Lesson 1 Harry’s Business Trip 1-2

    Vocabulary

    Lesson 3 Sources of Energy

    Lesson 4 Types of Words

    Dialogue

    Lesson 5 Good News & Bad News

    4/4

    Listening

    Lesson 1 Leonardo da Vinci 1-2

    Vocabulary

    Lesson 3 Sources of Pollution

    Lesson 4 Historical Figures

    Dialogue

    Lesson5 An Urgent Call

    Lesson 6 Setting the Bill

     

     

    Level 3

    Unit1

    1/4

    Listening

    Lesson 1 An Unusual Day

    Kathy usually gets up at 6:30, but this morning, she didn’t hear her alarm.

    As a result, she overslept.

    She didn’t get up until 7:00, 30 minutes later than usual.

    As a result, she didn’t have time to cook breakfast for her children.

     

    -Why did she oversleep? –She didn’t hear her alarm.

    -Why didn’t she cook breakfast? –She didn’t have time.

     

    Today Kathy and her kids left home early.

    They usually leave home at 7:30, but today they left at 7:15.

    They left early because they had to buy breakfast on their way to school.

     

    -Why did they leave home early? –They had to buy breakfast on their way to school.

    -What did they have to buy on their way to school? –their breakfast.

     

    It usually takes 45 minutes to drive her kids to school, but today it took longer.

    It took them longer because they stopped for breakfast along the way.

    It took 15 minutes for them to have breakfast.

    They ate at a little coffee shop along the side of the road.

     

    -How long does it usually take to drive her kids to school? –It usually takes 45 minutes.

    -How long did it take them to have breakfast? –It took 15 minutes.

     

    After eating breakfast, they got back into their car.

    On most days the traffic isn’t too bad in the morning.

    But this morning, it was much worse than usual.

    The cars were moving very slowly.

    As a result it took them longer than usual to get to school.

     

    -What did they do after eating breakfast? –They got back into their car.

     

    One of her children got to school on time, but the other two were late.

    They were late because their schools are farther away.

    They were both about 10 minutes late to school.

     

    -How late were two of her children? –They were about 10 minutes late.

     

    When Kathy finally got home she cleaned her house as usual.

    She vacuumed the living room and cleaned the bathroom.

    Then she talked with her friend on the phone as usual.

    When she finished talking with her friend she got into her car.

    She put the key into the ignition, and tried to start the engine.

    But the car’s engine didn’t start.

    Her car battery was dead, so she had to call for help.

     

    -What happened when she tried to start her car? –The car’s engine didn’t start.

    -Why did she have to call for help? –to get a new battery.

     

    After getting a new battery for her car, the engine started.

    Then Kathy drove to the mall to meet her friend.

    She arrived to the mall an hour late but her friend was waiting for her.

    They had lunch together and then they went shopping.

    They both bought new shoes and some things for their kids.

    Kathy bought a new tie for her husband.

     

    -What did Kathy buy for her husband? –a new tie.

    -Who was waiting for her at the mall? –Her friend was waiting for her.

     

    It’s now 3:00 and everything is going as usual.

    Kathy doesn’t want anything else to go wrong.

    She wants the rest of the day to go as usual.

    She doesn’t want any more surprises.

    And tomorrow she won’t oversleep.

    She never wants to oversleep again.

     

    -What doesn’t Kathy want? –more surprises.

    Lesson 2 Bus Schedule

    Here is a bus schedule at a bus stop.

    On most days the buses come on schedule but sometimes they don’t.

    Yesterday for example, several buses were late.

    This is because the traffic yesterday was much heavier than usual.

     

    -How was the traffic yesterday? –It was much heavier than usual.

    -Why were several buses late? –The traffic was heavier than usual.

     

    Bus number 38 was supposed to come at 8:40, but it was 5 minutes late.

    It didn’t come until 8:45.

    Bus number 60 was supposed to come at 8:30.

    But yesterday it didn’t come until 8:40.

    It was 10 minutes late.

    Not one bus come early.

     

    -How many buses came early? –Not one bus came early.

     

    As a result of the delays one man got on the wrong bus.

    He wanted to go to the airport so he wanted to get on bus number 38.

    He expected it to come at 8:40.

    Instead he got on bus number 60, which came at 8:40.

    He didn’t notice that it was the wrong bus.

    It didn’t go to the airport.

    As a result he missed his flight.

     

    -What time was bus number 38 supposed to come? -8:40.

    -Why did the man miss his flight? –He got on the wrong bus.

    Vocabulary

    Lesson 3 Activities &Food

    Weddings are where two people get married.

    This man and woman are getting married.

    The building in the middle is an office building.

    Many people come to work here during the week.

    These people are at a dance party.

    The woman in the green dress is dancing with her boyfriend.

    These two people are meeting for the first time.

    They are shaking hands.

    This young boy is brushing his teeth.

    He brushes his teeth several times a day.

     

    -Who are shaking hands? –They are shaking hands.

    Candies and cakes are sweet because they are made with lots of sugar.

    Eating too many sweets is not good for your teeth.

    Lemons and great food take a little sour so some people don’t like them.

    Some sour tasting foods have a lot of vitamin C.

    These red peppers are very hot and spicy.

    Eating hot or spicy food rises body temperature so don’t eat them before going into bed.

    These foods are deep-fried and greasy.

    Greasy foods have a lot of calories, so don’t eat them if you want to lose weight.

    Healthy foods are usually nature and don’t include dangerous chemical. Fruits and vegetables are examples of healthy foods.

     

    -How do lemons and great food taste? –a little sour.

    Lesson 4 Spatial Relations

     

    The triangle is inside the square.

    The square is around the triangle.

    The triangle is inside the circle.

    The circle is around the triangle.

    The square is inside the triangle.

    The triangle is around the square.

    The circle is between two small squares.

    There is a square on either side of the circle.

    The circle is on the left of the rectangle.

    The rectangle is on the right of the circle.

     

    Dialogue

    Lesson 5 Meeting at the Airport

    W: Hey, where are you? I don’t see you anywhere.

    M: I’m on the subway.

    W: My flight arrived early and I’m tired.

    M: I’m sorry to be late. I’ll be there as fast as I can.

     

    -Where is she? –She is at the airport.

     

    W: Where are you now?

    M: There are three more stops. I’ll be there in ten minutes.

    W: I’ll meet you at the bus stop in front of terminal 2. Then we can get a taxi.

    M: OK. I’ll look for you in front of terminal 2. See you soon.

     

    -What are they going to do after they meet? –Take a taxi.

    Lesson 6 Staying up late

    Lisa: What’s the matter, Tom?

    Tom: I don’t feel well.

    Lisa: Are you sick?

    Tom: No, I don’t think so. I’m just tired.

    Lisa: Didn’t you get enough sleep?

    Tom: No, I didn’t. I went to bed later than usual last night.

     

    -Why didn’t he get enough sleep? –He went to bed later than usual.

     

    Lisa: What time did you go to bed?

    Tom: I didn’t go to bed until 12:00.

    Lisa: Why did you stay up so late?

    Tom: I was watching some videos on line.

     

    -He didn’t go to bed until when? - He didn’t go to bed until 12:00.

     

    Lisa: What kind of videos?

    Tom: Music videos from all over the world.

    Lisa: Really?

    Tom: Sure, I’ll send you some links if you like.

    Lisa: Thanks, I like music videos too. They are really fun.

    Tom: Just don’t stay up too late.

    Lisa: Don’t worry, I won’t stay up too late. I need my sleep.

     

    -Why won’t she stay up too late? –She needs enough sleep.

    He was watching videos.

    He didn’t go to bed until 12:00.

    2/4

    Listening

    Lesson 1 Time Zones

    Our planet, the earth, is the third planet from the sun.

    It is a beautiful, rotating sphere.

    The side facing the sun is in daylight.

    The side facing away from the sun is in darkness.

    For example, when it’s daytime in the US, it’s nighttime in China.

    In fact, there’s a 12-hour time difference between Boston and Shanghai.

    When it’s midnight in Shanghai,it’s noon in Boston.

     

    -Which side of the earth is in daylight? –the side facing the sun.

    -What is the shape of our planet? –a sphere.

    -What time of the day is noon? –It’s 12:00 pm.

    -Which side of the earth is in darkness? –the side facing away from the sun.

     

    The earth rotates from west to east.

    To know which direction is east or west, watch the sun.

    The sun travels through the sky from east to west.

    The sun comes up in the east and goes down in the west.

    Again, this is because the earth rotates.

    It takes 24 hours for the earth to make a complete rotation.

    And that is the length of one day.

     

    -The sun comes up in which direction? –It comes up in the east.

     

    Because of the earth’s rotation, the earth is divided into time zones.

    Some countries, such as the US, have several time zones.

    When it’s 10 am in New York, it’s 7 am in San Francisco.

    Europe and the US are separated by several time zones.

    When it’s 5 pm in Paris, it’s 11 am in Boston.

    So there is a 6-hour difference between Paris and Boston.

    One large country, China, has just one time zone for the whole country.

    As a result, at the same time, some parts of the country can be dark and other parts can be light.

     

    -Which large country has only one time zone? –China.

    -Why is the earth divided into time zones? –It rotates.

     

    As you travel around the earth, the time changes.

    The time of day depends on your location on the planet.

    When you travel east or west, you may cross several time zones.

    For example, if you travel from Beijing to Los Angeles, you cross 8 time zones.

    That means, when it’s noon on Sunday in China, it’s 8 pm on Saturday in Los Angeles.

    For travelers, this means it can be very difficult to sleep after a long flight.

    The clock may say 8 pm, but for your body, it’s noon.

    This is called jet lag.

     

    -What causes jet lag? –crossing several time zones.

    -What happens if you travel east or west? –You may cross several time zones.

    -What changes as you travel around the earth? –the time.

    -What happens if you travel from Beijing to Los Angeles? –You will cross several time zones.

    It depends on how far east or west you travel.

    Crossing several time zones causes jet lag.

    Lesson 2 Kim’s Movie Star Dream

    Kim is a popular Korea actress.

    She’s 28 years old, slim, and beautiful.

    She has a large fan club, and her movies are very popular.

    Everywhere she goes, her fans want her autograph.

    But Kim wants more.

    She wants to be popular all over the world.

     

    -What does Kim do? –She is an actress.

    -What does Kim want? –She wants to be more popular.

    -What do her fans want? –Her autograph.

     

    Tomorrow is a special day for her.

    She’s leaving for Hollywood.

    She’s going to Hollywood to meet with some top movie executives.

    The meeting is scheduled the day after tomorrow.

    If the meeting goes well, she’ll be in a Hollywood movie.

    This is her chance to become a star.

     

    -When is she leaving for Holly Wood? –tomorrow.

    -What will happen if the meeting goes well? –She’ll be in a Hollywood movie.

    -When is she going to meet with executives? –the day after tomorrow.

     

    She met the movie’s director last year.

    He came to Korea and saw her latest movie.

    After that he decided to use her in his new movie.

    Fortunately, Kim’s English is excellent, so she can play the role.

     

    -Who did she meet in Korea last year? –the movie’s director.

    -What did the movie director decide to do? -He decided to use her in his new movie.

     

    The director wants her to play a major role in the movie.

    The movie story will take place in the future.

    At that time the world will be a very different place.

    Unfortunately, much of world will be polluted.

    Robots will do much of the work, and only the very rich can have a good life.

     

    -In the movie, who can have a good life? –the very rich.

    -What are robots? –machines.

     

    The ending of the movie is still a secret.

    Even Kim doesn’t know how it will end.

    But she hopes it will have a happy ending.

    She wants people to have hope for a better future.

     

    -What doesn’t Kim know? –the ending of the movie.

    Vocabulary

    Lesson 3 Action & Comparisons

    These people are having a meeting.

    The woman is giving a presentation.

    This person is having a scary dream.

    In his dream, something is chasing him, so he is running as fast as he can.

    This old man is a tourist.

    He is looking out the window of his tour bus.

    This young couple is in an art museum.

    They are looking at a famous painting.

    The sun is setting behind the mountains.

    The sky is turning red.

     

    Some buses, like this one, take tourists to places like the Great Wall.

    She’s giving a presentation at a meeting.

     

    The longest line is the one on the top.

    The top line is the longest of the three lines.

    The shortest line is the one in the middle.

    The line in the middle is shorter than the other two.

    The bottom line is the shortest.

    The shortest of these three lines is the one on the bottom.

    The shirt on the left is more expensive than the shirt on the right.

    The shirt on the right is less expensive than the shirt on the left.

    The shirt on the left isn’t as expensive as the one on the right.

    The shirt on the left costs less than the one on the right.

     

    The shirt on the left is more expensive than the shirt on the right.

    Lesson 4 Seasons & Weather

    Winter is the coldest season because the sun is at its lowest point in the sky.

    Winter sports include skiing and ice skating.

    Summer is the hottest season because the sun is at its highest point in the sky.

    Many people like to go swimming in the summer because of the hot weather.

    Spring is the season when the weather gets warmer each day.

    For many animals new life begins in the spring.

    Autumn is the season when the weather begins to cool and the days begin to shorten.

    Autumn is when trees turn many colors and leaves fall to the ground.

    Rainy season is the season when some countries get most of the rainfall.

    Rainy season usually lasts for one or two months.

    Dialogue

    Lesson 5 Missing the Flight

    M: Hi, I’m sorry to be late.

    W: What happened? You were supposed to be here an hour ago.

    M: Yes, I know, but I missed my flight.

     

    -How late is he? –H’s an hour late.

     

    W: You missed your flight? How did that happen?

    M: I got on the wrong bus this morning, so I was late to the airport.

    By the time I arrived, the gate was closed.

    W: What did you do then?

    M: I had to rebook my flight and get on the waiting list.

     

    -Why was he late to the airport? –He got on the wrong bus.

    -What did he do when he got to the airport? –He rebooked his flight.

    He had to get on a waiting list because other people were also trying to get on the flight.

     

    W: Oh, that’s too bad. At least you got here.

    M: Yes, it wasn’t easy getting on the next flight. I had to run to the gate.

    W: This kind of thing happens a lot lately. Last week I missed a flight, too.

     

    -What wasn’t easy? –It wasn’t easy getting on the next flight.

     

    M: What happened?

    W: There was a traffic accident near the airport.

    M: You were driving?

    W: No, I wasn’t. I was in a taxi. But it took a long time to get to the airport.

    The traffic was stopped for nearly 15 minutes.

     

    -Why did it take a long time to get to the airport? –The traffic was stopped because of an accident.

     

    W: By the time I got there, it was too late to get on the flight.

    The next flight wasn’t for another 3 hours, so it was a long wait.

    From now on, I’ll try to get to the airport much earlier.

    M: Me too.

     

    -How long did she have to wait for the next flight? –She had to wait three hours. She had to wait three hours for the next flight.

    Lesson 6 A Going Away Party

    M: What’s the matter? Why do you look so sad?

    W: Ada has a new job. She’s going to Beijing.

    M: Really? When is she leaving?

    W: She’s leaving at the end of next week.

    M: That soon?

    W: Yes, she just told me.

    M: That’s too bad. I really enjoy working with her.

    W: Me too, I’m going to miss her.

     

    -When is Ada leaving? –She is leaving at the end of next week.

     

    W: Let’s have a going-away party for her.

    M: Good idea. How about this weekend?

    W: Friday evening would be better. We can have it after work.

    M: Yes, Friday is better.

     

    -When are they going to have the party? –They’re going to have it on Friday evening.

    -Why is Friday evening better than the weekend? –They can have the party after work.

     

    W: Let’s go to her favorite restaurant, okay?

    M: Which one? The Italian one, or the German one?

    W: The Italian one has better food, so let’s go there. Their pizzas are awesome.

     

    -How good are the pizzas at the Italian restaurant? –They are awesome.

    -Why did they decide on the Italian restaurant? –They think it has better food.

     

    M: OK, I’ll make the reservations. 

    W: Let me check with Ada first. We don’t want her to miss her party.

    M: Yeah, that’s for sure. And could you please invite everyone in the office?

    W: Sure, no problem. Nobody will want to miss it.

     

    -What are they going to check with Ada? –They need to confirm that she can come to the party.

    3/4

    Listening

    Lesson 1 Buying a New Car 1-2

    Paul is a very successful businessman.

    He owns several restaurants.

    All of them are doing well.

    In fact, they are very profitable.

    To be profitable means that their income is more than their expenses.

    As a result, he is making a lot of money.

     

    -What does Paul do? –He is a businessman.

    -Why is he making a lot of money? –His restaurants are profitable.

    He is making money because his restaurants are profitable.

     

    Paul wants to buy a new car.

    He’s trying to decide which car to buy.

    He has plenty of money.

    As a result, he isn’t worried about the cost.

    He can afford an expensive car.

     

    -Why isn’t he worry about the cost? –He has plenty of money.

    -As a result is the same as saying… -so

     

    On the other hand, he doesn’t want to waste money.

    He wants a car he can rely on.

    It has to be safe and reliable, especially in cold winter weather.

    If a car breaks down in bad weather, it can be very dangerous.

     

     

    -What kinds of car does he want? –a safe, reliable car.

     

    Paul wants to help reduce pollution and smog.

    He would like to buy a clean car, something good for the environment.

    He is thinking about buying a Tesla.

    The Tesla is an all-electric car.

    It used batteries instead of gasoline.

    There is no exhaust so it doesn’t pollute the air.

     

    -What kind of car is Tesla? –It is a clean, electric car.

    -Why doesn’t the Tesla pollute the air? –It doesn’t exhaust.

     

    However, the car can’t go very far without recharging the battery.

    To charge the battery you can plug it in to an electrical outlet.

    Recharging the battery takes time.

     

    -What takes time? –Recharging the battery.

     

    One of Paul’s friends has one and he is quite happy with it.

    He says it’s reliable and well-engineered.

    There’re also several charging station near Paul’s office.

    So he isn’t worried about that.

    The cost for charging the battery is low.

    It’s less expensive than buying gasoline.

    His wife, Kathy, also likes the idea of buying an electric car.

    She likes the idea of driving a clean car.

    So it makes sense.

     

    -What’s less expensive than buying gasoline? –charging the battery.

    -Why isn’t Paul worried about finding charging stations? –There’re several charging stations near Paul’s office.

     

    In the future there may be driverless cars.

    This may be very safe, but Paul doesn’t like them.

    He enjoys driving.

    He likes to be in control of his car.

     

    -What does Paul enjoy doing? –He enjoys driving.

    Vocabulary

    Lesson 3 Spatial Relations & Needs

    The man in the middle is the heaviest.

    The man in the middle is heavier than the other two.

    The woman on the left is smarter than the man on the right.

    The man isn’t as smart as the woman is.

    The woman is standing under a bridge.

    The bridge is above the woman.

    There is a bridge over the river.

    The river is flowing beneath the bridge. The water is flowing over a waterfall.

    The waterfall is very high and beautiful.

    People need passports to travel internationally.

    Without a passport, you cannot leave your country or enter another country.

    You need a driver’s license to drive a car.

    It is against the law to drive without a driver’s license.

    Many people use credit cards to buy things on credit.

    When you have a credit card, you don’t need to carry cash.

    Smart phones are very useful and can do many things.

    You can use them to make phone calls, play games, or go shopping on the internet.

    We need to buy tickets in order to take a train, or watch a sport event.

    You can often buy tickets on line and sometimes you can get a discount.

     Lesson 4 Places of Business

    Banks are where people can deposit or withdraw money.

    You can also use online bank to pay bills, such as your credit card bill.

    Hotels are where travelers can stay overnight or for several days.

    If you plan to stay at a hotel you should make a reservation.

    Restaurants are where people go to eat with friends and family.

    There are many different kinds of restaurants, such as Indian, Italian, or Chinese restaurants.

    Repair shops are where people go to fix things which are broken or not working right.

    This repair shop fixes cars and can check to see if it’s safe to drive.

    Coffee shops are favorite place to meet new people or take a break from the office. They are usually less expensive than restaurants.

    Dialogue

    Lesson 5 Ordering Food from Home

    M: I’m tired of going out to eat. Let’s eat at home tonight.

    W: OK, are you going to cook?

    M: No, it’s too late, you know I’m not a good cook. Let’s order something.

     

    -What are they going to do? –They are going to order food.

    -Why does he want to eat at home? –He’s tired of going out to eat.

     

    W: What do you have in mind?

    M: I was thinking about a nice big pizza.

    W: Again? I had pizza last night. So, please, no pizza.

     

    -What was he thinking about ordering? –He was thinking about ordering a pizza.

    -Why doesn’t she want pizza? –She’s tired of eating pizza.

     

    M: OK, no pizza. Let’s order Chinese food, okay?

    W: Sweet and sour? You always like sweet and sour. I feel like eating something hot and spicy.

    M: OK, you order something hot and spicy, and I order sweet and sour. I don’t want anything spicy.

    My stomach doesn’t feel good. It’s a bit upset.

     

    -What does she feel like eating? –something hot and spicy.

    -Why doesn’t he want something hot and spicy? –His stomach doesn’t feel good.

     

    W: OK, if you want sweet and sour then I’ll have that too. And I’ll make a salad with lots of tomatoes.

    How long will it take for the food to get here.

    M: I don’t know. I’ll call and find out.

    W: Thanks. Hopefully it won’t take longer than an hour. I’m getting hungry.

     

    -What do they finally decide to order? –They decide to order sweet and sour.

    -How long will it take for the food to be delivered? –They don’t know.

    Lesson 6 Are Selfies Good or Bad?

    M: Hey, what did you do last night?

    W: I took a long walk from my hotel.

    M: You didn’t get lost?

    W: No, I didn’t.

     

    -What did she do last night? –She took a long walk.

    -What is she staying? –She is staying at a hotel.

     

    M: Where did you go, anywhere interesting?

    W: I walked to river. There were thousands of people there.

    M: You went to the river? How long did it take you to walk there.

    W: It took around 20 minutes.

    M: Did you see anything interesting?

    W: I was really surprised by how many people were there.

     

    -How did she get to the river? –She walked to the river.

    -What did she see at the river? –She saw thousands of people there.

     

    W: Many of them were taking pictures and selfies, Lots of selfies.

    M: Do you take selfies?

    W: Sure, don’t you?

    M: Sometimes, but my girlfriend takes a lot of selfies. Then she shares them with her friends on line.

    I don’t understand why people like to take so many pictures of themselves.

    W: That’s because you are old-fashioned.

     

    -What does his girlfriend put on line? –She puts her selfies on line.

    -What does it mean to take a selfies? –It means to take a picture of yourself with your smart phone.

     

    M: Hmm, I guess you are right. There are too many social media for me.

    When I go to a restaurant, I see many people looking at their smart phones.

    They don’t even look at the people they are with.

    W: Times are changing, my friend, whether you like it or not.

     

    -What are the people doing in the restaurant? –They are looking at their smart phones.

    4/4

    Listening

    Lesson 1 Christina’s Future Plans 1-2

    Christina sells women’s clothing in a department store.

    She usually works six days a week, but this week she’s going to take three days off.

    She’s taking time off so that she can visit her parents.

    Her parents live in the mountains, about three hours away by train.

    They are looking forward to seeing her.

    They haven’t seen her for almost a year.

    Christina is their only child.

     

    -What does Christina sell? –Women’s clothing.

    -When was the last time Christina saw her parents? –It was almost a year ago.

    -Why is she taking time off? –She is taking time off to visit her parents.

     

    Christina isn’t going on the trip by herself.

    Her boyfriend is going with her.

    She is going to introduce him to her parents.

    She and her boyfriend want to get married.

    If everything goes well, they plan to get married in 6 months.

     

    -What is the purpose of the trip? –To introduce her boyfriend to her parents.

    -When do they plan to get married? –In 6 months.

     

    After they get married, Christina plans to quit her job.

    She wants to spend more time designing clothes.

    She wants to set up her own business.

    This will take time.

    Her boyfriend thinks it’s a good idea.

    He is also thinking about starting his own business.

     

    -What does Christina plan to do after she gets married? –She plans to quit her job.

    -What does her boyfriend think it’s a good idea? –Start her own business.

     

    They don’t plan to have children right away.

    In fact, they may decide not to have children.

    They don’t know yet.

    It’s going to be a big decision.

     

    -What’s going to be a big decision? –To have children or not.

    -What may they decide not to do? –They may decide not to have children.

     

    Christina’s parents want her to marry and have children.

    They are looking forward to have grandchildren.

    They don’t want her to start her own business.

    They think it’s more important to have children.

    In fact, they would like her to live closer to them.

    They want to be close to their grandchildren.

     

    -What do Christina’s parents want? –They want her to marry and have children.

    -Where would Christina’s parents like her to live? –They would like her to live nearby.

     

    So Christina doesn’t plan to tell her parents everything.

    For now, she just wants them to meet her boyfriend.

    She wants them to be happy that she is going to get married.

    She wants them to like him and see her happiness.

    She wants her parents to accept her way of life.

    Life isn’t the same now as it used to be.

    Times are changing.

     

    -What does Christina want her parents to do for now? –She just wants them to meet her boyfriend.

    Vocabulary

    Lesson 3 Jobs & Weather

    Mechanics, like this one, fix cars.

    He is working in a repair shop.

    A delivery person delivers things, such as pizzas.

    This person works for a restaurant.

    A pharmacist sells medicines.

    Pharmacists, like this woman, work in a pharmacy.

    Thieves, like this one, steal things.

    This thief is stealing a television from a home.

    A musician, like this one, plays music.

    This musician is playing a guitar.

     

    Stealing things is against the law.

     

    These people are wearing masks because of the smog.

    One cause of smog is automobile exhaust.

    It’s raining hard so you need an umbrella.

    Heavy rain like this can cause flooding and mud slides.

    When the sky is overcast we can’t see the sun because of the clouds.

    A cloudy sky means that it might rain.

    We need to wear a coat when it’s cold and windy.

    In a very strong wind, it’s difficult to use an umbrella.

    We need to drink water or other liquids when it’s hot outside.

    When it’s really hot most people turn on the air conditioning.

    Lesson 4 Things to Read

    Here are some different types of things to read.

    Works or fictions include novels, short stories and plays, such as Shakespeare.

    We read fiction to enjoy stories of imagination and adventure.

    People read the news to learn about what’s happening in the world.

    We can get the news in newspapers and online.

    When we buy something, we often need to read an instruction manual.

    Instruction manuals show us how to put together or install things.

    Non-fiction works include biographies and books about science and history.

    We read non-fiction to learn about different subjects and real people.

    We can learn about the latest scientific research in journals and academic papers.

    Many online universities courses give a list of research papers to read.

    Dialogue

    Lesson 5 Foot Injury

    M1: What’s wrong?

    M2: I can’t walk. My left foot hurts.

    M1: Is it broken?

    M2: I don’t know if it’s broken, but it sure hurts.

     

    -What hurts? –His left foot hurts.

     

    M1: There’s one way to find out if it’s broken.

    M2: How?

    M1: You need to see a doctor. The doctor can X-ray your foot.

     

    -How can they find out if his foot is broken? –They need to see a doctor.

    -Who can X-ray his foot? –a doctor.

     

    M2: OK, let’s go. I can’t walk by myself. Can you help me into a taxi?

    M1: Sure, I’ll call a taxi. I’ll get you to a hospital as soon as possible.

    M2: Thanks. I sure hope it isn’t broken.

    M1: We’ll find out soon enough.

     

    -Where do they want to go? –They want to go to a hospital.

    Lesson 6 Discussing Eating out

    W: I don’t feel like cooking tonight. Let’s go out.

    M: Where would you like to go?

    W: I feel like eating some great Italian food.

    M: How about AI’s Italian, it’s always good.

     

    -What doesn’t she feel like doing? –cooking.

     

    W: We went there last week. Let’s try something new. You have no imagination.

    You always want to go to the same place.

    M: Right, I don’t like unpleasant surprises. I just want things to be simple.

     

    -What does she want to do? –She wants to try something new.

    -Why doesn’t she want to go to AI’s Italian? –They went there last week.

     

    W: OK, let’s compromise.

    M: What does that mean? What do you mean by compromise?

    W: Let’s go 50-50.

    This time we’ll go someplace new and new and next time we can go to one of your favorites.

    M: OK, I’ll compromise and make you halfway.

    W: Good, I’ll look for something new and make reservations.

     

    -What does she suggest? –She suggests that they compromise.

     

    M: Great, let’s not go too late.

    W: I’ll make reservations for 8. Is that okay?

    M: Yes, perfect.

     

    He doesn’t like unpleasant surprises.

    Unit2

    1/4

    Listening

    Lesson 1 Stats of Matter

    Matter is made of atoms and molecules.

    Water, for example, is the H2O molecule.

    This means that a molecule of water has 3 atoms.

    A water molecule has 2 hydrogen atoms and one oxygen atom.

    Substances like sugar have many atoms in their molecules.

    A molecule of sugar has many atoms, including carbine, hydrogen and oxygen.

     

    -What is H2O? –The water molecule.

    -What is matter made of? –Atoms and molecules.

     

    Matter is made of molecules such as the H2O which is the water molecule.

    Matter can be in one of 3 states, solid, liquid or gas.

    Water and ice are the same substance, but they are in different states.

    These states depend on the temperature of the molecules.

    When we heat a substance, the molecules move faster and try to take up more space.

    When we cool a substance, the molecules move more slowly.

    When we cool a substance to its freezing point, it becomes a solid.

     

    -How many states of matter are there? –Three.

    -What happens when we heat a substance? –the molecules move faster and try to take up more space.

    -What happens if we cool a liquid to its freezing point? –It becomes a solid.

     

    In a solid, the molecules move very little.

    Their positions are almost fixed.

    To be fixed means that their positions don’t change.

    If we heat the molecules, they move faster and away from each other.

    The solid begins to melt, like ice cream on a hot day.

     

    -How can we change a solid into a liquid? –heat it up.

    -How can we change a liquid into a solid? –cool it down.

     

    At a certain temperature, a solid begins to change into a liquid.

    The temperature at which a solid changes into a liquid depends on the substances.

    For water, the solid begins to change into a liquid when its temperature rises to above 100 degrees Celsius.

    For some substances, such as steel, the temperature at which it becomes a liquid is much higher.

    Steel often melts at around 1370 degrees Celsius.

     

    -At what temperature does ice begin to melt? –Above 0 degree Celsius.

    -What does the temperature at which a substance begins to melt depend on? –The substances.

     

    If we continue to heat a liquid, the molecules move even faster.

    At a certain temperature, the liquid begins to change into a gas.

    For water, the liquid begins to change into a gas at 100 degrees Celsius. This is the boiling point of water.

     

    -What happens if we continue to heat a liquid? –Molecules move even faster.

     

    Inside a star, such as our sun, the temperature is very high.

    Everything inside the sun is a gas.

    According to scientists, there are over 65 elements inside the sun.

    These include oxygen and iron.

    Over 90% of the sun is hydrogen gas.

     

    -How many elements are inside the sun? –More than 65.

     

     Lesson 2 Test Results

    Yesterday there was an important science test.

    Lisa, Tom and 20 other classmates took the test.

    The test was about the states of matter and how they are different.

    There were 25 questions on the test, and they had 45 minutes to take it.

     

    Here are some of the test results.

    Two students got perfect scores.

    The lowest score was 68 out of a hundred.

    The average score was 86.3

    Eleven students scored higher than average.

    Eleven students had below average scores.

     

    Tom missed two questions on the test, so his score was 92.

    His score was the eighth highest in the class.

    Lisa missed two and a half questions, so her score was 90.

    Her score was the tenth highest score.

    Her score was 4 points higher than the average score.

     

    Lisa was disappointed with her test results.

    She studied hard for the test, but she still didn’t do well.

    As a result, she plans to study harder for the next test.

    The next test will be in about two weeks.

     

    Tom was surprised and happy with his test results.

    He didn’t study hard, so his result was better than he expected.

    He was also happy that he did better than Lisa did.

     

     

    Vocabulary

    Lesson 3 Emotions

    She is screaming because she is really scared.

    Something is chasing her so she is screaming for help.

    He is shouting because he is angry.

    When he’s really angry he often shouts like this.

    She is sleeping because she’s tired.

    Last night she didn’t get enough sleep, so today she has no energy.

    She’s crying because she’s sad.

    She got some bad news a few minutes ago.

    She’s smiling because she’s happy.

    Her boyfriend just called and he’s returning from a long trip.

     

    Who is smiling because she got some good news?

    Lesson 4 Hobbies

    This man is hiking up a mountain trail.

    He is wearing hiking boots and is carrying a pack on his back.

    This man enjoys cooking.

    He attends a cooking class once a week.

    This woman enjoys gardening.

    She grows flowers, such as roses, and vegetables, such as tomatoes, in her garden.

    This boy loves playing games.

    He likes all kinds of games, including this video games on his computer.

    This old couple enjoys travelling.

    They take several trips a year, often to different countries.

    Dialogue

    Lesson 5 Ready for the Meeting

    W: Oh, there you are, finally.

    M: Yeah, I’m sorry.

    W: Why are you so late? You were supposed to be here 30 minutes ago.

    M: I got on the wrong subway by mistake.

     

    -When was he supposed to be there? -30 minutes ago.

    -Why was he late? –He took the wrong subway.

     

    W: Why didn’t you call? I was really worried.

    M: I don’t have my phone. I left it in the office because I was in such a hurry to get here.

    W: OK, well, you’re here now. We don’t have much time.

    M: Yes, we’ll have to hurry. The meeting starts in 15 minutes, right?

    W: Yes, it’s supposed to, if everyone gets here on time.

     

    -When is the meeting supposed to start? –in 15 minutes.

    -To hurry means.. –To go fast.

     

    W: Did you read my presentation?

    M: Yes, I do. It’s good, but it’s a bit too long. I’m afraid there won’t be enough time for questions.

    W: Do you have any suggestions?

    M: Yes, I do. I think the company introduction can be cut in half. They know what we do.

    W: OK, I won’t show the video. It’s about 2 minutes long.

    M: That’s a good idea. The video is on our website and is not that good any way.

     

    -What is she going to cut from her presentation? –the video.

    -Why is the presentation a bit too long? –There isn’t enough time for questions.

     

    W: Do you have any other suggestions?

    M: No, I don’t. I’m sure you’re doing a great job. Are you ready?

    W: Yes, I’m ready. The meeting room is on the 21st floor.

    M: OK, let’s go.

     

    -Where is the meeting going to be? –in a meeting room.

    She’s ready to give her presentation at the meeting.

    Lesson 6 Discussing Test Results

    Lisa: How did you do on yesterday’s science test?

    Tom: I did better than expected. How about you?

    Lisa: I didn’t do very well. I expected to do better than I did.

    Tom: What was your score?

    Lisa: I got a 90. What about you?

    Tom: I got a 92. I only missed two questions.

     

    -How well did he do on the test? –He did better than expected.

    She didn’t do as well as she expected.

     

    Lisa: So you did better than I did. And I really study for it too.

    Tom: That is a surprise. You usually do better than I do.

    Lisa: Yes, I wasn’t careful. I made one really stupid mistake.

    Tom: What was it?

    Lisa: I said 90% of the sun is Helium instead of Hydrogen.

    Tom: Wow. That was a stupid mistake.

     

    -Why was he surprised by the result? –He did better than she did.

     

    Tom: What was the average score for the class, do you know?

    Lisa: The average score was 86.3 and the lowest was 68.

    Tom: Do you know who got the lowest test score?

    Lisa: No, I don’t. I don’t know who got the lowest score.

    Tom: It’s probably a secret. Did anyone get a perfect score?

    Lisa: I think Ada and Sandi both got perfect score.

    Tom: Yes, they always do well. I wish I were as smart as they are.

     

    -What was the average test score? -86.3.

     

    2/4

    Listening

    Lesson 1 Paul’s Trip Plan 1-2

    In six weeks Paul is going on a trip.

    He is going to Japan and China.

    There are a couple of reasons for the trip.

    One reason is for business.

    He is thinking about starting restaurants in both countries.

    The other reason is for pleasure.

    He enjoys travelling and he’d like to visit some friends.

     

    -What’s going to happen in six weeks? –He is going on a trip.

    -What is he thinking about starting in both countries? –He is thinking about starting restaurants.

     

    Yesterday he went online and made airline reservations.

    There were plenty of seats on the plane, so it was easy.

    He also got a good discount.

    Unfortunately, he needs a new passport.

    His old passport is expiring next week.

    This is something he didn’t expect.

    Getting a new passport will take at least a week.

    He needs to apply for one right away.

     

    -Why did he need to get a new passport? –His old one is expiring soon.

    -What did he need to do right away? –apply for a new passport.

    -How long will it take to get a new passport? –At least a week.

     

    Paul also needs a visa to enter China.

    The last time he went to China was 3 years ago.

    Getting a visa may also take a week or even two.

    So he doesn’t have much time.

    He needs to hurry.

    He can’t get the visa until he gets his new passport.

    He’ll have to go to the Chinese consulate in Toronto.

    Hopefully there won’t be any delays.

     

    -What may take a week or two? –getting a visa.

    -When was the last time he went to China? -3 years ago.

     

    Paul has several friends in each country.

    One of his best friends lives near Mountain Fuji.

    His friend lives near a beautiful lake about 3 hours from Tokyo.

    His friend is a great cook and owns a little restaurant.

    The restaurant is located on a hill above the lake.

    It has a wonderful view and the food is wonderful.

    Paul is looking forward to eating there.

    Then he will spend the night at his friend’s house.

     

    -Where is Paul going to stay? –He’ll stay at his friend’s house.

    -What does his friend do? –He owns a restaurant.

     

    One way to get to his friend’s house is to go by train.

    If he takes a train his friend will meet him at the train station.

    There’s a train station about half an hour from his friend’s house.

    On the other hand he may decide to go by car.

    He can rent a car for a few days and see more of the country.

    He can use a GPS to help him with directions.

    He doesn’t speak Japanese so the directions need to be in English.

     

    -Why do the directions need to be in English? –He doesn’t speak Japanese.

    -If he takes a train, who will meet him? –His friend.

     

    In China Paul has a good friend who lives in Beijing.

    They studied at the same university in Canada more than 15 years ago.

    His Chinese friend wants to help Paul with his business.

    His friend has lots of business experiences.

    His friend can help Paul learn about doing business in China.

    Paul knows there is a lot to learn.

    He will certainly need his friend’s help.

     

    -Where did Paul meet his Chinese friend? –At a university in Canada.

    -What does Paul want to learn? –About doing business in China.

     

    While in Beijing, they plan to visit several Italian restaurants.

    They may meet with some of the owners too, but it isn’t certain yet.

    Most of the owners are Chinese.

    One or two of them may want to do business with Paul.

    If he has time he may go to the Great Wall of China.

    It’s a few hours outside Beijing by car.

     

    -Who may want to do business with Paul? –One or two restaurant owners.

     

    Altogether, the trip may take three or more weeks.

    Paul still isn’t sure how long he will stay in each country.

    He may spend a week in Japan and two weeks in China.

    He may decide to stay longer.

    Everything depends on his friends.

    He expects to get more information from them in the next day or two.

     

    -When does he expect to hear from his friends? –In a couple of days.

    -What do his plans depend on? –His friends.

    Vocabulary

    Lesson 3 Sports

    In basketball, players score points by shooting a basketball through a hoop.

    Each side has 5 players and the game is played on a basketball court.

    Football is probably the world’s most popular sport.

    Each team tries to score a goal by kicking the ball into a net.

    Baseball is a team sport where each side has 9 players.

    Baseball players use a bat to try to hit the ball and get on base.

    Golf is an individual sport where players try to hit the ball into a hole in the ground.

    The game is played on a golf course with 18 holes.

    In boxing the two boxers stand in a boxing ring and hit each other.

    Sometimes a boxer, like this one, knocks the other one out.

    Lesson 4 Injuries

    When people fall down, they can break a bone.

    A broken bone can be very painful.

    If someone is cut, they will bleed.

    A knife or sharp object can cut someone and cause bleeding.

    Poisons are very dangerous and cause death.

    Some snakes and spiders are poisonous, so be careful.

    A heart attack can happen very suddenly.

    If someone has a heart attack, call for an ambulance right away.

    If you catch on fire, fall to the ground and roll.

    Getting too close to a fire can be very dangerous.

    Dialogue

    Lesson 5 A Nightmare

    M: What’s the matter? You look really tired today.

    W: I am tired. I didn’t sleep well last night.

    M: Bad dream.

    W: Yes, exactly. I had a terrible dream, a really nightmare.

    M: So it woke you up.

    W: Yes, it woke me up. I was really scared.

    M: I’ve had those kinds of dreams too.

    W: It was so scary that I was afraid to go back to sleep.

     

    -Why didn’t she sleep well last night? –She had a terrible dream.

     

    M: Was something chasing you?

    W: No, nothing was chasing me, but I was falling.

    I was falling faster and faster, and it was dark. I couldn’t see or hear anything.

    M: Can you remember anything else?

    W: Yes, I remember now. In my dream I was screaming, but there was no sound.

    I thought I was going to die at any second.

    M: Wow. That is scary.

     

    -What was she doing in her dream? –falling and screaming.

     

    M: So what did you do when you woke up?

    W: I didn’t want to go back to sleep, so I checked the news online. Then I played the game.

    M: You didn’t go back to sleep?

    W: Actually I got too tired playing the game than I fell asleep.

    M: Well, at least you got some sleep. Some sleep is better than no sleep.

    W: I guess so. But I’m still tired. I hope I can get through the day.

     

    -What did she do when she woke up? –She went online.

    -What was she doing when she fell asleep? –She was playing a game online.

     

    M: Have a good lunch and then work out in the afternoon.

    W: Thanks, I’m already feeling a bit better.

    M: Hey, look, the boss is coming. Look like you’re working hard.

     

    -How is she feeling now? –She’s feeling a bit better.

    She had a terrible dream, and it woke her up.

    Lesson 6 Toilet Trouble

    M: Hey, what’s that awful smell?

    W: The toilet is broken in the men’s bathroom.

    M: Wow. I can’t work when it smells this bad. I need some fresh air.

     

    -What’s causing the awful smell? –a broken toilet.

    -Why can’t he work? –He can’t work because of the bad smell.

     

    W: OK, let’s take a break and go out for a walk. Get your computer and we can work at a coffee shop.

    M: Good idea. When do you think it will be cleaned up?

    W: A plumber is coming and he should be here soon. By the time we get back, the smell should be gone.

     

    -Who is coming to fix the toilet? –a plumber.

    -To take a break means… -To stop working for a while.

     

    M: That’s one job that I wouldn’t want. I hate to be around bad smells. What about you?

    W: Me too. I wouldn’t want to be a plumber.

    M: There are lots of jobs that I wouldn’t want.

    W: We can talk about that later. Get your computer and let’s get out of here.

     

    -What job wouldn’t they want to have? –They wouldn’t want to be a plumber.

    3/4

    Listening

    Lesson 1 Paul’s Overseas Trip 1-2

    Last month Paul went on a trip.

    He went to Japan and China.

    There were a couple of reasons for the trip.

    One reason for the trip was for business.

    He wanted to start some restaurants in both countries.

    The other reason was for pleasure.

    Paul enjoys travelling and he wanted to visit some friends.

     

    -What was he thinking about starting in both countries? –some restaurants.

     

    Before leaving on the trip Paul had several problems.

    First his passport was going to expire.

    As a result he needed to apply for a new passport.

    Second he needed to get a visa to enter China.

    In order to apply for a visa, he needed his new passport.

    He had 6 weeks to get everything done.

     

    -Why did he need a visa? –He needed a visa to enter China.

     

    After applying for a new passport it took 2 weeks to get it.

    Once he got the passport he went to the Chinese consulate in Toronto and applied for a visa.

    He filled out an application form and stood in a long line.

    He was surprised by how many people were applying for visas. It took more than an hour to submit his application.

     

    -How long did it take to submit the application? –It took more than an hour to submit it.

    -Why did he go to the Chinese consulate? –To apply for a visa.

     

    He submitted his application for the visa on a Friday.

    A week later he went back to the consulate to pick up his visa.

    To his surprise, when he got there, the consulate was closed.

    The consulate was closed because it was a Chinese holiday.

    Paul was angry at himself for not checking the consulate’s website.

    On its website the consulate’s schedule was posted.

    There was a notice saying that the consulate would be closed that day.

     

    -Why was the consulate closed? –It was a Chinese holiday.

      

    As a result, Paul had to come back the next Monday.

    This was because the consulate was closed on weekends.

    Finally on Monday, he got the visa and he was ready to go.

     

    -Why did he have to wait until Monday to come back? –The consulate was closed on weekends.

     

    Another problem with the trip was his travel schedule.

    He needed to extend his stay in Japan.

    One week in Japan wasn’t enough.

    3 Japanese restaurant owners wanted to meet with him.

    He needed more time for the meetings than a couple of days.

    And he didn’t want to miss staying with the good friend of his.

     

    -What did he need to do his schedule? –He needed to extend his stay in Japan.

    -What didn’t he want to miss? –Staying with a good friend of his.

     

    His friend lives near Mountain (Mt. for short) Fuji and owns a great restaurant.

    This was one thing Paul didn’t want to miss.

    As a result he extended his stay in Japan.

    Instead of staying for just a week, he decided to stay for 10 days.

     

    -What does his friend own? –He owns a great restaurant.

     

    As a result he had to change the dates for staying in China.

    The meetings in China were delayed by 3 days.

    Instead of arriving on the 1st of the month, he arrived on the 4th.

    Fortunately, there were no problems with his new schedule in China.

     

    -What problems were caused by his new schedule in China? –It didn’t cause any problems.

     

    However there were fewer meetings than he expected.

    There wasn’t much interest in opening new Italian restaurants. Still, he had one very good meeting.

    He met a young Chinese restaurant owner who was interested.

    The young man already has a restaurant, but he wants to improve it.

    He and Paul liked each other right away.

    They met twice in Beijing and are planning to meet again.

     

    -How much interest was there in opening new Italian restaurants? –not much.

    -How many times did Paul meet the young man? –They met twice.

     

    The young Chinese man’s name is G.

    He is planning to come to see Paul.

    They’re going to meet lately next week in Toronto.

    Together they will work on a business plan.

    Paul is glad that he took the trip.

    He thinks it was a successful and enjoyable trip.

     

    -What are they going to work on? –a business plan.

    Vocabulary

    Lesson 3 Emergency Vehicles

    Ambulances are used to transport injured or sick people to a hospital.

    An ambulance is trained medical personal who can treat injured or sick people.

    A wheel chair is for people who can’t walk.

    Wheel chairs have 4 wheels and are often pushed by people from behind.

    Fire engines are used to fight fires.

    Firefighters like this one often rescue people from burning buildings.

    Tow trucks are used to tow cars, this tow truck is towing a car to a repair shop.

    Helicopters are used to rescue people from dangerous places.

    This helicopter is lifting someone from a sinking boat.

     

    If your car won’t start, you should call for a tow truck.

    Lesson 4 Weather & Activities

    This tree is bending over because of the strong wind.

    It’s going to be windy for the next few days.

    It’s a very clear night, so they can look up and see many stars.

    There isn’t a single cloud in the sky.

    It’s very cold today, so they are wearing very warm clothes.

    Without warm clothes, they would freeze to death.

    It’s nice to eat ice cream on a hot day.

    This mother is buying ice cream for her daughter.

    This old man has to wear glasses to read.

    Without reading glasses, he can’t see clearly enough to read.

    Dialogue

    Lesson 5 Checking up on Ada

    M: How was Ada’s new job in Beijing?

    W: It seems to be going well. I talked with her last night.

    M: How much is she getting paid?

    W: I’m not sure. She said she’s earning more, but I don’t know she’s getting.

    M: Where is she living? Has she found a flat?

    W: No, not yet. She’s living with a friend, until she can find one of her own.

    Flats are more expensive there, and the quality isn’t good.

     

    -Who is Ada living with? –She’s living with a friend.

    -How long will Ada be living with her friend? –She’s going to stay until she can find a flat of her own.

     

    M: Did she say anything else?

    W: Her biggest complaint is the air quality. She hates the pollution.

    On some days the pollution is so bad that she is afraid to breathe.

    M: Yeah, I won’t want to live there.

    W: She’s hoping it will get better.

    M: I’m sure we will, but it’ll take time, especially with all the cars.

     

    -What is Ada’s biggest complaint? –the poor air quality.

     

    W: She also said she is still looking for a new boyfriend.

    M: That shouldn’t be difficult. She’s nice and she’s good-looking. Has she met anyone?

    W: No, I don’t think so. She’s looking for someone on the internet.

    M: Maybe she’ll be lucky.

    W: I think I’m going to try that too.

    M: Really?

    W: What other choices do we have? It’s so difficult to meet someone new. I never have any time.

    M: Me too. I’m always working. Maybe I’ll try online dating too.

     

    -Where is she looking for a new boyfriend? –She is looking for someone on the internet.

     

    M: If I’m lucky I may meet someone new, like Steve’s girlfriend.

    W: Oh, come one, you’re joking, right? I hope you can find someone better than her.

    M: Steve seems happy enough.

    W: Yes, but he is blind by love, you know that. I’m sure you won’t last for long.

    As soon as she gets bored, she’ll find someone else.

    M: You may be right. Let’s wait and see.

     

    -What is blinding Steve? –He is blinded by love.

     

    M: Hey, what about dinner? 

    W: Sure, it’s getting late and maybe I’ll be the woman of your dreams.

    M: Well, let’s take one night at a time. Let’s have some Indian food, okay?

    W: OK, tend and chicken for me. And I’m hungry.

     

    -What kind of food are they going to eat? –They are going to have Indian food. She’s earning more, but we don’t know how much she’s being paid.

     

     

    4/4

    Listening

    Lesson 1 Overview of Earth

    Earth is where we all live.

    It is our home in the solar system.

    There is no other place for us to live.

    Earth isn’t just any planet.

    It’s a very special place.

    It’s special because we depend on it for many things.

    Because of its importance we need to take care of it.

     

    -Why is earth so specially? –We depend on it for many things.

     

    We depend on the earth for its air, its water and many of its nature resources.

    Nature resources such as coal and oil give us energy.

    Other nature resources we depend on include forests and soil.

    Forests provide clean air and wood for building houses.

    Soil is needed to grow plants and keep them healthy.

    We need to take care of these resources and not to waste them.

     

    -What are examples of nature resources? –Coal and oil.

    -What don’t we want to do with nature resources? –We don’t want to waste them.

     

    The earth is a large, rotating sphere, about 4.5 billion years old.

    The equator, which divides the earth into two hemispheres, is about 40 thousand kilometers long.

    The earth’s diameter is 12756 kilometers.

    Its radius is half that, or 6378 kilometers.

    The radius is the distance from the earth center to its surface.

    Most of the earth’s surface is covered by water.

    About 75% of the earth’s surface is covered by water.

    The rest of the earth’s surface is land.

     

    -What divides the earth into two hemispheres? –The equator.

    -Besides water, what is the rest of the earth’s surface? –The rest of the earth’s surface is land.

     

    Just above the earth’s surface is the atmosphere.

    The atmosphere is a layer of gases about 500 kilometers thick.

    These gases include oxygen, nitrogen and carbon dioxide.

    This mixture of gases is the air that we breathe.

    As we move about the earth’s surface, the air gets thinner.

    At high altitudes, the air is too thin to breathe.

    At the edge of the atmosphere is space.

    There is no air at all in space.

     

    -Why can’t we breathe at very high altitudes? –The air is too thin.

    -What is at the upper edge of the atmosphere? –Space.

    -About how thick is the atmosphere? –It’s about 500 kilometer thick.

    Lesson 2 Water on Earth

    Most of the earth’s water is in the oceans.

    The two largest oceans are the Pacific and Atlantic Oceans.

    Unfortunately, we can’t drink ocean water.

    This is because ocean water has too much salt.

    Fortunately there is also water in lakes and rivers. These water isn’t salty so we can drink it.

    Only about 2% of the world’s water is fresh water.

    Without fresh drinking water we can’t live.

    A person can’t live for more than a few days without water.

     

    -How is fresh water different from ocean water? –Fresh water isn’t salty.

    -Why can’t we drink ocean water? –It has too much salt.

    One problem with ocean water is that we cannot drink it.

     

    Rivers are important.

    Most rivers begin in mountains and end in the oceans.

    The water flows from high ground to low ground.

    At first rivers are small and are called creeks or streams.

    As water enters from other streams, a river grows.

     

    -Where do most rivers end? –In the oceans.

    -In which diction do rivers flow? –It flows from high ground to low ground.

     

    Some rivers become very large and long.

    The longest river in the world is the Nile River, in Africa.

    It’s almost 6500 kilometers long.

    As for water volume, the Amazon is the largest river.

    The volume of water flowing through it per second is more than in any other river.

     

    -What is the world’s largest river by volume? –The Amazon, in South America.

     

    Another use of rivers is for energy.

    The energy of falling water is used to produce electricity.

    This use of water supplies over 20% of the world’s electricity.

    Rivers are also important for agriculture.

    Without water, farmers cannot grow food.

    And of course rivers can be used for transportation.

    Riverboats are used to carry things to inland cities or lakes.

     

    -How do farmers depend on rivers? –They are needed to grow food.

    Vocabulary

    Lesson 3 Things We Enjoy Doing

    This man goes running 5 days a week if the weather is good.

    On the weekends he runs 10 kilometers unless the weather is bad.

    This woman really enjoys reading, especially works of fiction.

    She has read hundreds of books.

    This young couple enjoys watching old movies, such as Titanic.

    They both cried when it sank and many people went down with the ship.

    These young boys enjoy playing sports on the weekend.

    Sometimes they play basketball and sometimes they play football.

    This young man eats too much sweet so he is overweight. He need to eat fewer sweets and exercises more.

     

    He is overweight because he eats too many sweets.

     Lesson 4 Continents

    Here are six of the earth’s seven continents.

    Asia is the largest continent both in land and in population.

    Asia covers 30% of the earth’s land area.

    Africa is the second largest continent.

    Of all the continent Africa has the youngest population.

    Europe is to the west of Asia, and is second smallest continent.

    Europe is the birthplace of classical music and some of the world’s greatest art and literature.

    North and South America are bordered on the west by the Pacific Ocean and on the east by the Atlantic Ocean.

    The first human beings to live in the Americas came from Asia more the 50000 years ago.

    Australia is the world’s smallest continent and the world’s largest island.

    Australia is surrounded by the Indian and Pacific Oceans.

    Dialogue

    Lesson 5 A Driverless Car

    M1: Hey , look at that.

    M2: Look at what?

    M1: Look out the window. Do you see the young lady in the red dress?

    M2: Yeah, I see her. Wow, she is beautiful and hot. Look at the way she walks.

    M1: Yes, no one behind her. Look in the car that’s following her.

    M2: I’d rather look at the young lady.

     

    -What does his opinion about the young lady? –He thinks she’s beautiful and hot.

    -Where is he supposed to look? –in the car.

     

    M2: So what’s so special about the car?

    M1: Look at the driver, do you see one?

    M2: No, I don’t. There isn’t anybody driving the car.

    M1: Right. It’s one of those new driverless cars.

    M2: Maybe it’s the woman’s car. It’s following her.

    M1: I don’t know. Maybe you are right.

    M2: Now that’s a smart car. Maybe I’ll go outside and follow her too.

    M1: Hey, get back to work.

     

    -Who is driving the car? –no one.

    -What is the car following? –a young lady.

    Lesson 6 Calling Customer Service

    Answering machine: Thank you for calling our customer support.

    Please listen to the following menu to help us direct your call.

    Please say or press 1 to pay your bill.

    Please say or press 2 to upgrade your service plan.

    Please say or press 3 to report a technical problem.

    Please say or press 4 if you want to hear this choice again.

    Customer: I don’t want any of these choices.

     

    -How does the custom feel? -Angry.

     

    Answering machine: You may also go to our website for help.

    Customer: I went to your website but it didn’t help. I want to speak to a human being.

    Answering machine: Your business is very important to us.

     

    -How does the custom feel? –Frustrated.

     

    Answering machine: Please say or press 5 or hang up to end this call.

    Customer: None of these. I want a human being. I want to cancel my service.

    Answering machine: Please wait while we connect you to a service representative.

    Customer: Finally. This is what they call customer service?

     

    -What is the custom trying to do? –He wants to cancel his service.

     

    Answering machine: To assist our representative, please say your first and last name.

    Customer: Tom Smith.

    Answering machine: We hear Tom Smith. If this is correct, say or press 1.

    If this is not correct, say or press 2. Customer: 1.

    Answering machine: Thank you. For security purpose, what was your father’s middle name?

    Customer: he didn’t have a middle name.

    Answering machine: Thank you. A customer service representative will be with you shortly.

     

    -Why did they want the custom’s father’s middle name? –To confirm the customer’s identity.

    -For security purpose means about the same as? –For safety reasons.

     

    Answering machine: I’m sorry but our offices are closed.

    Please call back during business hours.

    Our business offices are open Monday through Friday, from 8:00 am until 6:00 pm.

    Thank you for calling.

    Unit 3

    1/4

    Listening

    Lesson 1 Life & Conditions 1-2

    There are many forms of life on Earth, including human beings.

    Life exists in a variety of conditions.

    Some forms of life live in a watery environment, like the oceans.

    Other forms of life can be found in very dry areas, like deserts.

    However, for any form of life to exist, conditions must be right.

    When conditions are not right, that form of life will become extinct.

    To become extinct means to die out completely.

     

    -What must be right for life to exist?-Conditions.

    -What happens if conditions are not right? –Life cannot exist.

     

    Conditions must be right for life to exist.

    Millions of years ago, there were forms of life that no longer exist.

    When conditions changed, these forms of life died out.

    One extinction event happened about 250 million years ago.

    This was the largest extinction event of all time.

    Many forms of life became extinct.

    96% of all life in the oceans died out.

    Most insects also became extinct.

    This event happened over a period of several million years.

     

    -What happened about 250 million years ago? –Many forms of life became extinct.

    -What happens in an extinction event? –Many forms of life became extinct.

     

    The causes of this extinction event are still unknown.

    Possible causes include large volcanic eruptions and global warming.

    Some scientists believe that there were several causes.

    They believe that a series of events caused the extinctions.

    Scientists are working to better understand what really happened.

     

    -What is the one possible cause of this event? –Volcanic eruptions.

     

    In modern times, we humans face changing conditions.

    For humans to live, we need clean air and clean water.

    Pollution is now a growing problem around the world.

    Pollution poisons the air and water that we depend on.

    Polluted air makes people sick and afraid to go outside. Polluted water poisons our food supply.

    As a result, we never know which foods are safe to eat.

    Human beings cannot live in a poisoned environment.

    Therefore, pollution is a major threat to our existence.

     

    -What do humans need to live? –Clean air and clean water.

    -What poisons the air and water? –Pollution.

     

    Humans need temperatures to be in a comfortable range.

    To be in a comfortable range means to be neither too hot nor too cold.

    With global warming, global temperatures are rising.

    As temperatures rise, the polar icecaps will melt.

    As the polar ice caps melt, ocean levels will rise.

    Areas of some countries will soon be under water.

    People will be forced to relocate from flooded areas.

     

    -As temperatures rise, what will happen to the polar icecaps? –The polar icecaps will melt.

    -As the polar icecaps melt, what will happen? –Ocean levels will rise.

     

    In nature, even small changes can sometimes have large effects.

    It’s difficult to predict what’s going to happen.

    The entire ecosystem that we depend on is changing.

    Some of these changes are irreversible.

    Irreversible changes cannot be undone.

     

    -What can small changes sometimes cause? –Large effects.

    -What is happening to the world’s ecosystem? –Ecosystem is changing.

     

    Let’s hope that humans are smart enough to understand how the world is changing.

    With more understanding, we can make better choices about what to do.

    We can face the challenges of pollution and global warming.

    We need to do this before it’s too late.

    This planet Earth is our only home and we need to protect it.

     

    -What challenges do we need to face? –Pollution and global warming. We need to protect the environment that supports us.

    Vocabulary

    Lesson 3 Forms of Life

    Mammals are covered by hair or fur, have a backbone, and are warm blooded.

    All female mammals produce milk for their young.

    Reptiles are covered by scales, and includes snakes, lizards and turtles.

    Reptiles have a backbone and are cold blooded, which means they often relied on the external source of heat.

    Birds are covered by feathers and are warm blooded.

    Most birds can fly and many types of birds migrate great distances.

    Most insects such as ants and bees have a small three part of body with three pairs of legs.

    Some insects, like mosquitoes, spread diseases that cause the deaths of many humans.

    Unlike animals, plants get the energy that they need from the sun.

    Plants convert light energy, along with carbon dioxide and water, into chemical energy.

     

    Insects don’t have a backbone and most are cooled-blooded.

    Insects such as ants and bees live in well-organized colonies.

    Mosquitoes cause the deaths of more humans than any other animal.

    Mammals include some of the most intelligent animals on earth, such as elephants and human beings.

    Lesson 4 Instruments

    Scales and rulers are used to measure weight and length.

    Units of weight include kilograms and pounds, and units of length include centimeters and inches.

    These instruments are used to observe very large and very small objects.

    Telescopes are used to by astronomers and microscopes are used by biologists and doctors.

    These appliances are used in the kitchens of almost every home.

    Stoves are used to heat food and refrigerators are used to keep foods cool or cold.

    Household tools like these are used to build and repair things.

    Hammers are used to pound in nails and screwdrivers are used to turn a scow.

     

    If you need to pound in a nail, use a hammer.

    Dialogue

    Lesson 5 Dating Anniversary

    W: do you know what day it is today?

    M: what do you mean? Is it a special day?

    W: oh, so you don’t remember.

    M: remember what? What’s so special?

    W: it’s our anniversary. We started dating a year ago today.

    M: oh, really, I’m sorry.

     

    -When did they first start dating? –A year ago.

     

    M: just a minute. What do you think this is?

    W: oh, it’s a necklace.

    M: do you like it?

    W: yes, I do. It’s lovely, especially the red heart. May I put it on?

    M: no, let me do it.

     

    -What did he give her? –A necklace.

     

    W: so you did remember.

    M: of course I remembered. It’s a very special day for both of us.

    W: I have something for you too.

    M: you do?

    W: yes, but it will have to wait until later.

    M: oh, I can’t wait. Tell me what it is.

     

    -What would have to wait until later? –She’s going to give him a gift.

    Do you know what today is?

     

    W: can you guess what it is?

    M: could you give me a hint?

    W: we went there six month ago.

    M: oh, you mean Alfredo’s.

    W: yes, are you excited? You said you really like the food there.

    M: yes, that’s true. I also remember the dessert. Do you?

    W: yes, but let’s not talk about that now. Let’s now ruin the surprise.

     

    -What is Alfredo’s? –A restaurant.

    -What aren’t they going to talk about? –They aren’t going to talk about the desert.

    He remembered that today is their anniversary

    Lesson 6 Fine Dining

    W: That restaurant looks nice.

    M: Yes, but it looks expensive.

    W: Let’s go in and look the menu. Wow the menu looks great, especially the fish.

    M: Yes, it looks good, but look at those prices.

     

    -What doesn’t she like about the menu? –She likes the food choices.

     

    M: Let’s try somewhere else.

    W: Sometimes it’s ok to spend a little money.

    M: Yes, but these prices are a bit too high, don’t you think?

    W: Yes, there are a bit high. But don’t you think I’m worth it? Let’s enjoy ourselves.

    M: Ah, ok, if you put it that way. Let’s see if we can get a table.

    W: I’m glad you have your credit card.

    M: I sure hope the food is good.

    W: Stop worrying. Let’s just enjoy.

     

    -Who is going to pay the bill? –He will pay the bill.

    -How is he going to pay? –He is going to use his credit card. He is worried about spending so much money.

    2/4

    Listening

    Lesson 1 Quick Serve 1-2

    Quick Serve is a home repair company.

    It provides quick, reliable repair services to homes.

    Quick Serve handles plumbing and electrical issues, 24 hours a day.

    It also cleans roofs, fixes internet connections and replaces broken windows.

    For a small fee, customers subscribe to the service.

    Its main customers are the elderly, which means older people.

    Whenever customers have a problem, they can call for help.

    There is also a small service charge for each service call.

     

    -What kind of services does Quick Serve provide? –Home repair services

     

    The company was established 5 years ago and is growing rapidly.

    It started in one city but is now in 5 cities.

    The company plans to expand to 10 cities within the next 24 months.

    In each city there is a small central office in the low-rent area of the city.

    The central office handles the business, advertising, payroll and billing.

    It also takes calls from customers, either on line or by telephone. It takes calls 24 hours a day, 7 days a week.

     

    -When was the company established? –It started five years ago.

    -Where does the company locate its central offices? –They locate in low-rent areas.

     

    60% of the company’s employees work from their homes.

    When a customer calls into central office, a service employee is contracted.

    The service employee then contracts the customer and signs up an appointment.

    These service employees are highly trained and provide excellent service.

    In emergencies, such as a serious plumbing problem, service can be provided within an hour.

    One reason for this is that the service employees live in different parts of the city.

    They are not centrally located so it’s quicker and easier for them to travel to a customer’s home.

     

    -Where do 60% of the company’s employees work? –From their own homes.

     

    Quick Serve has an excellent reputation.

    Its prices are reasonable and its services are quick and efficient.

    The company’s service employees are clean, polite and efficient.

    In this type of business, person to person contact is the key to success.

    With each satisfied customer, more customers subscribe.

    Satisfied customers recommend Quick Serve to their friends.

    This kind of word of mouth advertising is very cost effective.

    Cost effective means that the results are good without paying a high price. In other words, quality service provides its own reward to the company.

     

    -What kind of customers recommend Quick Serve to their friends? –Satisfied customers.

    -What kind of reputation does the company have? –It has an excellent reputation.

     

    The company takes great pride in being honest with its customers.

    There are no hidden charges for their services.

    As a result, the number of customers in each city is growing rapidly.

    With the aging population there are more elderly people who need home repair services.

    These people need to have confidence in the service provider.

    They don’t want to be cheated.

    These people don’t mind to pay a reasonable fee for high quality service. High quality service should be rewarded.

     

    -What should be rewarded? –High quality service.

    -What is the company pride of? –It’s honest with its customers.

     

    The company provides a range of service plans, each with the different subscription plans.

    The least expensive service plan is called the basic plan.

    This plan provides non-emergency services with a very low service charge.

    The most expensive service plan is their VIP plan.

    The VIP plan provides emergency services 24 hours a day with no additional service charge.

    It also provides rebates to customers who don’t call for any services during the year.

    In addition, Quick Serve gives bonus points to customers for each year they subscribe.

    These bonus points can be used to buy new appliances such as stoves and refrigerators.

     

    -What kind of service plans does the company provide? –It has a range of plans.

    -What can bonus points be used for? –Buying new appliances.

     

    If the business continues to grow, the owners may decide to take the company public.

    This means that the public can buy shares of the company.

    It will then change from a privately-owned company to a public company.

    The owners believe that their business is successful and can expand around the world. They also believe that taking their company public can make them rich.

     

    -Why do the owners want to take their company public? –They can become rich.

    Vocabulary

    Lesson 3 Sciences

    Biology is the study of life, including its structure and evolution.

    Biologists study how life survives and reproduces.

    Chemistry is the study of matter, including the structure of atoms and molecule.

    Chemists study how various substances interact with each other.

    Astronomy is one of the oldest sciences.

    Astronomers study the structure and evolution of the universe, including the study of stars, planets, and galaxies.

    Geology is the study of the structure and history of the Earth and the other planets.

    Geologists study different types of rocks, earthquakes, and different layers of the Earth.

    Mathematic is the study of numbers, shapes, patterns and change. Mathematic is used by all other branches of science.

     

    Lesson 4 Disasters

    Here are some types of terrible events that hurt or kill people.

    Earthquakes are caused by forces deep within the Earth.

    During earthquakes, many people are often killed by collapsing buildings and bridges.

    Floods happen when rivers rise and overflow their banks.

    Flood waters damage or destroy many houses and businesses.

    Fires destroy buildings, land and forests.

    There are many causes for fire, including lightning.

    In a hurricane, high winds destroy buildings, and sometime cause flooding.

    Some hurricanes have winds of more than 200 miles an hour.

    Car accidents happen when cars collide, or when drivers lose control of their cars.

    One of the main causes of car accidents is driving too fast.

     

    When people are not careful, they can start fires that can cause a lot of damage.

    Dialogue

    Lesson 5 Desk Assembly

    W: What’s in the big box you are carrying?

    M: It’s a new desk. I just bought it and now I have to put it together.

    W: Do you need any help?

    M: No, I don’t think so. I just need to get my tools. I’ll need a screwdriver and maybe a hammer.

    W: Don’t forget to read the instructions.

     

    -What does he need? –Some tools.

     

    W: How are things going?

    M: I’m almost finished.

    W: Something doesn’t look right to me. The right side is higher than the left side.

    M: Oh, you are right. It looks like I put a couple of screws into the wrong places.

     

    -What doesn’t look right? –The desk.

     

    W: So now you have to take it apart.

    M: Great. And I thought I was almost finished.

    W: I told you to read the instructions. Did you read them?

    M: No, I didn’t read them. I hate to read instructions. I looked them, but they were confusing.

    W: Well, this is what happens when you don’t. You were too impatient. Anyway, what can I do to help you?

    M: Would you get another screwdriver and help me unscrew some of these screws?

    W: Ok, but next time please read the instructions.

     

    -What didn’t he do? –Read the instructions.

    -What was wrong with the instructions? –They were confusing.

    Lesson 6 Life and the Universe

    W: Do you ever look up at the sky and think about life and universe?

    M: I did when I was a kid. But I don’t do that for as much anymore. Why do you ask?

    W: Sometimes I feel like I lost in day-to-day details.

    Then when I look up at the sky, I see the big picture. I appreciate things more, even the little things.

     

    -What happens when she sees the big picture? –She appreciates things more.

    -What doesn’t he do so much anymore? –He doesn’t think about life and universe.

     

    M: You sound like a philosopher or a poet. I felt like that too when I was a kid.

    W: Don’t you feel like that anymore?

    M: No, I don’t. In fact, I try not to. When I think about things too deeply, I get depressed.

    It’s even a bit frightening.

    W: Really? For me, it’s just the opposite. Everything seems like a wonderful miracle.

    M: Doesn’t that frighten you a bit? The universe is so large and we are so small.

     

    -What happens when he thinks too deeply? –He gets depressed.

     

    W: What I realize is how little we understand. We just need to appreciate our lives and not get lost.

    M: Sometimes being lost isn’t so bad. Do you the expression, ignorance is bliss?

    W: Sure, I’ve heard it many times. To be ignorant is to be happy.

     

    -What does the word bliss mean? –Complete happiness.

    -What does she realize? –There is a lot that we don’t understand.

     

    M: Maybe it’s true. Maybe it’s best not to think or know too much.

    W: No, that’s not for me. I want to understand as much as possible. That’s why I became a scientist.

    M: Well, I respect your choice, but it’s not for me. If understanding is painful, I’d rather not understand.

     

    -Why does she become a scientist? –She wants to understand as much as possible. -What doesn’t he agree with? –Her choice.

    3/4

    Listening

    Lesson 1 Harry’s Business Trip 1-2

    Harry is on a business trip.

    Yesterday he was supposed to fly from San Francisco to Shanghai.

    However, things didn’t turn out the way they were supposed to.

    In fact, nothing went the way it was supposed to.

    Everything went wrong and he didn’t get on his flight.

    As a result, he is still in San Francisco.

     

    -What was he supposed to do yesterday? –Fly to Shanghai.

    -When was Harry supposed to fly to Shanghai? –Yesterday.

     

    The following is the summary of what happened.

    Yesterday morning he got up as usual and had breakfast.

    Everything seemed to be fine and he was looking forward to the trip.

    He was just about to check out of his hotel when he felt a pain.

    It was a pain in his lower back.

    It was a doll pain at first, not too bad.

    So he didn’t worry about it and he checked out of the hotel.

    Then he got on a shuttle bus to the airport.

     

    -Where was the pain located? –It was a pain in his lower back.

    -Why didn’t he worry about the pain? –It wasn’t too bad at first.

     

    About half way to the airport, the pain in his back started to get worse.

    It was a growing pain, and he was beginning to worry.

    Soon it was difficult for him to sit in the seat.

    The pain was getting worse.

    He wanted to lie down.

    He started to sweat and breathe quickly.

    He was in real pain then.

    On a scale of 1 to 10, the pain was an 8.

     

    -How was the pain changing? –It was getting worse.

    -Why did he want to lie down? –It was difficult for him to sit in the seat.

     

    When the bus got to the airport the bus driver helped him get off.

    It was difficult for him to walk but he finally made it to the terminal.

    Inside the terminal he went to the man’s bath room. He went to the toilet but that didn’t help.

    Instead of improving he felt dizzy and he threw up.

    By now he was wet for all the sweating.

    He knew he couldn’t get on his flight.

     

    -How did he feel after he went to the toilet? –He felt dizzy and sick.

    -Where did he go once he got inside the terminal? –He went to the men’s bathroom.

     

    He used his phone to call the airline.

    He explained the situation and cancelled his reservation.

    Then he called 911 for emergency help.

    911 is the emergency number to call for help in the United State.

     

    -What did he do to his reservation? –He cancelled it.

    -Why did he call 911? –He called 911 for emergency help.

     

    An ambulance arrived about 10 minutes after he called.

    By then he was in so much pain that he could barely walk.

    Once inside the ambulance they gave him oxygen to help him breathe.

    But the pain was still terrible.

    Then they drove him into a hospital near the airport.

    Luckily the hospital was on his health plan.

    That means his health insurance is supposed to pay for everything.

    Medical costs in the United States are very high.

     

    -Who was supposed to pay for his medicine care? –His health insurance company.

    -What did they give him inside the ambulance? –They gave him oxygen to help him breathe.

     

    When he arrived at the hospital he was taken into the emergency room.

    After some test a doctor told him he had a kidney stone.

    It was a very small stone but it caused a lot of pain.

    It was passing through a small turbine his body from his kidney to his bladder.

    The pain would go away once it got to his bladder.

    Until then he had to get pain medicine to reduce the pain.

     

    -Where was he taken when he got to the hospital? –He was taken to the emergency room.

    -What did he take to control his pain? –Some pain medicine.

     

    Harry didn’t have to stay at the hospital for very long.

    With the pain medicine the pain went away very quickly.

    He took a taxi back to his hotel and checked in for another night.

    Then he called the airline and made reservation for another flight.

    The flight will leave tomorrow.

    Until then he’ll just rest in his hotel.

    There may even be a good movie to watch.

     

    -Where will he be until his next flight? –He’ll stay in his hotel.

    -What is he going to do until his next flight? –He is going to have some rest.

     

    So when you are travelling, please be prepared for emergencies.

    Make sure you have medicine insurance.

    You never know when something like this can happen to you.

    So be prepared.

     

    -What should you have before travelling? –Medicine insurance. It’s a good idea to have medicine insurance before travelling.

    Vocabulary

    Lesson 3 Sources of Energy

    Solar energy is one of the cleanest and most plentiful sources of energy.

    Solar power depends on sunlight, so in cloudy weather and at night, no power is generated.

    Wind energy is nonpolluting but is only useful in place where there is a lot of wind.

    Wind turbines convert the kinetic energy of the wind into mechanical power.

    Nuclear energy is efficient and doesn’t produce carbon gases as a waste product.

    The dangers of nuclear power include deadly radioactive waste products.

    A major source of energy comes from the burning of fossil fuels, such as coal and oil.

    When we burn fossil fuels, waste gases such as CO2 are produced.

    Fossil fuels remain the largest source of energy for most countries.

    Hydropower comes from the kinetic energy of falling water.

    Output is reliable and can be regulated to meet the demand, except during the periods of drought.

     

    One of the main problems we face is how to reduce the use of the fossil fuels to produce energy.

    We need to reduce the use of the fossil fuels to produce energy. Dams are expensive to build and affect wildlife such as fish.

    Lesson 4 Types of Words

    Here are some different types of words in English.

    Words that are nouns or pronouns are used to represent objects.

    A noun or a pronoun can be a person, an animal or a thing, including an idea.

    Verbs are used to express actions, such as to sit down, or stand up.

    We also use verbs to express relationships, such as to love someone or to own something.

    We used adjectives to describe objects, such as a tall building.

    Adjectives are used with nouns and pronouns, but not with verbs.

    We use adverbs to describe actions, such as to run fast or walk slowly.

    Adverbs express the quality of an action, such as how well or poorly something is done.

    We use conjunctions to connect things or actions, such as to read and write.

    Conjunctions include words such as and, or, because, but, and yet.

     

    Nouns and pronouns can be used to represent any object.

    Dialogue

    Lesson 5 Good News & Bad News

    W: Hey, I’ve got some news, some good news and some bad news.

    M: OK, give me the bad news first.

    W: We are moving to a new office.

    M: When is this going to happen?

    W: We are supposed to move at the end of next month.

    M: How far away is the new office?

    W: We are not sure yet. But it will mean a longer commute for most of us.

    The new office will probably be on the other side of the city.

    M: The commute is already too long for me and I’m not going to change flats. We just bought one.

     

    -What did he just but? –He just bought a new flat.

    -How is the move going to affect the commute? –It’ll make the commute longer for most of the employees.

     

    M: Anyway, what’s the good news?

    W: The good news is that we are going to expand.

    The company is growing so we are going to hire more people.

    M: Well, I’ve got some news for you too.

    W: I hope it’s a good news.

    M: Well, that depends on your point of view. I’m planning to start my own business.

    W: Why? I thought you were happy working here.

    M: I like the work, but I’m not learning anything new. I think I can do better on my own.

     

    -Why is the company going to hire more people? –The company is growing.

     

    M: I was planning to wait a few months. But now that the office is moving, I’m ready to make the change.

    W: What is your wife think?

    M: She’s in fever of it and she will help me. She’s already designing a website.

    We’ll work from home at first.

    W: So you really are serious about this? You’re taking a big risk. Most new businesses fail.

    M: Yes, I know, but if I don’t do it now, I never will. I’m tired of working for others.

    W: I know what you mean.

     

    -What does his wife think his decision? –She’s in favor of it.

    -What is he serious about? –He is serious about starting his own business.

     

    M: Don’t tell anyone about this, OK? It’s still a secret.

    W: Sure, I won’t say anything to anybody. I’m sure this will come as a surprise to everyone.

    M: I’m sure changing offices will also come as a surprise to people.

    This is exactly why I want to work on my own. I don’t like these kinds of surprises.

    W: You are right about that. When are you going to let people know?

    M: I’ll make the announcement at the beginning of next month.

     

    -What is a secret? –His decision to leave the company.

    -When is he going to let people know about his decision to leave? –He’ll announce his decision at the beginning of next month.

    4/4

    Listening

    Lesson 1 Leonardo da Vinci 1-2

    Leonardo Da Vinci is one of the greatest geniuses of all time.

    He was a painter, an architect, an engineer and a scientist.

    He was born in Vinci, Italy in 1452.

    Vinci is a town just outside the great Italian city, Florence.

    His name Da Vinci means of Vinci.

    Leonardo’s father was a lawyer and a landowner and his mother was a present.

    Leonardo’s parents were never married to each other.

     

    -How long were his parents married? –They were never married.

    -Where was he born? –In Vinci, Italy.

     

    Leonardo lived with his mother until he was around 5 years old.

    When he was 5, he moved into the home of his father.

    By then, his father had married a 16-year-old girl.

    Leonardo’s mother married another man and moved to another town.

    She had many more children after that, with several different men.

    In the end, Leonardo had more than 15 half-sisters and brothers.

     

    -With whom did he live when he was 5? –His mother.

     

    As a young man, Da Vinci didn’t go to school.

    He was educated at home in reading, writing and mathematics.

    In other subjects, he was mostly self-educated.

    He had access to books at his father’s home.

    Leonardo spent a lot of time outdoors and developed a strong interest in nature.

    He loved to observe things, especially birds.

    He was also interested in the properties of water.

     

    -What did he have access to at home? –Books at his father’s home.

    -In what did he develop a strong interest? –He developed a strong interest in nature.

     

    Leonardo’s early drawings and paintings demonstrated a rare talent.

    His father and his father’s friend recognized his talent and encouraged him.

    When he was 15, he was sent to Florence.

    In Florence, he became an apprentice to a famous master painter.

    For the next few years Leonardo worked at his master’s workshop.

    It wasn’t long before his ability surpassed that of his master.

    Some people say that his master became jealous about Leonardo’s greatest talent.

    They say that the master vowed to never paint again.

    In 1478, with his father’s help, Leonardo set up his own workshop.

     

    -Who became jealous with Leonardo’s talent? –His master in Florence.

     

    In 1482, he entered the service of a powerful man in the city of Milan.

    This man was the duke of Milan.

    For the next few years, Leonardo designed buildings, machinery and weapons of war.

    Weapons were important because Italy was constantly at war during this period.

    From 1485 to 1490, Leonardo produced designs for a variety of weapons.

    In his notes, he predicted the development of advanced weapons such as submarines and flying machines. In 1499, the French invaded Italy, and Leonardo left Milan.

     

    -Why did Leonardo live Milan? –The French invaded Italy.

    -Who did Leonardo work for in Milan? –He worked for the duke of Milan.

     

    All together Leonardo spent 17 years in Milan.

    During this period he spent much of his time studying in nature.

    He dissected bodies, both human and animal, to study an illustrate anatomy.

    His detailed illustrations are masterpieces.

    Leonardo filled many notebooks with drawings and ideas.

    He wrote backwards so you need a mirror to read them.

     

    -Why do you need a mirror to read his notebooks? –He wrote backwards. He left Milan because the French invaded Italy.

     

    After 1500, Leonardo spent time in a number of Italian cities.

    He worked very slowly and the range of his interests was very wide.

    As a result Leonardo left many paintings and projects unfinished.

    One painting that he did finish was the Mona Lisa, one of the world’s most famous paintings.

    People are still interested in this painting, 500 years after he painted it.

    Though there are many theories nobody knows who the woman in the painting really was.

     

    -Why did Leonardo leave so many projects unfinished? –He worked slowly and had a wide range of interests.

    -Who was the woman in the painting? –Nobody knows for sure.

     

    In 1516, Leonardo left Italy for good when the French King, Francis I (the first), offered him a position.

    There he had a freedom to paint and draw whatever he wanted.

    Leonardo died in 1519 at the age of 67.

    Some said that the French king who had become a close friend was with him when he died.

    He was buried in the church which was destroyed during the French revolution.

    The exact location of his remains is unknown.

     

    -How old was he when he died? –He died at the age of 67.

    -Who offered Leonardo a position in 1516? –The king of France.

    Vocabulary

    Lesson 3 Sources of Pollution

    Waste water and carbon gases from farm animals are bad for the environment.

    Animals waste and other chemicals flow into the ground and pollute water supplies.

    Exhaust gases from automobiles are a major cause of air pollution and global warming.

    As a result many companies are trying to produce more efficient and cleaner cars.

    Pesticides and fertilizers are used by farmers to grow crops such as fruits and vegetables.

    These chemicals pollute water supplies when they flow into the ground or rivers.

    Factories like this one allow harmful chemicals to get into the air or water.

    Companies need to try harder to protect the environment and our health.

    Nuclear waste products are radioactive and can pollute the environment for thousands of years. They need to be safely transported and stored in a safe place.

     

    Nuclear waste products need to be stored in a safe place.

    Lesson 4 Historical Figures

    The British writer, Jane Austin, was born in England in 1775, one of seven children.

    She wrote some of the most popular love stories of all time.

    One of the most famous female rulers in history, Cleopatra had affairs with Julius Caesar and later with Mark Antony.

    She was known for her great beauty and charming voice.

    Born in 1756, Mozart composed and performed some of the world’s greatest classical music.

    He was the youngest of 7 children and by the age of 5, he was already composing music.

    The sun of the king, Alexander the great, was the military leader who created one of the largest empires in the ancient world.

    As a youth, Alexander was taught by the Greek philosopher Aristotle.

    Mohandas Gandy was a 20th century leader who used non-violent resistance to lead India to independence. Gandy dedicated his life to the pursuit of truth.

     

    Mozart started writing music as a young child.

    Dialogue

    Lesson5 An Urgent Call

    M: I’d like to speak with Mr. Bennett, please.

    W: I’m sorry, but he’s not here right now. Would you like to leave a voice message?

    M: It’s urgent that I speak with him. It’s an emergency.

    W: Oh, I see. What kind of emergency?

    M: It’s very personal so I can’t give you any details.

     

    -What does the word urgent mean? –Need quick attention.

    -Why doesn’t he want to leave a voice message? –It’s an urgent matter.

     

    W: Without any details I’m afraid I can’t give you his number.

    Give me your number and I’ll let him know about your call.

    Then maybe he’ll call you back, would that be okay?

    M: Sure, my number is 5834987. It would be great if he could call me within the next half hour.

     

    -Why doesn’t she give out Mr. Bennett’s number? –She needs more details.

     

    M1: That was a great dinner. Here, put away your wallet, I’ll the bill.

    M2: You paid last time, this time is my turn to pay.

    M1: Hey, you don’t have a job, and I do, let me pay.

    M2: Thanks for the offer, but I can handle it.

     

    -Why does he want to pay? –It’s his turn to pay.

     

    M1: Wait, let’s flip for it.

    M2: Flip for it? What does that mean?

    M1: Do you see this corn? This side is heads and the opposite is tails. I’ll flip up in the air.

     If it comes down with heads facing up, I’ll pay. If tails are the up, you can pay.

    M2: OK, that’s fine with me.

     

    -How are they going to decide who is going to pay? –They are going to flip a corn.

     

    M1: Look, it’s heads up, so I’ll pay.

    M2: Thanks, it’s very nice of you.

    M1: It’s my pleasure.

    Lesson 6 Setting the Bill

    W: Do you want anything else, Sir? Would you like to see the desserts menu?

    M: No, thanks, I’m ready for the check. Here is my credit card.

    W: I’m sorry, Sir, but we don’t take credit cards.

    M: You’re joking, right?

    W: No, sir. I’m not joking. Do you see that sign? It says cash only.

    M: I didn’t see it when I came in. I don’t have enough cash to pay the bill.

     

    -How did he plan to pay? –He planned to pay by credit card.

    -Why can’t he pay? –He doesn’t have enough cash.

     

    W: There is a bank down the street.

    If you let me hold your driver’s license, you can go and get the cash.

    M: OK, I hope the bank is open.

    W: The bank is closed, but you can use the ATM to get your cash.

     

    -Where can he get the cash? –He can get the cash at an ATM down the street. He has to leave his driver’s license with the waiter.

     

     

    展开全文
  • This is a very common interview question that has been asked at companies like Yahoo, Apple, and NCR. A process is an executing instance of an application. For example, ...

    Processes vs Threads

    This is a very common interview question that has been asked at companies like Yahoo, Apple, and NCR.

    A process is an executing instance of an application. For example, when you double-click the Microsoft Word icon, you start a process that runs Word. A thread is a path of execution within a process. Also, a process can contain multiple threads. When you start Word, the operating system creates a process and begins executing the primary thread of that process.

    It's important to note that a thread can do anything a process can do. But since a process can consist of multiple threads, a thread could be considered a 'lightweight' process. Thus, the essential difference between a thread and a process is the work that each one is used to accomplish. Threads are used for small tasks, whereas processes are used for more 'heavyweight' tasks - basically the execution of applications.

    Advertisement:  

    Another difference between a thread and a process is that threads within the same process share the same address space, whereas different processes do not. This allows threads to read from and write to the same data structures and variables, and also facilitates communication between threads. Communication between processes - also known as IPC, or inter-process communication - is quite difficult and resource-intensive.

    MultiThreading

    Threads, of course, allow for multi-threading. A common example of the advantage of multithreading is the fact that you can have a word processor that prints a document using a background thread, but at the same time another thread is running that accepts user input, so that you can type up a new document.

    If we were dealing with an application that uses only one thread, then the application would only be able to do one thing at a time - so printing and responding to user input at the same time would not be possible in a single threaded application.

    Each process has it's own address space, but the threads within the same process share that address space. Threads also share any other resources within that process. This means that it's very easy to share data amongst threads, but it's also easy for the threads to step on each other, which can lead to bad things.

    Multithreaded programs must be carefully programmed to prevent those bad things from happening. Sections of code that modify data structures shared by multiple threads are called critical sections. When a critical section is running in one thread it's extremely important that no other thread be allowed into that critical section. This is called synchronization, which we wont get into any further over here. But, the point is that multithreading requires careful programming.

    Also, context switching between threads is generally less expensive than in processes. And finally, the overhead (the cost of communication) between threads is very low relative to processes.


    Here's a summary of the differences between threads and processes:
    1. Threads are easier to create than processes since they don't require a separate address space.                       
    2. Multithreading requires careful programming since threads share data structures that should only be modified by one thread at a time. Unlike threads, processes don't share the same address space.               
    3. Threads are considered lightweight because they use far less resources than processes.
    4. Processes are independent of each other. Threads, since they share the same address space are interdependent, so caution must be taken so that different threads don't step on each other.  This is really another way of stating #2 above.                       
    5. A process can consist of multiple threads.

    展开全文
  • I wirte this article for three reasons, one for a friend who once chatted with me and said 'you qzone is as blank as a A4 paper, i don't know what the hell kind of person are you.' Actually,it's a go
  • What is the expectation maximization algorithm?

    千次阅读 2013-05-26 22:50:19
    he expectation maximization algorithm arises in many computational biology applications that involve probabilistic models. What is it good for, and how does it work? Introduction Probabilist
  • 【Tensorflow】基于卷积神经网络实现车牌的识别

    千次阅读 多人点赞 2019-12-21 16:32:57
    "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T...
  • In summary, the whole training process resembles showing a child many images of things, and him/her having to gradually figure out what to look for in the images to tell those things apart. Or if you ...
  • What Is GIS ?

    千次阅读 2006-02-18 22:43:00
    A Geographic Information System(GIS) supports several views for working with geographic information. Geodatabase view: A GIS is a spatial database containing data sets that represent geograph
  • I know references are syntactic sugar, so code is easier to read and write. But what are the differences? Summary from answers and links below: A pointer can be re-assigned
  • What's a Tri-state Buffer?

    千次阅读 2017-04-18 19:54:04
    What's a Tri-state Buffer? http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/CompOrg/tristate.html © 2003 by Charles C. Lin. All rights reserved. Introduction Before we talk about tri-...
  • What Is NXDOMAIN?

    千次阅读 2015-04-06 13:39:02
    What is NXDOMAIN? How does nxdomain affects my browsing? Explains the relationship between NXDOMAIN and DNS Hijacking. A DNS server is used to translate a domain name into an IP address or vise ver
  • What Is Text Mining?

    千次阅读 2009-10-31 16:18:00
    programs, and example, which is not a bad five-word summary of its contents.)   There are programs that can, with reasonable accuracy, extract information from text with somewhat ...
  • tips talk about three kinds of things knowledge-based skills,or specific skills you’ve learned either in school or by working,such as computer skills, a university ...is what we would call tra...
  • What is an Object?(转载)

    千次阅读 2005-02-06 11:00:00
    Objects defined So what is an object? An object is a component of a program that knows how to perform certain actions and to interact with other pieces of the program. Functions have previous
  • What are differences between Enumeration and Iterator This question is from early ages of interview , I have not seen this question on recent interviews but it was common during 2006-2007 , now days
  • Image Sampling and Nyquist Theorem (summary)

    千次阅读 2015-10-27 11:05:44
    This article is the summary of 1D, 2D sampling convolution and Nyquist Theorem from the textbook Digital Image Processing Third Edition, and the course of “Fundamentals of DigitalImage and Video ...
  • This article is the notes of machine learning week 5, Neural Networks Learning. It contains topic about how to apply Backpropagation algorithm in practice.
  • What is an ORA-04031 Error?

    千次阅读 2013-10-22 22:28:33
    What is an ORA-04031 Error?    The memory pool in the SGA are comprised of memory chunks in various sizes. When the database starts is started, you have a large chunk of memory allocated in the v
  • 流利说 Level 5 全文

    万次阅读 多人点赞 2019-05-22 10:53:33
    Level 5 Unit 1 1/4 Listening Lesson 1 Jessica’s Class Reunion1-2 Vocabulary Lesson 3 Actions and Change Lesson 4 Types of Information ...Lesson 5 A Customer Complaint 2/4 Listening L...
  • What Is Web 2.0

    千次阅读 2006-03-04 10:49:00
    What Is Web 2.0 Design Patterns and Business Models for the Next Generation of Softwareby Tim OReilly 09/30/2005 The bursting of the dot-com bubble in the fall of 2001 marked a turning point for
  • 转载:https://blogs.infoblox.com/ipv6-coe/fe80-1-is-a-perfectly-valid-ipv6-default-gateway-address/ In a recent article, I wrote about some of thecommon questions that IPv6 novices sometimes ask. We ...
  • 215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.What is the sum of the digits of the number 21000? /** * I dont have a good idea. * * I just calculate the result of 2
  • This is the Manual for Quagga 1.2.0. Quagga is a fork of GNU Zebra
  • statsmodels中的summary解读(使用OLS)

    万次阅读 多人点赞 2018-10-17 17:24:46
    给定序列X(x1,x2...xn),y,估计一个向量A(a0,a1.a2....)令y'=a0+a1*x1+a2*x2+...+an*xn, 使得(y'-y)^2最小,计算A。 2.代码如下 来源《python机器学习实践指南》 import patsy import statsmodels.api as sm f = '...
  • What's new in Swift 2.2

    千次阅读 2016-03-28 14:12:13
    From https://www.hackingwithswift.com/swift2-2Swift 2.2 is almost here, and cleans up a numberof quirks, adds some missing features, and deprecates – perhaps controversially – some language ...
  • Microsoft Application Architecture Solution Summary   Our goal User 1. Requirement 2. User activity 3. Future Requirement System 1. Design(Open for chang
  • Let’s begin by a short introduction to variable ... It is a mechanism in TensorFlow that allows for sharing variables accessed in different parts of the code without passing references to the vari
  • Blockchain Basics: A Non-Technical Introduction in 25 Steps By 作者: Daniel Drescher ISBN-10 书号: 1484226038 ISBN-13 书号: 9781484226032 Edition 版本: 1st ed. 出版日期: 2017-03-16 pages 页数: (276 ) ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 35,371
精华内容 14,148
关键字:

aissummarywhat