标签:用户 python continue number 年利率
作业1:让用户输入数字,累加
作业2:存10000块钱,年利率是3.25,多少年之后,存款能翻倍
作业3:求用户输入数字的平均分
作业1:
#!/usr/bin/env python # -*- coding: utf-8 -*- x=0 while True: num=raw_input(‘Please input number [Q/q to exit] : ‘) if num == ‘q‘ or num == ‘Q‘: print ‘total num : %d‘ % x break elif num == ‘‘: continue else: x=x+int(num)
作业2:
#!/usr/bin/env python # -*- coding: utf-8 -*- x=0 s=0 while x < 10000: lixi = 10000 * 0.0325 x = x + lixi s+=1 print s
作业3:
#!/usr/bin/env python # -*- coding: utf-8 -*- x=0 count=0 while True: num=raw_input(‘Please input number [Q/q to exit] : ‘) if num == ‘q‘ or num == ‘Q‘: print ‘total num : %d‘ % x break elif num == ‘‘: continue else: x=x+int(num) count+=1 print "avg num : %s" % int(x/count)
本文出自 “我是小白” 博客,请务必保留此出处http://878045653.blog.51cto.com/2693110/1681473
标签:用户 python continue number 年利率
原文地址:http://878045653.blog.51cto.com/2693110/1681473