百分制转五分制E
score = int(input())
degree = 'AABCDEEEEEE'
print('data error!') if (score > 100 or score < 0) else print(degree[10-score//10])
判断闰年
year = int(input())
if year % 400 == 0 or (year%4 == 0 and year %100!=0):
print(True)
else:
print(False)
火车票
def seat_numbers(seat): # 判定座位是否合法
if not(seat[:-1].isdigit()):# 万一输入是 2c1c排除
return False
if 1 <= int(seat[:-1]) <= 17 and seat[-1] in 'ABCDF':
return True
else:
return False
def window_or_aisle(seat): # 判定是窗口、过道还是中间
if seat[-1] in 'AF':
return '窗口'
elif seat[-1] in 'CD':
return '过道'
elif seat[-1] == 'B':
return '中间'
if __name__ == '__main__':
Seat = input().upper()
if seat_numbers(Seat):
print(window_or_aisle(Seat))
else:
print('输入错误')
身份证
a = input()
if a[16] in '02468x':
print(f'出生:{a[6:10]}年{a[10:12]}月{a[12:14]}日')
print('性别:女')
elif a[16] in '13579':
print(f'出生:{a[6:10]}年{a[10:12]}月{a[12:14]}日')
print('性别:男')
各数字之和
n = input() #将数字作为字符串输入
list = list(n) #将字符串转换为列表
s = 0
for i in range(len(list)):
s+= int(list[i]) #将字符转换为整数型,并累加列表中的每个数字
print(s)
本月天数
def get_days(year_month_day):
year = int(year_month_day[:4])
month = int(year_month_day[4:6])
day = int(year_month_day[6:])
if month in [1, 3, 5, 7, 8, 10, 12]:
return 31
elif month == 2:
if (year % 4 == 0 and year % 100!= 0) or year % 400 == 0:
return 29
else:
return 28
else:
return 30
year_month_day = input()
print(get_days(year_month_day))
列表删除数据
ls = list(map(int,input().split()))
n = int(input())
if n in ls:
for i in range(len(ls)):
ls.remove(n)
if n in ls:
continue
else:
break
print(ls)
else:
print('NOT FOUND')
年龄最大
import datetime
list_time = []
chuo=[]
a = input()
while a: # 当获取到空串时停止获取输入
list_time.append(a)
a = input()
#print(list_time)
for time in list_time:
time1=datetime.datetime.strptime(time,'%Y-%m-%d').timestamp()#转化为时间戳
chuo.append(time1)
chuo1=sorted(chuo)
index=chuo.index(chuo1[0])
print(list_time[index])
数列前n项和
#1×1+2×2+3×3……的前n项和
n = int(input())
sum = 0
for i in range(1,n+1):
sum = sum + i * i
print(sum)
最大素数
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
def max_prime(n):
max_prime = 1
for i in range(2, n + 1):
if is_prime(i):
max_prime = i
return max_prime
# 输入
n = int(input())
# 处理
max_prime_n = max_prime(n)
# 输出
print(max_prime_n)