The Smart Device Checker چالش 6 از جلسهی 25، سخت
(سختتر) برای هر دستگاه (به ترتیب فهرست) ایرادهایش را هر کدام در یک خط چاپ کن، به این ترتیب: رمزش در DEFAULTS بود: door-cam: change the default password؛ نسخهاش از latest کوچکتر بود: door-cam: update to 2.3.1؛ بخشش smart نبود: door-cam: move to the smart zone. دستگاه بیایراد: smart-tv: ok. آخر از همه تعداد دستگاههایی که دستکم یک ایراد دارند: devices to fix: 3. خروجی کامل:door-cam: change the default passworddoor-cam: update to 2.3.1door-cam: move to the smart zonesmart-tv: okrobot-vacuum: update to 1.10.0baby-monitor: change the default passwordbaby-monitor: move to the smart zonedevices to fix: 3
DEFAULTS = ["admin", "1234", "password", "0000", "12345"]
def version(v):
nums = []
for part in v.split("."):
nums.append(int(part))
return nums
devices = [
{"name": "door-cam", "password": "admin", "version": "2.1.0", "latest": "2.3.1", "zone": "family"},
{"name": "smart-tv", "password": "Moon-Lamp-Tiger-8", "version": "5.10.2", "latest": "5.10.2", "zone": "smart"},
{"name": "robot-vacuum", "password": "Rain-Cup-Owl-31", "version": "1.9.0", "latest": "1.10.0", "zone": "smart"},
{"name": "baby-monitor", "password": "1234", "version": "3.0.0", "latest": "3.0.0", "zone": "guest"},
]
to_fix = 0
for d in devices:
problems = []
راهنما و جواب این چالش · برگشت به درس جلسهی 25: اینترنت اشیا: دوربین و تلویزیون هوشمند
بیشتر بخوان: تابع در پایتون: آموزش def، پارامتر و return با مثال