data=int(input('请输入日期:'))
year=data//10000
month=data//100%100
day=data%100
print(f'{year}年{month}月{day}日'
s='you must believe yourself,'
t='when no one '
r='else dose !'
print('%s%s%s'%(s,t,r))
print(''.join([s,t,r])
print('{}{}{}'.format(s,t,r))
print(f'{s}{t}{r}')
r=int(input('请输入半径:'))
import math
c=2*math.pi*r
s=math.pi*r**2
print(f'圆的周长为{c},面积为{s}')
y=1
while y<=9:
x=1
while x<=y:
print(f'{x}*[y}={x*y}')
x+=1
y+=1
print()
print('===================猜数字小游戏===================')
import random
print('=====================游戏开始=====================')
boom=random.randint(1,100)
print('炸弹已生成,在1-100之间')
start=1
end=100
number=int(input('请输入1-100之间的数字:'))
while number!=boom:
if start<=number
for y in range(1,10):
for x in range(1,y+1):
print(f'{x}*{y}={x*y}',end=' ')
print()
方法1:
list_a=[1,5,3,15,6,5,0,1,1,5,7,5,1,5,2,1]
for i in list_a.copy(): #不加copy时结果会出现重复元素,是因为你删除元素,长度在减短,索引还在增加,所以你中间就会跳过一个元素了
if list_a.count(i)>1:
list_a.remove(i)
print(list_a)
方法2:
list_a.sort()
list1=list_a
for i in list1:
a=list1.count(i)
b=list1.index(i)
del list1[b:b+a-1]
print(list1)
list_1=[1,2,4,6]
list_2=[2,5,6,8]
set1=set(list_1)
set2=set(list_2)
print(set1&set2)
stra='anhcnxjjsnnxjHAKSnxaolxjhalk'
stra=stra.lower()
dic_={}
for i in stra:
dic_.update({i:stra.count(i)})
print(dic_)
stra='qwertyuiopasdfghjklzxcvbnm0123456789'
import random
passwords={}
passwords=set(passwords)
while len(passwords)!=10:
passwords.append(''.join(random.choices(stra,k=8)))
print(passwords)
li=[(9,2,5,6),(2,1,5,9),(7,6,4,8),(3,4,5,7)]
li.sort(key=lambda x:x[1])
print(li)
def isPrime(x):
if type(x)!=int and x<=0 and x==1:
return False
elif x==2:
return True
else:
for i in range(2,x):
if x%i==0:
return False
else:
return True
x=int(input('请输入一个整数:'))
print(isPrime(x))
def func(string):
li=list(string)
if li==sorted(li):
return 'UP'
elif li==sorted(li,reverse=True):
return 'DOWN'
else:
return False
string=input('请输入字符:')
print(func(string))