#10.1
with open ('learning_python.txt') as file_object:
print(file_object.read().rstrip())
#10.2
with open ('learning_python.txt') as file_object:
lines = file_object.readlines();
for line in lines:
print(line.replace('python','C').rstrip())
#10.3
with open ('guest_book.txt','a') as file_object:
while True:
name = input("What's your name(input quit to quit):")
if name == 'quit':
break
file_object.write(name+'\n')
#10.4
with open ('reason.txt','a') as file_object:
while True:
name = input("Why do you like promgramming(input quit to quit):")
if name == 'quit':
break
file_object.write(name+'\n')
#10.5
while True:
print()
addend = input("What's the addend(Enter 'q' to quit):")
if addend == 'q':
break
try:
addend = int(addend)
except ValueError:
print("Sorry, the " + addend + " is not a digit.")
continue
augend = input("What's the augend(Enter 'q' to quit):")
if augend == 'q':
break
try:
augend = int(augend)
except ValueError:
print("Sorry, the " + augend + " is not a digit.")
continue
print("The result of " + str(addend) + " plus " + str(augend) + " is " + str(addend + augend) + ".")
#10.1with open ('learning_python.txt') as file_object: print(file_object.read().rstrip())#10.2with open ('learning_python.txt') as file_object: lines = file_object.readlines(); for ...