初级
实现屏幕分辨率规格校验
未完成
初级参考
完整示例代码供参考,建议自己理解后重新输入
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd
st_csv = open_url("https://data.zuihe.com/dbd/ms-adlift/state_00/screen_types.csv").read()
screen_types = pd.read_csv(StringIO(st_csv))
VALID_RES = {'1920x1080','1280x720','1080x1920','720x1280'}
def validate(res, orientation):
w, h = map(int, res.split('x'))
expected = 'landscape' if w > h else 'portrait'
return res in VALID_RES, orientation == expected, expected
print("Screen type validation:")
for _, row in screen_types.iterrows():
res_ok, orient_ok, expected = validate(row['resolution'], row['orientation'])
status = 'OK' if res_ok and orient_ok else 'FAIL'
print(" "+row['model']+": "+row['resolution']+" "+row['orientation']+" expected="+expected+" -> "+status)
示例
输入
solve()
期望输出
Screen type validation: LCD-1080P-H: 1920x1080 landscape expected=landscape -> OK LCD-720P-H: 1280x720 landscape expected=landscape -> OK LCD-1080P-V: 1080x1920 portrait expected=portrait -> OK LCD-720P-V: 720x1280 portrait expected=portrait -> OK
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199