1.26 pairs capitalization printing, for example: Aa, Bb ......
for i in range(26):
print(chr(65+i)+chr(97+i))
2. A list contains 10 digits, and generates a new list, the new list number which requires number than before over
'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
list=[2,3,6,4,7,5,1,8,9,0]
list1=[]
for i in list:
list1.append(i+1)
print(list1)
3. Remove the descending first letter of each word, such as: I am a good boy!
method 1
tre='I am a good boy!'
t=tre.split()
#print(t)
t.reverse()
list=[]
#print(t)
for i in t:
list.append(i[0])
print(list)
Method 2
'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
a = "I AM A BOY"
result = []
for i in a.split()[::-1]:
result.append(i[0])
print(result)
4. Enter your birthday a month, if and else with a judgment of the month is not your birthday month
the first method, datetime module acquisition time
import datetime
date=datetime.datetime.now() #获取当前时间
# print(date.strftime('%Y-%m-%d')) #把当前时间格式化为可读懂的年月日
r=date.strftime('%m') #把当前时间格式化为可读懂的年月日,只取月份
print(r)
t=input('请输入自己的生日月份:')
if t==r:
print('true')
else:
print('不是')
The second method, time module acquisition time
'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
import time
# date=time.time() #获取当前时间
# print(date)
# print(time.localtime(time.time()))#按固定格式显示当前时间
# print(time.strftime('%Y-%m-%d')) #把当前时间格式化为可读懂的年月日
# print(time.strftime('%Y-%m-%d',time.localtime(time.time()))) #把时间格式化为可读懂的年月日,后一个参数可省略
# print(time.strftime('%m',time.localtime(time.time()))) #只取月儿份
#t=time.strftime('%m',time.localtime(time.time()))#只取月儿份
t=time.strftime('%m')#只取月儿份
print(t)
r=input('请输入自己的生日月份:')
if t==r:
print('true')
else:
print('不是')
5. Enter three letters: e, a, r, if input E, then the introduction of the cycle, if inputs a, execution continue, if the input r, then re-read the letter once, and printing, implemented using an infinite loop.
while True:
str = input('请输入三个字母:')
if str=='r':
print(str)
if str=='a':
continue
if str=='e':
break
else:
print('输入有误')
6. Enter three letters: e, a, r, if input E, then the loop is exited, if inputs a, execution continue, if the input r, then re-read the letter once, and print, only three letter input, repeat input the letter does not count.
'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
count = 0
for i in range(3):
letter = input("send a letter%d:"%i)
if letter == 'e':
break
elif letter == 'a':
continue
elif letter == 'r':
count += 1
if count == 2:
input("send a letter dddd:")
7. a string "abcdefg" is inserted into a list, each element of the letter representing the position of a list, for example:
["a","b","c","d","e","f","g"]
ls=["a","b","c","d","e","f","g"]
s="abcdefg"
lt=[]
#插入元素到后边
for i in s :
ls.extend(i)
print(ls)
for i in s:
ls.append(i)
print(ls)
#每个元素都插在第一个,或者说倒序插入列表前边
for i in s:
ls.insert(0,i)
print(ls)
8. [ 'A', 'b', 'c', 'd', 'e', 'f', 'g'] This operation list, spell a character string "adg"
'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
lis=['a','b','c','d','e','f','g']
print(len(lis))
t=lis[0]+lis[int(len(lis)/2)]+lis[-1]
print(t)
或
print("".join(lis[::3]))