- p. 41, problem 6 (save as
p2_6.py).
In addition to printing the function values, begin by printing x itself on each line.
The last three lines:
2.8 0.334988150156 -0.942222340669 -0.355529831651
2.9 0.239249329214 -0.97095816515 -0.246405393972
3.0 0.14112000806 -0.9899924966 -0.142546543074
- p. 41, problem 9 (save as
p2_9.py).
Enter name: Moe
Enter salary: 10000
Enter name: Larry
Enter salary: 30000
Enter name: Curly
Enter salary: 5000
Enter name: Shemp
Enter salary: 2000
Enter name: Joe
Enter salary: 50000
Enter name: End
Average salary: 19400.0
Highest: Joe 50000.0
Lowest: Shemp 2000.0
- p. 41, problem 11 (save as
p2_11.py).
Enter odometer reading: 200
Enter gallons procured: 10
Miles per gallon: 20.0
Enter odometer reading: 400
Enter gallons procured: 5
Miles per gallon: 40.0
Enter odometer reading: 1000
Enter gallons procured: 13
Miles per gallon: 46.1538461538
Enter odometer reading: 1210
Enter gallons procured: 4
Miles per gallon: 52.5
Enter odometer reading: -1
- p. 43, problem 24 (save as
p2_24.py).
Example 1:
First roll: 7
win!
Example 2:
First roll: 4
roll: 3
roll: 6
roll: 3
roll: 8
roll: 7
loss...
- p. 43, problem 25 (save as
p2_25.py).
Select a number from 1 to 128.
Your guess?64
Too low
Your guess?96
Too high
Your guess?80
Too high
Your guess?72
Too high
Your guess?68
you are correct!
- p. 43, problem 26 (save as
p2_26.py).
4 times 9 = 36
Correct!
6 times 6 = 36
Correct!
5 times 2 = 10
Correct!
8 times 5 = 40
Correct!
2 times 8 = 16
Correct!
4 times 4 = 4
Sorry, the answer is 16
6 times 4 = 24
Correct!
2 times 2 = 4
Correct!
2 times 3 = 6
Correct!
4 times 7 = 28
Correct!