Skip to main content
Contents Index
Search Book
Search Results:
No results.
Readability settings Prev Up Next Scratch ActiveCode Profile
title here
\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 1.15 Exercises
Activity 1.15.1 .
What is the function of the secondary memory in a computer?
Execute all of the computation and logic of the program
This would be correct if we asked what the CPU does.
Retrieve web pages over the Internet
This would be correct if we asked what the client does.
Store information for the long term, even beyond a power cycle
The secondary memory provides long term storage, even if you turn off the computer.
Take input from the user
The secondary memory does not ask users for input.
Activity 1.15.2 .
When talking about computers and code, which of the following is a program?
A set of instructions for your computer and CPU.
A program holds the instructions that answer the CPUโs "What next" question.
The process of creating and editing code.
Programming is the process of creating and editing these instructions.
An event that teaches you to write code.
This can be a program, but not the kind weโre talking about here.
A question you ask your computer.
While a program can ask your computer or the user a question, it typically answers the question of "what next" from your CPU.
Activity 1.15.3 .
Activity 1.15.4 .
Which of the following creates or contains โmachine codeโ?
The Python interpreter
The interpreter translates python source code from a human readable form to machine code
The keyboard
The keyboard provides textual input
A Python source file
The Python source file contains human readable programs
A word processing document
A word processing document contains text
Activity 1.15.5 .
Where in the computer is a variable such as โxโ stored after the following Python line executes?
Central processing unit
The CPU processses instructions
Main Memory
The main memory holds the values of the variables while a program executes
Secondary Memory
Secondary memory provides long-term storage. You must write out values to secondary memory to store them long-term.
Input Devices
Input devices do not store data
Output Devices
Ouptut devices do not store data
Activity 1.15.6 .
What will the following program print out:
x = 43
x = x + 1
print(x)
43
The value of x was changed.
44
While x was set to 43 originally it was changed to one more than the current value.
x + 1
This would be true if the code was priInput devices do not store data
Error because x = x + 1 is not possible mathematically
This code sets the value of x to the current value of x plus 1.
Activity 1.15.7 .
Pick the best replacements for 1 and 2 in the following sentence: When comparing compilers and interpreters, a compiler is like 1 while an interpreter is like 2.
1 = a process, 2 = a function
Compiling is a software process, and running the interpreter is invoking a function, but how is a process different than a function?
1 = translating an entire book, 2 = translating a line at a time
Compilers take the entire source code and produce object code or the executable and interpreters execute the code line by line.
1 = software, 2 = hardware
Both compilers and interpreters are software.
1 = object code, 2 = byte code
Compilers can produce object code or byte code depending on the language. An interpreter produces neither.
Activity 1.15.8 .
Activity 1.15.9 .
Activity 1.15.10 .
Activity 1.15.11 .
Activity 1.15.12 .
Try running the following code. Can you tell what is wrong with it and fix it?
Solution .
# The print function is spelled incorrectly
# and needs parentheses around its contents
print('Hello world!')
You have attempted
of
activities on this page.