7-1 jmu-Java&Python-统计一段文字中的单词个数并按单词的字母顺序排序后输出
a = input()
b = []
while a != "!!!!!":
a = a.split()
for i in range(len(a)):
b.append(a[i])
a = input()
b = list(set(b))
b = sorted(b)
print(len(b))
if len(b) < 10:
for i in range(len(b)):
print(b[i])
else:
for i in range(len(b)):
if i < 10:
print(b[i])
7-2 jmu-python-汇率兑换
a = input()
if a[0] == "R":
b = eval(a[1:])
print("$%.2f" % (b / 6.0))
elif a[0] == "$":
b = eval(a[1:])
print("R%.2f" % (b * 6.0))
7-3 jmu-python-回文数判断(5位数字)
a=input()
b=reversed(a)
if list(a)==list(b):
print("yes")
else:
print("no")
7-4 jmu-python-分段函数
a = eval(input())
if a < 3:
print("f({:.2f})={:.2f}".format(a, 1.2))
elif a == 3:
print("f({:.2f})={:.2f}".format(a, 10))
else:
print("f({:.2f})={:.2f}".format(a, 2 * a + 1))
7-5 产生每位数字相同的n位数
a, b = map(lambda x: x.strip(), input().split(","))
print(a * eval(b))
7-6 计算 11+12+13+…+m
a = eval(input())
sum = 0
for i in range(11, a + 1):
sum += i
print("sum = %d" % sum)
7-7 求出歌手的得分
a = eval(input())
b = list(map(int, input().split()))
b = sorted(b)
c = b[2:a - 2]
sum = 0
for i in range(len(c)):
sum += c[i]
print("aver=%.2f" % (sum / (a - 4)))
7-8 计算有n个字符串中最长的字符串长度
n = eval(input())
str = ""
max = 0
for i in range(n):
str = ""
str += input().strip()
if len(str) > max:
max = len(str)
print("length=%d" % max)
7-9 统计单词的个数
a = input().split()
print("count = %d" % len(a))
7-10 删除字符
a=input()
a=a.strip()
c=input()
c=c.strip()
a = a.replace(c.upper(), '').replace(c.lower(), '')
print("result: {}".format(a))
标签:10,python,sum,len,2f,PTA,eval,print,input
From: https://blog.csdn.net/q1820555847/article/details/143186906