Python Chapter 1
Testing out setting up quizzes online for study tools. This quiz will test your basic Python knowledge.
Results
congrats!
review what you’ve missed and try again!
#1. The part of a computer that runs programs is called __________.
The CPU is the most important component in a computer because it is the part of the computer that runs programs.
#2. Images, like the ones created with your digital camera, cannot be stored as binary numbers.
Computers are often referred to as digital devices. The term digital can be used to describe anything that uses binary numbers. Digital data is data that is stored in binary format, and a digital device is any device that works with binary data. Numbers and characters are stored in binary, but computers also work with many other types of digital data.
For example, consider the pictures that you take with your digital camera. These images are composed of tiny dots of color known as pixels. (The term pixel stands for picture element.) Each pixel in an image is converted to a numeric code
that represents the pixel’s color. The numeric code is stored in memory as a binary number.
#3. The __________ translates an assembly language program to a machine language program.
Assembly language programs cannot be executed by the CPU, however. The CPU only understands machine language, so a special program known as an assembler is used to translate an assembly language program to a machine language program.
#4. The rules that must be followed when writing a program are called __________.
#5. Assembly language is considered a high-level language.
Although assembly language makes it unnecessary to write binary machine language instructions, it is not without difficulties. Assembly language is primarily a direct substitute for machine language, and like machine language, it requires that you know a lot about the CPU. Assembly language also requires that you write a large number of instructions for even
the simplest program.
Because assembly language is so close in nature to machine language, it is referred to as a low-level language.
In the 1950s, a new generation of programming languages known as high-level languages began to appear. A high-level language allows you to create powerful and complex pro-grams without knowing how the CPU works and without writing large numbers of low-level
instructions. In addition, most high-level languages use words that are easy to understand.
#6. Today, CPUs are huge devices made of electrical and mechanical components such as vacuum tubes and switches.
#7. The physical devices that a computer is made of are referred to as __________.
Hardware is all the physical devices, or components, of which a computer is made.
#8. An interpreter is a program that both translates and executes the instructions in a high-level language program.
The Python language uses an interpreter, which is a program that both translates and
executes the instructions in a high-level language program. As the interpreter reads
each individual instruction in the program, it converts it to machine language instruc-tions then immediately executes them. This process repeats for every instruction in
the program. This process is illustrated in Figure 1-19. Because interpreters combine
translation and execution, they typically do not create separate machine language
programs.
#9. Main memory is also known as RAM.
#10. A __________ is enough memory to store a letter of the alphabet or a small number.
#11. This is a volatile type of memory that is used only for temporary storage while a program is running.
You can think of main memory as the computer’s work area. This is where the computer
stores a program while the program is running, as well as the data that the program is
working with. For example, suppose you are using a word processing program to write an
essay for one of your classes. While you do this, both the word processing program and the
essay are stored in main memory.
Main memory is commonly known as random-access memory, or RAM. It is called this
because the CPU is able to quickly access data stored at any random location in RAM.
RAM is usually a volatile type of memory that is used only for temporary storage while
a program is running. When the computer is turned off, the contents of RAM are erased.
#12. IDLE is an alternative method to using a text editor to write, execute, and test a Python program.
The CPU understands instructions written in a binary machine language.
#13. A(n) __________ is a set of instructions that a computer follows to perform a task.
A program is a set of instructions that a computer follows to perform a task.
#14. Today, CPUs are small chips known as __________.
Today, CPUs are small chips known as microprocessors. In addition to being much smaller than the old electromechanical CPUs in early computers, microprocessors are also much more powerful.
The historic – not modern – ENIAC is considered by many to be the world’s first programmable electronic computer. It was built in 1945 to calculate artillery ballistic tables for the U.S. Army. This machine, which was primarily one big CPU, was 8 feet tall, 100 feet long, and weighed 30 tons.
#15. Word processing programs, spreadsheet programs, email programs, web browsers, and games are all examples of utility programs.
A utility program performs a specialized task that enhances the computer’s operation or safeguards data. Examples of utility programs are virus scanners,
file compression programs, and data backup programs.
Programs that make a computer useful for everyday tasks are known as application software. These are the programs that people normally spend most of their time running on their computers. Two commonly used applications are Microsoft Word, a word processing program, and PowerPoint, a presentation program. Some other examples of application software are spreadsheet programs, email programs, web browsers, and game programs.
#16. A byte is made up of eight __________.
#17. A major drawback of Python is that Python code is more difficult to read than code in most other programming languages.
False; Designed with readability in mind: “Simple is better than complex”
#18. A component that collects data from people or other devices and sends it to the computer is called __________.
Input Devices
Input is any data the computer collects from people and from other devices. The component that collects the data and sends it to the computer is called an input device. Common input devices are the keyboard, mouse, touchscreen, scanner, microphone, and digital camera. Disk drives and optical drives can also be considered input devices, because programs and data are retrieved from them and loaded into the computer’s memory.
Output Devices
Output is any data the computer produces for people or for other devices. It might be a sales report, a list of names, or a graphic image. The data is sent to an output device, which formats and presents it. Common output devices are video displays and printers. Disk drives can also be considered output devices because the system sends data to them in order to be saved.
#19. An extensive encoding scheme that can represent characters for many languages in the world is __________.
The ASCII character set was developed in the early 1960s and was eventually adopted by almost all computer manufacturers. ASCII is limited, however, because it defines codes for only 128 characters. To remedy this, the Unicode character set was developed in the early 1990s. Unicode is an extensive encoding scheme that is compatible with ASCII, but can also represent characters for many of the languages in the world. Today, Unicode is quickly becoming the standard character set used in the computer industry
#20. A syntax error does not prevent a program from being compiled and executed.
The statements that a programmer writes in a high-level language are called source
code, or simply code. Typically, the programmer types a program’s code into a text
editor then saves the code in a file on the computer’s disk. Next, the programmer uses
a compiler to translate the code into a machine language program, or an interpreter
to translate and execute the code. If the code contains a syntax error, however, it can-not be translated. A syntax error is a mistake such as a misspelled keyword, a missing
punctuation character, or the incorrect use of an operator. When this happens, the
compiler or interpreter displays an error message indicating that the program contains
a syntax error. The programmer corrects the error then attempts once again to translate
the program.
Although people commonly violate the syntax rules of their native language when
speaking and writing, other people usually understand what they mean. Unfortunately, compilers and interpreters do not have this ability.
If even a single syntax error appears in a program, the program cannot be compiled or executed.
When an interpreter encounters a syntax error, it stops executing the program.
#21. In the __________ part of the fetch-decode-execute cycle, the CPU determines which operation it should perform.
When a CPU executes the instructions in a program, it is engaged in a process that is known as the fetch-decode-execute cycle. This cycle, which consists of three steps, is repeated for each instruction in the program. The steps are:
1. Fetch. A program is a long sequence of machine language instructions. The first step of the cycle is to fetch, or read, the next instruction from memory into the CPU.
2. Decode. A machine language instruction is a binary number that represents a com-mand that tells the CPU to perform an operation. In this step, the CPU decodes
the instruction that was just fetched from memory, to determine which operation it
should perform.
3. Execute. The last step in the cycle is to execute, or perform, the operation.
#22. In the __________ numbering system, all numeric values are written as sequences of 0s and 1s.
#23. Real numbers are encoded using the __________ technique.
The binary numbering system can be used to repre-sent only integer numbers, beginning with 0. Negative numbers and real numbers (such as 3.14159) cannot be represented using the simple binary numbering technique we discussed.
Computers are able to store negative numbers and real numbers in memory, but to do so they use encoding schemes along with the binary numbering system.
Negative numbers are encoded using a technique known as two’s complement, and real numbers are encoded in
floating-point notation. You don’t need to know how these encoding schemes work, only that they are used to convert negative numbers and real numbers to binary format.
#24. Python was first implemented in 1960.
Python was introduced in the 1990s.
#25. Python is a high-level language that excels at creating exceptionally fast-executing programs.
The answer is False; Powerful for object-oriented prog and dynamic typing; Python incurs overhead costs as the language is interpreted.


