摘要:
1 # 题目:利用条件运算符的嵌套来完成此题: 2 # 学习成绩>=90分的同学用A表示,60-90分之间的用B表示,60分以下的用C表示。 3 def score(n): 4 return "A" if n >= 90 else ("B" if n >= 60 else "C") 5 6 7 n 阅读全文
摘要:
1 def count(char): 2 a, b, c, d = 0, 0, 0, 0 3 for i in char: 4 if i == " ": 5 c += 1 6 elif i.isdecimal(): 7 a += 1 8 elif i.isalpha(): 9 b += 1 10 e 阅读全文
摘要:
1 def func(*args): 2 min = args[0] 3 max = args[0] 4 for el in args: 5 if el > max: 6 max = el 7 if el < min: 8 min = el 9 return {"最大值": max, "最小值": 阅读全文
摘要:
1 n = int(input("请输入一个整数:")) 2 if n % 1 == 0: 3 s = 1 4 for i in range(1, n): 5 s *= i 6 print(f"{n}! = {s}") 7 else: 8 print("输入的不是整数,error") 阅读全文