Nothing Special   »   [go: up one dir, main page]

PyCDS 01 Intro

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Chapter 1, Introduction to Computers and Python   1

Introduction to Computers and


Python
1.1   Introduction
1.1 Q1: Which of the following statements is false?
a. Software (that is, the Python instructions you write, which are also called
code) controls hardware (that is, computers and related devices).
b. Programmers use the Python Standard Library and various data-science
libraries to “reinvent the wheel.”
c. Programmers use libraries to create software objects that they interact with
to perform significant tasks with modest numbers of instructions.
d. IPython executes Python instructions interactively and immediately shows
their results.
Answer: b. Programmers use the Python Standard Library and various
data-science libraries to “reinvent the wheel.” Actually, programmers use
the Python Standard Library and various data-science libraries to avoid
“reinventing the wheel.”

1.1 Q2: Which of the following statements is false?


a. Decades ago, most computer applications ran on networked computers.
b. Today’s applications can be written with the aim of communicating among
the world’s computers via the Internet.
c. A key intersection between computer science and data science is artificial
intelligence.
d. All of the above statements are true.
Answer: a. Decades ago, most computer applications ran on networked
computers. Actually, decades ago, most computer applications ran on
“standalone” computers (that is, not networked together).

1.2   Hardware and Software


1.2 Q1: Which of the following statements is false?
a. Computers can perform calculations and make logical decisions phenomenally
faster than human beings can.
b. Computers process data under the control of sequences of instructions called
computer programs (or simply programs).
c. A computer consists of various physical devices referred to as hardware (such
as the keyboard, screen, mouse, solid-state disks, hard disks, memory,
d. Computing costs are rising dramatically, due to the increasing complexity of
hardware and software technologies.

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


2  Chapter 1, Introduction to Computers and Python

Answer: d. Computing costs are rising dramatically, due to the increasing


complexity of hardware and software technologies. Actually, computing
costs are dropping dramatically, due to rapid developments in hardware
and software technologies.

1.2.1  Moore’s Law


1.2 Q2: Every year or two, the capacities of computers have approximately
doubled inexpensively. This remarkable trend often is called ________.
a. the law of large numbers
b. the principal of least privilege
c. Moore’s law
d. Wirth’s law
Answer: c. Moore’s Law

1.2.2  Computer Organization


1.2 Q3: Which logical unit of the computer is the receiving section?
a. input unit
b. output unit
c. memory unit
d. central processing unit.
Answer: a. input unit.

1.2 Q4: Information in the memory unit is ________. It’s typically lost when the
computer’s power is turned off.
a. persistent
b. constant
c. sticky
d. volatile
Answer: d. volatile.

1.2 Q5: A gigabyte is approximately one ________ bytes.


a. thousand
b. million
c. billion
d. trillion.
Answer: c. billion.

1.2 Q6: The arithmetic and logic unit contains the ________ mechanisms that allow
the computer, for example, to compare two items from the memory unit to
determine whether they’re equal.
a. decision
b. calculation
c. addition
© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.
Chapter 1, Introduction to Computers and Python   3

d. None of the above.


Answer: a. decision

1.2 Q7: Information on secondary storage devices is ________ — it’s preserved


even when the computer’s power is turned off.
a. volatile
b. unstable
c. transient
d. persistent
Answer: d. persistent

1.2 Q8: Secondary storage information takes much ________ to access than
information in primary memory, but its cost per unit is much ________.
a. less time, less
b. longer, less
c. less time, more
d. longer, more
Answer: b. longer, less

1.3   Data Hierarchy


1.3 Q1: A(n) ________ is the smallest data item in a computer. It can have the value
0 or 1.
a. bit
b. byte
c. field
d. record
Answer: a. bit

1.3 Q2: Which of the following statements is false?


a. A computer’s character set represents every character as a pattern of 1s and
0s.
b. All Unicode® characters are composed of four bytes (32 bits)—a scheme
known as UTF-8 encoding.
c. Unicode contains characters for many of the world’s languages.
d. All of the above statements are true.
Answer: b. All Unicode® characters are composed of four bytes (32 bits)—a
scheme known as UTF-8 encoding. Actually, Python uses Unicode ®
characters that are composed of one, two, three or four bytes (8, 16, 24 or
32 bits, respectively)—known as UTF-8 encoding.

1.3 Q3: The most popular database model is the ________ database, in which data
is stored in simple tables.
a. network
© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.
4  Chapter 1, Introduction to Computers and Python

b. graph
c. relational
d. hierarchical
Answer: c. relational

1.3 Q4: Which one of the following statements is true?


a. a terabyte is larger than a petabyte.
b. a kilobyte is exactly 1000 bytes.
c. a gigabyte is 1024 megabytes.
d. an exabyte is 1024 zettabytes.
Answer: c. a gigabyte is 1024 megabytes.

1.4   Machine Languages, Assembly Languages and


High-Level Languages
1.4 Q1: Which of the following statements is false?
a. Any computer can directly understand only its own machine language,
defined by its hardware design.
b. The most widely used Python implementation—CPython (which is written in
the C programming language for performance)—uses a clever mixture of
compilation and interpretation to run programs.
c. Translator programs called assemblers convert assembly-language programs
to machine language at computer speeds.
d. Interpreter programs, developed to execute high-level language programs
directly, avoid the delay of compilation, and run faster than compiled programs.
Answer: d. Interpreter programs, developed to execute high-level
language programs directly, avoid the delay of compilation, and run faster
than compiled programs.
Actually, interpreter programs run slower than compiled programs.

1.4 Q2: Which of the following statements is false?


a. With the advent of assembly languages, computer usage increased rapidly, but
programmers still had to use numerous instructions to accomplish even the
simplest tasks.
b. To speed the programming process, high-level languages were developed in
which single statements could be written to accomplish substantial tasks.
c. Translator programs called assemblers convert high-level-language source
code into machine language.
d. High-level languages instructions look almost like everyday English and
contain commonly used mathematical notations.
Answer: c. Translator programs called assemblers convert high-level-
language source code into machine language. Actually, those translator

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


Chapter 1, Introduction to Computers and Python   5

programs are compilers. Assemblers convert assembly language programs


into machine language.

1.5   Introduction to Object Technology


1.5 Q1: Which of the following statements is false?
a. The classes that objects come from, are essentially reusable software
components.
b. Almost any verb can be reasonably represented as a software object in terms
of attributes (e.g., name, color and size) and behaviors (e.g., calculating, moving
and communicating).
c. A class that represents a bank account might contain one method to deposit
money to an account, another to withdraw money from an account and a third
to inquire what the account’s balance is.
d. All of the above statements are true.
Answer: b. Almost any verb can be reasonably represented as a software
object in terms of attributes (e.g., name, color and size) and behaviors
(e.g., calculating, moving and communicating). Actually, almost any noun
can be reasonably represented as a software object in terms of attributes
(e.g., name, color and size) and behaviors (e.g., calculating, moving and
communicating).

1.5 Q2: A program might call a bank-account object’s deposit ________ to


increase the account’s balance.
a. attribute
b. method
c. class
d. function
Answer: b. method

1. 5 Q3: A new class of objects can be created conveniently by inheritance—the


new class (called the ________) starts with the characteristics of an existing class
(called the ________), possibly customizing them and adding unique
characteristics of its own.
a. superclass, subclass
b. hyperclass, subclass
c. target, superclass
d. subclass, superclass
Answer: d. subclass, superclass

1.6   Operating Systems


1.6 Q1: Windows is a(n) ________ operating system—it’s controlled by Microsoft
exclusively.
© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.
6  Chapter 1, Introduction to Computers and Python

a. proprietary
b. private
c. open source
d. None of the above.
Answer: a. proprietary

1.6 Q2: ________ is by far the world’s most widely used desktop operating system.
a. Linux
b. MacOS
c. Windows
d. none of the above
Answer: c. Windows

1.6 Q3: With ________ software development, individuals and companies


contribute their efforts in developing, maintaining and evolving software in
exchange for the right to use that software for their own purposes, typically at
no charge.
a. object-oriented
b. high-level
c. open-source
d. proprietary
Answer: c. open-source

1.6 Q4: Which of the following organizations has millions of open-source


projects under development?
a. Python Software Foundation
b. GitHub
c. The Apache Software Foundation
d. The Eclipse Foundation
Answer: b. GitHub

1.7   Python
1.7 Q1: Python recently surpassed the programming language ________ as the
most popular data-science programming language.
a. DSPL
b. Java
c. C++
d. R
Answer: d. R

1.7 Q2: Which of the following are reasons why Python is popular and everyone
should consider learning it:

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


Chapter 1, Introduction to Computers and Python   7

a. It’s open source, free and widely available with a massive open-source
community.
b. It’s easier to learn than languages like C, C++, C# and Java, enabling novices
and professional developers to get up to speed quickly.
c. It’s easier to read than many other popular programming languages.
d. All of the above.
Answer: d. All of the above.

1.7 Q3: Which of the statements a), b) and c) below about the Anaconda Python
distribution is false?
a. It’s easy to install on Windows, macOS and Linux.
b. It supports the latest versions of Python, the IPython interpreter and Jupyter
Notebooks.
c. It includes other software packages and libraries commonly used in Python
programming and data science, allowing students to focus on learning Python,
computer science and data science, rather than software installation issues.
d. All of the above statements are true.
Answer: d. All of the above statements are true.

1.8   It’ s the Libraries!


1.8 Q1: Which of the following statements about libraries is false?
a. Using existing libraries helps you avoid “reinventing the wheel,” thus
leveraging your program-development efforts.
b. Rather than developing lots of original code—a costly and time-consuming
process—you can simply create an object of a pre-existing library class, which
takes only three Python statements.
c. Libraries help you perform significant tasks with modest amounts of code.
d. All of the above statements are false.
Answer: b. Rather than developing lots of original code—a costly and time-
consuming process—you can simply create an object of a pre-existing
library class, which takes only three Python statements. Actually, it takes
only one statement.

1.8.1  Python Standard Library


1.8 Q2: Which of the following Python Standard Library modules offers
additional data structures beyond lists, tuples, dictionaries and sets?
a. sys and statistics
b. collections
c. queue
d. b) and c)
Answer: d. b) and c).

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


8  Chapter 1, Introduction to Computers and Python

1.8 Q3: Which Python Standard Library module do we use for performance
analysis?
a. datetime
b. time
c. timeit
d. sys
Answer: c. timeit

1.8.2  Data-Science Libraries


1.8 Q4: Which of the following popular Python data science libraries are central
to machine learning, deep learning and/or reinforcement learning:
a. scikit-learn
b. keras and tensorflow
c. OpenAIGym
d. All of the above
Answer: d. All of the above

1.9   Other Popular Programming Languages


1.9 Q1: The popular programming languages Python and ________ are the two
most widely used data-science languages.
a. C
b. Java
c. JavaScript
d. R
Answer: d. R

1.10   Test-Drive: Using IPython and Jupyter Notebooks


1.10 Q1: In which IPython interpreter mode do you enter small bits of Python
code called snippets and immediately see their results:
a. interactive mode
b. script mode
c. program mode
d. None of the above
Answer: a. interactive mode

1.10.1  Using IPython Interactive Mode as a Calculator


1.10 Q2: When using IPython in interactive mode to evaluate a simple
arithmetic expression in a new session, which of the following is false?
a. The text "In [1]:" is a prompt, indicating that IPython is waiting for your
input. You can type ? for help or you can begin entering snippets

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


Chapter 1, Introduction to Computers and Python   9

b. After you type an expression like 45 + 72 and press Enter, IPython reads the
snippet, evaluates it and prints its result in Out[1]:.
c. Then IPython displays the In [2] prompt to show that it’s waiting for you to
enter your second snippet
d. Python uses x for multiplication and the forward slash (/) for division.
Answer: d. Python uses x for multiplication and the forward slash (/) for
division. Actually, Python uses the asterisk (*) for multiplication.

1.10 Q3: What value is produced when Python evaluates the following
expression?
5 * (12.7 - 4) / 2
a. 21
b. 21.75
c. 29.5
d. None of the above.
Answer: b. 21.75

1.10.2  Executing a Python Program Using the IPython Interpreter


No questions.

1.10.3  Writing and Executing Code in a Jupyter Notebook


1.10 Q4: Which of the following statements is false?
a. The Anaconda Python Distribution comes with the Jupyter Notebook—an
interactive, browser-based environment in which you can write and execute
code and intermix the code with text, images and video.
b. The JupyterLab interface enables you to manage your notebook files and
other files that your notebooks use (like images and videos).
c. Jupyter Notebooks use IPython by default.
d. All of the above statements are true.
Answer: d. All of the above statements are true.

1.10 Q5: Which of the following statements about the Jupyter Notebook is false?
a. The unit of work in a notebook is a cell in which you can enter code snippets.
b. By default, a new notebook contains one cell, but you can add more.
c. To execute the current cell’s code, type Ctrl + Enter (or control + Enter).
JupyterLab executes the code in IPython, then displays the results below the
cell.
d. All of the above statements are true.
Answer: d. All of the above statements are true.

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


10  Chapter 1, Introduction to Computers and Python

1.11   Internet and World Wide Web


1.11 Q1: Which of the following statements about the ARPANET and the Internet
is false?
a. The ARPANET was the precursor to today’s Internet.
b. Today’s fastest Internet speeds are on the order of millions of bits per second
with billion-bits-per-second (gigabit) speeds already being tested.
c. Although the ARPANET enabled researchers to network their computers, its
main benefit proved to be the capability for quick and easy communication via
what came to be known as electronic mail (e-mail).
d. The protocol (set of rules) for communicating over the ARPANET became
known as the Transmission Control Protocol (TCP). TCP ensured that messages,
consisting of sequentially numbered pieces called packets, were properly
delivered from sender to receiver, arrived intact and were assembled in the
correct order.
Answer: b. Today’s fastest Internet speeds are on the order of millions of
bits per second with billion-bits-per-second (gigabit) speeds already being
tested.
Actually, today’s fastest Internet speeds are on the order of billions of bits
per second with trillion-bits-per-second (terabit) speeds already being
tested.

1.11.1  Internet: A Network of Networks


1.11 Q2: Which of the following statements about the Internet is false?
a. One challenge was to enable different networks to communicate with each
other. ARPA accomplished this by developing the Internet Protocol (IP), which
created a true “network of networks,” the current architecture of the Internet.
b. The combined set of Internet protocols is now called TCP/IP.
c. Each Internet-connected- device has a TCP address—a unique numerical
identifier used by devices communicating via TCP/IP to locate one another on
the Internet.
d. Bandwidth—the information-carrying capacity of communications lines—on
the Internet has increased tremendously, while hardware costs have
plummeted.
Answer: c. Each Internet-connected- device has a TCP address—a unique
numerical identifier used by devices communicating via TCP/IP to locate
one another on the Internet. Actually, each Internet-connected- device has
an IP address—a unique numerical identifier used by devices
communicating via TCP/IP to locate one another on the Internet.

1.11.2  World Wide Web: Making the Internet User-Friendly


1.11 Q3: Which of the following statements is false?

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


Chapter 1, Introduction to Computers and Python   11

a. The World Wide Web is a collection of hardware and software associated with
the Internet that allows computer users to locate and view documents (with
various combinations of text, graphics, animations, audios and videos) on
almost any subject.
b. In 1989, Tim Berners-Lee of CERN (the European Organization for Nuclear
Research) began developing HyperText Markup Language (HTML)—the
technology for sharing information via “hyperlinked” text documents.
c. Berners-Lee also wrote communication protocols such as JavaScript Object
Notation (JSON) to form the backbone of his new hypertext information system,
which he referred to as the World Wide Web.
d. In 1994, Berners-Lee founded the World Wide Web Consortium (W3C),
devoted to developing web technologies.
Answer: c. Berners-Lee also wrote communication protocols such as
JavaScript Object Notation (JSON) to form the backbone of his new
hypertext information system, which he referred to as the World Wide
Web. Actually, in 1989, Tim Berners-Lee of CERN (the European
Organization for Nuclear Research) began developing HyperText Markup
Language (HTML)—the technology for sharing information via
“hyperlinked” text documents.

1.11.3  The Cloud


1.11 Q4: Which of the following statements about the cloud is false?
a. A service that provides access to itself over the Internet is known as a web
service.
b. Using cloud-based services in Python often is as simple as creating a software
object and interacting with it. That object then uses web services that connect to
the cloud on your behalf.
c. We’ll use Twitter’s web services via the Python library Tweepy to get
information about specific Twitter users, search for recent tweets and receive
streams of tweets as they occur—that is, in real time.
d. Azure is Google’s set of cloud-based services.
Answer: d. Azure is Google’s set of cloud-based services. Actually, Azure is
Microsoft’s set of cloud-based services.

1.11 Q5: The applications-development methodology of ________ enables you to


rapidly develop powerful software applications by combining (often free)
complementary web services and other forms of information feeds.
a. cloud computing
b. design patterns
c. proprietary computing
d. mashups
Answer: d. mashups.

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


12  Chapter 1, Introduction to Computers and Python

1.11.4  Internet of Things


1.11 Q6: The Internet is no longer just a network of computers—it’s an Internet
of Things. A thing is any object with which of the following?
a. an IP address
b. the ability to send data over the Internet
c. in some cases, the ability to receive data over the Internet
d. Things can have all of the above.
Answer: d. Things can have all of the above.

1.12   Software Technologies


1.12 Q1: Reworking programs to make them clearer and easier to maintain
while preserving their correctness and functionality is called ________.
a. refactoring
b. design patterns
c. editing
d. None of the above.
Answer: a. refactoring

1.12 Q2: Proven architectures for constructing flexible and maintainable object-
oriented software are called ________.
a. refactored architectures
b. software blueprints
c. engineered architectures
d. design patterns
Answer: d. design patterns

1.13   How Big Is Big Data?


1.13 Q1: Which of the following statements about big data is false?
a. For computer scientists and data scientists, data is now as important as
writing programs.
b. One megabyte is exactly one million (1,000,000) bytes.
c. According to a March 2016 AnalyticsWeek article, within five years there will
be over 50 billion devices connected to the Internet (most of them through the
Internet of Things, ) and by 2020 we’ll be producing 1.7 megabytes of new data
every second for every person on the planet.
d. The speed at which quantum computers now under development could
operate at is so extraordinary that in one second, a quantum computer
theoretically could do staggeringly more calculations than the total that have
been done by all computers since the world’s first computer appeared.
Answer: b. One megabyte is exactly one million (1,000,000) bytes.
Actually, one megabyte is exactly 220 = 1024 x 1024 = 1,048,576 bytes.

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.


Chapter 1, Introduction to Computers and Python   13

1.13 Q2: Which of the following statements about energy consumption is false?
a. According to a recent article, energy use for processing data in 2015 was
growing at 20% per year and consuming approximately three to five percent of
the world’s power.
b. Another enormous electricity consumer is the blockchain-based
cryptocurrency Bitcoin—processing just one Bitcoin transaction uses
approximately the same amount of energy as powering the average American
home for a year.
c. The energy use comes from the process Bitcoin “miners” use to prove that
transaction data is valid.
d. Together, Bitcoin and Ethereum (another popular blockchain-based platform
and cryptocurrency) consume more energy per year than Israel and almost as
much as Greece.
Answer: b. Another enormous electricity consumer is the blockchain-
based cryptocurrency Bitcoin—processing just one Bitcoin transaction
uses approximately the same amount of energy as powering the average
American home for a year. Actually, processing just one Bitcoin
transaction uses approximately the same amount of energy as powering
the average American home for a week.

1.13.1  Big Data Analytics


1.13 Q3: Which of the following "V’s of big data" is described by "the validity of
the data—is it complete and accurate? Can we trust that data when making
crucial decisions? Is it real?
a. Volume
b. Velocity
c. Variety
d. Veracity
Answer: d. Veracity

1.13.2  Data Science and Big Data Are Making a Difference: Use
Cases
No questions.

1.14   Case Study—A Big-Data Mobile Application


1.14 Q1: Once Waze converts a spoken command to text, it must determine the
correct action to perform, which requires:
a. JSON
b. speech recognition
c. natural language processing
© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.
14  Chapter 1, Introduction to Computers and Python

d. speech synthesis
Answer: c. natural language processing

1.14 Q2: Each of the following statements about a typical mobile social
navigation app is true. Which most captures the essence of the application?
a. The app processes massive amounts of crowdsourced data—that is, the data
that’s continuously supplied by users through their mobile GPS-based devices
worldwide.
b. The app uses speech synthesis to speak driving directions and alerts to you,
and speech recognition to understand your spoken commands.
c. The app uses your phone as a streaming Internet of Things (IoT) device. Each
phone is a GPS sensor that continuously streams data over the Internet to the
app.
d. The app probably stores its routing information in a graph database. Such
databases can efficiently calculate shortest routes.
Answer: a. The app processes massive amounts of crowdsourced data—
that is, the data that’s continuously supplied by users through their mobile
GPS-based

1.15   Intro to Data Science: Artificial Intelligence—at


the Intersection of CS and Data Science
1.15 Q1: What is the "ultimate goal" of the field of artificial intelligence?
a. Computers learning from massive amounts of data.
b. Computer vision.
c. Self-driving cars.
d. Artificial general intelligence—computers that perform intelligence tasks as
well as humans.
Answer: d. Artificial general intelligence—computers that perform
intelligence tasks as well as humans.

1.15 Q2: Which of the following statements about AI is false:


a. For many decades, AI has been a field with solutions and no problems.
b. Google’s AlphaZero is a game-playing AI that teaches itself to play games.
c. In a 1997 match between IBM’s DeepBlue computer system and chess
Grandmaster Gary Kasparov, DeepBlue became the first computer to beat a
reigning world chess champion under tournament conditions.
d.After training- itself in Go for just eight hours, AlphaZero was able to play Go
vs. its AlphaGo predecessor, winning 60 of 100 games.
Answer: a. For many decades, AI has been a field with solutions and no
problems. Actually, for many decades, AI has been a field with problems
and no solutions.

© Copyright 19922020 by Pearson Education, Inc. All Rights Reserved.

You might also like