python123.io 简单编程题合集
有些代码觉得⾃⼰写得真是很丑陋啊第K 序元素查
字符串反码A
整数阶乘组合计算
跳台阶
⼤多数元素A
lt = eval(input(""))n = eval(input(""))
lt = sorted(lt,reverse = True)print(lt[n-1])def func(text):
result = []
for c in text: if c.islower():
n = chr(ord('z') - (ord(c) - ord('a'))) elif c.isupper():
n = chr(ord('Z') - (ord(c) - ord('A'))) else:
n = c
result.append(n)
return ''.join(result)
str = input("")
print(func(str))n, a = eval(input())
s = 1
for i in range (1, n + 1):
s *= i
for k in range(1,n):
a1 = a ** k
a2 = a ** (k+1)
if s % a1 == 0 and s % a2 != 0:
tem = k
print(tem)
def func(n): if n == 1 or n == 2:
return n
a = 1
b = 2
c = 3
for i in range(3,n+1):
c = a + b
a = b
b = c
return c
num = eval(input(""))
print(func(num))
个⼈所得税计算E
货币转换Ilambda编程
括号配对检测 A
n!之和
lt = {}seq = eval(input(""))
for i in seq: lt[i] = lt.get(i,0) + 1
ret = list(d.items())
#print("ret = {}".format(ret))
ret.sort(reverse = True, key = lambda x : x[1])Num,n = ret[0]
print(Num)
n = eval(input(""))if n > 80000:
sum = (n - 3500) * 0.45elif n > 55000:
sum = (n - 3500) * 0.35
elif n > 35000:
sum = (n - 3500) * 0.3
elif n > 9000:
sum = (n - 3500) * 0.25
elif n > 4500:
sum = (n - 3500) * 0.1 if sum < 0:
sum = 0
else: sum = 0
print(int(sum))
str = input("")
if str[0:3] in ["USD"]:
R = eval(str[3:]) * 6.78
print ("RMB{:.2f}".format(R))
elif str[0:3] in ["RMB"]:
R = eval(str[3:]) / 6.78
print("USD{:.2f}".format(R))
str = input("")lt = []
for i in range(0,len(str)):
if str[i] == '(':
lt.append('(')
elif str[i] == ')' and len(lt) == 0:
print("配对不成功")
exit()
elif str[i] == ')':
lt.pop()
if lt == []:
print("配对成功")
else:
print("配对不成功")
s = 1
for i in range(1,n+1):
s *= i
return s
n = input("")
if n.isdigit() == False or n == '0':
print("输⼊有误,请输⼊正整数")
exit()
num = eval(n)
sum = 0
for i in range(1,num+1):
sum += fac(i)
print(sum)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论