python3--list的使用2

L = [365,'everyday',3.14,True]
print(L[-1])

print(L[-3])
#切片符号:相当于集合 [),半开半闭区间
print(L[0:3])
#不指定结束位,表示到最后一位结束
print(L[:3])
#不指定起始位,表示从头开始
print(L[1:])
#不指定起始和结束位,切片等于原始序列
print(L[:])

#点球游戏
#电脑为守门员,守住三个方向,左中右;人为发球员,想左中右三个方向发球,
#如果电脑方向=人发球方向,电脑+1否则人+1

from random import choice
#python3 使用input接收所有格式的输入
dircetion = input('Choose one side to shoot(L/M/R):')
print('your choose is ' + dircetion)
seq = ['L','M','R']
#choice函数随机取序列中的一个值
com = choice(seq)
print('computer\'s choice is ' + com)
computer = 0
person = 0
if dircetion == com:
    #python数字自相加
    computer+=1
    #python中输出数字使用%s %f占位
    print('wow!computer get a goal,now is %d '  %(computer))
else:
    person+=1
    print('wow!person get a goal,now is %d ' %(person))
    

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值