Commonly used modules and functions: os, sys, json, re, datetime, collections, itertools.
این مجموعه فلشکارت برای توسعهدهندگان پایتون طراحی شده است که میخواهند تسلط خود را بر ماژولهای پرکاربرد کتابخانه استاندارد افزایش دهند. پرسشها شامل نکات کلیدی و توابع پرکاربرد ماژولهایی مانند os، sys، json، re، datetime، collections و itertools است که در پروژههای روزمره و مصاحبهها کاربرد دارند.
ساختار این کارتها به صورت پرسش کوتاه در روی کارت و پاسخ دقیق در پشت آن تنظیم شده است. این روش برای یادگیری فعال و مرور بهینهسازی شده است تا مفاهیم به حافظه بلندمدت منتقل شوند.
برای استفاده مؤثر از این فلشکارتها، پیشنهاد میشود روزانه کارتهای مرور شده در سامانه یادمد را بر اساس جدول زمانی تکرار کنید. تمرکز روی درک مثالهای کوچک و نوشتن کدهای مرتبط در کنار مرور کارتها، روند یادگیری را پایدارتر میکند.
۱۲ کارت اول از ۶۰ — رو و پشت هر کارت
What is the primary purpose of the os module in Python?
The os module provides functions for interacting with the operating system, allowing tasks like file and directory manipulation, environment variable access, and path management.
How do you obtain the current working directory using the os module?
Use os.getcwd(), which returns a string representing the current working directory.
What does os.path.join() do?
It intelligently joins one or more path components using the correct separator for the operating system.
How can you check if a file exists using the os module?
Use os.path.exists(path), which returns True if the path refers to an existing path or an open file descriptor.
What is the difference between os.listdir() and os.scandir()?
os.listdir() returns a list of filenames, whereas os.scandir() returns an iterator of DirEntry objects that also expose file attribute data, making it more efficient for file type checking.
How do you create a directory, including any missing parent directories, using the os module?
Use os.makedirs(path), which creates intermediate directories as needed.
What is the primary purpose of the sys module in Python?
The sys module provides access to variables and functions that interact strongly with the Python interpreter itself.
What does sys.argv contain?
It contains a list of command-line arguments passed to a Python script, where sys.argv[0] is the script name itself.
How do you immediately exit a Python script programmatically using the sys module?
Use sys.exit([arg]), which raises a SystemExit exception that can be caught or used to exit the interpreter.
Where does Python look for imported modules, and which variable holds these paths?
Python looks in the directories listed in sys.path, which is a list of strings specifying the search path for modules.
How do you write to the standard error stream instead of standard output using the sys module?
Use print(..., file=sys.stderr) or write directly to sys.stderr.write().
What is the purpose of the json module in Python?
The json module provides methods to parse JSON strings into Python dictionaries/lists (deserialization) and convert Python objects into JSON strings (serialization).
این مجموعه برای برنامهنویسان مبتدی رو به پیشرفته که با سینتکس پایه پایتون آشنا هستند و میخواهند ابزارهای داخلی زبان را بهتر بشناسند، مناسب است.
بله، پرسشها به گونهای طراحی شدهاند که مباحث رایج مصاحبههای پایتون در زمینه کار با فایلها، پردازش متن و ساختار دادهها را پوشش دهند.
توصیه میشود روزانه زمان کوتاهی را به مرور کارتهای جدید و مرورهای سررسیده اختصاص دهید تا تکرار با فاصله به تثبیت مطالب کمک کند.
هنوز کسی آزمون نداده؛ اولین نفر باش.
تا ۲۰ سؤال چهارگزینهای از همین دسته، ۳۰ ثانیه برای هر سؤال. خودت را بسنج و رتبهات را میان بقیه ببین. هر نفر فقط یکبار میتواند شرکت کند.
برای شرکت در آزمون وارد شو