7-1 产生每位数字相同的n位数 (30 分)
a,b = map(int, input().split(",")) for i in range(1, b+1): print(a, end="")
7-2 输出10个不重复的英文字母 (50 分)
s = input() count = 0 data = [] for i in range(len(s)): if s[i].isalpha() and ("a"<=s[i]<="z" or "A"<=s[i]<="Z"): if s[i].upper() not in data and s[i].lower() not in data: count += 1 data.append(s[i]) if count == 10: break if count == 10: for i in data: print(i,end="") else: print("not found")
7-5 jmu-python-求三角形面积及周长 (10 分)
import math a = eval(input()) b = eval(input()) c = eval(input()) s = (a+b+c)/2 area = math.sqrt(s*(s-a)*(s-b)*(s-c)) perimeter = a+b+c print('area={:.2f};perimeter={:.2f}'.format(area, perimeter))
7-4 jmu-python-是否偶数 (10 分)
n = eval(input()) if (n % 2 == 0): print("{}是偶数".format(n)) else: print("{}不是偶数".format(n))
7-3 转换函数使用 (30 分)
a, b = input().split(",") print(int(a, eval(b)))
7-6 重要的事情说N遍 (20 分)
n = input() num = eval(input()) for i in range(1, num+1): print(n+"!", end="")
7-7 计算M和N的多个结果 (10 分)
m = eval(input()) n = eval(input()) print(m+n, end=" ") print(m*n, end=" ") print(m**n, end=" ") print(m%n, end=" ") if m > n: print(m) else: print(n)
7-8 计算 11+12+13+…+m (30 分)
m = eval(input()) sum = 0 for i in range(11, m+1): sum += i print("sum = {}".format(sum))
7-9 找出最大值和最小值 (10 分)
a = list(map(int, input().split(" "))) n = len(a) a.sort() print("Max={}".format(a[n-1])) print("Min={}".format(a[0]))