综合 random,[],raw_input,s.strip,s.isspace, format %s %d

 综合例子 random,[] 
1
# -*- coding: UTF-8 -*- 2 import random; 3 4 5 list=["石头","剪刀","","ok"] 6 7 guize=[["石头","剪刀"],["剪刀",""],["","石头"]] 8 9 while True: 10 skey=random.choice(list); #random.randint(1, 108) 11 print "-----电脑出了: ",skey 12 key=raw_input("请输入 石头,剪刀,布 \n") 13 key=key.strip(); 14 if not key or key.isspace(): 15 continue; 16 if key=="ok": 17 print "退出了" 18 break; 19 if not key in list: 20 continue; 21 print "----您出的是 ",key 22 if [key,skey] in guize: 23 print "*******恭喜您胜利*******\n" 24 continue; 25 else: 26 print "^^^^^您输了,再来一局^^^^\n" 27 continue; 28

 

1 principal = 5000        # Initial amount (本金)
2 rate = 0.0655             # Interest rate (利率)
3 numyears = 8            # Number of years (期数,年)
4 year = 1
5 while year <= numyears:
6         principal = principal*(1+rate)
7         print "",year, principal
8         print "%4d %0.3f" % (year, principal)
9         year += 1

 

转载于:https://www.cnblogs.com/xiaopythoner/p/3469322.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值