Python Basic Learning small Job (i)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.