Job 1: Let the user enter a number, accumulate
Job 2: Save 10000 yuan, the annual interest rate is 3.25, how many years later, the deposit can double
Job 3: Average number of user input
Job 1:
#!/usr/bin/env python#-*-coding:utf-8-*-x=0while true:num=raw_input (' Please input number [q/q to exit]: ') if num = = ' Q ' or num = = ' Q ': print ' total num:%d '% of break elif num = = ': Continue else: X=x+int (num)
Job 2:
#!/usr/bin/env python#-*-coding:utf-8-*-x=0s=0while x < 10000:lixi = 10000 * 0.0325 x = x + Lixi S+=1prin Ts
Job 3:
#!/usr/bin/env python#-*-coding:utf-8-*-x=0count=0while true:num=raw_input (' Please input number [q/q to exit]: ' if num = = ' Q ' or num = = ' Q ': print ' total num:%d '% of break elif num = = ': Continue El Se:x=x+int (num) count+=1print "avg Num:%s"% int (x/count)
This article is from the "I am small white" blog, please be sure to keep this source http://878045653.blog.51cto.com/2693110/1681473
Python Basic Learning small Job (i)