Фильтр Python: пошаговое руководство

–ú–µ—Ç–æ–¥ Python filter () –∏—Å–ø–æ–ª—å–∑—É–µ—Ç—Å—è –¥–ª—è —Ñ–∏–ª—å—Ç—Ä–∞—Ü–∏–∏ —Å–ø–∏—Å–∫–æ–≤, –Ω–∞–±–æ—Ä–æ–≤ –∏ –∫–æ—Ä—Ç–µ–∂–µ–π. filter () —Å–ª–µ–¥—É–µ—Ç –ª—é–±—ã–º –ø—Ä–µ–¥–æ—Å—Ç–∞–≤–ª–µ–Ω–Ω—ã–º –∫—Ä–∏—Ç–µ—Ä–∏—è–º –¥–ª—è —Ñ–∏–ª—å—Ç—Ä–∞—Ü–∏–∏ –∏—Ç–µ—Ä–∏—Ä—É–µ–º–æ–≥–æ –æ–±—ä–µ–∫—Ç–∞ –∏ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞–Ω–Ω—ã–π —Ä–µ–∑—É–ª—å—Ç–∞—Ç.

–ü—Ä–∏ –ø—Ä–æ–≥—Ä–∞–º–º–∏—Ä–æ–≤–∞–Ω–∏–∏ —É –≤–∞—Å –º–æ–∂–µ—Ç –±—ã—Ç—å —Å–ø–∏—Å–æ–∫ –∑–Ω–∞—á–µ–Ω–∏–π –∫–æ—Ç–æ—Ä—ã–µ –≤—ã —Ö–æ—Ç–∏—Ç–µ –∫–∞–∫–∏–º-—Ç–æ –æ–±—Ä–∞–∑–æ–º –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞—Ç—å. –ù–∞–ø—Ä–∏–º–µ—Ä, —É –≤–∞—Å –º–æ–∂–µ—Ç –±—ã—Ç—å —Å–ø–∏—Å–æ–∫ –∑–∞–∫–∞–∑–æ–≤ –Ω–∞ —Ñ–∞–π–ª—ã cookie, –∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ –≤–æ–∑–≤—Ä–∞—â–∞—Ç—å —Ç–æ–ª—å–∫–æ —Ç–µ, –∫–æ—Ç–æ—Ä—ã–µ –≤–∫–ª—é—á–∞—é—Ç —à–æ–∫–æ–ª–∞–¥, –∫–æ—Ç–æ—Ä—ã–µ –æ–±—Ä–∞–±–∞—Ç—ã–≤–∞—é—Ç—Å—è –∫–æ–Ω–∫—Ä–µ—Ç–Ω—ã–º –ø–æ–≤–∞—Ä–æ–º –≤ –≤–∞—à–µ–º –º–∞–≥–∞–∑–∏–Ω–µ —Ñ–∞–π–ª–æ–≤ cookie.

–í–æ—Ç –≥–¥–µ —Ñ–∏–ª—å—Ç—Ä Python (). –ú–µ—Ç–æ–¥ filter () –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è —Ñ–∏–ª—å—Ç—Ä–∞—Ü–∏–∏ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω–æ–≥–æ —Å–ø–∏—Å–∫–∞ –Ω–∞ –æ—Å–Ω–æ–≤–µ –ø—Ä–µ–¥–æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω–æ–≥–æ –Ω–∞–±–æ—Ä–∞ –∫—Ä–∏—Ç–µ—Ä–∏–µ–≤ –∏ –≤–æ–∑–≤—Ä–∞—Ç–∞ –∏—Ç–µ—Ä–∞—Ü–∏–∏ —Å –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞–Ω–Ω—ã–º–∏ –¥–∞–Ω–Ω—ã–º–∏.

–í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –º—ã –æ–±—Å—É–¥–∏–º –º–µ—Ç–æ–¥ filter () –∏ —Ç–æ, –∫–∞–∫ –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –µ–≥–æ –≤ —Å–≤–æ–µ–º –∫–æ–¥–µ. –ú—ã —Ç–∞–∫–∂–µ —Ä–∞—Å—Å–º–æ—Ç—Ä–∏–º –Ω–µ—Å–∫–æ–ª—å–∫–æ –ø—Ä–∏–º–µ—Ä–æ–≤ —Ñ—É–Ω–∫—Ü–∏–∏ –≤ –∫–æ–¥–µ Python.

Python Filter

–°–ø–∏—Å–∫–∏ - —ç—Ç–æ —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö –≤ Python, –∫–æ—Ç–æ—Ä—ã–π –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è —Ö—Ä–∞–Ω–µ–Ω–∏—è –Ω–µ—Å–∫–æ–ª—å–∫–∏—Ö –∑–Ω–∞—á–µ–Ω–∏–π —Å –æ–±—â–∏–º —Ç–µ–º–∞. –ù–∞–ø—Ä–∏–º–µ—Ä, –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Å–ø–∏—Å–æ–∫ –¥–ª—è —Ö—Ä–∞–Ω–µ–Ω–∏—è –≤—Å–µ–π –æ–¥–µ–∂–¥—ã, –∫–æ—Ç–æ—Ä–∞—è –ø—Ä–æ–¥–∞–µ—Ç—Å—è –≤ –º–µ—Å—Ç–Ω–æ–º –º–∞–≥–∞–∑–∏–Ω–µ –º–æ–¥–Ω–æ–π –æ–¥–µ–∂–¥—ã, –∏–ª–∏ –¥–ª—è —Ö—Ä–∞–Ω–µ–Ω–∏—è —Å–ø–∏—Å–∫–∞ –Ω–∞–∑–≤–∞–Ω–∏–π —è–∑—ã–∫–æ–≤ –ø—Ä–æ–≥—Ä–∞–º–º–∏—Ä–æ–≤–∞–Ω–∏—è.

–ß–∞—Å—Ç–æ, –∫–æ–≥–¥–∞ –≤—ã —Ä–∞–±–æ—Ç–∞–µ—Ç–µ —Å–æ —Å–ø–∏—Å–∫–∞–º–∏, –≤—ã " —Ö–æ—Ç–∏—Ç–µ –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞—Ç—å —Å–ø–∏—Å–æ–∫ –ø–æ –Ω–∞–±–æ—Ä—É –∫—Ä–∏—Ç–µ—Ä–∏–µ–≤. –ù–∞–ø—Ä–∏–º–µ—Ä, –≤—ã –º–æ–∂–µ—Ç–µ —É–ø—Ä–∞–≤–ª—è—Ç—å –∫–∏–Ω–æ—Ç–µ–∞—Ç—Ä–æ–º –∏ —Ö–æ—Ç–∏—Ç–µ –∑–Ω–∞—Ç—å, —Å–∫–æ–ª—å–∫–æ –ª—é–¥–µ–π –≤ –≤–æ–∑—Ä–∞—Å—Ç–µ –¥–æ 18 –ª–µ—Ç –ø–æ—Å–µ—â–∞—é—Ç —Ñ–∏–ª—å–º—ã –≤ –≤–∞—à–µ–º –∫–∏–Ω–æ—Ç–µ–∞—Ç—Ä–µ.

filter (), –≤—Å—Ç—Ä–æ–µ–Ω–Ω—ã–π –≤ —Ñ—É–Ω–∫—Ü–∏–∏, –º–æ–∂–µ—Ç –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å—Å—è –¥–ª—è —Ñ–∏–ª—å—Ç—Ä–∞—Ü–∏–∏ —Å–ø–∏—Å–∫–∞ –∏ –≤–æ–∑–≤—Ä–∞—Ç–∞ –∏—Ç–µ—Ä–∞—Ç–æ—Ä–∞. –í–æ—Ç —Å–∏–Ω—Ç–∞–∫—Å–∏—Å –º–µ—Ç–æ–¥–∞ filter ():

–ú–µ—Ç–æ–¥ filter () –ø—Ä–∏–Ω–∏–º–∞–µ—Ç –¥–≤–∞ –ø–∞—Ä–∞–º–µ—Ç—Ä–∞:

81% —É—á–∞—Å—Ç–Ω–∏–∫–æ–≤ –∑–∞—è–≤–∏–ª–∏, —á—Ç–æ –æ–Ω–∏ –±–æ–ª–µ–µ —É–≤–µ—Ä–µ–Ω—ã –≤ —Å–≤–æ–µ–π —Ç–µ—Ö–Ω–∏—á–µ—Å–∫–æ–π —Ä–∞–±–æ—Ç–µ –ø–µ—Ä—Å–ø–µ–∫—Ç–∏–≤—ã –ø–æ—Å–ª–µ –ø–æ—Å–µ—â–µ–Ω–∏—è —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è. –ù–∞–π–¥–∏—Ç–µ –ø–æ–¥—Ö–æ–¥ –∫ —É—á–µ–±–Ω–æ–º—É –ª–∞–≥–µ—Ä—é —Å–µ–≥–æ–¥–Ω—è.

–°—Ä–µ–¥–Ω–∏–π –≤—ã–ø—É—Å–∫–Ω–∏–∫ —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è –ø–æ—Ç—Ä–∞—Ç–∏–ª –º–µ–Ω–µ–µ —à–µ—Å—Ç–∏ –º–µ—Å—è—Ü–µ–≤ –Ω–∞ —Å–º–µ–Ω—É –∫–∞—Ä—å–µ—Ä—ã, –æ—Ç –Ω–∞—á–∞–ª–∞ —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è –¥–æ –ø–æ–∏—Å–∫–∞ —Å–≤–æ–µ–π –ø–µ—Ä–≤–æ–π —Ä–∞–±–æ—Ç—ã.

–£–∫–∞–∑–∞–Ω–Ω—ã–π –≤–∞–º–∏ –ø–æ–≤—Ç–æ—Ä—è–µ–º—ã–π –æ–±—ä–µ–∫—Ç –º–æ–∂–µ—Ç –±—ã—Ç—å –±—ã—Ç—å –ª—é–±—ã–º–∏ –∏—Ç–µ—Ä–∞–±–µ–ª—å–Ω—ã–º–∏, —Ç–∞–∫–∏–º–∏ –∫–∞–∫ —Å–ø–∏—Å–∫–∏, –Ω–∞–±–æ—Ä—ã –∏ –∫–æ—Ä—Ç–µ–∂–∏ Python.

–ü—Ä–∏–º–µ—Ä—ã —Ñ–∏–ª—å—Ç—Ä–æ–≤ Python

–î–∞–≤–∞–π—Ç–µ —Ä–∞—Å—Å–º–æ—Ç—Ä–∏–º –ø—Ä–∏–º–µ—Ä, —á—Ç–æ–±—ã –ø—Ä–æ–¥–µ–º–æ–Ω—Å—Ç—Ä–∏—Ä–æ–≤–∞—Ç—å, –∫–∞–∫ –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —ç—Ç–æ—Ç –º–µ—Ç–æ–¥.

–ü—Ä–µ–¥–ø–æ–ª–æ–∂–∏–º, –≤—ã —Ä–∞–±–æ—Ç–∞–µ—Ç–µ —Å –∂—É—Ä–Ω–∞–ª—å–Ω—ã–º –∫–∏–æ—Å–∫–æ–º –∏ —Ö–æ—Ç–∏—Ç–µ –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, –Ω—É–∂–Ω–æ –ª–∏ –≤–∞–º –∑–∞–∫–∞–∑—ã–≤–∞—Ç—å –Ω–æ–≤—ã–π –∏–Ω–≤–µ–Ω—Ç–∞—Ä—å. –ï—Å–ª–∏ —É –≤–∞—Å –º–µ–Ω—å—à–µ 20 –≤—ã–ø—É—Å–∫–æ–≤ –∫–∞–∫–æ–≥–æ-–ª–∏–±–æ –∂—É—Ä–Ω–∞–ª–∞, –≤–∞–º –Ω–µ–æ–±—Ö–æ–¥–∏–º–æ –æ—Ñ–æ—Ä–º–∏—Ç—å –Ω–æ–≤—ã–π –∑–∞–∫–∞–∑; –µ—Å–ª–∏ —É –≤–∞—Å –±–æ–ª–µ–µ 20 –≤—ã–ø—É—Å–∫–æ–≤ –∂—É—Ä–Ω–∞–ª–∞, –≤–∞–º –Ω–µ –Ω—É–∂–Ω–æ —Ä–∞–∑–º–µ—â–∞—Ç—å –Ω–æ–≤—ã–π –∑–∞–∫–∞–∑. –£ –≤–∞—Å –µ—Å—Ç—å —Å–ø–∏—Å–æ–∫ –Ω–æ–º–µ—Ä–æ–≤, –≤ –∫–æ—Ç–æ—Ä–æ–º —Ö—Ä–∞–Ω–∏—Ç—Å—è –∫–æ–ª–∏—á–µ—Å—Ç–≤–æ –∏–º–µ—é—â–∏—Ö—Å—è —É –≤–∞—Å –º–∞–≥–∞–∑–∏–Ω–æ–≤.

–ß—Ç–æ–±—ã –ø—Ä–æ–≤–µ—Ä–∏—Ç—å, –Ω—É–∂–Ω–æ –ª–∏ –≤–∞–º —Ä–∞–∑–º–µ—â–∞—Ç—å –∑–∞–∫–∞–∑ –Ω–∞ –∫–∞–∫–∏–µ-–ª–∏–±–æ –º–∞–≥–∞–∑–∏–Ω—ã, –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Å–ª–µ–¥—É—é—â–∏–π –∫–æ–¥:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: [17, 14]

–î–∞–≤–∞–π—Ç–µ —Ä–∞–∑–±–µ—Ä–µ–º –Ω–∞—à –∫–æ–¥. –í –ø–µ—Ä–≤–æ–π —Å—Ç—Ä–æ–∫–µ –º—ã –æ–ø—Ä–µ–¥–µ–ª—è–µ–º –ø–µ—Ä–µ–º–µ–Ω–Ω—É—é —Å –∏–º–µ–Ω–µ–º sizes, –≤ –∫–æ—Ç–æ—Ä–æ–π —Ö—Ä–∞–Ω–∏—Ç—Å—è –∫–æ–ª–∏—á–µ—Å—Ç–≤–æ –≤—ã–ø—É—Å–∫–æ–≤ –∫–∞–∂–¥–æ–≥–æ –∂—É—Ä–Ω–∞–ª–∞, –∏–º–µ—é—â–µ–≥–æ—Å—è —É –Ω–∞—Å –≤ –∏–Ω–≤–µ–Ω—Ç–∞—Ä–µ.

–ó–∞—Ç–µ–º –º—ã –æ–ø—Ä–µ–¥–µ–ª—è–µ–º —Ñ—É–Ω–∫—Ü–∏—é —Å –∏–º–µ–Ω–µ–º checkQuantities, –∫–æ—Ç–æ—Ä—ã–π –ø—Ä–æ–≤–µ—Ä–∏—Ç, –µ—Å—Ç—å –ª–∏ —É –Ω–∞—Å –≤ –Ω–∞–ª–∏—á–∏–∏ –º–µ–Ω–µ–µ 20 –≤—ã–ø—É—Å–∫–æ–≤ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω–æ–≥–æ –∂—É—Ä–Ω–∞–ª–∞. –ï—Å–ª–∏ —É –Ω–∞—Å –º–µ–Ω—å—à–µ 20 –≤—ã–ø—É—Å–∫–æ–≤, –Ω–∞—à–∞ —Ñ—É–Ω–∫—Ü–∏—è checkQuantities –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True; –≤ –ø—Ä–æ—Ç–∏–≤–Ω–æ–º —Å–ª—É—á–∞–µ –æ–Ω –≤–µ—Ä–Ω–µ—Ç False.

–ó–∞—Ç–µ–º –º—ã –∏—Å–ø–æ–ª—å–∑—É–µ–º –º–µ—Ç–æ–¥ filter () –∏ —É–∫–∞–∂–µ–º checkQuantities –≤ –∫–∞—á–µ—Å—Ç–≤–µ –Ω–∞—à–µ–π —Ñ—É–Ω–∫—Ü–∏–∏ –∏ –∫–æ–ª–∏—á–µ—Å—Ç–≤–∞ –≤ –∫–∞—á–µ—Å—Ç–≤–µ –Ω–∞—à–µ–≥–æ –∏—Ç–µ—Ä–∞—Ç–∏–≤–Ω–æ–≥–æ –æ–±—ä–µ–∫—Ç–∞. –≠—Ç–æ —Å–æ–æ–±—â–∞–µ—Ç –Ω–∞—à–µ–º—É –º–µ—Ç–æ–¥—É filter () –≤—ã–ø–æ–ª–Ω–∏—Ç—å checkQuantities –¥–ª—è –∫–∞–∂–¥–æ–≥–æ —ç–ª–µ–º–µ–Ω—Ç–∞ –≤ –º–∞—Å—Å–∏–≤–µ –∫–æ–ª–∏—á–µ—Å—Ç–≤–∞.

–ó–∞—Ç–µ–º –º—ã —Ä–∞—Å–ø–µ—á–∞—Ç—ã–≤–∞–µ–º —Ä–µ–∑—É–ª—å—Ç–∞—Ç –Ω–∞—à–µ–≥–æ filter () –∏ –∏—Å–ø–æ–ª—å–∑—É–π—Ç–µ list (), —á—Ç–æ–±—ã –ø—Ä–µ–æ–±—Ä–∞–∑–æ–≤–∞—Ç—å –µ–≥–æ –≤ —Å–ø–∏—Å–æ–∫. –≠—Ç–æ –≤–∞–∂–Ω–æ, –ø–æ—Ç–æ–º—É —á—Ç–æ filter () –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞–Ω–Ω—ã–π –æ–±—ä–µ–∫—Ç, –∞ –Ω–µ —Å–ø–∏—Å–æ–∫. –ò—Ç–∞–∫, –µ—Å–ª–∏ –º—ã —Ö–æ—Ç–∏–º —É–≤–∏–¥–µ—Ç—å –Ω–∞—à–∏ –¥–∞–Ω–Ω—ã–µ, –Ω–∞–º –Ω—É–∂–Ω–æ –ø—Ä–µ–æ–±—Ä–∞–∑–æ–≤–∞—Ç—å –∏—Ö –≤ —Å–ø–∏—Å–æ–∫.

–ö–∞–∫ –≤–∏–¥–∏—Ç–µ, –Ω–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –¥–≤–∞ –∑–Ω–∞—á–µ–Ω–∏—è: 17 –∏ 14. –ö–∞–∂–¥–æ–µ –∏–∑ –Ω–∏—Ö –º–µ–Ω—å—à–µ 20, —á—Ç–æ –æ–∑–Ω–∞—á–∞–µ—Ç, —á—Ç–æ –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ —Ä–∞–±–æ—Ç–∞–ª–∞ –¥–æ–ª–∂–Ω—ã–º –æ–±—Ä–∞–∑–æ–º.

–î–∞–≤–∞–π—Ç–µ " s —Ä–∞—Å—Å–º–æ—Ç—Ä–∏–º –µ—â–µ –æ–¥–∏–Ω –ø—Ä–∏–º–µ—Ä, —á—Ç–æ–±—ã –ø–æ–∫–∞–∑–∞—Ç—å, –∫–∞–∫ —Ä–∞–±–æ—Ç–∞–µ—Ç —ç—Ç–æ—Ç –º–µ—Ç–æ–¥. –î–æ–ø—É—Å—Ç–∏–º, –º—ã –∏–Ω—Å—Ç—Ä—É–∫—Ç–æ—Ä –ø–æ —Ç–∞–Ω—Ü–∞–º –∏ —Ö–æ—Ç–∏–º –∑–Ω–∞—Ç—å –≤–æ–∑—Ä–∞—Å—Ç –∫–∞–∂–¥–æ–≥–æ –≤ –Ω–∞—à–µ–º –∫–ª–∞—Å—Å–µ, –∫–æ—Ç–æ—Ä–æ–º—É –æ—Ç —Å–µ–º–∏ –¥–æ –¥–µ—Å—è—Ç–∏ –ª–µ—Ç, –≤–∫–ª—é—á–∞—è —Å–µ–º—å –∏ –¥–µ—Å—è—Ç—å –ª–µ—Ç. –ú—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Å–ª–µ–¥—É—é—â–∏–π –∫–æ–¥, —á—Ç–æ–±—ã –ø–æ–ª—É—á–∏—Ç—å —ç—Ç–∏ –¥–∞–Ω–Ω—ã–µ:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: [7, 9, 8, 10, 8, 9]. –ö–∞–∫ –≤–∏–¥–∏—Ç–µ, –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞–ª–∞ —É—á–∞—â–∏—Ö—Å—è –≤ –≤–æ–∑—Ä–∞—Å—Ç–µ –æ—Ç —Å–µ–º–∏ –¥–æ –¥–µ—Å—è—Ç–∏ –ª–µ—Ç. –∏–∑ —ç–ª–µ–º–µ–Ω—Ç–æ–≤ –Ω–∞—à–µ–≥–æ —Å–ø–∏—Å–∫–∞, –≤–∫–ª—é—á–∞—è —Å–µ–º—å –∏ –¥–µ—Å—è—Ç—å. –†–µ–∑—É–ª—å—Ç–∏—Ä—É—é—â–∏–π —Å–ø–∏—Å–æ–∫ —Å–æ–¥–µ—Ä–∂–∏—Ç –Ω–∞—à–∏ –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞–Ω–Ω—ã–µ –¥–∞–Ω–Ω—ã–µ.

–§–∏–ª—å—Ç—Ä Python —Å Lambda

–ß—Ç–æ–±—ã —Å–¥–µ–ª–∞—Ç—å –Ω–∞—à—É —Ä–∞–±–æ—Ç—É —Ñ–∏–ª—å—Ç—Ä–∞ –±–æ–ª–µ–µ —ç—Ñ—Ñ–µ–∫—Ç–∏–≤–Ω–æ–π, –º—ã –º–æ–∂–µ–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Ñ—É–Ω–∫—Ü–∏—é Lambda map list. –õ—è–º–±–¥–∞ - —ç—Ç–æ —Å–ø–µ—Ü–∏–∞–ª—å–Ω–∞—è —Ñ—É–Ω–∫—Ü–∏—è, –∫–æ—Ç–æ—Ä–∞—è –æ–ø—Ä–µ–¥–µ–ª—è–µ—Ç—Å—è –±–µ–∑ –∏–º–µ–Ω–∏ –∏ –º–æ–∂–µ—Ç –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å—Å—è –¥–ª—è –Ω–∞–ø–∏—Å–∞–Ω–∏—è –∫–æ—Ä–æ—Ç–∫–∏—Ö –æ–¥–Ω–æ—Å—Ç—Ä–æ—á–Ω—ã—Ö –∞–Ω–æ–Ω–∏–º–Ω—ã—Ö —Ñ—É–Ω–∫—Ü–∏–π –≤ Python.

–ò—Ç–∞–∫, –¥–∞–≤–∞–π—Ç–µ –≤–æ–∑—å–º–µ–º –ø—Ä–∏–≤–µ–¥–µ–Ω–Ω—ã–π –≤—ã—à–µ –ø—Ä–∏–º–µ—Ä –∫–æ–ª–∏—á–µ—Å—Ç–≤–∞ –≤ –∂—É—Ä–Ω–∞–ª–µ. –í —ç—Ç–æ–º –ø—Ä–∏–º–µ—Ä–µ –º—ã —Å–æ–∑–¥–∞–ª–∏ —Ñ—É–Ω–∫—Ü–∏—é, –∫–æ—Ç–æ—Ä–∞—è –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, –µ—Å—Ç—å –ª–∏ –Ω–∞ —Å–∫–ª–∞–¥–µ –º–µ–Ω–µ–µ 20 –∏–∑–¥–∞–Ω–∏–π –∂—É—Ä–Ω–∞–ª–∞, –∏ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–ª–∏ filter () –¥–ª—è –≤—ã–ø–æ–ª–Ω–µ–Ω–∏—è —ç—Ç–æ–π —Ñ—É–Ω–∫—Ü–∏–∏ –≤ –Ω–∞—à–µ–º —Å–ø–∏—Å–∫–µ –∂—É—Ä–Ω–∞–ª–æ–≤. –ó–∞—Ç–µ–º –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–µ—Ä–Ω—É–ª–∞ —Å–ø–∏—Å–æ–∫ –≤—Å–µ—Ö –∂—É—Ä–Ω–∞–ª–æ–≤, –¥–ª—è –∫–æ—Ç–æ—Ä—ã—Ö —É –Ω–∞—Å –±—ã–ª–æ –º–µ–Ω–µ–µ 20 –≤—ã–ø—É—Å–∫–æ–≤.

–ú—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Ñ—É–Ω–∫—Ü–∏—é Lambda –¥–ª—è –≤—ã–ø–æ–ª–Ω–µ–Ω–∏—è —Ç–æ–≥–æ –∂–µ –¥–µ–π—Å—Ç–≤–∏—è, –Ω–æ –±–æ–ª–µ–µ —ç—Ñ—Ñ–µ–∫—Ç–∏–≤–Ω–æ. –í–æ—Ç –∫–æ–¥, –∫–æ—Ç–æ—Ä—ã–π –º—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: [17, 14] .

–ö–∞–∫ –≤–∏–¥–∏—Ç–µ, –Ω–∞—à–∏ —Ä–µ–∑—É–ª—å—Ç–∞—Ç—ã —Ç–∞–∫–∏–µ –∂–µ, –Ω–æ –Ω–∞—à –∫–æ–¥ –∑–Ω–∞—á–∏—Ç–µ–ª—å–Ω–æ –∫–æ—Ä–æ—á–µ. –í–º–µ—Å—Ç–æ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–∏—è –≤—Å–µ–π —Ñ—É–Ω–∫—Ü–∏–∏ –º—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–ª–∏ Lambda –¥–ª—è –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–∏—è –æ–¥–Ω–æ—Å—Ç—Ä–æ—á–Ω–æ–π —Ñ—É–Ω–∫—Ü–∏–∏.

–≠—Ç–∞ –æ–¥–Ω–æ—Å—Ç—Ä–æ—á–Ω–∞—è —Ñ—É–Ω–∫—Ü–∏—è –ø—Ä–æ–≤–µ—Ä—è–µ—Ç, –µ—Å—Ç—å –ª–∏ —É –Ω–∞—Å –Ω–∞ —Å–∫–ª–∞–¥–µ –º–µ–Ω—å—à–µ 20 –∫–æ–ø–∏–π –∂—É—Ä–Ω–∞–ª–∞, –∏ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç True –∏—Ç–µ—Ä–∞—Ç–æ—Ä—É filter (), –µ—Å–ª–∏ —ç—Ç–æ –ü–æ—Å–ª–µ –≤—ã–ø–æ–ª–Ω–µ–Ω–∏—è –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Å–ø–∏—Å–æ–∫ —Å –¥–≤—É–º—è –∑–Ω–∞—á–µ–Ω–∏—è–º–∏: 17 –∏ 14.

"–ö–∞—Ä—å–µ—Ä–Ω–∞—è –∫–∞—Ä–º–∞ –≤–æ—à–ª–∞ –≤ –º–æ—é –∂–∏–∑–Ω—å —Ç–æ–≥–¥–∞, –∫–æ–≥–¥–∞ —è –±–æ–ª—å—à–µ –≤—Å–µ–≥–æ –≤ –Ω–µ–π –Ω—É–∂–¥–∞–ª–∞—Å—å, –∏ –±—ã—Å—Ç—Ä–æ –ø–æ–º–æ–≥–ª–∞ –º–Ω–µ –ø—Ä–æ–π—Ç–∏ –∫—É—Ä—Å –æ–±—É—á–µ–Ω–∏—è. –ß–µ—Ä–µ–∑ –¥–≤–∞ –º–µ—Å—è—Ü–∞ –ø–æ—Å–ª–µ –≤—ã–ø—É—Å–∫–∞ —è –Ω–∞—à–ª–∞ —Ä–∞–±–æ—Ç—É —Å–≤–æ–µ–π –º–µ—á—Ç—ã, –∫–æ—Ç–æ—Ä–∞—è —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤–æ–≤–∞–ª–∞ –º–æ–∏–º —Ü–µ–Ω–Ω–æ—Å—Ç—è–º –∏ —Ü–µ–ª—è–º –≤ –∂–∏–∑–Ω–∏! "

–í–µ–Ω–µ—Ä–∞, –∏–Ω–∂–µ–Ω–µ—Ä-–ø—Ä–æ–≥—Ä–∞–º–º–∏—Å—Ç –≤ Rockbot

< p> –§—É–Ω–∫—Ü–∏—è Python filter () –º–æ–∂–µ—Ç –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å—Å—è –¥–ª—è —Ñ–∏–ª—å—Ç—Ä–∞—Ü–∏–∏ –∏—Ç–µ—Ä–∏—Ä—É–µ–º–æ–≥–æ –æ–±—ä–µ–∫—Ç–∞ –Ω–∞ –æ—Å–Ω–æ–≤–µ –Ω–∞–±–æ—Ä–∞ –ø—Ä–µ–¥–æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã—Ö –∫—Ä–∏—Ç–µ—Ä–∏–µ–≤ –∏ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –æ—Ç—Ñ–∏–ª—å—Ç—Ä–æ–≤–∞–Ω–Ω—ã–π –∏—Ç–µ—Ä–∏—Ä—É–µ–º—ã–π –æ–±—ä–µ–∫—Ç. –≠—Ç–æ—Ç –º–µ—Ç–æ–¥ –º–æ–∂–µ—Ç –±—ã—Ç—å –ø–æ–ª–µ–∑–µ–Ω, –µ—Å–ª–∏ —É –≤–∞—Å –µ—Å—Ç—å —Å–ø–∏—Å–æ–∫ –¥–∞–Ω–Ω—ã—Ö, –∏–∑ –∫–æ—Ç–æ—Ä—ã—Ö –≤—ã —Ö–æ—Ç–∏—Ç–µ –ø–æ–ª—É—á–∏—Ç—å —Ç–æ–ª—å–∫–æ –∑–Ω–∞—á–µ–Ω–∏—è, —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤—É—é—â–∏–µ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–º –∫—Ä–∏—Ç–µ—Ä–∏—è–º.

–í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –º—ã –æ–±—Å—É–¥–∏–ª–∏ —Å–∏–Ω—Ç–∞–∫—Å–∏—Å –º–µ—Ç–æ–¥–∞ filter () –∏ —Ç–æ, –∫–∞–∫ –µ–≥–æ –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –≤ Python. –∏–∑—É—á–∏–ª–∏ –Ω–µ—Å–∫–æ–ª—å–∫–æ –ø—Ä–∏–º–µ—Ä–æ–≤ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏—è filter () –≤ –¥–µ–π—Å—Ç–≤–∏–∏, –∞ –∑–∞—Ç–µ–º —Ä–∞—Å—Å–º–æ—Ç—Ä–µ–ª–∏, –∫–∞–∫ filter () –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Å —Ñ—É–Ω–∫—Ü–∏–µ–π Python Lambda, —á—Ç–æ–±—ã —Å–¥–µ–ª–∞—Ç—å –Ω–∞—à –∫–æ–¥ –±–æ–ª–µ–µ —ç—Ñ—Ñ–µ–∫—Ç–∏–≤–Ω—ã–º.

–¢–µ–ø–µ—Ä—å —É –≤–∞—Å –µ—Å—Ç—å –∏–Ω—Ñ–æ—Ä–º–∞—Ü–∏—è, –Ω–µ–æ–±—Ö–æ–¥–∏–º–∞—è –¥–ª—è –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏—è filter (), –∫–∞–∫ —É —ç–∫—Å–ø–µ—Ä—Ç–∞ –ø–æ Python!

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method