1.
(10)
name='aleX leNb' print(name.split('l',1))
(13)
name='aleX leNb' a=name.replace('a','A') print(a)
(14)
name='aleX leNb' count=0 for i in name: if i =='l': count+=1 print(count)
(15)
name='aleX leNb' count=0 for i in name[0:4]: if i =='l': count+=1 print(count)
(16)
name='aleX leNb' print(name.index('N'))
(17)
name='aleX leNb' print(name.find('N'))
2.
(6)
s='123a4b5c' print(s[-3::-2])
3.
s='123a4b5c' for i in s : print(i)
4.
s='123a4b5c' for i in range(0,len(s)) : print(s+'sb')
5.
s='abcdefg' for i in s: print(str(i)+'sb')
6.
s='321' for i in s: print('倒计时%s秒' %i)
7.
count=input('请输入内容:').strip() a=count.split('+') b=int(a[0])+int(a[1]) print(b)
8.
count=input('请输入内容:').strip() a=count.split('+') b=0 for i in range(0,len(a)): b=b+int(a[i]) print(b)
9.
count=input('请输入内容:').strip() a=0 for i in count: if i.isdigit(): a=a+1 print(a)
10.
a=input('请输入:').upper() while 1: if a=='A': print('走大路回家') b=input('公交车还是步行?') if b=='公交车': print('十分钟到家') break elif b=='步行': print('20分钟回家') break elif a=='B': print('走小路回家') break elif a=='C': print('绕道回家') c=input('游戏厅还是网吧?') if c=='游戏厅': print('你爸爸会打死你,给我重新选A,B,C') elif c=='网吧': print('你妈会打死你,给我重新选A,B,C') else:print('傻逼')
11.
count=0 sum=0 while count <99: count = count + 1 if count==88: continue if count %2!=0: sum=sum+count elif count %2==0: sum=sum-count print(sum)
12.
a=input('') if a[-1::-1]==a: print('回文')
13.
a=input('') digit_num = 0 upper_num=0 lower_num=0 for i in a: if i.isdigit(): digit_num+=1 elif i.isupper(): upper_num+=1 elif i.islower(): lower_num+=1 print(digit_num) print(upper_num) print(lower_num)
14.
name=input('姓名') place=input('地点') hobby=input('爱好') print('敬爱的{}喜欢在{}{}'.format(name,place,hobby))