10-1
with open('10-1.txt') as f: print(f.read()) with open('10-1.txt') as f: for line in f: print(line.strip()) with open('10-1.txt') as f: lines = f.readlines() for line in lines: print(line.strip())
10-2
with open('10-1.txt') as f: fs = f.read() print(fs.replace('Python','C'))
10-3
with open('10-3.txt','a') as f: name = input("What's your name?") f.write(name + '\n')
10-6
a = input('The first num') b = input('The second num') try: a = int(a) b = int(b) print(a+b) except ValueError: print('Wrong input')