Exercise one: Hit all the even numbers between 1-100
Def even_print (): For I in range (1,101): If I% 2 = = 0: print (i) even_print ()
Exercise two: Design a function, create 10 files on the desktop, and name them as numbers
Def text_creation (): path = ' c:/users/administrator/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 ()
Exercise three: Compound interest calculation functions
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)
Python little practice, play all the even numbers between 1-100, design a function, create 10 files on the desktop, and numerically named, compound interest Calculation function