import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
n = int(input())
for i in range(n):
name = input()
# name里面的每个字符都是大写字母就输出VALID
print('VALID' if all(c.isupper() for c in name) else 'INVALID')
注意:all()函数 - 这是一个内置函数,用于判断可迭代对象中的所有元素是否都为真。如果所有元素都为真,则返回True,否则返回False。
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
n = int(input())
count = 0
for i in range(n):
fruits = input()
if fruits == "logia":
count+=100
if fruits == "paramecia":
count+=75
if fruits == "zoan":
count+=25
print(f"{count} beli")
更优雅的写法,用字典(作者:u_know_not)
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
n = int(input())
s=0
for i in range(n):
fruits = input()
s+={"logia":100,"paramecia":75,"zoan":25}[fruits]
print(s,"beli")
import sys
import math
is_leap = input()
year_type = input()
count = 0
count += 5*29+5*30
if is_leap == "LEAP":
count+= 29
if year_type == "MISSING":
count+=2*29
if year_type == "SERIAL":
count+= 29+30
if year_type == "FULL":
count+= 2*30
print(count)
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
m = int(input())
n = int(input())
# Write an answer using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)
# 相加和在1~7
print((m+n-1)%7+1)
这里可以理解(m+n)为窗口左右移动,后面的+1是为了窗口整体移动,让0 ~ 6变成1~7
或者这样也可以(作者:mmlyd)
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
m = int(input())
n = int(input())
# Write an answer using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)
a = (m+n)%7
if a!=0:
print(a)
else:
print(7)
不完全
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
months = input()
my_months = "JFMAMJJASOND"
# 检测到months在my_months的位置
print(my_months[(my_months.index(months)+len(months))%12])