Sample For Solution Manual Starting Out With Python 4th Global Edition by Tony Gaddis
Sample For Solution Manual Starting Out With Python 4th Global Edition by Tony Gaddis
Display “Jack
Shepard”
Display “123
Lost Lane”
Display
“Boston, MA
99999”
Display “704-
555-1212”
Display
“Computer
Science”
End
Programming Exercise 2-2
End
Input salesTotal
A
Programming Exercise 2-3
Display
Input item1 Input item4 “Subtotal: $”,
subtotal
Display
Input item2 Input item5 “Total: $”,
total
A B End
Programming Exercise 2-5
Set
distance6Hours = Display
SPEED * 6 distance10Hours
, “miles in 10
hours.”
Set
distance10Hours =
SPEED * 10
Display
distance15Hours
, “miles in 15
Set hours.”
distance15Hours =
SPEED * 15
A End
Programming Exercise 2-6
# Calculate miles-per-gallon.
mpg = miles / gallons
Display “Enter
the miles Set mpg = miles /
driven.” gallons
Display “You
used”, mpg
Input miles
“miles per
gallon.”
A
Programming Exercise 2-8
Display “Enter
the charge for Display “Tax:
food.” $”, tax
A
Programming Exercise 2-9
sugar = (cookies *
Constant Real SUGAR_RECIPE) /
COOKIES_RECIPE = COOKIES_RECIPE
Display flour,
48.0
“cups of flour.”
butter = (cookies *
BUTTER_RECIPE) /
Constant Real COOKIES_RECIPE
SUGAR_RECIPE = 1.5 End
flour = (cookies *
FLOUR_RECIPE) /
Constant Real COOKIES_RECIPE
BUTTER_RECIPE = 1.0
Display “To
make”, cookies,
Constant Real “cookies, you
FLOUR_RECIPE = 2.75 will need:”
B
A
Programming Exercise 2-11
Input female
Display
“Female:”,
percentFemale,
“%”
total = male + female
End
A
Programming Exercise 2-12
# Named constants
COMMISSION_RATE = 0.03
NUM_SHARES = 2000
PURCHASE_PRICE = 40.0
SELLING_PRICE = 42.75
# Variables
amountPaidForStock = 0.0 # Amount paid for the stock
purchaseCommission = 0.0 # Commission paid to purchase stock
totalPaid = 0.0 # Total amount paid
stockSoldFor = 0.0 # Amount stock sold for
sellingCommission = 0.0 # Commission paid to sell stock
totalReceived = 0.0 # Total amount received
profitOrLoss = 0.0 # Amount of profit or loss
# Calculate the amount that Joe paid for the stock, not
# including the commission.
amountPaidForStock = NUM_SHARES * PURCHASE_PRICE
# Calculate the total amount that Joe paid, which is the amount
# he paid for the stock plus the commission he paid his broker.
totalPaid = amountPaidForStock + purchaseCommission
Display “Profit
Set purchaseCommission B (or loss if
= COMMISSION_RATE * negative): $,
amountPaidForStock profitOrLoss
A End
Exercise 2-13 Planting Grapevines
print('How many times per year is the interest compounded? ', end='')
n = int(input())
print('For how many years will the account earn interest? ', end='')
t = int(input())
TRUE/FALSE
1. A software developer is the person with the training to design, create, and test computer programs.
ANS: T
2. A computer is a single device that performs different types of tasks for its users.
ANS: F
3. All programs are normally stored in ROM and are loaded into RAM as needed for processing.
ANS: F
4. The instruction set for a microprocessor is unique and is typically understood only by the
microprocessors of the same brand.
ANS: T
ANS: T
ANS: F
7. The main reason to use secondary storage is to hold data for long periods of time, even when the
power supply to the computer is turned off.
ANS: T
8. RAM is a volatile memory used for temporary storage while a program is running.
ANS: T
9. The Python language uses a compiler which is a program that both translates and executes the
instructions in a high-level language.
ANS: F
10. IDLE is an alternative method to using a text editor to write, execute, and test a Python program.
ANS: T
MULTIPLE CHOICE
2. Which of the following is considered to be the world's first programmable electronic computer?
a. IBM
b. Dell
c. ENIAC
d. Gateway
ANS: C
3. Where does a computer store a program and the data that the program is working with while the
program is running?
a. in main memory
b. in the CPU
c. in secondary storage
d. in the microprocessor
ANS: A
4. What type of volatile memory is usually used only for temporary storage while running a program?
a. ROM
b. TMM
c. RAM
d. TVM
ANS: C
6. Which computer language uses short words known as mnemonics for writing programs?
a. Assembly
b. Java
c. Pascal
d. Visual Basic
ANS: A
7. The process known as the __________ cycle is used by the CPU to execute instructions in a program.
a. decode-fetch-execute
b. decode-execute-fetch
c. fetch-decode-execute
d. fetch-execute-decode
ANS: C
10. The encoding technique used to store negative numbers in the computer's memory is called
a. Unicode
b. ASCII
c. floating-point notation
d. two's complement
ANS: D
11. The __________ coding scheme contains a set of 128 numeric codes that are used to represent
characters in the computer's memory.
a. Unicode
b. ASCII
c. ENIAC
d. two's complement
ANS: B
13. What is the largest value that can be stored in one byte?
a. 255
b. 128
c. 8
d. 65535
ANS: A
14. The disk drive is a secondary storage device that stores data by __________ encoding it onto a
spinning circular disk.
a. electrically
b. magnetically
c. digitally
d. optically
ANS: B
15. A __________ has no moving parts and operates faster than a traditional disk drive.
a. DVD drive
b. solid state drive
c. jumper drive
d. hyper drive
ANS: B
16. Which of the following is not a major component of a typical computer system?
a. the CPU
b. main memory
c. the operating system
d. secondary storage devices
ANS: C
MULTIPLE RESPONSE
1. Select all that apply. To create a Python program you can use
a. a text editor
b. a word processor if you save your file as a .docx
c. IDLE
d. Excel
ANS: A, C
COMPLETION
ANS: program
2. The term ___________ refers to all the physical devices that make up a computer.
ANS: hardware
3. The __________ is the part of the computer that actually runs programs and is the most important
component in a computer.
ANS: magnetically
ANS: Microprocessors
6. __________ is a type of memory that can hold data for long periods of time, even when there is no
power to the computer.
ANS: flash
9. The Python __________ is a program that can read Python programming statements and execute them.
ANS: interpreter
10. In __________ mode, the interpreter reads the contents of a file that contains Python statements and
executes each statement.
ANS: script