def bounce(num):
    #初始高度
    height=100
    #总高度
    total=0
    for i in range(num):
        #第一次下落高度
        total+=height
        #后续的高度变化
        height/=2
    return total,height
if __name__ == ‘__main__‘:
    t, h = bounce(10)
    print("它在第10次落地时,共经过{}米,第10次反弹高度是{}".format(t, h))
def reversalword(word):
    ‘‘‘:arg 接受的字符串‘‘‘
    alist=[]
    #对字符串按照空格进行切片
    for i in word.split(‘ ‘):
        #将切片的字符串反转添加到列表中
        alist.append(i[::-1])
        #通过空格连接每一个单词
    return ‘ ‘.join(alist)
if __name__ == ‘__main__‘:
    word="Let‘s take LeetCode contest"
    print( reversalword(word))原文:https://www.cnblogs.com/wonderlandlove/p/13258156.html