组合数据类型综合练习:1.组合数据类型练习

jiesheng jiesheng     2022-10-27     756

关键词:

#字符串
s = ‘Hello‘
for i in s:
    print(i)
  
# 列表
ls = [‘p‘, ‘y‘, ‘Char‘, ‘m‘]
for i in ls:
    print(i)
  
# 元组
tup = tuple(‘tuple‘)
for i in tup:
    print(i)
  
# 字典
names = [‘Help‘, ‘Make‘, ‘Charm‘, ‘Better‘]
score = [98, 89, 78, 80]
dic = dict(zip(names, score))
print(dic)
for i in dic:
    print(i)
print(dic.keys())
  
# 集合
s = set(dic.keys())
print(s)
for i in s:
    print(i)

  

组合数据类型综合练习

1.组合数据类型练习:分别定义字符串,列表,元组,字典,集合,并进行遍历。定义字符串并进行遍历>>>str=‘Micheal‘>>>foriinstr: print(i)定义列表并进行遍历 >>>list=[‘Micheal‘,‘jackson‘,‘Make‘,‘Bambam‘,‘... 查看详情

组合数据类型练习,综合练习(代码片段)

‘‘‘字符串‘‘‘str="Thisisastring"foriinstr:print(i)‘‘‘列表‘‘‘list=[‘a‘,‘b‘,‘c‘,‘hasee‘]foriinlist:print(i)‘‘‘元组‘‘‘tup=(‘a‘,‘b‘,123,‘hasee‘)foriintup:print(i)‘‘‘字典‘‘‘dict=‘jakey‘:1,‘imp‘:2fork,vindict.items 查看详情

组合数据类型综合练习

字符串联系: ss=[‘ff‘,‘ss‘,‘re‘]foriinss:  print(i)ffssre  列表:lis=list(ss)lis[‘ff‘,‘ss‘,‘re‘]lis.append(list(‘132456‘))lis[‘ff‘,‘ss‘,‘re‘,[‘1‘,‘3‘,‘2‘,‘4‘,‘5‘,‘6‘]]foriinlis:print(i)ffssre[‘1 查看详情

组合数据类型综合练习(代码片段)

字符串str=‘HelloWorldHiWorld‘print(str)foriinstr:print(i) 列表aaa=list(‘HelloWorld‘)aaa.append(12345)aaa.append(list(‘abc‘))print(aaa)foriinaaa:print(i)元组abcd=tup1=(‘HelloWorld‘)print(abcd)foriinabcd:print 查看详情

组合数据类型综合练习

 总结列表,元组,字典,集合的联系与区别:列表中的数据是可以通过wf[3]=‘adssa‘这样直接修改的;而元组就不可以。如果元组中有列表这个元素,则可以修改元组中列表中的元素。字符串、集合和列表都可以进行更改,... 查看详情

组合数据类型综合练习(代码片段)

字符串联系:t1=[‘ab‘,‘bc‘,‘cd‘]foriint1:print(i)结果:列表:lis=list(t1)lis.append(list(‘132456‘))foriinlis:print(i)结果:元组:tur=(‘uu‘,‘ee‘,‘eee‘)tur(‘uu‘,‘ee‘,‘eee‘)foriintur:print(i)结果: 字典:classmates=[‘Michae 查看详情

组合数据类型综合练习:英文词频统计

字符串:str1=‘abcd‘foriinstr1:print(i)列表:str2=[‘a‘,‘b‘,[‘c‘,‘d‘]]foriinstr2:print(i)元组:str3=(‘a‘,‘b‘,[‘c‘,‘d‘])foriinstr3:print(i)字典:name=[‘a‘,‘b‘,‘c‘]score=[90,80,70]dict1=dict(zip(name,score))print(dict 查看详情

组合数据类型练习

e=‘asdbfg‘foroine:print(o)a=[‘1‘,‘2,‘,‘3‘]foriina:print(i)b=(‘1‘,‘2‘,3)forjinb:print(j)d=‘a‘:‘1‘,‘b‘:‘2‘,‘c‘:‘3‘form,ninenumerate(d):print(‘keyis:‘+str(m),‘valueis:‘+str(n))c=set(‘321‘)forkinc:print 查看详情

组合数据类型练习(代码片段)

1.组合数据类型练习:分别定义字符串,列表,元组,字典,集合,并进行遍历。1.定义字符串,并进行遍历>>>str="987">>>foriinstr:print(i)2.定义列表,并进行遍历>>>a=[‘9‘,‘7‘,‘8‘]>>>foriina:print(i)3.定义... 查看详情

英文词频统计预备,组合数据类型练习

1、a=‘‘‘EverynightinmydreamsIseeyou,IfeelyouThatishowIknowyougoonFaracrossthedistanceAndspacesbetweenusYouhavecometoshowyougoonNearfarWhereveryouareIbelieve,ThattheheartdoesgoonOncemoreyouopenthedoorAn 查看详情

英文词频统计预备,组合数据类型练习

1.s=‘‘‘Wedon‘ttalkanymoreWedon‘ttalkanymoreWedon‘ttalkanymoreLikeweusedtodoWedon‘tlaughanymoreWhatwasallofitfor?Wedon‘ttalkanymoreLikeweusedtodoIjustheardyou(ya)foundtheoneyou‘vebeenlookin‘Theoneyoube 查看详情

英文词频统计预备,组合数据类型练习

1.read=‘‘‘ZhuangZhou‘sfamilywaspoor.Once,hewenttotheofficialwhosupervised1riverstoborrowsomegrain.Theofficialsaid:"Well,waituntiltheendoftheyearwhenIcollectthetaxesfromthepeople,thenIwilllendyou300gol 查看详情

组合数据类型练习(代码片段)

1.分别定义字符串,列表,元组,字典,集合,并进行遍历字符串:str=‘hello,linjiangshen‘foriinstr:print(i)list=[‘hello‘,‘lin‘,‘jiang‘,‘shen‘]foriinlist:print(i)tu=(‘hello‘,‘jiangshen‘)foriintu:print(i)di=‘hello‘:1,‘lin‘:2,‘jiang‘:3, 查看详情

组合数据类型练习,英文词频统计实例

1、实例:下载一首英文的歌词或文章,统计单词出现的次数,将所有,.?!替换为空格,将所有大写转换为小写。never=‘‘‘SeeIneverthoughtthatIcouldwalkthroughfireIneverthoughtthatIcouldtaketheburnIneverhadthestrengthtotakeithigherUntilIreachedthepointofnoret... 查看详情

组合数据类型练习

一·分别定义字符串,列表,元组,字典,集合,并进行遍历1.字符串2.列表3.元组4.字典5.集合二总结列表,元组,字典,集合的联系与区别。列表是以中括号包围的,元组是圆括号,字典是大括号,而且里面的每个元素有两个值... 查看详情

组合数据类型练习(代码片段)

‘‘‘字符串‘‘‘str="Thisisastring"foriinstr:print(i)‘‘‘列表‘‘‘list=[‘a‘,‘b‘,‘c‘,‘hasee‘]foriinlist:print(i)‘‘‘元组‘‘‘tup=(‘a‘,‘b‘,123,‘hasee‘)foriintup:print(i)‘‘‘字典‘‘‘dict=‘jakey‘:1,‘imp‘:2fork,vindict.items 查看详情

组合数据类型练习,英文词频统计实例

1、由字符串创建一个作业评分表,做增删改查询统计遍历操作,例如查询第一个3分的下标,统计1分的同学有几个,3分的同学有几个,增删改查等等。>>>fenshu=list(‘1213223131312232323‘)>>>fenshu[‘1‘,‘2‘,‘1‘,‘3‘,... 查看详情

组合数据类型练习,英文词频统计实例

1、由字符串创建一个作业评分表,做增删改查询统计遍历操作,例如查询第一个3分的下标,统计1分的同学有几个,3分的同学有几个,增删改查等等。>>>fenshu=list(‘1213223131312232323‘)>>>fenshu[‘1‘,‘2‘,‘1‘,‘3‘,... 查看详情