'''
Function:计算EXCEL地址
Auto:Sherry
Date:2022.1.21
'''
word =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
n =int(input(''))if n inrange(1,2147483647):whileTrue:if n <=26:print(word[n-1])breakelse:if n /26<=26:
a = n //26-1print(word[a],end='')
n = n -26continue
读取文件并且按需换行
'''
Function:PayTheList
Auto:Sherry
Date:2022-04-08 17:28
'''
f =open("f:\Python_Datebase\PythonTestDate\ListOfSupermarket.txt",encoding='utf-8')list=[]for line in f:
line = line.replace("\n","")
line = line.replace(" ",",")
line = line.replace(" ","")print(line)
line = line.split(",")list.append(line)print(list)
'''
Function:单词分析
Auto:Sherry
Date:2022-02-27 19:12
'''
word=input()
a=0
b=[]for i in word:
c=word.count(i)if c>=a:
a=c
for j in word:if word.count(j)==a:
b.append(j)
b.sort()print(b[0])print(a)
数字的各位平方和循环圈
'''
Function:各位平方和循环圈
Auto:Sherry
Date:
'''defsp(a):
a = a.replace('',' ')
a = a.split(' ')return a
deffun(a):whileTrue:sum=0for i inrange(1,len(a)-1):
num =int(a[i])**2sum+= num
print(sum)ifsum==1:breakelse:
fun(a = sp(a =str(sum)))
fun(a = sp(a=input('')))
合数数量
'''
Function:合数数量
Auto:Sherry
Date:2022-04-08 16:17
'''
count =0for i inrange(1,2021):if i ==1:continuefor j inrange(2, i):if i % j ==0:
count +=1breakprint(count)
回文日期
'''
Function:回文日期
Auto:Sherry
Date:2022-02-27 20:21
'''
n =int(input())if n >=10000101and n <=89991231:while n <=89991231:
n +=1
n =str(n)if n[0]==n[7]and n[1]==n[6]and n[2]==n[5]and n[3]==n[4]:
n =int(n)print(n)breakelse:
n =int(n)while n <=89991231:
n +=1
n =str(n)if n[0]== n[2]== n[5]== n[7]and n[1]== n[3]== n[4]== n[6]:
n =int(n)print(n)breakelse:
n =int(n)
成绩统计
'''
Function:成绩统计
Auto:Sherry
Date:2022-02-27 19:47
'''
students =input()
i =0list=[]while i <int(students):
i +=1
score =input()list.append(int(score))
list1 =[]for i inrange(len(list)):iflist[i]>=60:
list1.append(list[i])
list2 =[]for i inrange(len(list)):iflist[i]>=85:
list2.append(list[i])print("{}%".format(round(len(list1)/len(list)*100)))print("{}%".format(round(len(list2)/len(list)*100)))
'''
Function:拆分计算
Auto:Sherry
Date:2022-04-08 13:50
'''
count =0for i inrange(1,2021):
word =str(i)for j in word:ifint(j)==2:
count +=1print(count)
操作二阶魔方
'''
Function:操作二阶魔方
Auto:Sherry
Date:2022.1.15
Test:
cube[0][0][0] = ['蓝色', '橙色', '白色']
cube[0][0][1] = ['蓝色', '红色', '白色']
cube[0][1][0] = ['绿色', '橙色', '白色']
cube[0][1][1] = ['绿色', '红色', '白色']
cube[1][0][0] = ['蓝色', '橙色', '黄色']
cube[1][0][1] = ['蓝色', '红色', '黄色']
cube[1][1][0] = ['绿色', '橙色', '黄色']
cube[1][1][1] = ['绿色', '红色', '黄色']
'''
cube =[['蓝色','橙色','白色'],['蓝色','红色','白色'],['绿色','橙色','白色'],['绿色','红色','白色'],['蓝色','橙色','黄色'],['蓝色','红色','黄色'],['绿色','橙色','黄色'],['绿色','红色','黄色']]print('初始颜色是:', end='')for i inrange(len(cube[3])):print(cube[3][i], end='')print()
choose =input('请输入按照什么旋转:')for i in choose:if i =='x':
a = cube[3][0]
b = cube[3][1]
c = cube[3][2]
cube[3][0]= cube[2][0]
cube[3][1]= cube[2][2]
cube[3][2]= cube[2][1]
cube[2][0]= cube[6][0]
cube[2][1]= cube[6][2]
cube[2][2]= cube[6][1]
cube[6][0]= cube[7][0]
cube[6][1]= cube[7][2]
cube[6][2]= cube[7][1]
cube[7][0]= a
cube[7][1]= c
cube[7][2]= b
if i =='y':
a = cube[3][0]
b = cube[3][1]
c = cube[3][2]
cube[3][0]= cube[7][2]
cube[3][1]= cube[7][1]
cube[3][2]= cube[7][0]
cube[7][0]= cube[5][2]
cube[7][1]= cube[5][1]
cube[7][2]= cube[5][0]
cube[5][0]= cube[1][2]
cube[5][1]= cube[1][1]
cube[5][2]= cube[1][0]
cube[1][0]= c
cube[1][1]= b
cube[1][2]= a
if i =='z':
a = cube[3][0]
b = cube[3][1]
c = cube[3][2]
cube[3][0]= cube[2][1]
cube[3][1]= cube[2][0]
cube[3][2]= cube[2][2]
cube[2][0]= cube[0][1]
cube[2][1]= cube[0][0]
cube[2][2]= cube[0][2]
cube[0][0]= cube[1][1]
cube[0][1]= cube[1][0]
cube[0][2]= cube[1][2]
cube[1][0]= b
cube[1][1]= a
cube[1][2]= c
for i inrange(len(cube[3])):print(cube[3][i], end='')
求100!内有多少正约数
'''
Function:求100!内有多少正约数
Auto:Sherry
Date:2022-04-08 16:25
'''deffun(n):sum=1# 给一个求阶乘的容器for i inrange(1, n +1):sum*= i
print(sum)returnsum
n = fun(100)list=[]while n notinrange(n):# 保证输出了一个质因数之后继续循环输出质因数for j inrange(2, n +1):if n % j ==0:
n =int(n / j)# 这里写成 n /= j的时候会报错,# 因为除法在第二次循环的时候把n变成了浮点数if n ==1:# 这里是输出 1print(j)else:# j 一定是素数list.append(j)print('{} *'.format(j), end=' ')print(len(list))break
算式900
'''
Function:算式900
Auto:Sherry
Date:2022.1.16
'''for a inrange(10):if a ==0:continueelse:for s inrange(10):if s == a:continueelse:for d inrange(10):if a == d or s==d:continueelse:for f inrange(10):if f == a or f == s or f ==d:continueelse:for g inrange(10):if g ==0or g==a or g==s or g==d or g==f:continueelse:for h inrange(10):if h ==a or h == s or h==d or h==f or h==g:continueelse:for j inrange(10):if j ==a or j==s or j==d or j==f or j==g or j==h:continueelse:for k inrange(10):if k==a or k==s or k==d or k==f or k==g or k==h or k==j:continueelse:for l inrange(10):if l ==0or l==a or l==s or l==d or l==f or l==g or l==h or l==j or l==k:continueelse:for i inrange(10):if i==a or i==s or i==d or i==f or i==g or i==h or i==j or i==k or i==l:continueelif((a*1000+s*100+d*10+f)-(g*1000+h*100+j*10+k))*(l*10+i)==900:print("({}{}{}{}-{}{}{}{})*{}{}=900".format(a,s,d,f,g,h,j,k,l,i))
'''
Function:门牌制作
Auto:Sherry
Date:2022-02-28 15:03
'''
num =0for i inrange(1,2021):
i =str(i)for j inrange(len(i)):if i[j]=="2":
num +=1print(num)
数位排序
'''
功能:数位排序
作者:Sherry
时间:2022.6.21
n = int(input())
m = int(input())
l = []
for i in range(1, n+1):
l.append(str(i))
print(l)
l = sorted(l, #对l列表排序
key=lambda x: sum( #这里调用key关键字并且使用lambda函数 x表示里面的值,sum表示将值求和
map(int, x) #便利x并且返回x的整形状态
))
print(l[m-1])e
'''deffun_sum(num):sum=0#初始化和while num !=0:#如果不为0则继续下一步sum+= num %10#差分求和
num =int(num /10)#求完和之后除以10并向下取整returnsum#返回各位数字和#接收变量
num =int(input())
index =int(input())#创建列表用来排序
nums =[i for i inrange(1, num +1)]#根据接收的变量来建立循环次数for i inrange(num):#建立比较大小的循环for j inrange(num -1- i):#进行判断大小if fun_sum(nums[j])> fun_sum(nums[j +1]):#这里和刚才一样用一个n来充当容器好替换列表前后的值
n = nums[j]
nums[j]= nums[j +1]
nums[j +1]= n
#输出所需要的值print(nums[index -1])
斐波那契数列求和
'''
功能:生产斐波拉西数列
作者:Sherry
时间:2022.6.21
'''list=[1,1]#这里创建前两项sum=0#输出化和
n =int(input())#让用户输入多少项for i inrange(n):
j =list[i]+list[i +1]#计算下一项的值list.append(j)#将下一项的值放入listfor i inrange(len(list)-2):#因为一开始我给出了前两项所以在这范围-2sum+=list[i]#计算前n项和print(sum)#输出前n项和
玫瑰花数
#功能:输出玫瑰花数#作者:Sherry#2022-6-21# 键入值
Num =1000while Num inrange(1000,10000):#建立循环
x1 = Num %10#提出最后一位
x2 = Num //10%10#提出倒数第二位 下面依次类推
x3 = Num //100%10
x4 = Num //1000
Num_sum = x1 **4+ x2 **4+ x3 **4+ x4 **4#算出各位数的四次方和#进行比较if Num == Num_sum:# 若相同则输出 否则直接跳过print('{} = {} ^ 4 + {} ^ 4 + {} ^ 4 + {} ^ 4'.format(Num, x4, x3, x2, x1))#循环次数num+1
Num +=1
计算纸张尺寸
'''
功能:计算纸张尺寸
作者:Sherry
时间:2022.6.21
'''#创建列表以判断输入内容是否合格list=["A0","A1","A2","A3","A4","A5","A6","A7","A8","A9"]
cc =input()#创建输入的内容
a =1189#初始长
b =841#初始宽#判断是否是正确的输入内容if cc notinlist:#如果不是重新运行,这里没有做次数或者死循环print("尺寸输入错误")else:#先取出数字---也就是循环次数
n =int(cc[1])#建立循环,次数由输入里面的数字决定for i inrange(n):#判断长边短边 并且对半处理 使用int是因为消耗所以使用向下取整if a > b:
a =int(a/2)else:
b =int(b/2)#这里做这个是输出的时候让长边一直在上面输出,所以用了一个c来充当容器并转换 a , b 值if a<b:
c = a
a = b
b = c
print(a)print(b)