'''
计算a^2+b^2+c^2
'''
def calc(*number):
sum = 0
for n in number:
sum = sum + n * n
return sum
print(calc(1,2,3))
'''
计算阶乘n!
'''
def jiecheng():
num = int(input("请输入一个数字:"))
n = 1
#查看数字是负数,0或正数
if num < 0:
print("负数没有阶乘")
elif num == 0:
print("0的阶乘是1")
else:
for i in range(1,num+1):
n = n * i
print("%d 的阶乘为%d" % (num,n))
print(jiecheng())
'''
把原字典的键值对颠倒并生产新的字典
'''
dict1={"A":"a","B":"b","C":"c"}
dict2={y:x for x,y in dict1.items()}
print(dict2)
'''
随机生成验证码的两种方式
'''
import random
list1 = []
for i in range(65,91):
list1.append(chr(i))
for j in range(97,123):
list1.append(chr(j))
for k in range(48,58):
list1.append(chr(k))
ma = random.sample(list1,6)
print(ma)
ma = ''.join(ma)
print(ma)