【刷题 Python Tip】题目1~5

【题目1】just print a+b

give you two var a and b, print the value of a+b, just do it!!

print (a + b)

【题目2】list排序

给你一个list L,如L=[2,8,3,50],对L进行升序并输出:

a = sorted(L)
print (a)

【题目3】字符串逆序

给你一个字符串 a,如a=‘12345’,对a进行逆序输出a:

print(a[::-1])

【题目4】输出字典key

给你一个字典a,如a={1:1,2:2,3:3},输出字典a的key,以‘,’链接,如‘1,2,3’:

test=[str(x) for x in a.values()]
print ','.join(test) 

【题目5】输出字符串奇数位置的字符串

给你一个字符串a,输出字符奇数位置的字符串。如a=‘12345’,则输出135:

test=[str(x) for x in a.values()]
print ','.join(test) 

以后每天做题1~3道,并写下解题过程和思路。

原文地址:https://www.cnblogs.com/guohaojintian/p/6017326.html