n=eval(input())
if int!=type(n):
print("输入有误,请输入正整数")
elif n==0:
print("输入有误,请输入正整数")
else:
t=1
s=0
for i in range(1,n+1):
for j in range(1,i+1):
t=t*j
s=s+t
t=1
print(s)
try:
score = eval(input())
if score>100 or score<0:
print("输入有误!")
else:
a = int(100 / 10)
if a == 10 or a == 9:
print("输入成绩属于A级别。")
print("祝贺你通过考试!")
elif a == 8:
print("输入成绩属于B级别。")
print("祝贺你通过考试!")
elif a == 7:
print("输入成绩属于C级别。")
print("祝贺你通过考试!")
elif a == 6:
print("输入成绩属于D级别。")
print("祝贺你通过考试!")
else:
print("输入成绩属于E级别。")
except:
print("输入有误!")
finally:
print("好好学习,天天向上!")
def numSum(n):
sum=0
x=0
while n!=0:
x=n%10
n=int(n/10)
sum=sum+x*x
return sum
num=eval(input())
if num==1:
print(True)
else:
count = num
limit=0
while count!=1 and limit<1000:
count=numSum(count)
if count==4:
print(False)
break
limit+=1
if count==1:
print(True)
flag=False
for i in range(3):
name=input()
powd=input()
if name=="Kate" and powd=="666666":
print("登录成功!")
flag=True
break
if flag==False:
print("3次用户名或者密码均有误!退出程序。")
class Solution:
def generateParenthesis(self, n):
res = []
self.helper(res, 1,0, n, "(")
return res
def helper(self, res, i, j, n, path):
if i > n:
return
if i == n and j == n:
res.append(path)
return
elif i > j:
self.helper(res, i + 1, j, n, path + "(")
self.helper(res, i, j + 1, n, path + ")")
elif i == j:
self.helper(res, i + 1, j, n, path + "(")
num=eval(input())
object=Solution()
print(object.generateParenthesis(num))
def fib(n):
if n<=2:
return 1
return fib(n-1)+fib(n-2)
num=eval(input())
list=[]
for i in range(num+2):
if i==0:
print(0,end=', ')
elif fib(i)<=num:
list.append(fib(i))
print(fib(i),end=', ')
sum=0
for j in range(len(list)):
sum=sum+list[j]
avg=int(sum/len(list))
print(sum,end=', ')
print(avg)
def getText():
txt=open("hamlet.txt","r").read()
txt=txt.lower()
for ch in '!"#$%&()*+,-./:;<=>?@[\\]·^_{|}~':
txt=txt.replace(ch," ")
return txt
hamletTxt=getText()
words=hamletTxt.split()
counts={}
for word in words:
counts[word]=counts.get(word,0)+1
items=list(counts.items())
items.sort(key=lambda x:x[1],reverse=True)
for i in range(10):
word,count=items[i]
print("{0:<10},{1:>5}".format(word,count))
def jude(n):
m=n
a=int(m/100)
m=m%100
b=int(m/10)
m=m%10
if pow(m,3)+pow(a,3)+pow(b,3)==n:
return True
else:
return False
for i in range(100,1000):
if jude(i)==True and i!=407:
print(i,end=',')
elif i==407:
print(i)
str1=input()
for i in range(len(str1)):
print(str1[i])
str=input()
strout=''
for i in range(len(str)):
if 'a' <= str[i] and str[i] <= 'z':
strout+=chr((ord(str[i])-97+3)%26+97)
elif 'A' <= str[i] and str[i] <= 'Z':
strout += chr((ord(str[i]) - 65 + 3) % 26 + 65)
else:
strout += str[i]
print(strout)