#! /usr/bin.env python3
#! -*- coding:utf-8 -*-
'''
习题3:生成字符串a1b2c3d4e5f6g7h8i9j10
习题4:生成字符串a1B2c3D4e5F6g7H8i9J10
'''
def ascii_output_3():
s=""
for i in range(97,107):
s+=chr(i)+str(i-96)
return s
def ascii_output_4():
s=''
for i in range(97,107):
if i%2==0:
s+=chr(i-32)
s+=str(i-96)
else:
s+=chr(i)
s+=str(i-96)
return s
if __name__ == '__main__':
print("生成字符串a1b2c3d4e5f6g7h8i9j10\n %s" % ascii_output_3())
print("生成字符串a1B2c3D4e5F6g7H8i9J10\n %s" % ascii_output_4())
网友评论