Authors' official companion web site
year = 2021
month = 1
day = 20
print("Today is", year, month, day, sep="/")
The output is actually:
Today is/2021/1/20This is actually not the desired output. A better solution would be:
print("Today is: ", end="")
print(year, month, day, sep="/")
(thanks to Jeremy Zhang)
# print triangular figure w/out string multiplication
for i in range(1, 6):
for j in range(i):
print("#", end="")
print()
(thanks to Josh Boggess)
print_binary.
It should be to_binary.
line.split should be lines.split .
print("input:", s.rstrip())
lis.insert(lis[i])should be:
lis.append(lis[i])
] brace.
It should be:
[36, 12, 25, 19, 46, 31, 22]
people, male, female, young, old, silly, and hungry.
There should also be sets named rich and poor.
fibonacci rather than fib.
The complete code should be:
def fibonacci(n): if n <= 2: return 1 else: return fibonacci(n - 1) + fibonacci(n - 2)
if test is incorrect.
Its <= operator should be < .
The line of code should be:
if self.day < self.days_in_month():
if test is incorrect.
Its <= operator should be < .
The line of code should be:
if self.day < self.days_in_month():
compute_interest method; the heading shown is incorrect.
It should be:
def compute_interest(self, rate)
from_absolute_day method as an accessor.
It should be referred to as a mutator method, since it modifies the Date object.
Have you found an error in our textbook? If so, please email us at:
authors AT buildingpythonprograms DOT com