'''
@Author: your name
@Date: 2020-07-28 11:34:24
@LastEditTime: 2020-07-28 12:04:47
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \vscode_py\day22.py
'''
# Question 90
# 统计字符串中的字母数量
def Q90():
s=input()
dic={}
for i in s:
dic[i]=dic.get(i,0)+1 # 如果字典中有这个值,那么数量+1,否则返回默认值0
print("\n".join(['%s %s' % (k, v) for k, v in dic.items()]))
# Question 91
# 倒序排列字符串
def Q91():
s=input()
# ans=s[::-1]
# print(ans)
ans=''.join(reversed(s))
print(ans)
# Question 92
# 打印偶数索引的值
def Q92():
s=input()
ans=[s[i] for i in range(len(s)) if i%2==0]
print(''.join(ans))
# Question 93
# 打印所有的排列组合
# Please write a program which prints all permutations of [1,2,3]
def Q93():
import itertools
# print(list(itertools.permutations([1,2,3])))
# Question 94
# 鸡兔同笼
def Q94():
head=35
leg=94
for i in range(head+1):
if i*2+(head-i)*4==leg:
return i,head-i
return "No solutions!"
if __name__ == "__main__":
# Q90()
# Q91()
# Q92()
# Q93()
ans=Q94()
print(ans)
【Python Practice】Day 22 Question 90-94
最新推荐文章于 2020-10-11 17:00:00 发布