牛客网python入门篇~元组练习

NP62 运动会双人项目

my_tuple=(input(),input())
print(my_tuple)

NP63 修改报名名单

entry_form=('Niuniu','Niumei')
print(entry_form)
try:
    entry_form[1]='Niukele'
except TypeError:
    print("The entry form cannot be modified!")

NP64 输出前三同学的成绩

my_tuple=tuple(input().split())
print(my_tuple[0:3])

NP65 名单中出现过的人

my_tuple=tuple(['Tom', 'Tony', 'Allen', 'Cydin', 'Lucy', 'Anna'])
print(my_tuple)
name=input()
for i in my_tuple:
    if i==name:
        print("Congratulations!");break
else:
    print("What a pity!")

NP66 增加元组的长度

my_tuple1=tuple(range(1,6))
print(my_tuple1)
print(len(my_tuple1))

my_tuple2=tuple(range(6,11))
print(my_tuple1+my_tuple2)
print(len(my_tuple1+my_tuple2))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值