10 月 132020
 
def text_creation():
    path = 'C:/Users/harveymei/Desktop/'
    for name in range(1,11):
        with open(path + str(name) + '.txt', 'w') as text: #文件操作
            text.write(str(name)) #写入内容
            text.close()
            print('Done')
text_creation()
def invest(amount, rate, time):
    print('principal amount: {}'.format(amount)) #字符串格式化填充
    for t in range(1, time + 1):
        amount = amount * (1 + rate)
        print('year {}: ${}'.format(t, amount))
invest(100, .05, 8)
invest(2000, .025, 5)
def even_print():
    for i in range(1,101):
        if i % 2 == 0:
            print(i)
even_print()

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)